feat(pull-requests): review threads in the diff pane and Review tab as the viewer

Merged
SA
1mo ago
+613-225

Stacked on #8799 (→ #8771 → #8765).

Summary

The last places that read or resolved review threads with the workspace host's GitHub access now act as the viewer, the same way the PR pane does (local gh first, then the Superset connection):

  • Diff pane: thread annotations and the inline CommentThread, both reply and resolve
  • Sidebar Review tab: the thread list, and "resolve all" in CommentsSection

The host still answers which PR the workspace links to (git.getPullRequest reads its own database; it doesn't call GitHub). That lookup is now one hook, useLinkedPullRequest, which also returns the PR as a PullRequestTarget.

One cache for threads. Every surface reads usePullRequestThreads(target) and writes through useReviewThreadActions(target). Resolving a thread in the PR pane updates the diff pane and the Review tab right away; the old cross-cache invalidation of git.getPullRequestThreads is gone.

Conversation comments. The Review tab lists them, and the host's thread read used to supply them. pullRequestOnGithub(...).threads() now returns the latest 100 in the same GraphQL request. The PR pane keeps taking its conversation from the PR read, so they aren't shown twice.

CommentThread now takes onReply/onSetResolved props instead of calling the host itself, so its test passes plain functions.

After this, no desktop or mobile code calls the deprecated host thread procedures (git.*Thread*, pullRequests.getThreads/replyToThread/setThreadResolution).

Follow-up

The diff pane's CommentThread and the Code tab's PullRequestCommentThread are now the same component with injected actions and could be merged.

Test plan

  • tests: desktop 8820, shared 1500 (new: conversation comments come back with threads, minus empty ones), trpc 740, host PR suites 465, mobile 239, all passing
  • tsc clean in touched files; check:i18n, sherif
  • In the app: resolve a thread in the PR pane → the diff pane annotation and the Review tab update; reply from the diff pane is attributed to you in a cloud workspace

Summary by cubic

Review threads in the diff pane and sidebar Review tab now act as the viewer (local gh first, then the Superset connection) instead of the workspace host's GitHub access, matching the PR pane.

  • All surfaces read and write threads through usePullRequestThreads and useReviewThreadActions, so resolving or replying in one view updates the others immediately; "resolve all" writes every thread, then refreshes the list once.
  • useLinkedPullRequest is the single hook for which PR a workspace links to; the host still answers the lookup, and the PR is returned as a PullRequestTarget.
  • Thread reads now return the latest 100 conversation comments in the same GraphQL request; the Review tab lists them and the PR pane filters them out.
  • Without a GitHub login the Review tab explains why comments are missing and offers "Connect GitHub"; reads the organization's App can't make likewise ask for a connection instead of a dead-end not-found.
  • Mobile PR rows read their diffstat with one REST request again, merges return GitHub's message, and Settings says it could not check rather than "Not connected".
  • CommentThread now takes onReply and onSetResolved props instead of calling the host itself.
  • No desktop or mobile code calls the deprecated host thread procedures (git.*Thread*, pullRequests.getThreads/replyToThread/setThreadResolution) anymore.

Follow-up

The diff pane's CommentThread and the Code tab's PullRequestCommentThread are now the same component with injected actions and could be merged.

Review fixes (whole stack)

  • #8765: a read that GitHub refused no longer falls back to the host's gh, which could show a PR the viewer can't access.
  • Connect GitHub: reads the org's App can't make (repo not installed, or no installation) now offer "Connect GitHub" instead of a dead-end not-found.
  • Mobile PR list: rows read their diffstat with one REST request (getPullRequestDiffstat), not the full detail read.
  • Merges and thread reads: merges return GitHub's message again, and failed thread reads log their cause.
  • Review tab: says why comments are missing and offers "Connect GitHub"; "resolve all" refreshes once.
  • Mobile Settings: says "Couldn't check" when the connection status fails to load.
  • Copy: the docs say which identity reads and which writes, and the German, Dutch and Polish strings are reworded.