refactor(pull-requests): clean up after the viewer-auth stack
Merged
SA
1mo ago+80+80+01234567890123456789-54-54-01234567890123456789
Summary
Cleanup after the viewer-auth stack (#8765, #8771, #8799, #8980, #8991). No behaviour change.
normalizeThreadsToCommentstakes the sharedPullRequestThreadstype; conversation comments are no longer optional (the old host read sometimes omitted them).usePullRequestThreadsuses TanStack Query'sskipTokeninstead of a placeholder query key and a throw;pullRequestThreadsQueryKeyaccepts no target.useReviewThreadActionstakes 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 withoutmock.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,ViewerPullRequestandnotConnectedErrorinviewer-octokit; mobile'sGithubAccessFailure,GITHUB_CONNECTION_QUERY_KEYandgetPullRequestDetailQueryKey. - 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 (
CommentThreadin the diff pane,PullRequestCommentThreadin 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
PullRequestProviderand 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
useReviewThreadActionstest: resolve all on three threads makes three writes and one refresh - trpc 743, shared 1500, desktop 8846, mobile 239 passing;
tscclean in trpc, shared, api, and no errors in touched desktop or mobile files;bun run lintexits 0;check:i18nreports 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.
normalizeThreadsToCommentsnow takes the sharedPullRequestThreadstype; conversation comments are no longer optional.usePullRequestThreadsuses TanStack Query'sskipTokeninstead of a placeholder query key and a throw.useReviewThreadActionstakes 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'sGithubAccessFailure,GITHUB_CONNECTION_QUERY_KEY, andgetPullRequestDetailQueryKey. - 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
PullRequestProviderand 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.