Skip to content

feat(web): pull request files can be marked as viewed - #7721

Open
yordis wants to merge 10 commits into
pingdotgg:mainfrom
TrogonStack:yordis/feat-pr-files-viewed-upstream
Open

feat(web): pull request files can be marked as viewed#7721
yordis wants to merge 10 commits into
pingdotgg:mainfrom
TrogonStack:yordis/feat-pr-files-viewed-upstream

Conversation

@yordis

@yordis yordis commented Aug 20, 2026

Copy link
Copy Markdown
Contributor
  • A review spread over an afternoon, or picked up on a second machine, starts again from the top every time, so large changes get read in the browser and only small ones stay here.
  • The marks are the host's rather than ours: a checkbox only this app remembers is worse than none, because it looks like the one GitHub shows, disagrees with it, and leaves a reviewer unsure which of the two knows what they have actually read.
  • Declared per provider, so GitHub offers it and the hosts with no equivalent hide the control rather than showing one that cannot keep its promise.
  • Read apart from the patch, because viewed state moves on every press and a patch moves only when somebody pushes; sharing one read would mean either re-fetching a three-hundred-file diff per checkbox or showing a reader their own last press as stale.

Note

Medium Risk
Adds new pull-request RPCs and GitHub GraphQL mutations that write viewer state, plus dedicated cache invalidation. Paths are sent as GraphQL variables rather than interpolated into the query.

Overview
Lets reviewers tick files off on GitHub pull requests so a long review can be resumed on another machine or in the browser. Marks live on the host, not locally; GitLab/Bitbucket/Azure hide the control.

Code tab: each file header gets a Viewed checkbox that also folds/unfolds the file. A toolbar count tracks files on screen; files pushed since they were cleared show Changed. Presses are optimistic, batched after 400ms, and rolled back on failure.

Backend: new pullRequests.filesViewed / setFilesViewed RPCs (read vs operate scope). GitHub pages GraphQL viewed state (capped at 5×100 files, then truncated) and batches mark/unmark into one aliased mutation. Viewed state has its own 15s cache; ticking a file does not drop the diff cache. Unsupported hosts fail with a dedicated operation error.

Reviewed by Cursor Bugbot for commit 6b44e51. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Add per-file viewed tracking to pull requests

  • Introduces viewedFiles capability, contracts (PullRequestFileViewedState, PullRequestFilesViewedResult, PullRequestSetFilesViewedInput), and two WebSocket RPCs (pullRequests.filesViewed, pullRequests.setFilesViewed) for reading and writing per-file viewed state.
  • GitHub provider implements GraphQL pagination (up to 5 pages) for reads and a single batched aliased mutation for writes, with paths passed as variables to avoid query injection.
  • Service layer adds a dedicated 15s/128-entry cache for viewed files; setFilesViewed bumps only the filesViewed epoch so the diff cache stays valid.
  • Web UI shows a Viewed checkbox per file header with optimistic overlay, batched flushes after 400ms, failure rollback, Changed indicator for stale (dismissed) states, and fold-state sync via toggleFileDiffFoldForViewed.
  • Behavioral Change: setFilesViewed on unsupported hosts returns PullRequestOperationError("filesViewed")/("setFilesViewed") instead of a generic error; RPC_REQUIRED_SCOPES now requires AuthOrchestrationReadScope for reads and AuthOrchestrationOperateScope for writes.

Macroscope summarized 6b44e51.

@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 423f92bd-d74d-4268-8c6c-24e818cea662

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XL 500-999 changed lines (additions + deletions). labels Aug 20, 2026

@macroscopeapp macroscopeapp Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the changed web UI: the new viewed-file checkbox in the diff header, the counter in the toolbar, and the fold/overlay logic modules. Two findings, both on changed lines in PullRequestCodeTab.tsx.

Posted via Macroscope — UI Consistency

Comment thread apps/web/src/components/pullRequest/PullRequestCodeTab.tsx
Comment thread apps/web/src/components/pullRequest/PullRequestCodeTab.tsx Outdated
Comment thread apps/web/src/components/pullRequest/usePullRequestFilesViewed.ts Outdated
Comment thread apps/server/src/sourceControl/githubGraphQlBudget.ts Outdated
Comment thread apps/web/src/components/pullRequest/usePullRequestFilesViewed.ts Outdated
Comment thread apps/web/src/components/pullRequest/PullRequestCodeTab.tsx
Comment thread apps/web/src/components/pullRequest/usePullRequestFilesViewed.ts Outdated
@macroscopeapp

macroscopeapp Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This PR introduces a new user-facing feature (marking PR files as viewed) with new UI components, RPC endpoints, GraphQL mutations, and client-side state management across multiple packages. New feature additions warrant human review.

You can add or adjust custom eligibility rules. Learn more.

Comment thread apps/web/src/components/pullRequest/PullRequestCodeTab.tsx
Comment thread apps/server/src/sourceControl/githubGraphQlBudget.ts Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2bc61d8. Configure here.

Comment thread apps/web/src/components/pullRequest/usePullRequestFilesViewed.ts Outdated

@macroscopeapp macroscopeapp Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the web UI changes (PullRequestCodeTab.tsx, pullRequestDiff.logic.ts, pullRequestFilesViewed.logic.ts, usePullRequestFilesViewed.ts) for shared-primitive use, Tailwind/CSS ownership and virtualizer behavior.

Both findings from the previous run are resolved: the Checkbox no longer carries a partial size-* override, and truncated is now threaded through the hook and surfaced in the meta line with the same Tooltip + TriangleAlertIcon treatment the withheld-diff caveat uses. Two remaining items below — one virtualizer regression risk, one accessible-name issue on the new control.

Posted via Macroscope — UI Consistency

Comment thread apps/web/src/components/pullRequest/PullRequestCodeTab.tsx Outdated
Comment thread apps/web/src/components/pullRequest/PullRequestCodeTab.tsx
yordis added 10 commits August 20, 2026 18:06
A review spread over an afternoon, or picked up on a second machine, started
again from the top every time, so large changes were read in the browser and
only small ones stayed here.

The marks are the host's rather than ours because a checkbox only this app
remembers is worse than none: it looks like the one GitHub shows, disagrees
with it, and leaves a reviewer unsure which of the two knows what they have
actually read.

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
…he window resets

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
…since

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
…at it is partial

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
…he wrong way

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
…count

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
…carries

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
A press moved the whole viewed view, and every file header on screen was memoized on it, so one tick cost a rebuild of all of them. The same mark also has to say whether the control is offered at all, or a capability arriving after the first paint leaves the headers without a box.

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
It borrowed its name from the label beside it, and that label turns into "Changed" once the file has been pushed to, leaving a reader who cannot see it with no idea what the box does.

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@yordis
yordis force-pushed the yordis/feat-pr-files-viewed-upstream branch from 1296cb6 to 6b44e51 Compare August 20, 2026 22:07
@yordis

yordis commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author
Screen.Recording.2026-08-20.at.6.15.29.PM.mov

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

Labels

size:XL 500-999 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant