anomalyco / anomalyco/opencode
Cross-session file change leak: "Files Changed" panel shows modifications from other sessions in the same directory
@Hona is already working on this.
Since Aug 9, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
Bug
When two sessions run in the same directory, the "Files Changed" review panel in one session displays file modifications made by the other session — even if that session didn't modify any files.
Affected: Desktop/Web app (packages/app)
Not affected: TUI (packages/tui) — uses per-session session_diff[sessionID], already isolated
Expected behavior
Session 2's "Files Changed" panel should show 0 files (it didn't modify anything).
Actual behavior
Session 2's "Files Changed" panel shows the files that Session 1 modified.
Root cause
The default review mode is "git" (packages/app/src/pages/session.tsx:374), which queries Vcs.diff("git") — equivalent to git status + git diff HEAD on the entire working tree. This is directory-scoped and shared across all sessions in the same folder.
Two triggers cause Session 2 to refresh and pick up Session 1's changes:
- File watcher (
session.tsx:952-961): anyfilesystem.changedevent firesrefreshVcs()in all sessions in the same directory. - Session idle (
session.tsx:1097-1106): when Session 2's response completes (status →idle), it also callsrefreshVcs().
Additionally, the vcsKey cache key (session.tsx:679-682) is ["session-vcs", directory, branch, default_branch] — no session ID — so sessions share the same cached diff result.
The TUI doesn't have this issue because its sidebar reads sync.data.session_diff[sessionID] (packages/tui/src/feature-plugins/sidebar/files.tsx:17), which is keyed by session ID.
Suggested fix
Keep "git" as the default review mode, but attribute working tree changes to the session that made them. Filter the Vcs.diff("git") results to only include files that the current session actually modified, using the session's own snapshot/turn diff data as the filter.
Concretely, intersect the git working tree diff with the current session's turnDiffs (lastUserMessage().summary.diffs) so only files changed by this session are shown. This preserves the git mode experience (real git diffs, syntax highlighting, staging support) while ensuring per-session isolation.
The vcsKey cache key should also include the session ID to prevent cross-session cache sharing.
Plugins
No response
OpenCode version
No response
Steps to reproduce
- Open two sessions in the same project directory (desktop app)
- In Session 1, ask the agent to edit a file
- In Session 2, ask the agent a simple question that doesn't involve any file modifications
- Wait for Session 2 to finish responding
Screenshot and/or share link
Operating System
Windows11
Terminal
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.