feat(github): pull request tool window, timeline and review flow (#477)

Replaces the Pull Requests tool window with a full review workflow on top of gh's authentication.

- List with search, quick filters and paging; a tab per pull request and a New Pull Request tab.
- Details: commit picker, changes tree with viewed state, CI and reviewer status, merge, close and reopen.
- Timeline editor: comments, review threads, reactions and suggested changes.
- Review in the diff viewer and, for the checked-out branch, in the editor (review mode).
- New generic vcs extension points: registerDiffViewerProvider, lineInlays, reviewGutter, branch widget extensions; new vcs_merge_base and gh_api commands.
- CSP: img-src allows https://avatars.githubusercontent.com for avatars.

Fixed while testing against a real repository: remotes behind an SSH host alias, mergeability stuck on UNKNOWN, Apply Locally staying disabled after a checkout, relative links navigating the app's page, and review inlays wider than the pane.

Co-authored-by: imacross <[email protected]>
Цей коміт міститься в:
imacross authored and GitHub committed 2026-10-31 07:50:43 +08:00
1 джерело 696377acc2
коміт 059fd8a69b
192 files changed
+23668 -2076

No files matched your search

+99
Переглянути файл
@@ -0,0 +1,99 @@
/**
* Review in the diff viewer (IntelliJ's `GHPRReviewDiffExtension`): pull request diffs
* (opened by `openPullRequestFileDiff` / the details panel's commit diffs, context
* `PULL_REQUEST_DIFF`) get their review threads as inlays, the gutter "+" with single- and
* multi-line comments, Start Review / Add Single Comment, the review toolbar and the viewed
* toggle, through the vcs diff viewer provider point. Also registers the editor actions and
* Settings › Version Control › GitHub. The editor actions also serve review mode's editors.
*/
import { registerDiffViewerProvider } from "@/features/vcs/diffViewerProviders";
import { registerActions } from "@/platform/actions";
import { getContext } from "@/platform/context";
import { lazyComponent } from "@/ui";
import { registerSettingsPage } from "@/workbench/contributions";
import { useGhRepository } from "../data/repository";
import { activeReviewEditor } from "../reviewMode/editor";
import { clearNewComments } from "./newComments";
import { activeReviewDiff, createReviewDiff } from "./reviewDiff";
/** The editor actions apply to the focused review diff, or to the review in the active editor (review mode). */
const WHEN = "projectOpen && githubConnected && (githubReviewDiff || githubReviewEditor)";
function reviewTarget() {
const diff = activeReviewDiff();
return (getContext().diffEditorFocus && diff) || activeReviewEditor() || diff;
}
/** "Mark File as Viewed" / "Mark File as Not Viewed" in the focused review diff; false when none is focused. */
export function toggleReviewDiffViewed(): boolean {
const diff = activeReviewDiff();
if (!diff) return false;
diff.toggleViewed();
return true;
}
export function activateReviewDiff(): () => void {
const disposers = [
registerDiffViewerProvider({ id: "github.review", create: createReviewDiff }),
registerActions([
{
// Code.Review.Editor.New.Comment
id: "github.pullRequest.diff.addComment",
title: "Add Review Comment",
description: "Create a new code review comment on the line under the caret",
category: "GitHub",
when: WHEN,
run: () => reviewTarget()?.addComment(false),
},
{
id: "github.pullRequest.diff.addMultilineComment",
title: "Add Multiline Review Comment",
description: "Create a new code review comment on the selected lines",
category: "GitHub",
when: WHEN,
run: () => reviewTarget()?.addComment(true),
},
{
// CodeReview.PreviousComment
id: "github.pullRequest.diff.previousComment",
title: "Previous Comment",
description: "Go to previous visible comment",
category: "GitHub",
icon: "arrow-up",
when: WHEN,
run: () => void reviewTarget()?.gotoComment(-1),
},
{
// CodeReview.NextComment
id: "github.pullRequest.diff.nextComment",
title: "Next Comment",
description: "Go to next visible comment",
category: "GitHub",
icon: "arrow-down",
when: WHEN,
run: () => void reviewTarget()?.gotoComment(1),
},
{
id: "github.pullRequest.diff.refreshReview",
title: "Refresh Review Data",
category: "GitHub",
icon: "refresh",
when: WHEN,
run: () => reviewTarget()?.refresh(),
},
]),
registerSettingsPage({
id: "vcs.github",
title: "GitHub",
order: 9,
keywords: ["pull request", "viewed", "review"],
component: lazyComponent(() => import("./GithubSettingsPage").then((m) => m.GithubSettingsPage)),
}),
useGhRepository.subscribe((s, prev) => {
const a = s.connection?.coordinates;
const b = prev.connection?.coordinates;
if (a?.owner !== b?.owner || a?.name !== b?.name) clearNewComments();
}),
];
return () => disposers.reverse().forEach((d) => d());
}