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: () => {