You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 5a50cfb
Browse filesBrowse the repository at this point in the historyBrowse files
fix(daemon): keep an active replay session's daemon alive over the CLI path (#1390)
* fix(daemon): keep an active replay session's daemon alive over the CLI path
A `replay <script>.ad` with no terminal `close` reports its session as
still active per ADR 0016's consumption contract, but the real CLI
client tears down the daemon that ran it (and its owned ephemeral
state dir) regardless — the request's own success response gets
overwritten seconds later by an empty `session list`. This happens
whenever the client started the daemon itself, independent of whether
the state dir was randomly generated or passed explicitly via
--state-dir/AGENT_DEVICE_STATE_DIR, matching #1384's live repro.
Add `sessionActive` to `ReplayCommandResult`, computed from whether the
session survives in the daemon's own store (never by re-parsing the
script), and gate the client's one-shot teardown on it — mirroring the
existing ADR-0012 repair-divergence keep-alive. A kept-alive owned
daemon now also attaches a --state-dir address hint to the response so
the caller can reach it. `test` is unaffected: its own per-file runner
already closes each session before the suite summary is built.
Fixes#1384
* fix(daemon): fix CI formatting, address #1390 review feedback
- oxfmt --check flagged the new test file; reformatted (CI fix).
- Address hint now names --session <name> too, using the response's
session verbatim (already the fully-qualified cwd-scoped store key) —
a bare --session default only resolves by coincidence from the same
cwd, per resolveEffectiveSessionName's explicit-flag bypass.
- Add a test closing the loop: a follow-up sendToDaemon using the
hinted --state-dir/--session reaches the same kept-alive daemon
without spawning a new one.
- Pin that a completed (non-diverging) --save-script repair also keeps
its daemon alive via the same guard, since its terminal source close
is always skipped (ADR 0012 Fix 3) — document the resulting deferred
heal-commit timing in ADR 0012.
* test(daemon): reduce complexity of new active-session tests for CI gate
Fallow's audit gate (new-only findings) flagged the two new active-
session tests for exceeding the CRAP threshold. Extract the shared
fixture wiring into replayLeavingSessionActive/parseAddressHint
helpers (also cutting duplication between the two tests), and drop
repeated optional chaining on response.data in favor of a single
narrowing assert.ok(data) — same assertions, lower branch count.
* fix(daemon): add sessionActive to MCP schema, real-producer tests, ADR fix
Addresses the second review pass on #1390:
- MCP replay output schema (src/mcp/command-output-schemas.ts) omitted
the new required sessionActive field entirely; add it.
- ADR 0016 still claimed "the absence of close changes ... nor the
success response shape", contradicting the new required field this
PR adds. Amend it to document the sessionActive contract and why
the real CLI/IPC client needs it (issue #1384).
- All prior lifecycle tests exercised sessionActive only through a
fake HTTP response in the client-layer tests, so deleting either
real producer line (session-replay-runtime.ts, session-replay-
maestro-response.ts) would not have failed anything. Add tests
against the real runReplayScriptFile producer (native .ad close-less
-> true, terminal close -> false, Maestro close-less -> true) and
strengthen the provider-scenario (real daemon route) test with the
same assertion. Verified each new test fails when its corresponding
producer line is reverted, then restored.
Live-validated the fix on real backends (booted iOS 16 simulator and
a running Android Pixel 9 Pro XL emulator), replaying issue #1384's
exact repro end to end: the owning daemon and its session both survive
a close-less replay and remain fully addressable via the hinted
--state-dir/--session on both platforms. That validation surfaced a
separate, pre-existing bug -- `session list` (no explicit --session)
omits cwd-scoped sessions opened via a replay's internal `open`
dispatch, because session-open.ts's resolveImplicitSessionScope(req)
sees a different req than the top-level replay request and leaves
session.sessionScope unset -- filed as #1394, out of scope here since
it is a sessionScope-propagation gap unrelated to the client-side
teardown this PR fixes; the session itself is never actually lost.
* fix(daemon): hint --session at explicit state dirs too, shell-quote the hint
Addresses the third review pass on #1390 (P2 x2):
- withActiveSessionAddressHint (renamed from ...IfOwned) no longer
suppresses the active-session hint entirely for an explicit
--state-dir/AGENT_DEVICE_STATE_DIR caller. The session name is
cwd-qualified and, per #1394, `session list` can't rediscover it
either, so --session is now hinted regardless of ownedStateDir;
--state-dir is only included when the state dir is the client's own
randomly-generated one the caller has no other way to learn.
- attachActiveSessionAddressHint now shell-quotes (shellQuoteIfNeeded,
the same helper session-recovery-hints.ts/request-lock-policy.ts
already use) both the state dir and session name, so the hint stays
literally copy-pasteable even if either contains spaces or shell
metacharacters. Added tests pinning both the unsafe-value quoting
and that quoting was actually exercised (not just coincidentally
unchanged) -- verified they fail against a raw-interpolation
reversion, then restored the fix.
'Replay a recorded session. For Maestro YAML compatibility flows, use replay <flow.yaml> --maestro and keep the target binding such as --platform ios on the replay command.',
96
+
'Replay a recorded session. For Maestro YAML compatibility flows, use replay <flow.yaml> --maestro and keep the target binding such as --platform ios on the replay command. A script with no terminal close leaves its session (and daemon) running until you close it or it idle-reaps — no different from a session opened interactively.',
0 commit comments