Skip to content

fix(code): persist model selection during task creation#1386

Open
richardsolomou wants to merge 1 commit intomainfrom
fix/model-selection-persistence
Open

fix(code): persist model selection during task creation#1386
richardsolomou wants to merge 1 commit intomainfrom
fix/model-selection-persistence

Conversation

@richardsolomou
Copy link
Copy Markdown
Member

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:

  1. 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. Now TaskInput keeps its own selectedModel state via the existing onModelChange callback, giving a stable value that survives preview session resets.

  2. 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-creation setSessionConfigOption IPC call, introducing a race window. Now the preferred model flows through agent.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 — passes
  • pnpm lint — no new warnings
  • pnpm --filter code test — 536 tests pass
  • pnpm --filter agent test — 204 tests pass

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
@richardsolomou richardsolomou requested a review from a team March 31, 2026 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Selected model during task creation does not persist

1 participant