Repository navigation
Files Changed: show cross-project edits (merge server + tool-metadata diffs) #778
Description
Important
Problem — Files Changed only shows diffs within the session's project directory (the VS Code workspace folder). Cross-package developers editing files outside the project — common in monorepo or multi-project workflows — are blind to those changes. Before the server-diff trust fix (ca5a1be2), the panel accidentally showed all edits because the client-side accumulateDiffs() fallback scraped every tool-edit part regardless of directory. The fix correctly prioritized the server endpoint but lost cross-project visibility as a side effect.
Approach — Merge both diff sources in the reviewDiffs memo: server shadow-git diffs (authoritative for in-project files) unioned with tool-metadata diffs (for files outside the project directory), deduplicated by normalized file path with server winning on conflict. Cross-project visibility is the emergent effect of server-wins dedup — no explicit "is this under the project?" check, just set subtraction. The file tree's buildCollapsedTree already computes a common root from all paths and adjusts the dropdown automatically.
Scope — in: the reviewDiffs memo in session.tsx (~30 lines). out: server endpoint, shadow-git system, accumulateDiffs(), buildCollapsedTree, the diff viewer.
Assumptions — Tool-metadata quality is acceptable for cross-project diffs (misses bash sed on external files, which is rare for cross-project work). The server endpoint continues to be the ground truth for in-project files.
Acceptance Criteria
- Files edited by the agent outside the session's project directory appear in the Files Changed panel
- In-project files still use server shadow-git diffs (filesystem truth, not tool metadata)
- When both sources report the same file, the server version is displayed (server-wins dedup)
- The file tree dropdown adjusts its common root to encompass both in-project and cross-project files
- When the server hasn't responded yet, tool-metadata diffs display alone (current fallback behavior preserved — all files shown, including in-project)
Testing Decisions
Extend the existing fast suite (pnpm --filter amicode test). The reviewDiffs memo is pure computation — testable with mock server-diff and tool-metadata inputs without a running server.
Key Decisions
- Server-wins dedup (D1): when a file path appears in both sources, the server diff is kept — it carries a real git cumulative patch; tool-metadata patches are last-edit-only approximations for multi-edit files.
- Always compute tool-metadata, merge via set subtraction (D2): the tool-metadata scrape runs unconditionally. The merge drops any tool-metadata entry whose normalized path appears in the server set. In the fallback branch (server not yet responded), there is no server set to subtract, so all tool-metadata diffs are shown (preserving current behavior).
- Unified path normalization (D3): the two sources currently use different normalization — server diffs use an inline conditional, tool-metadata uses
toHomePath(). Both must normalize throughtoHomePath()for dedup to work correctly on edge cases (absolute paths under$HOME). - Tool-metadata gaps accepted (D4): tool metadata misses
bash sed/bash rmon external files. Extending the server to snapshot multiple directories is out of scope (fork-level change).
Constraints & Invariants
- The server endpoint, shadow-git system, and
accumulateDiffs()function are not modified buildCollapsedTreereceives whatever paths the merged set contains — no special-casing- The
touchedFilesQuery(separate query) is not affected - No new dependencies
Prior Art
- The
reviewDiffsmemo insession.tsx(lines 708–759) — the merge point accumulate-diffs.ts— theaccumulateDiffsfunction andToolEditParttypereview-panel-v2.tsx(lines 158–177) —buildCollapsedTreeand common-root computation- Commit
ca5a1be2— the server-diff trust fix that introduced the current scoping
Source
Spec: spec-20260903-134500-cross-project-files-changed · Review: approved-mechanical (3 advisories resolved: D2/AC5 tension, D3 normalization divergence, filtering mechanism)
Activity
feat: Files Changed shows cross-project edits (#778)
chore: remove dead merge-diffs module (#778 inlined the logic)
jeonghun-jj-lee commentedon Sep 12, 2026
Implemented across #774 (mergeServerAndToolDiffs with projectPrefix dedup, server-wins, cross-project tool-metadata fallback) and #845 (per-session file watcher for external-change refresh + crossProjectStatus). All five acceptance criteria are met in
accumulate-diffs.ts.