fix(web): open PR toast actions in app (#9006)
This commit is contained in:
1 parent
8339508f5c
commit
43bafd4674
1 file changed
+14
-7
@@ -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);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user