fix: resolve model aliases in setSessionConfigOption (#401)#403
Open
mudrii wants to merge 1 commit intozed-industries:mainfrom
Open
fix: resolve model aliases in setSessionConfigOption (#401)#403mudrii wants to merge 1 commit intozed-industries:mainfrom
mudrii wants to merge 1 commit intozed-industries:mainfrom
Conversation
|
We require contributors to sign our Contributor License Agreement, and we don't have @mudrii on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
e5bfa93 to
ae45898
Compare
|
We require contributors to sign our Contributor License Agreement, and we don't have @mudrii on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
Author
signed |
|
The cla-bot has been summoned, and re-checked this pull request! |
) setSessionConfigOption used exact-match validation for the model config option. Model options are stored with full identifiers like 'claude-opus-4-6', but ACP clients (e.g. acpx 'set model opus') pass human-friendly aliases like 'opus' or display names like 'Claude Opus'. The exact match fails, returning 'Invalid value for config option'. The fix falls back to the existing resolveModelPreference() function when the exact match fails for model config options. This function already implements fuzzy matching (exact, substring, tokenized) but was only wired up for unstable_setSessionModel, not the config option path. Additionally, the resolved canonical model ID (not the caller-supplied alias) is now used for all downstream operations (setModel call and configOptions currentValue update), ensuring consistent state.
ae45898 to
caaae6c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #401 by enabling model alias/fuzzy resolution in
setSessionConfigOptionwhen updating themodelconfig option.Root cause
setSessionConfigOptionvalidated model values using an exact string match against config option values (model IDs likeclaude-opus-4-5):Clients often send human-friendly model preferences (
opus,sonnet,Claude Sonnet), which failed this exact check and produced:Invalid value for config option model: <value>The file already had
resolveModelPreference(...), which supports exact/display/substring/tokenized matching, but that logic was only used in model initialization paths and not insetSessionConfigOption.What changed
1) Fuzzy model resolution in
setSessionConfigOptionconfigId === "model"and exact match fails, map config option entries toModelInfo[](value+displayName) and callresolveModelPreference(...).resolvedValue) for:query.setModel(...)session.configOptionscurrent value updateconfigOptions)2) Notification behavior unchanged by design
updateConfigOption(...)insetSessionConfigOption.config_option_updatenotification is sent for this RPC (response already returns fullconfigOptions).Tests
Added focused coverage in
src/tests/session-config-options.test.tsunderdescribe("setSessionConfigOption"):opus->claude-opus-4-5sonnet->claude-sonnet-4-5Claude Sonnet->claude-sonnet-4-5gpt-4)Behavior before / after
Before
setSessionConfigOption({ configId: "model", value: "opus" })-> errorAfter
setModel("claude-opus-4-5")configOptions.model.currentValue === "claude-opus-4-5"Verification
npm run build✅npm test✅ (all tests passing)