From 4935ea48bb408eca5a7c712d470bbb1e50ed932f Mon Sep 17 00:00:00 2001 From: j4rviscmd Date: Fri, 13 Mar 2026 17:44:57 +0900 Subject: [PATCH] feat: add configurable status bar priority setting Add zaiUsage.statusBarPriority configuration to allow users to control the position of the z.ai Usage item in the status bar. The priority is read at activation time and applied to the StatusBarItem constructor. When the setting changes, the user is prompted to reload the window since priority cannot be updated at runtime. --- package.json | 5 +++++ src/extension.ts | 23 ++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index b9bd0d8..cdb7e39 100644 --- a/package.json +++ b/package.json @@ -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." } } } diff --git a/src/extension.ts b/src/extension.ts index 7092414..96bfdb1 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -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("statusBarPriority", 10000); + const statusBarItem = vscode.window.createStatusBarItem( vscode.StatusBarAlignment.Right, - 100, + priority, ); statusBarItem.text = getLabel("..."); statusBarItem.show(); @@ -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 ( @@ -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: () => {