refactor(pull-requests): clean up after the viewer-auth stack

Merged
SA
1mo ago
+80-54

Summary

Cleanup after the viewer-auth stack (#8765, #8771, #8799, #8980, #8991). No behaviour change.

  • normalizeThreadsToComments takes the shared PullRequestThreads type; conversation comments are no longer optional (the old host read sometimes omitted them).
  • usePullRequestThreads uses TanStack Query's skipToken instead of a placeholder query key and a throw; pullRequestThreadsQueryKey accepts no target.
  • useReviewThreadActions takes its client as a parameter (defaulting to the viewer client). That gives "resolve all writes every thread, then reads the list once" a regression test without mock.module. The review bot raised that behaviour on #8980, citing the GitHub-quota incident.
  • No longer exported: helpers used only in their own file: PullRequestInput, ViewerPullRequest and notConnectedError in viewer-octokit; mobile's GithubAccessFailure, GITHUB_CONNECTION_QUERY_KEY and getPullRequestDetailQueryKey.
  • One stale comment that still named the removed "cloud route" and "older host" paths is corrected.

Considered and left out

  • Merging the twin thread components (CommentThread in the diff pane, PullRequestCommentThread in the Code tab). They now take the same injected actions, but they're styled differently (bordered card vs full-bleed band with avatars), so merging would change one surface's look.
  • A PullRequestProvider and rendering the shared read directly. Both are larger structural refactors with no clear payoff yet.
  • Session workspaces still hide the PR badge's pane and the diff pane's PR link "because the PR content query is project-scoped". That's no longer true, but enabling them is a behaviour change, so it belongs in its own PR.

Test plan

  • new useReviewThreadActions test: resolve all on three threads makes three writes and one refresh
  • trpc 743, shared 1500, desktop 8846, mobile 239 passing; tsc clean in trpc, shared, api, and no errors in touched desktop or mobile files; bun run lint exits 0; check:i18n reports no changes

Summary by cubic

Cleanup after the viewer-auth stack; no behavior change. Removes code that's no longer reachable, tightens the shared thread type, and gives "resolve all" a regression test.

  • normalizeThreadsToComments now takes the shared PullRequestThreads type; conversation comments are no longer optional.
  • usePullRequestThreads uses TanStack Query's skipToken instead of a placeholder query key and a throw.
  • useReviewThreadActions takes its client as a parameter (defaulting to the viewer client), so "resolve all" (write every thread, then refresh once) is testable without module mocks.
  • Helpers used only in their own file are no longer exported: PullRequestInput, ViewerPullRequest, notConnectedError, and mobile's GithubAccessFailure, GITHUB_CONNECTION_QUERY_KEY, and getPullRequestDetailQueryKey.
  • Corrects a stale comment that still named the removed cloud and host read paths.

Considered and left out

  • Merging the twin thread components: they take the same injected actions but are styled differently.
  • A PullRequestProvider and rendering the shared read directly: larger refactors with no clear payoff yet.
  • Showing the PR badge and link in session workspaces: a behavior change, so it belongs in its own PR.

Summary by CodeRabbit

  • Improvements
    • Pull request discussions now avoid unnecessary requests when repository information is unavailable or the viewer cannot act on the pull request.
    • Resolving multiple review threads refreshes the affected discussion list.
  • Tests
    • Added coverage for resolving multiple review threads and refreshing their discussion list.