diff --git a/apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx b/apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx index 7237b435748..081ca93b242 100644 --- a/apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx +++ b/apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx @@ -531,11 +531,38 @@ export function PullRequestDetailPanel({ // and at worst answer from it. const invalidate = useAtomCommand(pullRequestEnvironment.invalidate, { reportFailure: false }); const [refreshToken, setRefreshToken] = useState(0); - const refreshFromHost = useCallback(async () => { - await invalidate({ environmentId, input: { reference } }); - refreshDetail(); - setRefreshToken((token) => token + 1); - }, [environmentId, invalidate, reference, refreshDetail]); + const refreshFromHost = useCallback( + async (showFeedback = false) => { + const toastId = showFeedback + ? toastManager.add({ + type: "loading", + title: "Refreshing pull request...", + }) + : null; + const result = await invalidate({ environmentId, input: { reference } }); + refreshDetail(); + setRefreshToken((token) => token + 1); + if (toastId !== null) { + toastManager.update( + toastId, + result._tag === "Failure" + ? { + type: "error", + title: "Could not refresh pull request", + description: readableFailure( + squashAtomCommandFailure(result), + "Try again in a moment.", + ), + } + : { + type: "success", + title: "Pull request refreshed", + }, + ); + } + }, + [environmentId, invalidate, reference, refreshDetail], + ); // A refresh asked for by the page: the detail, and through the token below, the diff with it. const appliedForcedToken = useRef(forcedRefreshToken); useEffect(() => { @@ -1143,7 +1170,10 @@ export function PullRequestDetailPanel({ - void refreshFromHost()}> + void refreshFromHost(true)} + > Refresh