You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 through toHomePath() for dedup to work correctly on edge cases (absolute paths under $HOME).
Tool-metadata gaps accepted (D4): tool metadata misses bash sed/bash rm on 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
buildCollapsedTree receives whatever paths the merged set contains — no special-casing
The touchedFilesQuery (separate query) is not affected
No new dependencies
Prior Art
The reviewDiffs memo in session.tsx (lines 708–759) — the merge point
accumulate-diffs.ts — the accumulateDiffs function and ToolEditPart type
review-panel-v2.tsx (lines 158–177) — buildCollapsedTree and common-root computation
Commit ca5a1be2 — the server-diff trust fix that introduced the current scoping
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-sideaccumulateDiffs()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
reviewDiffsmemo: 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'sbuildCollapsedTreealready computes a common root from all paths and adjusts the dropdown automatically.Scope — in: the
reviewDiffsmemo insession.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 sedon external files, which is rare for cross-project work). The server endpoint continues to be the ground truth for in-project files.Acceptance Criteria
Testing Decisions
Extend the existing fast suite (
pnpm --filter amicode test). ThereviewDiffsmemo is pure computation — testable with mock server-diff and tool-metadata inputs without a running server.Key Decisions
toHomePath(). Both must normalize throughtoHomePath()for dedup to work correctly on edge cases (absolute paths under$HOME).bash sed/bash rmon external files. Extending the server to snapshot multiple directories is out of scope (fork-level change).Constraints & Invariants
accumulateDiffs()function are not modifiedbuildCollapsedTreereceives whatever paths the merged set contains — no special-casingtouchedFilesQuery(separate query) is not affectedPrior Art
reviewDiffsmemo insession.tsx(lines 708–759) — the merge pointaccumulate-diffs.ts— theaccumulateDiffsfunction andToolEditParttypereview-panel-v2.tsx(lines 158–177) —buildCollapsedTreeand common-root computationca5a1be2— the server-diff trust fix that introduced the current scopingSource
Spec:
spec-20260903-134500-cross-project-files-changed· Review: approved-mechanical (3 advisories resolved: D2/AC5 tension, D3 normalization divergence, filtering mechanism)