Skip to content

record: replaying a flow whose own close runs mid-capture silently rebinds outPath and drops touch-overlay telemetry #1330

Closed

Description

@thymikee

Summary

Surfaced while pre-vetting device-capture footage for a blog post. With an active record start
session on Android, replaying a .ad flow whose own last line is close tears the session down
mid-recording. The subsequent record stop falls into a durable-manifest recovery path that:

  • writes the video to a cwd-relative default path (./recording-<Date.now()>.mp4), silently
    ignoring the outPath the user originally requested with record start <outPath>, and
  • returns gestureEvents: [], which skips the touch-overlay burn-in entirely, with a warning
    that reads like a crash recovery even though nothing crashed.

This is silent data loss (wrong output file + lost touch-overlay/telemetry) presented as a
successful record stop.

Repro

record start out.mp4 --scope device
replay <flow-ending-in-close>.ad
record stop

Observed:

  • record stop response outPath is ./recording-<timestamp>.mp4 in the daemon's cwd, not
    out.mp4.
  • events: [] in the response.
  • Warning text: "Recovered Android recording after daemon restart from durable device
    manifest… touch overlay burn-in is unavailable after daemon restart because gesture telemetry
    is stored in daemon memory."

Nothing about this run actually restarted the daemon — the replayed flow's own close command
tore down the session the recording was attached to, and the recovery path (designed for daemon
crash/restart) is the only path record stop has left to fall back on, so it treats a live
same-process teardown identically to a genuine daemon restart.

Root cause (read from source)

  1. close inside a replayed .ad ends the session that owns activeSession.recording. By the
    time record stop runs, activeSession.recording is gone
    (src/daemon/handlers/record-trace-recording.ts:346-349,
    resolveRecordingToStop → recoverMissingRecordingState).
  2. recoverMissingRecordingState calls prepareRecoveredRecording(req, backend, activeSession)
    (src/daemon/handlers/record-trace-recording.ts:386-401), which resolves the output path from
    the record stop request, not the original record start request:
    function resolveNativeRecordingOutputPath({ req }: RecordingOutputPathContext): string {
      const requestedPath = req.positionals?.[1];
      return requestedPath ?? defaultRecordingPath(undefined);
    }
    (src/daemon/handlers/record-trace-recording-backends.ts:138-141). record stop never carries
    the original outPath positional, so this always falls through to:
    export function defaultRecordingPath(platform: Platform | undefined): string {
      return `./recording-${Date.now()}${recordingExtensionForPlatform(platform)}`;
    }
    (src/recording/output-path.ts:17-19) — the cwd-relative default, silently discarding the
    user's out.mp4.
  3. The recovery warning strings (including the exact text quoted above) live in
    src/daemon/handlers/record-trace-android-recovery-manifest.ts:26-32 and are emitted
    unconditionally by this code path, regardless of whether the daemon process actually
    restarted.
  4. Because gesture telemetry only lives in daemon memory (activeSession.recording.gestureEvents),
    a recovered recording always reconstructs with gestureEvents: []. In
    src/daemon/handlers/record-trace-finalize.ts:41-46, finalizeRecordingOverlay treats
    gestureEvents.length === 0 as "nothing to overlay" and skips the burn-in silently — no error,
    just a video with no touch overlay and no telemetry file.

Impact

  • Output file silently lands at the wrong path (cwd-relative default instead of the requested
    outPath), which for scripted/CI capture pipelines means the video may be hard to find or may
    get overwritten by the next take.
  • Touch-overlay burn-in and gesture telemetry are silently dropped with no video-affecting error,
    only a warning — easy to miss in automation.
  • The "after daemon restart" wording in the warning is actively misleading for this trigger: nothing
    restarted, an in-flow close did.

Artifacts

From the pre-vet capture session under
~/.agent-device-bench/wave3/blog-videos/_style-sample/:

  • settings-battery.ad — the flow variant that ends in close (the trigger shape).
  • legC-battery-no-close.ad — the same flow with the trailing close removed, kept
    specifically as the workaround used to avoid tripping this bug while capturing.
  • style-sample-device-v2.mp4 + style-sample-device-v2.gesture-telemetry.json — the take that
    avoided the bug by driving the flow with discrete press/wait commands (not a replayed .ad
    with an embedded close) and calling record stop before close; its
    state-v2/sessions/vhsSampleDevice/events.ndjson shows record stop returning a normal
    outPath and non-empty telemetry when close runs after record stop, in contrast to the
    broken ordering above.

Source leads

  • src/daemon/handlers/record-trace-recording.ts (recoverMissingRecordingState,
    prepareRecoveredRecording)
  • src/daemon/handlers/record-trace-recording-backends.ts (resolveNativeRecordingOutputPath)
  • src/recording/output-path.ts (defaultRecordingPath)
  • src/daemon/handlers/record-trace-android-recovery-manifest.ts (recovery warning strings)
  • src/daemon/handlers/record-trace-android-recovery.ts (recovery candidate construction)
  • src/daemon/handlers/record-trace-finalize.ts (finalizeRecordingOverlay skips overlay when
    gestureEvents.length === 0)

Activity

  1. added
    bug
    on Jul 18, 2026
  2. thymikee commented on Jul 18, 2026

    @thymikee
    MemberAuthor

    Triaged as bug + ready-for-agent. ADR 0015 and current help make public close the session finalizer that releases active recordings. A replayed terminal close therefore must leave recording state and its durable manifest consistently finalized; a later record stop must not reinterpret same-process teardown as daemon-restart recovery, invent a new output path, or silently lose telemetry. The implementation should add an end-to-end daemon regression for record start <explicit path> → replay ending in close → record stop, asserting the original artifact/finalization semantics, manifest cleanup, honest response/warning behavior, and overlay/telemetry preservation where close successfully finalizes them.

  3. thymikee commented on Jul 18, 2026

    @thymikee
    MemberAuthor

    Retested on current main (ef118b9d1), which includes #1325 ("finalize active recording on session/daemon teardown"). The reported symptoms are resolved:

    • Recording finalizes to the requested outPath (no more cwd-relative recording-<ts>.mp4 default).
    • Touch-overlay telemetry is retained — 2 gesture events captured for the 2-tap flow (was gestureEvents: []).
    • The misleading "Recovered … after daemon restart" warning no longer fires.

    The original report was filed against a pre-#1325 build (my local main was behind). Minor non-blocking nit for a possible follow-up: after the flow's own trailing close finalizes the recording via the #1325 teardown path, a subsequent explicit record stop returns success:false (nothing left to stop) rather than echoing the already-finalized result — cosmetic.

    Closing as fixed by #1325.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions