Skip to content

fix: stop cap record cleanly before the drive fills - #4583

Open
richiemcilroy wants to merge 2 commits into
mainfrom
fix/cli-record-low-storage
Open

richiemcilroy wants to merge 2 commits into
mainfrom
fix/cli-record-low-storage

Conversation

@richiemcilroy

@richiemcilroy richiemcilroy commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

cap record now watches free space on the recording's drive with the same rule and cadence as Cap Desktop. It refuses to start at 512 MB free or less, emits a storage event when space runs low, and before saving would no longer fit it stops by itself, saves everything captured, emits stopped with reason: lowStorage and exits 3. Detached sessions record the same in cap record status, and cap record stop reports it. Successful recordings print and return exactly what they did before.

Docs: cap guide --json (exit code 3, storage event), README and the Cap skill.

Testing: unit tests for the stop reason, events and session fields; real recordings on small volumes on macOS, Windows and Linux, base vs head (results in the PR thread).

Confidence Score: 4/5 · The PR appears safe to merge, with a non-blocking gap in low-space warning reports.RetriggerView in GreptileConfidence Score: 4/5

The PR appears safe to merge, with a non-blocking gap in low-space warning reports.

Findings

  1. P2 Low-space warning can be skipped ▶
Fix with agent prompt
### Issue 1
apps/cli/src/record.rs:250-255
`watch_storage` skips `on_warning` when its first sample is `Exhausted`. A recording can start just above 512 MiB free and reach this branch before the first check two seconds later. It stops and saves, but never emits the documented `storage` event. Detached sessions also keep `storageLow` false until saving finishes.

Report the low-space transition before returning, unless it was already reported.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds low-space protection to CLI recordings using Desktop's shared storage checks.

  • The CLI saves recordings before low disk space blocks finalization.
  • Detached sessions show when low disk space stopped a recording.

Reviews (1) · Last reviewed commit: "style: rustfmt" · Reviewed by Greptile

@vercel

vercel Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
cap-status Ignored Ignored Preview Nov 27, 2026 11:41am UTC

@richiemcilroy
richiemcilroy marked this pull request as ready for review November 27, 2026 12:57
@sandchest-com

sandchest-com Bot commented Nov 27, 2026

Copy link
Copy Markdown

Sandchest

Sandchest reviewed 29a1af9: nothing exploitable found in this change.

Sandchest reviews every change for vulnerabilities an attacker could use · 1 credit · Review details

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Capy found no issues.

View 1 other finding in Capy.

Open in Capy

Comment thread apps/cli/src/record.rs
Comment on lines +250 to +255
DiskSpaceStatus::Exhausted => {
log_storage(
storage,
"Recording storage is low; stopping to save the recording",
);
return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Low-space warning can be skipped

watch_storage skips on_warning when its first sample is Exhausted. A recording can start just above 512 MiB free and reach this branch before the first check two seconds later. It stops and saves, but never emits the documented storage event. Detached sessions also keep storageLow false until saving finishes.

Report the low-space transition before returning, unless it was already reported.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/cli/src/record.rs
Line: 250-255

Comment:
**Low-space warning can be skipped**

`watch_storage` skips `on_warning` when its first sample is `Exhausted`. A recording can start just above 512 MiB free and reach this branch before the first check two seconds later. It stops and saves, but never emits the documented `storage` event. Detached sessions also keep `storageLow` false until saving finishes.

Report the low-space transition before returning, unless it was already reported.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

This branch has not been deployed

No deployments
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

GitHub 镜像 · 非官方 · 不支持登录