GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(web): PR timeline "Open activity on host" buttons honor 'Open lin… · patroza/t3code@60eed62

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/web/src/components/pullRequest
    • PullRequestTimelineTab.browser.test.tsx
    • PullRequestTimelineTab.tsx
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/web/src/components/pullRequest/PullRequestTimelineTab.browser.test.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/pullRequest/PullRequestTimelineTab.browser.test.tsx
+75Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,23 @@ import {
22
EnvironmentId,
33
ProjectId,
44
SourceControlProviderKind,
5+
ThreadId,
56
type PullRequestDetailView,
67
} from "@t3tools/contracts";
78
import { expect, it, vi } from "vite-plus/test";
89
import { userEvent } from "vite-plus/test/browser";
910

11+
const linkState = vi.hoisted(() => ({
12+
openLink: vi.fn(async () => {}),
13+
useOpenLink: vi.fn(),
14+
}));
15+
vi.mock(import("~/browser/useOpenLink"), () => ({
16+
useOpenLink: (threadRef: unknown) => {
17+
linkState.useOpenLink(threadRef);
18+
return linkState.openLink;
19+
},
20+
}));
21+
1022
import { render } from "../../../test/render";
1123
import "../../index.css";
1224
import { PullRequestTimelineTab } from "./PullRequestTimelineTab";
@@ -221,3 +233,66 @@ it("gives each comment and review a heading for screen reader navigation", async
221233
await expect.element(screen.getByText("One question", { exact: true })).toBeVisible();
222234
await expect.element(screen.getByRole("heading", { name: /alice commented/ })).toBeVisible();
223235
});
236+
237+
it("opens activity host links through the link-target setting", async () => {
238+
linkState.openLink.mockClear();
239+
linkState.useOpenLink.mockClear();
240+
const reviewUrl = `${detail.url}#pullrequestreview-1`;
241+
const commentUrl = `${detail.url}#issuecomment-2`;
242+
const threadRef = {
243+
environmentId: EnvironmentId.make("environment"),
244+
threadId: ThreadId.make("thread-1"),
245+
};
246+
const commented: PullRequestDetailView = {
247+
...detail,
248+
commits: [],
249+
comments: [
250+
{
251+
id: "review",
252+
kind: "review",
253+
author: { login: "bob", name: null, avatarUrl: null },
254+
body: "Looks good",
255+
createdAt: "2026-10-01T00:00:00Z",
256+
url: reviewUrl,
257+
path: null,
258+
reviewState: "APPROVED",
259+
},
260+
{
261+
id: "comment",
262+
kind: "issue-comment",
263+
author: { login: "alice", name: null, avatarUrl: null },
264+
body: "One question",
265+
createdAt: "2026-10-01T00:01:00Z",
266+
url: commentUrl,
267+
path: null,
268+
reviewState: null,
269+
},
270+
],
271+
};
272+
await using screen = await render(
273+
<div style={{ height: 600 }}>
274+
<PullRequestTimelineTab
275+
scrollerRef={() => {}}
276+
detail={commented}
277+
environmentId={threadRef.environmentId}
278+
threadRef={threadRef}
279+
reference={detail}
280+
order="oldest"
281+
onOpenCommit={() => {}}
282+
onRefresh={() => {}}
283+
/>
284+
</div>,
285+
);
286+
await userEvent.click(screen.getByRole("button", { name: "Open activity on host" }));
287+
expect(linkState.useOpenLink).toHaveBeenCalledWith(threadRef);
288+
expect(linkState.openLink).toHaveBeenLastCalledWith(reviewUrl, {
289+
event: expect.objectContaining({ metaKey: false, ctrlKey: false }),
290+
});
291+
292+
await userEvent.click(screen.getByRole("button", { name: /1 comment/ }));
293+
const buttons = screen.getByRole("button", { name: "Open activity on host" }).all();
294+
await userEvent.click(buttons[1]!);
295+
expect(linkState.openLink).toHaveBeenLastCalledWith(commentUrl, {
296+
event: expect.objectContaining({ metaKey: false, ctrlKey: false }),
297+
});
298+
});
Collapse file

‎apps/web/src/components/pullRequest/PullRequestTimelineTab.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/pullRequest/PullRequestTimelineTab.tsx
+15-9Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ import { msg, T, useGT, useMessages, Var } from "gt-react";
2828
import { m } from "~/i18n/messages";
2929
import { useEffect, useEffectEvent, useRef, useState, type ReactNode } from "react";
3030

31+
import { useOpenLink } from "~/browser/useOpenLink";
3132
import { cn } from "~/lib/utils";
32-
import { readLocalApi } from "~/localApi";
3333
import { pullRequestEnvironment } from "~/state/pullRequests";
3434
import { RelativeTime } from "~/components/RelativeTime";
3535

@@ -219,15 +219,20 @@ function AddToChatButton({
219219
);
220220
}
221221

222-
function OpenOnHostButton({ url, onOpen }: { url: string | null; onOpen: (url: string) => void }) {
222+
type OpenOnHost = (
223+
url: string,
224+
event: { readonly metaKey: boolean; readonly ctrlKey: boolean; readonly button?: number },
225+
) => void;
226+
227+
function OpenOnHostButton({ url, onOpen }: { url: string | null; onOpen: OpenOnHost }) {
223228
const gt = useGT();
224229
return url === null ? null : (
225230
<Button
226231
size="icon-xs"
227232
variant="ghost-muted"
228233
className="-mr-1 shrink-0"
229234
aria-label={gt("Open activity on host")}
230-
onClick={() => onOpen(url)}
235+
onClick={(event) => onOpen(url, event)}
231236
>
232237
<ExternalLinkIcon className="size-3" />
233238
</Button>
@@ -247,7 +252,7 @@ function ConversationCard({
247252
event: PullRequestTimelineEvent;
248253
editable: PullRequestComment | null;
249254
cwd: string;
250-
onOpen: (url: string) => void;
255+
onOpen: OpenOnHost;
251256
reactions: ReactionSurface;
252257
showPath?: boolean;
253258
/** A reply goes with its conversation, from the card that heads it. */
@@ -402,7 +407,7 @@ function ConversationGroup({
402407
events: ReadonlyArray<PullRequestTimelineEvent>;
403408
editable: ReadonlyMap<string, PullRequestComment>;
404409
cwd: string;
405-
onOpen: (url: string) => void;
410+
onOpen: OpenOnHost;
406411
reactions: ReactionSurface;
407412
}) {
408413
const [open, setOpen] = useState(
@@ -493,7 +498,7 @@ function ReviewThreadEvent({
493498
detail: PullRequestDetailView;
494499
editable: ReadonlyMap<string, PullRequestComment>;
495500
cwd: string;
496-
onOpen: (url: string) => void;
501+
onOpen: OpenOnHost;
497502
reactions: ReactionSurface;
498503
}) {
499504
const gt = useGT();
@@ -734,7 +739,7 @@ function ReviewVerdictEvent({
734739
outcome: PullRequestReviewOutcome;
735740
stale: boolean;
736741
cwd: string;
737-
onOpen: (url: string) => void;
742+
onOpen: OpenOnHost;
738743
reactions: ReactionSurface;
739744
}) {
740745
const gt = useGT();
@@ -911,8 +916,9 @@ export function PullRequestTimelineTab({
911916
}, [revealUrl, targetIndex]);
912917
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- the hold observes DOM outside React and must end with the tab
913918
useEffect(() => () => stopHolding.current?.(), []);
914-
const openOnHost = (url: string) => {
915-
void readLocalApi()?.shell.openExternal(url);
919+
const openLink = useOpenLink(threadRef);
920+
const openOnHost: OpenOnHost = (url, event) => {
921+
void openLink(url, { event }).catch(console.error);
916922
};
917923

918924
const rowKey = (row: PullRequestTimelineRow) => {

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.