Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
"type": "boolean",
"default": true,
"description": "Use z.ai icon in status bar instead of text label 'z.ai:'"
},
"zaiUsage.statusBarPriority": {
"type": "number",
"default": 10000,
"description": "Priority of the z.ai Usage item in the status bar (higher = further left among right-aligned items). Change takes effect after reloading the window."
}
}
}
Expand Down
23 changes: 22 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,13 @@ const API_URL = "https://api.z.ai/api/monitor/usage/quota/limit";
* @param context - The extension context provided by VSCode.
*/
export function activate(context: vscode.ExtensionContext): void {
const priority = vscode.workspace
.getConfiguration("zaiUsage")
.get<number>("statusBarPriority", 10000);

const statusBarItem = vscode.window.createStatusBarItem(
vscode.StatusBarAlignment.Right,
100,
priority,
);
statusBarItem.text = getLabel("...");
statusBarItem.show();
Expand Down Expand Up @@ -461,6 +465,10 @@ export function activate(context: vscode.ExtensionContext): void {
* When `zaiUsage.refreshInterval` or `zaiUsage.useIcon` changes, the status bar
* is refreshed and the polling interval is restarted so the new settings take
* effect without requiring a window reload.
*
* When `zaiUsage.statusBarPriority` changes, the user is notified that a window
* reload is required for the new priority to take effect, because the priority is
* set at status bar item creation time and cannot be changed at runtime.
*/
vscode.workspace.onDidChangeConfiguration((e) => {
if (
Expand All @@ -470,6 +478,19 @@ export function activate(context: vscode.ExtensionContext): void {
updateStatusBar();
startInterval();
}
if (e.affectsConfiguration("zaiUsage.statusBarPriority")) {
void (async () => {
const selection = await vscode.window.showInformationMessage(
"z.ai Usage: Status bar priority changed. Reload the window to apply.",
"Reload Window",
);
if (selection === "Reload Window") {
await vscode.commands.executeCommand(
"workbench.action.reloadWindow",
);
}
})();
}
}),
{
dispose: () => {
Expand Down
Loading