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...@@ -226,17 +226,14 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
226 });226 });
227 return;227 return;
228 }228 }
229 const promise = api.shell.openExternal(prUrl);229 void api.shell.openExternal(prUrl).catch((err) => {
230 toastManager.promise(promise, {230 toastManager.add({
231 loading: { title: "Opening PR...", data: threadToastData },231 type: "error",
232 success: { title: "PR opened", data: threadToastData },
233 error: (err) => ({
234 title: "Unable to open PR link",232 title: "Unable to open PR link",
235 description: err instanceof Error ? err.message : "An error occurred.",233 description: err instanceof Error ? err.message : "An error occurred.",
236 data: threadToastData,234 data: threadToastData,
237 }),235 });
238 });236 });
239 void promise.catch(() => undefined);
240 }, [api, gitStatusForActions?.openPr?.url, threadToastData]);237 }, [api, gitStatusForActions?.openPr?.url, threadToastData]);
241238
242 const runGitActionWithToast = useCallback(239 const runGitActionWithToast = useCallback(