Skip to content

[CR-5][P1] Add revision-bound remote diffs, context folding and file navigation #324

Open

Description

@BunsDev

Outcome

Reconstruct R4's grouped unified diffs and right-hand file tree inside the split Code Review workspace. Every displayed patch, expanded context and future comment anchor must refer to the selected remote PR revision, never the user's unrelated local working tree.

Parent: #319. Blocked by accepted artifacts: #321's file/patch/context reads and #322's Changes/split host; shared identities and reference fixtures come from #320. Can proceed in parallel with #323. Produces revision/line anchors and bounded evidence for CR-6/7.

Verified starting point / proposed files

Read current AGENTS.md, current main/open PRs and #320's source map. Audit baseline cb33db5df00e235f68d36b5fac556dc30e0851f2 contains apps/desktop/src/renderer/components/ChangesPanel.tsx with exported Diff, FileIcon, FileGroup, folding, wrap/highlight options and LOCAL Discard controls. apps/desktop/src/main/engine/git.ts supplies local filesystem operations. Reuse pure presentation only; do not pass remote paths or PR identifiers into local diff/discard handlers.

Proposed additions when no equivalent exists: apps/desktop/src/renderer/components/code-review/PrChanges.tsx, a focused pure patch model beside it or in the existing shared diff module, apps/desktop/test/code-review-diff.test.ts, and apps/desktop/e2e/code-review-diff.spec.ts. Confirm placement before implementation. No Monaco/editor-library migration unless measured need and an explicit reviewed decision justify it.

Items to do

  • Write failing parser/model tests for multiple hunks, added/deleted/renamed files, old/new line numbering, empty files, no-final-newline markers, Unicode/space-containing paths, binary files and omitted/truncated patches. Preserve both old and new paths and diff sides where required.
  • Define a revision-bound file identity and line anchor using [CR-1][P1] Establish the Code Review reference contract and deterministic fixtures #320's PrKey/PrRevision, validated path, side and line/range. Old anchors become outdated when the head changes; never silently reinterpret them on a new revision.
  • Extract or adapt the smallest pure rendering layer from the existing Changes presentation. Give remote views no Discard/revert/local-open capability. Preserve local Changes behavior with regression tests before and after extraction.
  • Render multiple file sections with compact headers, additions/deletions, collapsed unchanged-context rows and a filterable hierarchical file navigator. File selection scrolls to the correct section without losing the user's overall position; support independently scrollable diff and tree, wrapping and collapsed file state.
  • Fetch bounded extra context at the exact remote base/head revisions. Render cancellation/retry and stale responses correctly. Never read a same-named local file as a convenient fallback, execute a repo hook, checkout the branch or apply a patch to show it.
  • Represent binary, unavailable, oversized and provider-truncated data explicitly. Distinguish total provider counts from the subset currently rendered or loaded. A missing patch is not a zero-line change. Provide a validated Open in GitHub fallback where useful.
  • Bound fetching, parsing and mounted content. Begin with lazy per-file loading and measured limits; introduce virtualization only where needed while preserving selection, keyboard access and line anchors. Record behavior on synthetic large-file and many-file fixtures rather than asserting performance from a small screenshot.
  • Keep filenames/code inert and path-direction handling understandable. Add keyboard file navigation, visible focus and accessible add/remove/context labels; color alone must not encode the change type.

Acceptance criteria

  • AC1: R4's overview-plus-grouped-diff arrangement, file tree, context folds and selected-file behavior work through actual controls and match approved reference geometry.
  • AC2: parser and anchor fixtures prove correct old/new line references for additions, deletions, renames and missing final newlines. Expanding context preserves those references.
  • AC3: changing PR/account/head during a delayed patch request cannot overwrite the current view. Old review/comment anchors remain explicitly outdated.
  • AC4: no remote diff action can call local Discard, read an arbitrary workspace path or execute code. Existing local Changes/discard tests still pass.
  • AC5: binary/omitted/oversized/truncated responses remain distinguishable and disclose incomplete coverage; no invented code or false zero counts.
  • AC6: keyboard and narrow-window navigation work; measured stress runs establish bounded requests/DOM/memory and record latency on a named environment. Any agreed performance budget is documented and enforced by an appropriate regression test.

Validation / handoff

Run the focused Node patch/anchor tests, local Changes regressions and Electron Playwright tests, then pnpm build && pnpm test and pnpm test:e2e. Use synthetic stress cases such as 1,000 files and a 3 MiB textual patch as test inputs, not claims about GitHub's API limits. Document chosen product limits and the actual endpoint's current limits separately. Record exact SHA, screenshots, timings, coverage limitations and commands in docs/reviews/; update docs/status.md. Do not auto-accept goldens or merge.

Sources: #319, the verified ChangesPanel/git entry points, GitHub PR API, Playwright snapshots.

