Repository navigation
feat(web): file headers with state chips, a collapse chevron, and copy path - #1334
Conversation
[Medium impact] The changes affect the browser review stream, not shared review-state behavior. The PR appears safe to merge with these non-blocking display issues. FindingsFix with agent prompt### Issue 1
packages/hunk/src/web/stream/FileSection.tsx:228-233
**Rendered Markdown cannot fold.** A rename-only Markdown file can still offer and show its full rendered document. But `fileHasBody` returns false for that file, so this check removes its collapse chevron even while the document is visible. Include the rendered preview when deciding whether the file has a body, and update that decision when its view changes.
### Issue 2
packages/hunk/src/web/stream/FileSection.tsx:405
**Empty files keep stale space.** These bodies can now shrink to zero, but `ReviewStream` only saves heights greater than zero. For example, render a rename-only Markdown file, switch back to Diff, then scroll away. The old preview height stays cached and gets applied when the file leaves the mounted window, leaving a large blank area under its header. Save zero heights for mounted bodies or clear their old measurements when they become empty.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryUpdates browser file headers with state chips, copy-path buttons, and controls for folding any file.
Two non-blocking issues remain around Markdown previews and empty-body height tracking. Reviews (1) · Last reviewed commit: "feat(web): file headers with state chips..." · Reviewed by Greptile |
| // A file with rows to draw can fold; a header-only row has nothing under it to hide. | ||
| const hasBody = plan ? fileHasBody(plan) : emptyReason === undefined; | ||
|
|
||
| return ( | ||
| <header className="file-header" data-file-header={fileKey}> | ||
| {viewed && hasBody ? ( |
There was a problem hiding this comment.
Rendered Markdown cannot fold. A rename-only Markdown file can still offer and show its full rendered document. But
fileHasBody returns false for that file, so this check removes its collapse chevron even while the document is visible. Include the rendered preview when deciding whether the file has a body, and update that decision when its view changes.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/hunk/src/web/stream/FileSection.tsx
Line: 228-233
Comment:
**Rendered Markdown cannot fold.** A rename-only Markdown file can still offer and show its full rendered document. But `fileHasBody` returns false for that file, so this check removes its collapse chevron even while the document is visible. Include the rendered preview when deciding whether the file has a body, and update that decision when its view changes.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| ) : mounted ? ( | ||
| ) : plan.emptyReason === "too-large" ? ( | ||
| <p className="file-placeholder">{TOO_LARGE_MESSAGE}</p> | ||
| ) : plan.emptyReason ? null : mounted ? ( |
There was a problem hiding this comment.
Empty files keep stale space. These bodies can now shrink to zero, but
ReviewStream only saves heights greater than zero. For example, render a rename-only Markdown file, switch back to Diff, then scroll away. The old preview height stays cached and gets applied when the file leaves the mounted window, leaving a large blank area under its header. Save zero heights for mounted bodies or clear their old measurements when they become empty.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/hunk/src/web/stream/FileSection.tsx
Line: 405
Comment:
**Empty files keep stale space.** These bodies can now shrink to zero, but `ReviewStream` only saves heights greater than zero. For example, render a rename-only Markdown file, switch back to Diff, then scroll away. The old preview height stays cached and gets applied when the file leaves the mounted window, leaving a large blank area under its header. Save zero heights for mounted bodies or clear their old measurements when they become empty.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.c2f3f6c to
fa100b7
Compare
f9f41e6 to
a8cf997
Compare
fa100b7 to
7e7c423
Compare
…y path A file header in the browser review stream now dims the directory and bolds the file name, states what kind of change it is in a chip (new, deleted, renamed with no content changes, binary, too large) instead of printing "+0 −0" and a sentence row, and gains a chevron that collapses any file, a copy-path button, and a button-like Viewed control whose shortcut hint comes from the keymap. Files with nothing to draw become header-only rows. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…t right The source-boundary gate scans for `from "…"` to find module specifiers, and a class name ending in `from` followed by a quote matched it. The old-path span is now `file-path-previous`, and the helper's field is `previous` to match. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
a03d8ab to
7947fdd
Compare
Problem
In the browser review stream a file header is a path,
+A −D, and a Viewed checkbox. A rename with no content change, a binary file, and a too-large file all print+0 −0and then spend a body row on a sentence. A viewed file leaves a "Viewed · show changes" row behind, and only viewed files can be collapsed.Approach
old -> newincluded), as issection[aria-label].web/format/fileHeader.tsbuilds the chip from what the review document already says (changeKind,flags.untracked, the sharedReviewEmptyDiffReason): new, deleted, untracked, "renamed, no content changes", binary, too large, empty. Nothing is re-derived in the renderer. Zero line stats are hidden rather than printed.foldedset, so any file can be collapsed. A hunk reveal, deep link, or composer opens a folded file through the same path that opens a viewed one. Marking or clearing viewed resets the fold. The "Viewed · show changes" row is gone; the chevron (aria-expanded) replaces it. No shared state.hunk.web.toggleViewed; no chord, no hint.No binding or command table is touched, and no key label is written as a literal.
Non-goals and known gaps
Tests
fileHeader.test.ts;useViewedFilestests for folding.review-stream: chips and header-only rows, folding an unviewed file and opening it with hunk navigation, copy path through the clipboard. Inreview-viewed: the key hint appears only on the selected header and equals the chord the command palette shows for the command; the checked style..file-collapsedselectors became.file-collapse[aria-expanded="false"]across the suite.review-interactive"shares the filter and note visibility with a second page" pressedaa second time as soon as the other page reflected the first press; the acting page's own copy can lag by tens of milliseconds, so the second press could resend "hide". It failed consistently with this change and passes on the base. The test now also waits for the acting page before the second press. In-page toggle-to-repaint time measured the same in both builds (10–50 ms); why the ordering shifted is not understood.bun run typecheck,bun run lint,bun run format:check,bun run deps:check: pass.bun test packages/hunk/src/web: 278 pass, 0 fail.bun run test:web: 124 passed, 7 skipped (the opt-in capture specs), 0 failed, run after the last edit.Checked in
github-dark-defaultand a light theme at 1440px and 800px across modified, new, deleted, renamed, rename-only, binary, too-large, Markdown, image, viewed, and changed-since-viewed files. Platform: macOS only.A second commit renames the old-path span's class to
file-path-previous: the source-boundary gate scans forfrom "…", and a class name ending infrombefore a quote matched it.bun test scripts/qualitypasses.Stack
6 of 9. Each PR is based on the one above it in this table and contains only its own change.
mainMerge order: 1 to 9, from the top of the table. After a PR merges, the next one's base becomes
main(GitHub retargets it when the merged branch is deleted; otherwise change the base by hand) and its diff still shows only its own change.This PR description was generated by Claude Code using Claude Fable 5.2