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
This commit is contained in:
Askhz 2026-04-14 11:35:03 +08:00
parent 48d64ccd23
commit ccd135c4ed
2 changed files with 11 additions and 8 deletions

View File

@ -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)],

View File

@ -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