Long-running goal prompt

Implement CR-5 for #319 in TypeSafeAI/modex after reading #320/#321/#322, current source, open PRs and scoped AGENTS.md. Verify the owned worktree and current main. Start with failing patch/anchor and local Changes regression tests. Reuse the smallest pure part of ChangesPanel to build a read-only, revision-bound remote diff with grouped file sections, a filterable file tree and bounded context expansion. Keep remote PR paths out of local filesystem/discard handlers. Treat binary, omitted and truncated patches honestly, reject stale responses, and preserve old/new side-and-line anchors across rendering. Do not migrate editors, execute PR code, checkout branches, apply patches or call providers. Measure large-data behavior and inspect R4 plus keyboard/narrow layouts. Work in small tested slices; checkpoint full SHA, changed files, commands/results, evidence, limits and one next action. Finish with a signed reviewable PR and criterion-level proof, not visual similarity alone. Do not merge or release.

Follow-up / resume prompt

Resume CR-5 by verifying worktree ownership, live issue/PR state and the actual diff. Rerun patch/anchor and local Changes smoke tests. Confirm the producer contract and selected remote revision before using cached content or previous findings. Continue the smallest missing acceptance item, concentrating on stale responses, incomplete patches and source/line accuracy. Preserve unrelated shell changes and avoid broad refactors. Keep performance numbers tied to a named environment and fresh SHA; update evidence and the next action without automatic golden acceptance or merge.

Independent review prompt

Independently test renamed/deleted files, no-final-newline hunks, omitted/binary patches and head changes while context loads. Try remote filenames that resemble local paths and verify no filesystem mutation or fallback occurs. Check line anchors, keyboard navigation, measured large-data behavior and local Changes regressions. Compare R4 against approved references and report concrete acceptance failures, not an overall looks-good judgment.

