[FR] Daemon: migrate tracked sessions to the new CLI version on self-update/restart
Summary
On a self-hosted daemon, when the CLI/daemon updates to a new version, already-running sessions keep executing their old pinned CLI binary. A daemon restart re-adopts them but doesn't relaunch them on the new version — so an "auto-update" leaves active sessions stale-versioned until manually reopened.
Environment
Self-hosted (Linux, systemd-managed daemon, SQLite light server). Sessions spawned --started-by daemon --happy-starting-mode remote.
Observed
- Session shell runs from
~/.happier/cli-dev/versions/<X>/happier … claude. - After CLI update to
<Y>+ daemon restart, the new (version Y) daemon re-tracks the session, but the process is still version X (pinned path). daemon restartkeeps sessions by default (stopSessions=false) but performs no version migration.- (Separately: the session↔daemon control link goes stale across a restart and self-heals only lazily on next interaction.)
Impact
Operators running automated CLI updates can't move in-flight sessions to the new version without manually stopping/reopening each — defeats auto-update for active work.
Proposal
On daemon self-update/restart to a new CLI version, migrate tracked sessions: for each, respawn with existing_session on the new binary (resume from server state). The pieces already exist — spawnSession({existing_session}) (used by automationRunExistingSession), resolveRespawnSessionRuntimeSnapshot, stopDaemonSession, POST /spawn-session. An opt-in daemon restart --migrate-sessions (or automatic on version-change) would do it.
Interim workaround
We daemon stop-session <id> each tracked session post-update so it relaunches on the new CLI when reopened (state preserved server-side). The only unattended respawn trigger today is the internal POST /spawn-session (token+nonce) — too internal to depend on externally.
Implemented on dev and shipped starting in cli-v0.2.10-dev.41.
Commit ad74c8fd7c (feat(cli-daemon): add restart orchestration and session runner runtime coordination) adds planned runner restarts: a tracked session's runner is respawned on the current CLI runtime, resuming from server state. Later hardening landed in 0646eaa5b5, 0aab582c79 and 10b8080e07.
How to migrate in-flight sessions after a CLI update:
happier daemon restart --restart-session-runners: restarts the daemon, keeps sessions, then moves tracked runners onto the current CLI.happier daemon restart-session-runners [--session-id <id>] [--dry-run] [--force-current-cli]: restarts eligible runners in place. By default this only touches stale runners (if_stale);--force-current-clirestarts all of them.- UI: the stale-runner banner offers a per-session restart.
happier doctorguided repair offers "restart daemon and session runners".
Restarts wait for a turn boundary or idle, are fenced per process instance, and skip duplicate or terminal restarts.
Not covered here: migrating sessions automatically when the daemon self-updates. The protocol already reserves restart reasons for this (self_update_interactive_prompt, restart_session_runners_on_update_config, daemon_dist_generation_rollout), but no update flow calls them yet. I'll open a smaller follow-up if that's still wanted. The core ask (move active sessions to the new version without stopping and reopening each one by hand) is now a single command, so I'm closing this.