feat(cli): honor --model alone without requiring --provider#854
feat(cli): honor --model alone without requiring --provider#8540xfandom wants to merge 1 commit intoGitlawb:mainfrom
Conversation
gnanam1990
left a comment
There was a problem hiding this comment.
Thanks! Closes #808 cleanly — defers to applyProviderFlagFromArgs when both flags are set, and the 9-test matrix covers every provider branch plus the ollama colon-syntax case. LGTM 🚀
72c7796 to
1fc3ccc
Compare
|
@kevincodex1 Any update on this |
gnanam1990
left a comment
There was a problem hiding this comment.
Re-approved at 1fc3ccc after the rebase onto current main.
Verified locally:
bun test src/utils/providerFlag.test.ts src/utils/providerAutoDetect.test.ts
→ 64 pass / 0 fail
The --model resolution still defers cleanly to applyProviderFlagFromArgs when both flags are present, and the matrix (9 provider branches + the ollama colon-syntax case) still passes after the rebase. No fingerprints / red flags introduced. LGTM 🚀
09908ea to
ddbbee9
Compare
|
Rebased onto current @gnanam1990 — re-approval ping if it still looks clean. |
Closes Gitlawb#808. Today `openclaude --model <name>` is parsed by Commander inside main.tsx but the startup banner and any provider-env-reading code run first, so the override is invisible until request time and saved-profile users see their stale model in the banner. Add applyModelFlagFromArgs that runs after saved-profile env application and before the banner. It routes the value to the env var matching the already-active provider (OPENAI_MODEL / GEMINI_MODEL / MISTRAL_MODEL / ANTHROPIC_MODEL) so the banner, resolution, and request payload all agree. Skipped when --provider is also present; that path is still handled by applyProviderFlagFromArgs. No writes to .openclaude-profile.json — override is process-scoped.
ddbbee9 to
b78d8bf
Compare
|
Rebased onto current No logic changes since the prior approval. |
|
Any update on this @kevincodex1 @gnanam1990 |
Summary
--model <name>now works standalone (no--providerrequired), overriding the active session model process-scoped.OPENAI_MODEL/GEMINI_MODEL/MISTRAL_MODEL/ANTHROPIC_MODEL) after saved-profile application and before the startup banner, so the banner, provider resolution, and outgoing request payload all agree.--provider <name> --model <name>path (handled byapplyProviderFlagFromArgs).Closes #808.
Why
Today Commander parses
--modelinsidemain.tsx, but the startup banner and provider-env-reading code run earlier. Saved-profile users runningopenclaude --model gpt-4o-minisaw their stale profile model in the banner, and callers reading the*_MODELenv var directly (e.g.StartupScreen.detectProvider) missed the override entirely.The fix mirrors the existing
--providerearly-path incli.tsx: hook into the bootstrap flow right beforeprintStartupScreen()and propagate the flag value to the correct env var.No writes to
.openclaude-profile.json— override is process-scoped, as the issue asked.Changes
src/utils/providerFlag.ts— exportparseModelFlag, addapplyModelFlagFromArgsthat detects active provider fromCLAUDE_CODE_USE_*and sets the matching*_MODEL.src/entrypoints/cli.tsx— callapplyModelFlagFromArgsafter saved-profile env application and before the startup banner, gated on--modelbeing present.src/utils/providerFlag.test.ts— new tests coveringparseModelFlagandapplyModelFlagFromArgsacross OpenAI / Gemini / Mistral / GitHub / Anthropic providers, saved-profile override, colon-bearing Ollama tags, and the--providerpassthrough no-op.Test plan
bun test src/utils/providerFlag.test.ts— 34 pass, 0 failbun test(full suite) — 1227 pass, 0 failopenclaude --model gpt-4o-mini→ banner showsgpt-4o-mini, profile file unchangedopenclaude --model gemini-2.0-flash→ banner showsgemini-2.0-flashopenclaude --provider openai --model gpt-4o→ existing behavior preserved