Skip to content

fix: improve session ownership and recovery guidance#674

Merged
thymikee merged 9 commits into
mainfrom
fix/session-recovery-hints
Jun 2, 2026
Merged

fix: improve session ownership and recovery guidance#674
thymikee merged 9 commits into
mainfrom
fix/session-recovery-hints

Conversation

@thymikee
Copy link
Copy Markdown
Member

@thymikee thymikee commented Jun 2, 2026

Summary

This changes the default local session model so multiple agents can use the same host daemon without accidentally attaching to each other's default session.

How session ownership works now

  • Commands that omit --session still use the public session name default.
  • Internally, that implicit default session is scoped by the caller's git worktree root, falling back to the current working directory when no git root exists.
  • The scoped internal key is opaque to callers. Human/JSON output continues to report the public session name, so normal raw commands can keep omitting --session.
  • Explicit --session <name> and AGENT_DEVICE_SESSION remain global and backwards compatible. Use them only when a script intentionally wants a shared/reusable session handle.
  • session list is 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

  • If another workspace already owns the selected device, implicit callers now get an opaque DEVICE_IN_USE conflict instead of being handed another agent's session name.
  • Record-only sessions created by record start are marked as such and released when recording stops, including failed stop/finalization paths.
  • open and record start output Session state: <path> for humans and sessionStateDir in JSON so agents can find the per-session artifact directory for cleanup/debugging.
  • Device-in-use, selector-lock, and stale daemon metadata errors now include concrete recovery commands such as session list, record stop --session ..., close --session ..., or the safe metadata cleanup command.
  • Daemon response finalization now preserves handler-provided hints instead of replacing them with generic fallback guidance.

Validation

Manual device verification covered recovery behavior on Android emulator emulator-5554 and iOS device 00008150-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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

Size Report

Metric Base Current Diff
JS raw 1.1 MB 1.1 MB +2.6 kB
JS gzip 363.1 kB 363.9 kB +797 B
npm tarball 468.0 kB 468.7 kB +680 B
npm unpacked 1.6 MB 1.6 MB +2.8 kB

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 28.1 ms 26.4 ms -1.7 ms
CLI --help 43.3 ms 41.3 ms -2.0 ms

Top changed chunks:

Chunk Raw diff Gzip diff
dist/src/2415.js +3.0 kB +887 B
dist/src/args.js -2.1 kB -687 B
dist/src/session.js +457 B +198 B
dist/src/record-trace.js +291 B +122 B
dist/src/9542.js +508 B +81 B

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/daemon/session-recovery-hints.ts Outdated

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}. ` +
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@thymikee thymikee changed the title fix: improve session recovery guidance fix: improve session ownership and recovery guidance Jun 2, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-06-02 21:06 UTC

@thymikee thymikee merged commit 491ad7e into main Jun 2, 2026
19 checks passed
@thymikee thymikee deleted the fix/session-recovery-hints branch June 2, 2026 21:06
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.

1 participant