Skip to content

Snapshot feature consumes excessive disk space (170GB+ in my case) #17753

@JinHanAI

Description

@JinHanAI

Description

The snapshot feature accumulated 170GB of disk space on my Mac. The git objects in ~/.local/share/opencode/snapshot/ grew unchecked over time.

Root Cause

Looking at packages/opencode/src/snapshot/index.ts:

  • The entire worktree is tracked via git
  • Cleanup only runs hourly via scheduler with git gc --prune=7.days
  • No disk space warning when snapshot grows large
  • Temporary pack files (tmp_pack_*) may not be cleaned up if opencode crashes

Steps to Reproduce

  1. Use opencode regularly over time
  2. Check ~/.local/share/opencode/snapshot/ directory size
  3. In my case: du -sh ~/.local/share/opencode/snapshot/ showed 170GB

Workaround

  1. Delete the snapshot directory: rm -rf ~/.local/share/opencode/snapshot/
  2. Disable snapshot in config: {"snapshot": false}

Suggested Fix

Add a disk space warning when the snapshot directory exceeds a threshold (e.g., 1GB). This would alert users before the problem gets out of hand.

I'm willing to submit a PR for this if the maintainers agree with the approach.

Environment

  • OS: macOS Sequoia 15.3
  • OpenCode: latest (via brew)

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions