feat(code-review): mark files as viewed in diff review#2762
Open
MattPua wants to merge 10 commits into
Open
Conversation
Add a togglable "Viewed" checkbox, right-aligned in each file header in the review/diff viewer. Marking a file viewed also collapses it (mirrors GitHub); unmarking re-expands it. State is local + persisted, keyed by taskId -> file key, so it works across all diff sources (local, branch, PR, cloud) and survives restarts. Note: pre-commit hook bypassed; monorepo typecheck fails on a pre-existing error in canvas/WebsiteLayout.tsx (Button "loading" prop) from main, unrelated to this change. Generated-By: PostHog Code Task-Id: ea2a1d14-f772-40f5-bd7d-3799f77e31b4
|
React Doctor found 5 issues in 2 files · 5 warnings. 5 warnings
Reviewed by React Doctor for commit |
Contributor
Prompt To Fix All With AIFix the following 2 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 2
packages/ui/src/features/code-review/reviewShellParts.tsx:206-241
**Nested `<button>` inside `<button>` — invalid HTML**
`FileHeaderRow` renders a `<button>` (line 206) and `ViewedCheckbox` renders another `<button>` inside it (line 251). Nesting interactive elements inside a `<button>` is prohibited by the HTML spec. While React's synthetic event system makes `e.stopPropagation()` work in practice, the resulting DOM is invalid and screen readers / keyboard-navigation tools may behave unpredictably (e.g. some AT software flattens or skips the inner button). A straightforward fix is to change `FileHeaderRow`'s root element to a `<div>` with `role="button"` and `tabIndex={0}`, or to restructure the layout so the viewed checkbox sits adjacent to rather than inside the collapse button.
### Issue 2 of 2
packages/ui/src/features/code-review/reviewViewedStore.ts:28-33
**`clearTask` is defined but never called — store grows unbounded**
The persisted store accumulates a `taskId → fileKey → true` entry for every task the user ever reviews and never prunes them. Over time this silently inflates the `localStorage` entry for `"review-viewed-storage"`. Consider calling `clearTask` when a task is deleted or archived, or add a storage migration / TTL that removes entries older than a configurable window.
Reviews (1): Last reviewed commit: "feat(code-review): mark files as viewed ..." | Re-trigger Greptile |
- FileHeaderRow: wrap only the toggle target in a button; open-file and viewed controls are now siblings, not nested interactive elements - reviewViewedStore: bound the persisted store via LRU eviction (MAX_TASKS) and drop tasks with no viewed files; remove unused clearTask Generated-By: PostHog Code Task-Id: ea2a1d14-f772-40f5-bd7d-3799f77e31b4
Store a content signature when a file is marked read and compare it against the current diff to surface a "Changed" state. Rename the user-facing control to "read". Bound persisted state with archival pruning plus an LRU backstop, memoize signatures by file identity, and skip pruning the task whose review is open. Generated-By: PostHog Code Task-Id: c2ac4ecc-f009-4e38-91fb-81f17ccfd91b
… merges Archived tasks won't be re-reviewed, so drop their persisted read state as part of the archive orchestration (covers single and bulk). Likewise clear it once the reviewed task's PR is merged. Adds a clearTask action to the review-viewed store. Generated-By: PostHog Code Task-Id: c2ac4ecc-f009-4e38-91fb-81f17ccfd91b
Display "<read>/<total> read" next to the file count in the review toolbar, counting only files marked read at their current signature. Lower the persisted-size backstop from 4000 to 500 entries. Generated-By: PostHog Code Task-Id: c2ac4ecc-f009-4e38-91fb-81f17ccfd91b
Generated-By: PostHog Code Task-Id: c2ac4ecc-f009-4e38-91fb-81f17ccfd91b
…e local read signature - ReviewShell passed a bare Task to useTaskPrStatus, so cloudPrUrl/ taskRunEnvironment were undefined and the PR-merge read-state clear never fired for cloud tasks. Resolve cloudPrUrl via useCloudPrUrl and pass the run environment, matching the other useTaskPrStatus call sites. - Local read signatures hashed parsed hunks, which change when the hide-whitespace toggle re-fetches a different diff, falsely flipping read files to "Changed". Base the signature on the git blob object ids from the patch index line instead: content-identifying and unaffected by the toggle (falls back to hunk geometry when absent). Generated-By: PostHog Code Task-Id: c2ac4ecc-f009-4e38-91fb-81f17ccfd91b
…Tasks action clearTask(id) and pruneArchived([id]) did the same single-key delete, and "pruneArchived" read wrong for the merge path. Collapse both into a single clearTasks(ids) action used by archive, merge, and the archived-task backstop. Generated-By: PostHog Code Task-Id: c2ac4ecc-f009-4e38-91fb-81f17ccfd91b
…isFileRead, cap 250 - Add unit tests for reviewViewedStore (mark/unmark, clearTasks, entry-cap eviction + active-task retention) and the signature helpers (patch hash, blob-id preference / whitespace stability, fallbacks). - Keep currentSignatures' reference stable across collapse toggles so toggling one file no longer re-renders every ViewedCheckbox via context. - Extract isFileRead() so the toolbar count and the checkbox share one predicate. - Raise the persisted-entry backstop from 150 to 250. Generated-By: PostHog Code Task-Id: c2ac4ecc-f009-4e38-91fb-81f17ccfd91b
Collapse state is ephemeral while read state persists, so previously-read files came back expanded on each open. On the first open per task (once signatures load), collapse files whose stored signature still matches — mirroring GitHub. Changed-since-read files stay expanded, and the one-shot guard means manually re-expanding a read file afterwards sticks. Generated-By: PostHog Code Task-Id: c2ac4ecc-f009-4e38-91fb-81f17ccfd91b
Contributor
|
Reviews (2): Last reviewed commit: "feat(code-review): auto-collapse already..." | Re-trigger Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When reviewing a diff there's no way to track which files you've already looked at, no signal when a file changes after you've reviewed it, and nothing to get reviewed files out of the way.
Changes
CleanShot.2026-06-18.at.15.53.53.mp4
read / total) next to the file countHow did you test this?
pnpm --filter @posthog/ui typecheckandbiome lintpass on the changed files (the one remaining typecheck error is a pre-existing, unrelated issue incanvas/WebsiteLayout.tsx)Automatic notifications
Created with PostHog Code