Skip to content

feat: Add model parameter to spawn session options#159

Open
mark9232 wants to merge 1 commit intoslopus:mainfrom
mark9232:fix/model-selection-from-mobile
Open

feat: Add model parameter to spawn session options#159
mark9232 wants to merge 1 commit intoslopus:mainfrom
mark9232:fix/model-selection-from-mobile

Conversation

@mark9232
Copy link

@mark9232 mark9232 commented Feb 4, 2026

Summary

Allows mobile app to specify model (e.g., 'sonnet', 'opus') when spawning sessions.

Changes:

  • Add model field to SpawnSessionOptions interface
  • Extract model from spawn-happy-session RPC params
  • Set ANTHROPIC_MODEL env var from model option (takes precedence over profile)
  • Pass --model flag 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:

[API MACHINE] Spawning session with params: {"type":"spawn-in-directory","directory":"...","agent":"claude"}

No model field was being passed or used.

Solution

This PR adds support for a model field in the spawn session options. When the mobile app sends model: "sonnet", the daemon will:

  1. Set ANTHROPIC_MODEL=sonnet in the spawned process environment
  2. Pass --model sonnet flag to the Claude CLI

The fix is backward compatible - if mobile doesn't send model, behavior is unchanged.

Files Changed

  • src/modules/common/registerCommonHandlers.ts - Add model to interface
  • src/api/apiMachine.ts - Extract and pass model from RPC params
  • src/daemon/run.ts - Use model in env and CLI args

Testing

  • Spawn session from mobile with model selection
  • Verify daemon logs show model being set
  • Verify Claude uses the correct model

Note for Mobile App

The mobile app (slopus/happy) needs to be updated to send model in 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

Allows mobile app to specify model (e.g., 'sonnet', 'opus') when spawning sessions.

Changes:
- Add `model` field to SpawnSessionOptions interface
- Extract `model` from spawn-happy-session RPC params
- Set ANTHROPIC_MODEL env var from model option (takes precedence over profile)
- Pass --model flag to Claude CLI when spawning

This fixes an issue where model selection in the mobile app was ignored,
causing sessions to always start with the default model.

Fixes slopus#158

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
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.

Mobile app model selection not passed to daemon spawn command

1 participant