@devries-cameron20 / t3code-1 / commits / 665351fc39
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): show readable errors when a stack action fails (#24118)

Co-authored-by: GPT-6.1 Sol <noreply@openai.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Victor Vogel committed Oct 31, 2026 at 21:30 UTC 665351fc391dab0105bf2653d96bd164f878a4c3
2 files changed +82 -1
apps/web/src/components/pullRequest/PullRequestStackMenu.browser.test.tsx new
+75
@@ -0,0 +1,75 @@
1 +import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
2 +import { EnvironmentId, ProjectId } from "@t3tools/contracts";
3 +import { expect, it, vi } from "vite-plus/test";
4 +import { page } from "vite-plus/test/browser";
5 +
6 +const state = vi.hoisted(() => ({ detail: "" }));
7 +
8 +vi.mock(import("~/state/use-atom-command"), async () => {
9 + const { PullRequestOperationError } = await import("@t3tools/contracts");
10 + const { Cause } = await import("effect");
11 + const { AsyncResult } = await import("effect/reactivity");
12 + return {
13 + useAtomCommand: (() => async () =>
14 + AsyncResult.failure(
15 + Cause.fail(new PullRequestOperationError({ operation: "runAction", detail: state.detail })),
16 + )) as never,
17 + };
18 +});
19 +
20 +import "~/index.css";
21 +import { render } from "../../../test/render";
22 +import { ToastProvider } from "../ui/toast";
23 +import { PullRequestStackMenu } from "./PullRequestStackMenu";
24 +
25 +function setup(detail: string) {
26 + state.detail = detail;
27 +}
28 +
29 +const HEAD_MOVED = "The stack head moved. Refresh the stack before trying again.";
30 +
31 +it.each([
32 + { label: "Merge stack", detail: HEAD_MOVED, description: HEAD_MOVED },
33 + { label: "Rebase stack", detail: HEAD_MOVED, description: HEAD_MOVED },
34 + {
35 + label: "Rebase stack",
36 + detail: "GitHub CLI command failed.",
37 + description:
38 + "The host refused the rebase. A rebase stops at the first commit that does not apply cleanly.",
39 + },
40 +])("$label refused with $detail shows $description", async (row) => {
41 + setup(row.detail);
42 + await using screen = await render(
43 + <ToastProvider>
44 + <PullRequestStackMenu
45 + environmentId={EnvironmentId.make("environment")}
46 + reference={{
47 + projectId: ProjectId.make("project"),
48 + repository: "owner/repository",
49 + number: 2,
50 + }}
51 + hostLabel="GitHub"
52 + terminology={sourceControlClients.get("github").changeRequest}
53 + stack={{
54 + id: "stack",
55 + number: 1,
56 + url: "https://github.com/owner/repository/stack/1",
57 + base: "main",
58 + layers: [{ number: 2, headBranch: "feature", headSha: "abc123", state: "open" }],
59 + }}
60 + canMerge
61 + canRebase
62 + mergeMethod="squash"
63 + onActed={() => {}}
64 + />
65 + </ToastProvider>,
66 + );
67 + if (row.label === "Rebase stack") {
68 + await screen.getByRole("button", { name: "Stack 1, layer 1 of 1" }).click();
69 + await page.getByRole("menuitem", { name: row.label }).click();
70 + } else {
71 + await screen.getByRole("button", { name: row.label, exact: true }).click();
72 + }
73 + await page.getByRole("dialog").getByRole("button", { name: row.label, exact: true }).click();
74 + await expect.element(page.getByText(row.description, { exact: true })).toBeInTheDocument();
75 +});
apps/web/src/components/pullRequest/PullRequestStackMenu.tsx
+7 -1
@@ -27,6 +27,7 @@ import { PullRequestStackLayers } from "./PullRequestStackLayers";
27 import { PullRequestStackHeader } from "./PullRequestStackHeader";
28 import { PullRequestStackLayerContent } from "./PullRequestStackLayerContent";
29 import { PullRequestGlyph } from "./pullRequestIcons";
30 +import { readableFailure } from "./pullRequestDetail.logic";
31
32 export function PullRequestStackMenu({
33 hostLabel,
@@ -114,7 +115,12 @@ export function PullRequestStackMenu({
115 toastManager.update(toastId, {
116 type: "error",
117 title: action === "merge" ? "Could not merge the stack" : "Could not rebase the stack",
117 - description: String(squashAtomCommandFailure(result)),
118 + description: readableFailure(
119 + squashAtomCommandFailure(result),
120 + action === "merge"
121 + ? "The host refused the merge. Check that you have write access, that the checks it requires have passed, and that the branch is not conflicting."
122 + : "The host refused the rebase. A rebase stops at the first commit that does not apply cleanly.",
123 + ),
124 });
125 } else {
126 toastManager.update(toastId, {