feat(desktop): add model picker to workspace create dialog
Description
Adds a model dropdown next to the agent picker in the v2 new-workspace dialog so a session can start on a specific model (e.g. claude --model sonnet) without touching the agent's CLI config.
- The dropdown appears only for agents that support model selection:
claude,codex,gemini,copilot,cursor-agent,opencode(via their--modelflag) plus the built-in Superset chat agent (via the existingmetadata.model→harness.switchModelpath). Agents without known model support (amp, pi, droid, mastracode) show no dropdown. - First option is Default → no
--modelflag is passed, the CLI keeps its own default. - The last selected model is remembered per agent preset (localStorage map keyed by presetId, so it survives host switches); stale model ids fall back to Default.
Implementation:
packages/shared/src/agent-models.ts— curated, hand-maintained per-preset model registry (AGENT_MODEL_SUPPORT,getAgentModelSupport,buildAgentModelArgs) shared by the renderer (dropdown options) and host-service (flag injection).packages/host-service— optionalmodelfield on theworkspaces.createagent-launch sugar andagents.run;buildAgentCommandStringinserts the model args between the base args and the prompt, covering both argv and stdin/heredoc transports, shell-quoted. Unknown preset/model degrades to no flag rather than a broken launch.apps/desktop— newAgentModelSelectpill component (same@superset/ui/selectpattern asAgentSelect) and auseAgentModelPreferencehook, wired into the dialog'sPromptGroupanduseSubmitWorkspace. The renderer type for the new field flows automatically from the host router's inferred input type.
Related Issues
Closes #5247
Type of Change
- Bug fix
- New feature
- Documentation
- Refactor
- Other (please describe):
Testing
- Unit tests added:
packages/shared/src/agent-models.test.ts(registry validity, arg building) andpackages/host-service/src/trpc/router/agents/agents.test.ts(buildAgentCommandStringwith model args for argv transport, stdin/heredoc transport, empty model args unchanged, shell-quoting of hostile values). Fullbun testsuites for both packages pass. turbo typecheckgreen for@superset/shared,@superset/host-service,@superset/desktop;bun run lintexits 0.- Manually tested against the local Docker dev stack (
setup.local.sh+bun run dev:desktop): Claude + Sonnet launches the terminal withclaude --dangerously-skip-permissions --model sonnet '<prompt>'; Default passes no flag; Amp shows no dropdown; the Superset chat agent starts on the selected model; the per-agent choice is restored when reopening the dialog.
Additional Notes
The model lists are intentionally curated and hand-maintained in a single file (agent-models.ts); they will drift with CLI releases and are easy to update. Claude uses the stable opus/sonnet/haiku CLI aliases to minimize drift. Happy to adjust scope, model lists, or placement based on review.
Summary by cubic
Adds a model picker to the new workspace dialog so sessions can start on a specific model without editing CLI configs. Also centralizes the Superset chat model catalog in @superset/shared/agent-models so the picker and chat.getModels stay in sync.
-
New Features
- Desktop: Added
AgentModelSelectnext to the agent picker; shown forclaude,codex,gemini,copilot,cursor-agent,opencode, and the built-in Superset chat agent. “Default” passes no flag. - Preference: Remembers the last selected model per agent preset in localStorage; stale or out‑of‑registry model IDs fall back to Default.
- Shared (
@superset/shared/agent-models): Curated registry and helpers (AGENT_MODEL_SUPPORT,getAgentModelSupport,buildAgentModelArgs) for supported models and CLI flags. - Host Service (
@superset/host-service): Optionalmodelonworkspaces.createandagents.run. For terminal agents, inserts model args between base args and the prompt (argv and stdin/heredoc, shell-quoted). For the Superset chat agent, setsmetadata.model.
- Desktop: Added
-
Bug Fixes
- Rejects model ids outside the curated registry in
buildAgentModelArgs, degrading to no flag instead of a broken launch. - Guards localStorage writes in the preference hook; quota/security errors only skip persistence.
- Rejects model ids outside the curated registry in
Summary by CodeRabbit
- New Features
- Added an AI model picker to the new workspace flow, including a “Default” option, and forward the chosen model when launching agents.
- Persist the last-selected model per preset and restore it on subsequent workspace creations.
- Enable model-aware agent runs for both chat and terminal executions.
- Tests
- Added coverage for curated model support catalogs, model-to-CLI argument construction, and safe model injection/quoting behavior.