@@ -17,7 +17,15 @@ import type {
1717} from "@t3tools/contracts" ;
1818import { useNavigate } from "@tanstack/react-router" ;
1919import * as Option from "effect/Option" ;
20- import { useCallback , useEffect , useEffectEvent , useMemo , useRef , useState } from "react" ;
20+ import {
21+ type MouseEvent ,
22+ useCallback ,
23+ useEffect ,
24+ useEffectEvent ,
25+ useMemo ,
26+ useRef ,
27+ useState ,
28+ } from "react" ;
2129import { flushSync } from "react-dom" ;
2230import {
2331 CheckIcon ,
@@ -91,7 +99,11 @@ import { resolvePathLinkTarget } from "~/terminal-links";
9199import { type DraftId , useComposerDraftStore } from "~/composerDraftStore" ;
92100import { readLocalApi } from "~/localApi" ;
93101import { getSourceControlPresentation } from "~/sourceControlPresentation" ;
94- import { openPullRequestLink } from "~/lib/openPullRequestLink" ;
102+ import {
103+ openPullRequestLink ,
104+ parseChangeRequestUrl ,
105+ shouldOpenPullRequestExternally ,
106+ } from "~/lib/openPullRequestLink" ;
95107
96108interface GitActionsControlProps {
97109 gitCwd : string | null ;
@@ -1442,7 +1454,7 @@ export default function GitActionsControl({
14421454 const toastCta = actionResult . toast . cta ;
14431455 let toastActionProps : {
14441456 children : string ;
1445- onClick : ( ) => void ;
1457+ onClick : ( event : MouseEvent < HTMLButtonElement > ) => void ;
14461458 } | null = null ;
14471459 if ( toastCta . kind === "run_action" ) {
14481460 toastActionProps = {
@@ -1455,9 +1467,19 @@ export default function GitActionsControl({
14551467 } ,
14561468 } ;
14571469 } else if ( toastCta . kind === "open_pr" ) {
1470+ const pullRequestNumber = parseChangeRequestUrl ( toastCta . url ) ?. number ;
14581471 toastActionProps = {
14591472 children : toastCta . label ,
1460- onClick : ( ) => {
1473+ onClick : ( event ) => {
1474+ if (
1475+ pullRequestNumber !== undefined &&
1476+ onOpenPullRequest &&
1477+ ! shouldOpenPullRequestExternally ( event )
1478+ ) {
1479+ closeResultToast ( ) ;
1480+ onOpenPullRequest ( pullRequestNumber ) ;
1481+ return ;
1482+ }
14611483 const api = readLocalApi ( ) ;
14621484 if ( ! api ) return ;
14631485 closeResultToast ( ) ;
0 commit comments