Activity

  1. added
    enhancement
    on Oct 19, 2026
  2. BunsDev commented on Oct 20, 2026

    @BunsDev
    ContributorAuthor

    The CR-1 contract is on main as 43d5b9c (#334). Bind to these files at that commit:

    • apps/desktop/src/shared/code-review.ts (the contract)
    • apps/desktop/test/fixtures/code-review.ts (synthetic fixtures)
    • docs/design/code-review.md (source map, references, inventory, open decisions)

    For CR-5:

    • diffCoverage reports what a diff holds: binary counts as covered, and a too-large or provider-omitted patch counts as missing.
    • The R4 fixture and the truncatedFiles and headChanged faults are in the fixtures.
    • The remote diff reuses only Diff and FileIcon from ChangesPanel.tsx. It never reaches Discard.

    Coven-Harness: Claude Code / claude-opus-5-5

  3. mariscate commented on Oct 22, 2026

    @mariscate

    Refreshed goal prompts — 2026-10-22 (main at 0e674e7)

    Where it stands: not started; this is next in Gate A, in parallel with #323. Ready on main:

    • Reads: the files (revision, cursor) and context (revision, side, path, start/end) operations, served by read-service.ts.
    • Contract: diffCoverage and PatchState (text or omitted: binary / too-large / provider).
    • Fixtures: R4, the truncatedFiles and headChanged faults, and stressFiles(n) for the 1,000-file run.
    • Host: the Changes/split host from Integrate Code Review inbox and workspace with main-owned PR reads #367. Its "diff" and "files" placeholders are in renderer/code-review/PrPane.tsx.
    • Reuse: only Diff and FileIcon from ChangesPanel.tsx; nothing remote may reach Discard.
    • Viewed toggle (C65): still Val's decision, so leave it unavailable.

    Long-running goal prompt

    Implement CR-5 (#324) in TypeSafeAI/modex. Read AGENTS.md, #319, this issue, docs/design/code-review.md and apps/desktop/src/shared/code-review.ts, then verify main's SHA. Create your own worktree (scripts/worktree.sh new cr5-diff). First write red tests: a pure patch/anchor model (several hunks, add/delete/rename, no final newline, Unicode or space-containing paths, binary/omitted/too-large, old/new line numbers), and local Changes/Discard regressions that must keep passing. Then replace PrPane's diff and files placeholders with a read-only remote diff: grouped file sections, folded context, a filterable file tree, and context expansion through the `context` op at the exact base/head revision. Put the code in apps/desktop/src/renderer/code-review/. Reuse only Diff and FileIcon from ChangesPanel. Anchors are PrKey + PrRevision + path + side + line; after a head change they are outdated, never moved. Reject stale replies with acceptsReply. Never read local files, check out branches, apply patches or call Discard. Make missing or partial coverage visible and keep provider totals separate from what is loaded. Load per file lazily; measure the stressFiles(1000) run and a 3 MiB patch on a named machine before adding virtualization. Run pnpm build && pnpm test && pnpm test:e2e. Record timings and evidence in docs/reviews, update docs/status.md, and open one signed PR without merging.
    

    Follow-up / resume prompt

    Resume CR-5. Confirm you own the worktree, fetch main, and read the latest checkpoint and PR review. Re-run the patch/anchor tests and the local Changes regressions before relying on earlier work. If #323 landed, merge main and reconcile PrPane without losing either slice. Next, take the weakest AC: stale replies during a head change, incomplete patches, keyboard navigation in the file tree, or the measured stress budget. Tie each performance number to a SHA and machine. Post a checkpoint: SHA, results, limits, and one next action.
    
  4. BunsDev commented on Oct 23, 2026

    @BunsDev
    ContributorAuthor

    Refreshed goal prompts — 2026-10-23 (main at 203a350)

    On main already:

    • the files and context reads, diffCoverage and PatchState;
    • the R4 fixture, the truncatedFiles and headChanged faults, and stressFiles(n);
    • the Changes/split host with its "diff" and "files" placeholders.

    The remote diff itself has not landed.

    In progress, not pushed: the worktree cr5-remote-diffs has two signed commits on 68860a0:

    • e22575a: revision-bound remote diffs and file navigation;
    • 0fd82e1: bounded retained patches and kept diff context.

    There is no remote branch or PR.

    What the branch adds:

    • PrChanges.tsx, patch.ts and file-pages.ts;
    • Diff/FileIcon moved into a pure presentation module, still re-exported by ChangesPanel;
    • e2e/code-review-diff.spec.ts;
    • the evidence doc docs/reviews/2026-10-23-cr5-remote-diffs.md.

    Evidence, from the evidence doc:

    • pnpm build && pnpm test passed: 2,018 passed, 16 skipped.
    • Focused Electron runs passed 51/51 after an independent review. All four important findings were fixed, with red tests first.
    • The first full desktop E2E run had one failure, in the navigation fixture. It was fixed and passed in a focused rerun.
    • The full E2E run on the final head hasn't been recorded.

    Stress numbers (M5 Max, one fixture run each):

    • 1,000 files load in 3,039 ms, including app launch;
    • selecting a file takes 59 ms;
    • a 3 MiB patch is rejected before parsing.

    Still open:

    • the full gates on the final head, a push, and a PR;
    • an authenticated run against real PRs;
    • the R4 comparison against the original, which is missing;
    • integration with the overview from feat(code-review): add PR overview, activity and evidence cards #393 (CR-4): both change PrPane.tsx, CodeReviewView.tsx and code-review.css;
    • human VoiceOver;
    • C65 (Viewed), which stays unavailable until Val decides.

    Long-running goal prompt

    Land CR-5 (#324) in TypeSafeAI/modex. The implementation exists in the local worktree cr5-remote-diffs (head 0fd82e1); do not start over.
    
    Read AGENTS.md, #319, this issue, docs/design/code-review.md (C63–C79) and the branch's docs/reviews/2026-10-23-cr5-remote-diffs.md, then verify main's SHA. Before you touch the worktree, run scripts/worktree.sh claim cr5-remote-diffs, then check. If another session owns it, stop and ask.
    
    1. Merge current main. If #393 (CR-4) has landed, reconcile PrPane, CodeReviewView and code-review.css so that the overview and the diff both work.
    2. Run pnpm build && pnpm test && pnpm test:e2e on the final head and record the results. The full E2E run is still missing.
    3. Push the branch and open one signed PR that states the open gates: the original R4 comparison, authenticated behaviour, human VoiceOver, and the Viewed decision (C65).
    4. With Val's go-ahead, run an authenticated read-only Electron check on a real PR. Keep it separate from the fixture evidence.
    
    Keep the rules the branch already enforces:
    - anchors are PrKey + PrRevision + path + side + line, and after a head change they become outdated, never moved;
    - stale replies are rejected with acceptsReply;
    - nothing reads local files, checks out, applies patches or reaches Discard;
    - loaded counts stay separate from provider totals.
    
    Tie each performance number to a SHA and machine. Update docs/status.md, and hand CR-8 (#327) the head SHA. Don't merge without Val's go-ahead.
    

    Follow-up / resume prompt

    Resume CR-5.
    1. Confirm you own cr5-remote-diffs, fetch main, and check whether #393 or your PR has landed or has new review comments.
    2. Re-run the patch/anchor unit tests, e2e/code-review-diff.spec.ts and the local Changes/Discard regressions before relying on earlier results.
    3. If the PR isn't open yet, finish the full gates and open it. Otherwise take the weakest open item: a review finding, PrPane reconciliation with CR-4, or the authenticated check.
    Post a checkpoint: SHA, results, limits, and one next action.
    
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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions