authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-02-17 16:08:39-08:00
committergravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-02-17 16:09:09-08:00
log09ac18db8204e0057a6cf0f73424e4345f2070ab
treeab4437eaa6f1d2e0ee3c7704dc0d9ae63cc54153
parent376efdd3401235dbba95474689e7c092aa08b858

Refactor PR opening logic in GitActionsControl component

- Simplify the promise handling for opening PR links by directly using `void api.shell.openExternal(prUrl).catch(...)` - Enhance error handling by adding a toast notification for failure cases, improving user feedback on PR link issues

1 files changed, 4 insertions(+), 7 deletions(-)

apps/web/src/components/GitActionsControl.tsx+4-7
......@@ -226,17 +226,14 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
226226 });
227227 return;
228228 }
229 const promise = api.shell.openExternal(prUrl);
230 toastManager.promise(promise, {
231 loading: { title: "Opening PR...", data: threadToastData },
232 success: { title: "PR opened", data: threadToastData },
233 error: (err) => ({
229 void api.shell.openExternal(prUrl).catch((err) => {
230 toastManager.add({
231 type: "error",
234232 title: "Unable to open PR link",
235233 description: err instanceof Error ? err.message : "An error occurred.",
236234 data: threadToastData,
237 }),
235 });
238236 });
239 void promise.catch(() => undefined);
240237 }, [api, gitStatusForActions?.openPr?.url, threadToastData]);
241238
242239 const runGitActionWithToast = useCallback(