Repository navigation
fix(daemon): settle orphaned recording records when a recording starts - #4218
Conversation
|
@sylvain-abadie is attempting to deploy a commit to the Callstack Team on Vercel. A member of the Team first needs to authorize it. |
|
At edfa596, the code has no blocking problem, but the live Android evidence is missing. The PR body describes the emulator run in prose only. Please paste the Could a smaller design work? Keep refusing, but make Not blocking, and fine to take or leave: (1) The settle at record-runtime-orphan-recovery.ts#L26 picks same-device unheld records, while the refusal fires for any non-completed record with this session path or this device. An orphan under the same session name on another device is still refused, and a user who runs The only failing check is the Vercel deployment authorization, which is not a code problem. No conflicts are known. |
There was a problem hiding this comment.
All reported issues were addressed across 6 files
Reply to a comment to ask cubic a question or push back. It learns from your replies.
View guided diff | Re-trigger cubic
A device that restarts mid-recording can leave its screen recording record open with a pending cleanup when the daemon's own recovery ran while the device was still booting. Only daemon start and a device claim reconciliation retried it, and a recovered record stop cannot finish it without a playable artifact, so once the claim was gone every later record start on that device was refused with cleanup-unconfirmed. The start preflight now lists the records it refuses on, and record start runs the exact-owner recovery for the ones whose session the daemon no longer holds, so the settle set cannot drift from the refusal. A recovered stop and this settle share one recovery-control helper. A record whose cleanup cannot be confirmed, or whose session is still held, still refuses the start, and the refusal names that session.
edfa596 to
d9ef23d
Compare
|
Thanks. I tried the hint-only design first: in this state,
Evidence: host macOS 26.7.1. Android emulator The
|
|
At d9ef23d, the settle follows the refusal set and shares one recovery helper, and the live Android output covers the earlier request. One problem remains: the start-time settle can bind the wrong device and lose a live recording's only record. All checks pass. The refusal set, and so the settle set, also holds a non-completed record at the start's own The rule to satisfy: exact-owner recovery binds the device the record names, never the requester's device. None of the open inline threads still applies: the record-runtime-orphan-recovery.ts thread is outdated because the file is deleted, and |
A start refuses on a non-completed record at its own session path even when that record names another device. The settle recovered that record through the start device, so a recording still running on the other device could have its only record completed from the wrong one. The settle now recovers only records on the start device. A record that another device left under the same session name still refuses, and the refusal names that device: stop it in that session, or start under another session name.
The start-time settle ran exact-owner recovery, which force-cleans any capture it can reattach. On an iOS simulator that discarded a video a record stop in the old session could still export, so a new start on the same simulator lost the earlier recording. The settle now does what the record's own stop would: it finishes the record, so the export lands at its output path and a later record stop in that session returns it. Only a record that cannot finish, such as an Android recording whose device restarted, falls back to exact-owner recovery.
|
Thanks, confirmed and fixed. Updated to To your open question first:
Known limits:
EvidenceHost macOS 26.7.1. Android emulators: Android fault: The 1. iOS, before this update ( The same run with the start on simulator A itself ( 2. Android, at 3. iOS, at 4. iOS, at Also at |
There was a problem hiding this comment.
1 issue found across 5 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/capture-kit/src/capture-admission/durable-capture-start-preflight.ts">
<violation number="1" location="packages/capture-kit/src/capture-admission/durable-capture-start-preflight.ts:83">
P3: `otherDevice` is decided by the full identity key, but the hint prints only `device.id`. When the id matches and only the shape differs, the message names the start device itself as the other device. Decide the other-device case by id so the wording matches the printed id.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
| const otherDevice = | ||
| deviceIdentityKey(conflict.envelope.device) === deviceIdentityKey(deviceIdentity(device)) | ||
| ? undefined | ||
| : conflict.envelope.device.id; |
There was a problem hiding this comment.
P3: otherDevice is decided by the full identity key, but the hint prints only device.id. When the id matches and only the shape differs, the message names the start device itself as the other device. Decide the other-device case by id so the wording matches the printed id.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/capture-kit/src/capture-admission/durable-capture-start-preflight.ts, line 83:
<comment>`otherDevice` is decided by the full identity key, but the hint prints only `device.id`. When the id matches and only the shape differs, the message names the start device itself as the other device. Decide the other-device case by id so the wording matches the printed id.</comment>
<file context>
@@ -80,13 +80,19 @@ function assertNoConflictingManifest<K extends string, C>(
const [conflict] = listDurableCaptureStartConflicts(definition, resourcePath, device).records;
if (!conflict) return;
const session = conflict.envelope.sessionId;
+ const otherDevice =
+ deviceIdentityKey(conflict.envelope.device) === deviceIdentityKey(deviceIdentity(device))
+ ? undefined
</file context>
| const otherDevice = | |
| deviceIdentityKey(conflict.envelope.device) === deviceIdentityKey(deviceIdentity(device)) | |
| ? undefined | |
| : conflict.envelope.device.id; | |
| const otherDevice = | |
| conflict.envelope.device.id === device.id ? undefined : conflict.envelope.device.id; |
There was a problem hiding this comment.
Not changing this. The settle skips a record by the same full identity key (deviceIdentityKey), so the refusal decides "other device" by that rule too. If the hint compared only ids, a record the settle skipped, with the same id but a different shape, would get the "for this device" wording, although the start never tried to settle it. The message stays tied to what the start actually did.
The record start help and the changeset described the fallback for a record that cannot finish only as the exact-owner recovery a daemon restart runs. Say that this recovery discards what the recording left, so a caller knows a start can delete an unfinished recording.
|
At c254f79, the help-text problem from the earlier review (#4218 (comment)) is fixed: the help and changeset now say the start-time fallback discards what an unfinishable recording left. I found no new code problems, the one check is green, and there are no conflicts. I read the change and did not run it; the Android and iOS simulator transcripts are yours and predate c254f79, which changes only help text and the changeset. One design question before this is ready: could Not blocking, take or leave: the help still ends with "only closing the session disposes them", which holds only while the daemon holds that session; the hand-written identity comparisons could use |
listDurableCaptureStartConflicts already decided whether each record is on the start device, then dropped that fact, so the start-time settle and the refusal wording each compared device identities again. Return onStartDevice with each record and read it in both places, so what the settle skips and what the refusal calls another device can not drift apart. Compare with sameDeviceIdentity. The record help said only closing the session disposes what a failed record stop keeps. That holds only while the daemon holds the session; once it does not, the next record start on that device settles it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks. Took the tag, updated to
This is a refactor with no behavior change, so I did not rerun the devices. The existing tests pin both reads of the flag: if the settle ignores
|
|
At 2482c01, the code looks good, and the design question from the earlier review is settled. The one reported check is green and there are no conflicts. I read the change and did not run it; the refactor looks behavior-neutral, and the Android and iOS simulator runs in the PR body cover the earlier heads. Keeping the "other device" hint as the id only is fine, since the record stays refused either way (P3 thread). The other open threads are fixed or no longer apply at this head and can be resolved. |
|
The Coverage failure at |
Summary
A device that restarts mid-recording can leave its screen recording record
open/cleanup-pendingwith reasonownership-fence-lost. This happens when daemon recovery runs while the device is still booting: Android reports the manifest as missing while /sdcard is not mounted, and recovery then retains the record. Only daemon start and device-claim reconciliation retry it, and a recoveredrecord stopcannot finish it because the recording died with the device. After the claim is gone, everyrecord starton that device fails withcleanup-unconfirmed.The start preflight now lists the records it refuses on, and
record startsettles the ones on its own device whose session the daemon no longer holds:finishRecoveredDurableCapture, so a video that can still be exported (an iOS simulator recording whose daemon died) lands at its output path, and a laterrecord stopin that session returns it. Only a record that cannot finish, such as the Android reboot case, falls back to the existing exact-owner recovery.record stopkeeps its retry.cleanup-unconfirmed, and the refusal names the session.The retry sits at
record start, not in device-claim reconciliation: claim reconciliation settles only the claim's own session, and Android screen recording is the only capture kind with a device-side manifest that can misread during boot.Commits:
d9ef23d18adds the start-time settle.b18cb9fedkeeps it on the start device.570661e62finishes a record before cleaning it.c254f79c9says in the help that the fallback recovery discards what the recording left.2482c01a9lets the settle and the refusal read oneonStartDeviceflag from the conflict list.Validation
Tested SHA: 2482c01.
pnpm check:affected --run --head 2482c01a9passed (format, lint, typecheck, layering, fallow, build, vitest-related, unit),exactCommit=true.Tests in
record-runtime-orphan-recovery.test.ts(8 cases):missing: the record endscompletedand the start succeeds.reattachis not called, and the refusal names that device.cleanup-unconfirmed.record stop); the refusal names the session.Live runs (commands and record states are in the review thread):
Medium_PhoneAPI 36 as A,Pixel_2API 27 as B): the stuck record from a reboot refuses a start on B under its own session name and stays open. A start under another session name on B succeeds. A start on A settles the record tocompleted/cleanedand records normally.record stopin that session then exports the video.Known limits: on Android the failed finish leaves an unplayable
<out>.collected.mp4next to the old output path, as a failedrecord stopdoes today. Not covered: a physical iOS device, and two concurrentrecord startrequests on one device.🤖 Generated with Claude Code