Skip to content
TypeScript

fix(web): a failed review guide keeps Try again reachable (#26073)

NotAnNvidiaFane123ac644eef
diff --git a/apps/web/src/components/pullRequest/PullRequestGuideTab.browser.test.tsx b/apps/web/src/components/pullRequest/PullRequestGuideTab.browser.test.tsx
new file mode 100644
index 00000000000..0b746725e62
--- /dev/null
+++ b/apps/web/src/components/pullRequest/PullRequestGuideTab.browser.test.tsx
@@ -0,0 +1,75 @@
+import { EnvironmentId, ProjectId, type PullRequestRef } from "@t3tools/contracts";
+import { expect, it, vi } from "vite-plus/test";
+import { userEvent } from "vite-plus/test/browser";
+
+vi.mock(import("./guide/useReviewGuideWriter"), () => ({ useReviewGuideWriter: vi.fn() }));
+
+import { render } from "../../../test/render";
+import { useReviewGuideWriter } from "./guide/useReviewGuideWriter";
+import { PullRequestGuideTab } from "./PullRequestGuideTab";
+
+const reference: PullRequestRef = {
+ projectId: ProjectId.make("project"),
+ repository: "owner/repo",
+ number: 1,
+};
+
+const verboseFailure = [
+ "Codex CLI command failed: OpenAI Codex v0.164.0",
+ ...Array.from({ length: 200 }, (_, line) => `prompt line ${line}: read the change in order`),
+ "ERROR: provider auth command `sh` timed out after 5000 ms",
+].join("\n");
+
+it("keeps Try again inside a short panel when a failed guide has long diagnostics", async () => {
+ const write = vi.fn(async () => {});
+ vi.mocked(useReviewGuideWriter).mockReturnValue({
+ query: { isPending: false, error: null } as never,
+ data: {
+ guide: null,
+ run: {
+ _tag: "Failed",
+ headSha: "head",
+ failedAt: "2026-10-27T16:37:47.661Z",
+ detail: verboseFailure,
+ },
+ currentHeadSha: "head",
+ },
+ running: false,
+ canWrite: true,
+ write,
+ });
+ const panel = document.createElement("div");
+ panel.style.cssText = "position: relative; width: 480px; height: 360px; overflow: hidden";
+ const tab = document.createElement("div");
+ tab.style.cssText = "position: absolute; inset: 0";
+ panel.append(tab);
+ document.body.append(panel);
+ using _panel = { [Symbol.dispose]: () => panel.remove() };
+
+ await using screen = await render(
+ <PullRequestGuideTab
+ environmentId={EnvironmentId.make("environment")}
+ reference={reference}
+ title="Test pull request"
+ workspaceRoot="/workspace"
+ active
+ canComment={false}
+ rangeComments={false}
+ onAskAboutLines={null}
+ onAskAboutStop={null}
+ onFinishReview={null}
+ onOpenFile={() => {}}
+ />,
+ { container: tab },
+ );
+
+ const retry = screen.getByRole("button", { name: "Try again" });
+ await expect.element(retry).toBeVisible();
+ const panelBox = panel.getBoundingClientRect();
+ const retryBox = retry.element().getBoundingClientRect();
+ expect(retryBox.top).toBeGreaterThanOrEqual(panelBox.top);
+ expect(retryBox.bottom).toBeLessThanOrEqual(panelBox.bottom);
+
+ await userEvent.click(retry);
+ expect(write).toHaveBeenCalledOnce();
+});
diff --git a/apps/web/src/components/pullRequest/PullRequestGuideTab.tsx b/apps/web/src/components/pullRequest/PullRequestGuideTab.tsx
index fef668b3f34..c7a032f6ffd 100644
--- a/apps/web/src/components/pullRequest/PullRequestGuideTab.tsx
+++ b/apps/web/src/components/pullRequest/PullRequestGuideTab.tsx
@@ -104,18 +104,24 @@ export function PullRequestGuideTab({
);
}
return (
- <div className="flex min-h-48 flex-col items-center justify-center gap-2 px-4 py-10 text-center">
+ <div className="scrollbar-gutter-both flex h-full flex-col items-center justify-center-safe gap-2 overflow-y-auto px-4 py-10 text-center">
<p className="text-sm font-medium text-foreground">
- {running ? "Writing a review guide" : "No review guide yet"}
+ {running
+ ? "Writing a review guide"
+ : failure === null
+ ? "No review guide yet"
+ : "Could not write a review guide"}
</p>
<p className="max-w-md text-xs text-muted-foreground">
- {failure ??
- query.error ??
- (running
- ? "An agent is reading the change. A large one takes a few minutes. You can leave; you will be told when it is ready."
- : "A guide is a tour of the change: stops through the code in reading order, with the calls only a maintainer can make.")}
+ {running
+ ? "An agent is reading the change. A large one takes a few minutes. You can leave; you will be told when it is ready."
+ : failure === null
+ ? (query.error ??
+ "A guide is a tour of the change: stops through the code in reading order, with the calls only a maintainer can make.")
+ : FAILURE_HINT}
</p>
{writeButton(failure === null ? "Write guide" : "Try again", "sm")}
+ {failure === null || running ? null : <FailureDetails detail={failure} />}
</div>
);
}
@@ -125,9 +131,16 @@ export function PullRequestGuideTab({
<Alert variant={running ? "info" : "warning"}>
{running ? <Spinner /> : <TriangleAlertIcon />}
<AlertDescription>
- {running
- ? "Rewriting this guide. You will be told when the new one is ready."
- : (failure ?? "Written before the latest push.")}
+ {running ? (
+ "Rewriting this guide. You will be told when the new one is ready."
+ ) : failure === null ? (
+ "Written before the latest push."
+ ) : (
+ <>
+ {`Could not rewrite this guide. ${FAILURE_HINT}`}
+ <FailureDetails detail={failure} />
+ </>
+ )}
</AlertDescription>
{!running && canWrite ? <AlertAction>{writeButton("Rewrite", "xs")}</AlertAction> : null}
</Alert>
@@ -156,3 +169,18 @@ export function PullRequestGuideTab({
</GuideProseContext>
);
}
+
+const FAILURE_HINT = "Check the review guide model in Settings → Source control.";
+
+function FailureDetails({ detail }: { detail: string }) {
+ return (
+ <details className="w-full max-w-lg text-xs text-muted-foreground">
+ <summary className="cursor-pointer rounded-sm -outline-offset-2 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring">
+ Technical details
+ </summary>
+ <pre className="scrollbar-gutter-both mt-2 max-h-40 overflow-auto whitespace-pre-wrap break-words rounded-lg border border-border bg-muted/40 p-3 text-left font-mono text-xs">
+ {detail}
+ </pre>
+ </details>
+ );
+}