fix: improve session ownership and recovery guidance#674
Conversation
Size Report
Startup median (7 runs, lower is better):
Top changed chunks:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b27aea3717
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| return ( | ||
| `Recording session "${session.name}" owns this device. ` + | ||
| `Run agent-device record stop --session ${session.name}; if the session still appears in agent-device session list, run ${closeCommand}. ` + |
There was a problem hiding this comment.
Quote session names in recovery commands
When a session is named with spaces or shell metacharacters, this hint emits the raw name inside a copy-pastable shell command (--session is parsed as a plain string elsewhere, not restricted to shell-safe tokens). In that scenario the suggested record stop command either fails for names like my session or can execute unintended shell syntax if copied verbatim; build these command snippets from a shell-quoted session name instead.
Useful? React with 👍 / 👎.
|
Summary
This changes the default local session model so multiple agents can use the same host daemon without accidentally attaching to each other's
defaultsession.How session ownership works now
--sessionstill use the public session namedefault.defaultsession is scoped by the caller's git worktree root, falling back to the current working directory when no git root exists.--session.--session <name>andAGENT_DEVICE_SESSIONremain global and backwards compatible. Use them only when a script intentionally wants a shared/reusable session handle.session listis scoped the same way, so one worktree's implicit default session does not reveal or overtake another worktree's implicit default session.Recovery and cleanup
DEVICE_IN_USEconflict instead of being handed another agent's session name.record startare marked as such and released when recording stops, including failed stop/finalization paths.openandrecord startoutputSession state: <path>for humans andsessionStateDirin JSON so agents can find the per-session artifact directory for cleanup/debugging.session list,record stop --session ...,close --session ..., or the safe metadata cleanup command.Validation
Manual device verification covered recovery behavior on Android emulator
emulator-5554and iOS device00008150-001849640CF8401C: recording conflict hints, record-stop cleanup on success/failure, normal device-in-use hints, and bound-session lock mismatch hints.Local validation covered formatting, focused Vitest suites for session routing/recovery/output/help, Fallow, typecheck/lint, build, and smoke tests. GitHub Actions passed for unit, integration, coverage, Fallow, smoke, typecheck, and bundle-size checks before merge.