Skip to content

feat(snapshot): Bound snapshot memory use and add storage cleanup - #4035

Open
wsp1911 wants to merge 2 commits into
openBitFun:mainfrom
wsp1911:fix/snapshot
Open

wsp1911 wants to merge 2 commits into
openBitFun:mainfrom
wsp1911:fix/snapshot

Conversation

@wsp1911

@wsp1911 wsp1911 commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Bound memory use during snapshot capture, history loading, and file-tool checks. The default capture limit is 128 MiB. Eligible files larger than 8 MiB stream to blob storage.
  • Add a Storage page under Data & Maintenance. It shows snapshot usage by workspace and previews the sessions and bytes eligible for cleanup before confirmation.
  • Include leftover snapshots from removed sessions in every time range. Record cleanup work before deleting a session so an interrupted cleanup can resume.

Type and Areas

  • Type — Bug fix and feature
  • Areas — Rust snapshot and session services, desktop/Tauri, settings UI, localization, and the product capability registry

Motivation / Impact

A user reported an out-of-memory crash while working with a 41 GB binary in an SSH workspace. Snapshot capture and loading legacy history could read large payloads into memory. The new read limits and streaming paths address both the current file and oversized history left by an earlier session.

Deleting a session could also leave snapshot files on disk when its snapshot manager was unavailable. The Storage page exposes those leftovers and their workspace ownership. Cleanup rechecks references and writer locks before reclaiming files, preserving workspace baselines, shared content, and undo checkpoints.

Verification

  • cargo check --locked -p openbitfun-desktop and pnpm run capabilities:check — both passed on the PR head.
  • pnpm --dir src/web-ui exec vitest run src/app/scenes/settings/pages/data/StorageSettingsPage.test.tsx — 5 tests passed on the PR head.
  • node scripts/check-git-object-sizes.mjs --base HEAD~2 --head HEAD and git diff --check HEAD~2..HEAD — passed.
  • cargo test --locked -p openbitfun-core --no-default-features --features agent-runtime,remote-workspace,git --lib service::snapshot:: — all 53 tests passed on the PR head, including large-file streaming, legacy restoration, simulated SSH profile isolation, and cleanup.
  • During development, the same command with the session_manager::tests::deletion filter passed all 7 session deletion tests.
  • On a temporary copy of an affected store, the preview identified 4 removed sessions and estimated 1,794,443 reclaimable bytes. Cleanup freed exactly that amount and left 40,018 bytes of baselines.

Reviewer Notes

AI-assisted implementation, tested with focused automated regressions and a copied storage fixture. SSH behavior was exercised with a simulated workspace transport. Live SSH, Peer Device, Remote Control, and Detached Dispatch were outside the manual test coverage.

To review the UI, open Settings → Data & Maintenance → Storage. Select a workspace, switch between 7 days, 30 days, and all sessions, and expand a workspace group. The time cutoff applies to existing sessions. Confirmed leftovers from removed sessions are eligible at every cutoff. Changing filters updates the preview. Cleanup requires confirmation.

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, or skipped checks are explained.
  • User-facing strings, docs, and locales are updated where applicable.

Show snapshot usage by workspace and preview the space that cleanup can
reclaim. Include snapshots of removed sessions in every time range and
preserve shared files and rollback checkpoints.

Record pending cleanup before deleting a session so reclamation can
resume after a restart.
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