Skip to content

Files Changed: show cross-project edits (merge server + tool-metadata diffs) #778

Description

@jeonghun-jj-lee

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 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

Source

Spec: spec-20260903-134500-cross-project-files-changed · Review: approved-mechanical (3 advisories resolved: D2/AC5 tension, D3 normalization divergence, filtering mechanism)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions