feat: Add model parameter to spawn session options #159
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
Allows mobile app to specify model (e.g., 'sonnet', 'opus') when spawning sessions.
Changes:
modelfield toSpawnSessionOptionsinterfacemodelfromspawn-happy-sessionRPC paramsANTHROPIC_MODELenv var from model option (takes precedence over profile)--modelflag to Claude CLI when spawning (both regular and tmux modes)Problem
When selecting a model in the Happy Coder mobile app before spawning a session, the model selection was ignored. Sessions always started with the default model (Opus 4.5) regardless of user selection.
Evidence from daemon logs:
No
modelfield was being passed or used.Solution
This PR adds support for a
modelfield in the spawn session options. When the mobile app sendsmodel: "sonnet", the daemon will:ANTHROPIC_MODEL=sonnetin the spawned process environment--model sonnetflag to the Claude CLIThe fix is backward compatible - if mobile doesn't send
model, behavior is unchanged.Files Changed
src/modules/common/registerCommonHandlers.ts- Addmodelto interfacesrc/api/apiMachine.ts- Extract and passmodelfrom RPC paramssrc/daemon/run.ts- Usemodelin env and CLI argsTesting
Note for Mobile App
The mobile app (slopus/happy) needs to be updated to send
modelin the spawn params:{ "type": "spawn-in-directory", "directory": "/path/to/dir", "agent": "claude", "model": "sonnet" }Fixes #158
Generated with Claude Code
via Happy
Co-Authored-By: Claude noreply@anthropic.com
Co-Authored-By: Happy yesreply@happy.engineering