Session Changes / Modified Files show changes from origin/main #4575

Open
opened 2026-02-16 17:44:39 -05:00 by yindo · 3 comments
Owner

Originally created by @nathanchapman on GitHub (Jan 9, 2026).

Originally assigned to: @adamdotdevin on GitHub.

Description

"Session Changes" (in OpenCode Desktop) / "Modified Files" (in the TUI) is showing a bunch of irrelevant changes that neither I nor OpenCode made. I believe it's diffing against origin/main and treating the diff as if there are changes, rather than looking at the base branch

I'm using graphite, so that may be contributing here. These additional changes show up regardless of which branch I checkout in the stack. I can't provide screenshots yet, as this is happening on a private repo, but I'll work on getting a repro with screenshots that I can share

Plugins

No response

OpenCode version

1.1.11

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

macOS 15.7.3

Terminal

TUI + desktop app

Originally created by @nathanchapman on GitHub (Jan 9, 2026). Originally assigned to: @adamdotdevin on GitHub. ### Description "Session Changes" (in OpenCode Desktop) / "Modified Files" (in the TUI) is showing a bunch of irrelevant changes that neither I nor OpenCode made. I believe it's diffing against origin/main and treating the diff as if there are changes, rather than looking at the base branch I'm using graphite, so that may be contributing here. These additional changes show up regardless of which branch I checkout in the stack. I can't provide screenshots yet, as this is happening on a private repo, but I'll work on getting a repro with screenshots that I can share ### Plugins _No response_ ### OpenCode version 1.1.11 ### Steps to reproduce _No response_ ### Screenshot and/or share link _No response_ ### Operating System macOS 15.7.3 ### Terminal TUI + desktop app
yindo added the bugweb labels 2026-02-16 17:44:39 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 9, 2026):

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

  • #6903: opencode report internal files as modified files in the session
  • #5049: auto update shows the updated file in "Modified Files" section on the right sidebar

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 9, 2026): This issue might be a duplicate of existing issues. Please check: - #6903: opencode report internal files as modified files in the session - #5049: auto update shows the updated file in "Modified Files" section on the right sidebar Feel free to ignore if none of these address your specific case.
Author
Owner

@nathanchapman commented on GitHub (Jan 9, 2026):

Follow-up Root Cause Analysis from OpenCode:

After digging through the codebase, I believe I've identified the root cause. This is related to rebasing/restacking rather than just branch switching.

How the Snapshot System Works

OpenCode maintains a separate git repository for snapshots at ~/.local/share/opencode/snapshot/<project-id>/. The project-id is derived from the root commit hash, so all branches in a repo share the same snapshot directory.

When a session starts, [`Snapshot.track()`](https://github.com/anomalyco/opencode/blob/dev/packages/opencode/src/snapshot/index.ts#L12-L35) runs git add . and git write-tree to create a tree object representing the current worktree state. Session diffs are computed by comparing the step-start snapshot to the step-finish snapshot.

The Bug

The problem occurs when you rebase (or gt restack with Graphite):

You start a session before rebasing → OpenCode creates snapshot S1
You rebase your stack, pulling in upstream changes from main
You continue the session (or start a new one) → OpenCode creates snapshot S2
The diff S1 → S2 now includes all changes from main that came in via rebase
The snapshot system has no awareness that a rebase occurred - it just sees "file content changed" and reports those as session changes. This explains why the changes appear to be from other people's commits on main.

Potential Fixes

Detect HEAD changes: Track the HEAD commit when creating snapshots. If HEAD changes unexpectedly (rebase, checkout, etc.), invalidate stale snapshots
Fresh snapshots per-session: Don't rely on persistent snapshot state across sessions
Branch+commit aware snapshots: Include branch name and/or commit hash in the snapshot path
@nathanchapman commented on GitHub (Jan 9, 2026): Follow-up Root Cause Analysis from OpenCode: ``` After digging through the codebase, I believe I've identified the root cause. This is related to rebasing/restacking rather than just branch switching. How the Snapshot System Works OpenCode maintains a separate git repository for snapshots at ~/.local/share/opencode/snapshot/<project-id>/. The project-id is derived from the root commit hash, so all branches in a repo share the same snapshot directory. When a session starts, [`Snapshot.track()`](https://github.com/anomalyco/opencode/blob/dev/packages/opencode/src/snapshot/index.ts#L12-L35) runs git add . and git write-tree to create a tree object representing the current worktree state. Session diffs are computed by comparing the step-start snapshot to the step-finish snapshot. The Bug The problem occurs when you rebase (or gt restack with Graphite): You start a session before rebasing → OpenCode creates snapshot S1 You rebase your stack, pulling in upstream changes from main You continue the session (or start a new one) → OpenCode creates snapshot S2 The diff S1 → S2 now includes all changes from main that came in via rebase The snapshot system has no awareness that a rebase occurred - it just sees "file content changed" and reports those as session changes. This explains why the changes appear to be from other people's commits on main. Potential Fixes Detect HEAD changes: Track the HEAD commit when creating snapshots. If HEAD changes unexpectedly (rebase, checkout, etc.), invalidate stale snapshots Fresh snapshots per-session: Don't rely on persistent snapshot state across sessions Branch+commit aware snapshots: Include branch name and/or commit hash in the snapshot path ```
Author
Owner

@alexandrereyes commented on GitHub (Jan 28, 2026):

I'm experiencing a related issue with .NET projects. When the agent compiles the project (e.g., runs dotnet build), all files in bin/ and obj/ folders appear as "modified" in the Session Changes / Review panel, even though they are properly listed in .gitignore:

This pollutes the changes view with dozens of DLLs, PDBs, and other build artifacts that are completely irrelevant to the actual code changes made by the agent.

Expected behavior: Files matching .gitignore patterns should not appear in the session diff / modified files list.

@alexandrereyes commented on GitHub (Jan 28, 2026): I'm experiencing a related issue with .NET projects. When the agent compiles the project (e.g., runs `dotnet build`), all files in `bin/` and `obj/` folders appear as "modified" in the Session Changes / Review panel, even though they are properly listed in `.gitignore`: This pollutes the changes view with dozens of DLLs, PDBs, and other build artifacts that are completely irrelevant to the actual code changes made by the agent. **Expected behavior:** Files matching `.gitignore` patterns should not appear in the session diff / modified files list.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4575