fix(code): persist model selection during task creation#1386
Open
richardsolomou wants to merge 1 commit intomainfrom
Open
fix(code): persist model selection during task creation#1386richardsolomou wants to merge 1 commit intomainfrom
richardsolomou wants to merge 1 commit intomainfrom
Conversation
The model selected in the task creation UI was lost because it was only stored in the preview session's Zustand state, which could be transiently reset. Additionally, the agent started with the default model (opus) and was changed post-creation via IPC, introducing a race window. Fix by tracking the selection in local React state and passing it through agent.start so the agent initializes with the correct model. Fixes #1380
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.
Problem
When selecting a model (e.g. Sonnet) during task creation, the selection was lost and the task always started with Opus.
Closes #1380
Changes
Two-pronged fix:
Track model selection in local React state (
TaskInput.tsx): The model was previously read only from the preview session's Zustand store (modelOption.currentValue), which could be transiently reset. NowTaskInputkeeps its ownselectedModelstate via the existingonModelChangecallback, giving a stable value that survives preview session resets.Pass model to agent.start (
schemas.ts,service.ts,claude-agent.ts): Previously the agent always started with the default model (opus) and the model was changed via a post-creationsetSessionConfigOptionIPC call, introducing a race window. Now the preferred model flows throughagent.start→_meta.claudeCode.options.model→ agent session creation, so the agent initializes with the correct model from the start.How did you test this?
pnpm typecheck— passespnpm lint— no new warningspnpm --filter code test— 536 tests passpnpm --filter agent test— 204 tests pass