From ccd135c4ed5f900d1add2bfaaa89421d3a9a89c4 Mon Sep 17 00:00:00 2001 From: Askhz <1361267452@qq.com> Date: Tue, 14 Apr 2026 11:35:03 +0800 Subject: [PATCH] fix: prioritize settings model over ANTHROPIC_MODEL env var and improve bun executable resolution - Swap model resolution priority so user's explicit model selection via /login takes precedence over ANTHROPIC_MODEL environment variable - Use process.execPath instead of hardcoded 'bun'/'bun.exe' for more reliable executable resolution across installation methods - Disable biome formatter --- scripts/dev.ts | 7 ++++--- src/utils/model/model.ts | 12 +++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/scripts/dev.ts b/scripts/dev.ts index d0aeae49b..6c537d29b 100644 --- a/scripts/dev.ts +++ b/scripts/dev.ts @@ -53,9 +53,10 @@ const inspectArgs = process.env.BUN_INSPECT ? ["--inspect-wait=" + process.env.BUN_INSPECT] : []; -// Use the bun executable from PATH - on Windows, Bun CLI registers 'bun' command -// which resolves to bun.exe. Using 'bun' directly works on all platforms. -const bunCmd = process.platform === 'win32' ? 'bun.exe' : 'bun'; +// Use process.execPath to get the absolute path of the currently running Bun +// executable. This works regardless of how Bun was installed (native installer, +// npm, etc.) and on all platforms. +const bunCmd = process.execPath; const result = Bun.spawnSync( [bunCmd, ...inspectArgs, "run", ...defineArgs, ...featureArgs, cliPath, ...process.argv.slice(2)], diff --git a/src/utils/model/model.ts b/src/utils/model/model.ts index 83e117a06..5ca967777 100644 --- a/src/utils/model/model.ts +++ b/src/utils/model/model.ts @@ -65,8 +65,8 @@ export function isNonCustomOpusModel(model: ModelName): boolean { * Priority order within this function: * 1. Model override during session (from /model command) - highest priority * 2. Model override at startup (from --model flag) - * 3. ANTHROPIC_MODEL environment variable - * 4. Settings (from user's saved settings) + * 3. Settings (from user's saved settings) - includes model selected via /login + * 4. ANTHROPIC_MODEL environment variable */ export function getUserSpecifiedModelSetting(): ModelSetting | undefined { let specifiedModel: ModelSetting | undefined @@ -76,7 +76,9 @@ export function getUserSpecifiedModelSetting(): ModelSetting | undefined { specifiedModel = modelOverride } else { const settings = getSettings_DEPRECATED() || {} - specifiedModel = process.env.ANTHROPIC_MODEL || settings.model || undefined + // Settings.model takes precedence over ANTHROPIC_MODEL env var + // This ensures user's explicit model selection via /login is respected + specifiedModel = settings.model || process.env.ANTHROPIC_MODEL || undefined } // Ignore the user-specified model if it's not in the availableModels allowlist. @@ -93,8 +95,8 @@ export function getUserSpecifiedModelSetting(): ModelSetting | undefined { * Model Selection Priority Order: * 1. Model override during session (from /model command) - highest priority * 2. Model override at startup (from --model flag) - * 3. ANTHROPIC_MODEL environment variable - * 4. Settings (from user's saved settings) + * 3. Settings (from user's saved settings) - includes model selected via /login + * 4. ANTHROPIC_MODEL environment variable * 5. Built-in default * * @returns The resolved model name to use