From 43bafd4674841fb8782f5174033b684aa0d83f67 Mon Sep 17 00:00:00 2001 From: eimexdev <130890337+eimexdev@users.noreply.github.com> Date: Wed, 2 Sep 2026 00:34:39 -0500 Subject: [PATCH] fix(web): open PR toast actions in app (#9006) --- apps/web/src/components/GitActionsControl.tsx | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/apps/web/src/components/GitActionsControl.tsx b/apps/web/src/components/GitActionsControl.tsx index d448a720ebfc6a16b2dbb5ef9f7b6d15ac5b0e84..1c75476b96d6d38431598448adbc666904987b03 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) => 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); }, }; } -- 2.54.0