Skip to content

feat(desktop): store VM image + staged binaries in the cache dir#268

Merged
robdmac merged 1 commit into
mainfrom
feat/vm-cache-dir
Jul 15, 2026
Merged

feat(desktop): store VM image + staged binaries in the cache dir#268
robdmac merged 1 commit into
mainfrom
feat/vm-cache-dir

Conversation

@robdmac

@robdmac robdmac commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

The VM disk image (1GB) and staged runtime binaries lived under the app-data dir (/Library/Application Support/com.orcabot.desktop). They're large and fully regenerable, so move them to the cache dir (~/Library/Caches/com.orcabot.desktop/vm):

The VM disk image (~1GB) and staged runtime binaries lived under the app-data
dir (~/Library/Application Support/com.orcabot.desktop). They're large and fully
regenerable, so move them to the cache dir (~/Library/Caches/com.orcabot.desktop/vm):

- Caches is the OS-purgeable bucket and what uninstallers/cleaners treat as
  disposable, so a deleted app no longer strands ~1GB of precious-looking data.
- Application Support now holds only real user data (workspace, D1 db, secrets key).
- One-time migration on first launch after upgrade:
  - same-volume: instant atomic rename (the macOS case);
  - cross-volume (EXDEV; split XDG dirs / roaming profiles): copy into a temp
    sibling, atomically rename it into place — so a crash mid-copy never leaves a
    truncated sandbox-<version>.img that ensure_vm_image would boot;
  - the old dir is reclaimed (reclaim_old_vm_dir) ONLY after stage_vm_resources
    confirms a valid image — never on mere directory existence — so a failed
    migration+download (e.g. cache volume full) can't delete the last working image;
  - any copy/swap failure preserves the old dir.
- If cache staging fails but the preserved old dir still has a valid image, boot
  from it instead of failing every launch; a later writable-cache launch migrates
  and reclaims it.
- Falls back to the data dir if no cache dir resolves (no behavior change there).

stage_vm_resources / ensure_vm_image now take the resolved vm_dir instead of
deriving it from data_dir; start_sandbox_vm resolves it from app_cache_dir().
Bumps main + vm-image REVISION markers; updates desktop/CLAUDE.md image-staging.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014t8Ukp4NPWtqJ55X261wMZ
@robdmac
robdmac merged commit 3244f6d into main Jul 15, 2026
1 check passed
@robdmac
robdmac deleted the feat/vm-cache-dir branch July 15, 2026 00:00
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