Repository navigation
[Bug] "Modified Files" panel does not clear after git commit #11856
Copy link
Copy link
Closed
Description
Description
After committing files with git commit, the "Modified Files" panel in the sidebar still shows those files as modified. Users expect committed files to be removed from this list.
Steps to Reproduce
- Start OpenCode in a git repository
- Make changes to files using OpenCode (AI edits)
- Observe "Modified Files" panel shows the changed files
- Run
git add . && git commit -m "commit message"(either via OpenCode bash tool or external terminal) - Observe "Modified Files" panel still shows the same files
Expected Behavior
Files that have been committed should be removed from the "Modified Files" list, since they are no longer "modified" from git's perspective.
Actual Behavior
Committed files remain in the "Modified Files" list until the session ends or OpenCode is restarted.
Root Cause Analysis
After investigating the codebase, I found that:
-
session_diffis computed from OpenCode's internal snapshot system, not the user's git repository- Internal snapshots are stored in
~/.local/share/opencode/snapshot/{project-id}/ SessionSummary.summarize()computes diff betweenstep-startandstep-finishsnapshot hashes
- Internal snapshots are stored in
-
No git commit event detection exists
FileWatcheronly watches.git/HEADfor branch changes (packages/opencode/src/file/watcher.ts)Vcsnamespace only handlesBranchUpdatedevents (packages/opencode/src/project/vcs.ts)- There is no handler that detects when a
git commithappens
-
session_diffis never refreshed after external git operations- Once computed,
session_diffpersists until session ends - User's
git commitdoes not trigger any recalculation
- Once computed,
Relevant Code
packages/opencode/src/session/summary.ts:
async function summarizeSession(input: { sessionID: string; messages: MessageV2.WithParts[] }) {
const diffs = await computeDiff({ messages: input.messages })
// ...
await Storage.write(["session_diff", input.sessionID], diffs)
Bus.publish(Session.Event.Diff, { sessionID: input.sessionID, diff: diffs })
}packages/opencode/src/project/vcs.ts:
// Only watches for branch changes, not commits
const unsubscribe = Bus.subscribe(FileWatcher.Event.Updated, async (evt) => {
if (evt.properties.file.endsWith("HEAD")) return
// ... only handles branch changes
})Proposed Solution
Option A: Detect git commit and filter session_diff
- Watch for
.git/indexor.git/refs/heads/*changes inFileWatcher - On commit detection, filter
session_diffto only include files that are still uncommitted - Publish updated diff to UI
Option B: Periodically refresh session_diff
- After bash tool executions that might be git commands, refresh
session_diff - Compare against current
git diff --name-only HEADto filter committed files
Environment
- OS: macOS
- OpenCode version: latest from
devbranch - Commit:
7b3c82d95c10e7ec364d8b970209dadfdb43e4dc
Related Issues
- Session summary/diff is worktree-global (not session-scoped) causing cross-session attribution #11802 - Related issue about session_diff being worktree-global (different but related problem)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
github-actions commentedon Feb 2, 2026
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if these don't address your specific case.
taetaetae commentedon Feb 2, 2026
Thanks for the duplicate check!
I reviewed #10920 and it describes the same symptom (changes tab not updating after commit), but from the Desktop/Web perspective.
This issue provides:
session/summary.ts,project/vcs.ts,snapshot/index.ts)The root cause is the same:
session_diffis computed from OpenCode's internal snapshot system and never refreshed after external git operations.I'm happy to work on a PR if the maintainers agree with one of the proposed approaches. The fix would likely benefit both #10920 (Desktop) and this issue (TUI) since they share the same backend code.
cc @adamdotdevin @rekram1-node
azkore commentedon Feb 19, 2026
For anyone who doesn't want to wait for a proper fix and would like to clean up the sidebar right now — here's a workaround script (AI-assisted) that I've been using:
https://gist.github.com/azkore/807e5736aad043ad5d442acb686140cd
How it works: As described in the issue, the sidebar is driven by snapshot tree hashes stored in
step-start/step-finishparts, not by actual git state. The script clears those stale snapshot references and injects a fresh baseline (HEADtree → current working tree) thatcomputeDifftreats as native. After running it, the sidebar reflects real uncommitted changes — and stays correct through subsequent prompts because the injectedstep-startanchorsfromtoHEAD.Heads up: This directly mutates the OpenCode DB and snapshot data. Works great for me but please back up your DB (
~/.local/share/opencode/opencode.db) before trying it. Best run while the session is idle.Usage:
oc-refresh-diff <session-id>github-actions commentedon Apr 21, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.
fix: session changes panel always empty — restore diff computation