Skip to content

snapshot-home-directory-hang #32974

Closed as not planned
Closed as not planned

Description

@eskbusiness

Description

01-snapshot-home-directory-hang.md

Issue: Snapshot on home directory hangs opencode indefinitely

Summary

Running opencode from the home directory (~) causes the program to freeze completely because it tries to create a git-based snapshot of the entire home folder — which can be hundreds of gigabytes with tens of thousands of files.


The Problem (non-technical)

Imagine you sit down at your computer, open a terminal, type opencode, and the program starts... but then nothing responds. You cannot type, you cannot click, you cannot even close it cleanly. You have to open another terminal and force-kill it.

This happens because opencode, when it starts, tries to take a "snapshot" of every file in the current directory so it can track changes later. If you are in your home folder — which might have your Desktop, Documents, Downloads, and years of accumulated files — that snapshot can take many minutes or even hours. During that time, the program is completely frozen.

Technical Explanation

opencode's architecture uses an internal git worktree for its snapshot system (implemented in opencode/src/backend/snapshot.ts). When a session starts, it:

  1. Initializes a bare git repository under ~/.local/share/opencode/snapshot/<hash>/
  2. Runs git add --all --sparse against the workspace root directory
  3. Blocks the TUI event loop until this git operation completes

When the workspace root is the home directory (~):

  • Size: The home directory in our case is 223 GB with ~20,000 modified files
  • Git overhead: The home directory itself is already a git repository (with no .gitignore), so git scans all tracked files
  • No progress indicator: The TUI shows no spinner, no progress bar, no timeout
  • No cancellation: There is no way to cancel or interrupt the snapshot; Ctrl+C is not captured

The log shows evidence of this:

message=tracking hash=<sha1> cwd=/home/user git=/home/user/.local/share/opencode/snapshot/<hash>/<bare>

But during the actual snapshot operation, even logging pauses because git add is blocking the event loop.

Steps to Reproduce

# Prerequisite: your home directory should be a git repo
# or contain many files (common for any long-term user)
cd ~

# Run opencode
opencode

# Result:
# - TUI appears for ~1 second
# - Then the interface freezes
# - CPU goes to 100% (git process)
# - No keyboard input works
# - Must kill with: kill -9 $(pgrep opencode)

Current Workaround

Set "snapshot": false in ~/.config/opencode/opencode.json:

{
  "snapshot": false
}

This disables all snapshot functionality, which means the undo/revert feature no longer works.

Suggested Fixes (any one would help)

  1. Auto-detect workspace scope: If the workspace is the home directory (or any directory that is unusually large), either disable snapshots automatically or warn the user.

  2. Timeout mechanism: Set a 30-second timeout on snapshot initialization. If git add does not complete within that time, disable snapshots for the session and continue.

  3. Progress indicator: Show a spinner or progress bar during snapshot init so the user knows what is happening instead of seeing a frozen screen.

  4. Async snapshot: Run the snapshot in a background thread/coroutine and allow the TUI to become interactive immediately. The snapshot completes whenever it completes.

  5. Respect .gitignore: If the workspace root already has a .gitignore, use it to exclude common large directories (node_modules, .cache, .local, etc.) from the snapshot.

Plugins

No response

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. github-actions commented on Jun 19, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • The Description field contains only a link to an uploaded file — please paste the actual content inline so it is readable without downloading
    • Steps to reproduce, OpenCode version, Operating System, and Terminal are all empty (_No response_). These fields help us reproduce and diagnose the issue — please fill them in
    • The issue title appears to be a filename slug rather than a human-readable description of the problem

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


    This issue might be a duplicate of existing issues. Please check:

    If you believe this was flagged incorrectly, please let a maintainer know.

  2. github-actions commented on Jun 19, 2026

    @github-actions
    Contributor

    Thank you for updating the issue — the description is now inline, which is an improvement. However, there are still a few things that need to be addressed:

    What still needs to be fixed:

    • Steps to reproduce, OpenCode version, Operating System, and Terminal fields are still empty (_No response_). Please fill these in — even brief answers help us reproduce and diagnose the issue.
    • The description appears to be AI-generated (extensive non-technical explanations, highly polished structure with multiple layered sections). Please replace it with a concise, first-hand description of what you actually experienced.
    • The issue title is still a filename slug (snapshot-home-directory-hang) rather than a plain human-readable sentence.

    Please edit the issue to address these points.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

needs:complianceThis means the issue will auto-close after 2 hours.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions