Skip to content
TypeScript

fix(web): open PR toast actions in app (#9006)

eimexdev43bafd467484
diff --git a/apps/web/src/components/GitActionsControl.tsx b/apps/web/src/components/GitActionsControl.tsx
index d448a720ebf..1c75476b96d 100644
--- a/apps/web/src/components/GitActionsControl.tsx
+++ b/apps/web/src/components/GitActionsControl.tsx
@@ -17,7 +17,15 @@ import type {
} from "@t3tools/contracts";
import { useNavigate } from "@tanstack/react-router";
import * as Option from "effect/Option";
-import { useCallback, useEffect, useEffectEvent, useMemo, useRef, useState } from "react";
+import {
+ type MouseEvent,
+ useCallback,
+ useEffect,
+ useEffectEvent,
+ useMemo,
+ useRef,
+ useState,
+} from "react";
import { flushSync } from "react-dom";
import {
CheckIcon,
@@ -91,7 +99,7 @@ import { resolvePathLinkTarget } from "~/terminal-links";
import { type DraftId, useComposerDraftStore } from "~/composerDraftStore";
import { readLocalApi } from "~/localApi";
import { getSourceControlPresentation } from "~/sourceControlPresentation";
-import { openPullRequestLink } from "~/lib/openPullRequestLink";
+import { openPullRequestLink, useOpenPrLink } from "~/lib/openPullRequestLink";
interface GitActionsControlProps {
gitCwd: string | null;
@@ -995,6 +1003,7 @@ export default function GitActionsControl({
() => (activeThreadRef ? { threadRef: activeThreadRef } : undefined),
[activeThreadRef],
);
+ const openPrLink = useOpenPrLink(activeThreadRef ?? undefined);
const activeDraftThread = useComposerDraftStore((store) =>
draftId
? store.getDraftSession(draftId)
@@ -1442,7 +1451,7 @@ export default function GitActionsControl({
const toastCta = actionResult.toast.cta;
let toastActionProps: {
children: string;
- onClick: () => void;
+ onClick: (event: MouseEvent<HTMLButtonElement>) => void;
} | null = null;
if (toastCta.kind === "run_action") {
toastActionProps = {
@@ -1457,11 +1466,9 @@ export default function GitActionsControl({
} else if (toastCta.kind === "open_pr") {
toastActionProps = {
children: toastCta.label,
- onClick: () => {
- const api = readLocalApi();
- if (!api) return;
+ onClick: (event) => {
closeResultToast();
- void api.shell.openExternal(toastCta.url);
+ openPrLink(event, toastCta.url);
},
};
}