Skip to content

fix: preserve recordings when storage runs low - #2148

Merged
richiemcilroy merged 5 commits into
mainfrom
fix/recording-storage-safeguards
Aug 26, 2026
Merged

fix: preserve recordings when storage runs low#2148
richiemcilroy merged 5 commits into
mainfrom
fix/recording-storage-safeguards

Conversation

@richiemcilroy

@richiemcilroy richiemcilroy commented Aug 26, 2026

Copy link
Copy Markdown
Member

Summary

  • Show native low-storage warnings before recording, including deep-link starts, and restore the editor if preflight fails.
  • Sample free space and recording size every two seconds in one cancellable background task. Cache completed-fragment sizes with a bounded cache, reserve finalization space, and freeze the timer while saving.
  • Fix muxer reader shutdown deadlocks without killing slow writers. Preserve original fragments and recover complete segments missing from the last manifest.
  • Serialize and atomically replace Instant metadata, and stop upload tasks before exposing recovery after a local failure.

Verification

  • Scoped GPUI and recording checks passed, including an isolated source snapshot with the committed GPUI dependency patch.
  • GPUI recording (10), upload (11), library (14), and deep-link (16) tests passed. Coverage includes concurrent metadata updates, a partial write failure, upload cancellation, and recovery with stale recording state.
  • cap-muxer (8) unit tests passed. The isolated PR snapshot passed all 27 cap-utils library tests, including growing files, a 1 GiB recording reserve, and the cache limit.
  • All 9 out-of-process muxer integration tests passed against the rebuilt helper, including real encoded output, shutdown without stdin EOF, and preservation of a writer taking more than five seconds.
  • Native dialogs and automatic low-storage stopping were verified on macOS; the live test preserved all 119 captured frames.
  • A macOS benchmark of the actual monitor source with 10,000 fragments averaged 4.1 ms per cached sample over 200 samples, about 0.2% of one CPU core at the two-second interval. This is not a whole-app profile.
  • Real Instant media recovered and fully decoded with complete and truncated fragments when manifest entries were all unaccepted, the manifest was corrupt JSON, or the manifest was missing.
  • All 10 recording recovery unit tests passed. Scoped cap-utils and cap-recording Clippy checks passed.
  • Root and GPUI formatting and the isolated diff check passed.

Scope and limitations

CI is not fully green: the macOS sync job failed the unchanged channel-drain timing test (55 ms versus a 50 ms budget); all 10 recovery tests passed in that job. The same timing test passed five local retries. Windows and Linux A/V sync jobs passed; the macOS job is being rerun on the same PR head (attempt 2). Other native CI remains separate from these results.
Only the 11 recording/storage files in this PR are included. Concurrent platform, release, camera, and web changes are excluded. Authenticated Instant uploads and Windows/Linux runtime behavior were not exercised here. The two existing documentation tests in untouched crates/utils/src/lib.rs fail in the isolated base snapshot; those unrelated examples are unchanged. No migrations or deployment changes.

Greptile Summary

The PR adds storage-aware recording preflight, monitoring, finalization, and recovery while preserving media when local saving cannot complete.

  • Accounts for current recording size when reserving finalization space and automatically stopping.
  • Rejects truncated M4S fragments while recovering complete fragments omitted from stale manifests.
  • Adds atomic Instant metadata updates and safer muxer/upload shutdown behavior.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the recording-size monitor now reserves finalization space, and recovery rejects the truncated fragment state identified previously.

Important Files Changed

Filename Overview
apps/desktop-gpui/src/session.rs Coordinates the cancellable storage monitor with recording lifecycle transitions and low-storage stopping.
crates/utils/src/disk_space.rs Measures recording size with a bounded fragment cache and reserves sufficient space for finalization.
apps/desktop-gpui/src/library.rs Exposes interrupted Instant recordings only when initialization data and at least one structurally complete display fragment exist.
crates/recording/src/recovery.rs Filters incomplete M4S tails and recovers complete fragments omitted from stale, corrupt, or missing manifests.
apps/desktop-gpui/src/recording.rs Preserves local artifacts on low-storage failures and serializes Instant metadata and finalization updates.
crates/cap-muxer/src/main.rs Revises muxer shutdown handling to avoid reader deadlocks without prematurely terminating slow writers.

Reviews (2): Last reviewed commit: "fix: reject incomplete fragments during ..." | Re-trigger Greptile

@superagent-security

Copy link
Copy Markdown

Manage your Superagent protection

Superagent has paused scans for this repository because this unlinked GitHub App installation has used all three included PR scans.

You have 0 of 3 included PR scans remaining.

Create a free account to continue protection, manage scan settings, review security history, and control which repositories are protected.

@richiemcilroy

Copy link
Copy Markdown
Member Author

hey @greptileai, please re-review the PR

Comment thread apps/desktop-gpui/src/session.rs Outdated
Comment thread apps/desktop-gpui/src/library.rs
@richiemcilroy

Copy link
Copy Markdown
Member Author

hey @greptileai, please re-review the PR

@richiemcilroy
richiemcilroy merged commit aa93b22 into main Aug 26, 2026
26 of 30 checks passed
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