The best way to control Claude Code, Codex and more from any computer or phone
feat(web): pr panel actions confirm in place (#17710)
maria committed
Oct 10, 2026 at 02:22 UTC
1f093d119b91263deb83f0d18e1504b791fdbbd4
2 files changed
+174
-132
apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx
+119
-132
@@ -88,15 +88,6 @@ import { vcsEnvironment } from "~/state/vcs";
88
import { formatRelativeTimeLabel } from "~/timestampFormat";
89
import { useUiStateStore } from "~/uiStateStore";
90
91
-import {
92
- AlertDialog,
93
- AlertDialogClose,
94
- AlertDialogDescription,
95
- AlertDialogFooter,
96
- AlertDialogHeader,
97
- AlertDialogPopup,
98
- AlertDialogTitle,
99
-} from "../ui/alert-dialog";
91
import { EnvironmentMachineIcon } from "../EnvironmentMachineIcon";
92
import { Badge } from "../ui/badge";
93
import { Button } from "../ui/button";
@@ -183,25 +174,10 @@ import {
174
summarizePullRequestChecks,
175
} from "./pullRequestPresentation";
176
import { PullRequestGlyph } from "./pullRequestIcons";
177
+import { useInlineActionConfirm } from "./useInlineActionConfirm";
178
179
type DetailTab = "summary" | "timeline" | "code";
180
189
-const ACTION_SUCCESS_LABELS: Record<PullRequestAction, string> = {
190
- merge: "Pull request merged",
191
- ready: "Marked ready for review",
192
- draft: "Converted to draft",
193
- close: "Pull request closed",
194
- reopen: "Pull request reopened",
195
- "update-branch": "Branch updated with the base branch",
196
- // True whichever it did: a pull request that was already mergeable merges the moment this is
197
- // armed, and the client has no way to tell that apart from one still waiting on something.
198
- "enable-auto-merge":
199
- "Auto-merge turned on — merges as soon as this is ready, sooner if it already is",
200
- "disable-auto-merge": "Auto-merge turned off",
201
- revert: "Revert pull request opened",
202
- "approve-workflows": "Workflows approved",
203
-};
204
-
181
/** Said as the thing that did not happen, rather than as the operation that returned an error. */
182
const ACTION_FAILURE_LABELS: Record<PullRequestAction, string> = {
183
merge: "Could not merge this pull request",
@@ -578,11 +554,7 @@ export function PullRequestDetailPanel({
554
const setMergeMethod = (method: PullRequestMergeMethod) => {
555
setMergeMethodSelection({ pullRequestKey, method });
556
};
581
- const [confirmation, setConfirmation] = useState<{
582
- readonly open: boolean;
583
- readonly action: "merge" | "close" | "enable-auto-merge" | "revert" | "approve-workflows";
584
- }>({ open: false, action: "merge" });
585
- const confirmAction = confirmation.action;
557
+ const inlineConfirm = useInlineActionConfirm(pullRequestKey);
558
// Which handoff is preparing, keyed so a per-finding button can say "Preparing..." on itself
559
// alone. One at a time whatever the key: they all check the same pull request out.
560
const [handoff, setHandoff] = useState<string | null>(null);
@@ -986,7 +958,10 @@ export function PullRequestDetailPanel({
958
onActed?.(action, "failed");
959
return false;
960
}
989
- toastManager.add({ type: "success", title: ACTION_SUCCESS_LABELS[action] });
961
+ // Reverting opens another PR; the current panel has no new state to show.
962
+ if (action === "revert") {
963
+ toastManager.add({ type: "success", title: "Revert pull request opened" });
964
+ }
965
// A branch update moves the head commit, which leaves the diff atom pointed at a comparison
966
// that no longer exists — the same staleness the manual refresh button fixes, so it goes
967
// through that path rather than a second one. Every other action here only changes metadata;
@@ -1918,27 +1893,44 @@ export function PullRequestDetailPanel({
1893
size="xs"
1894
variant="default"
1895
disabled={actionPending}
1921
- onClick={() =>
1922
- setConfirmation({ open: true, action: "enable-auto-merge" })
1923
- }
1896
+ {...inlineConfirm.props(
1897
+ "enable-auto-merge",
1898
+ () => void perform("enable-auto-merge", selectedMergeMethod),
1899
+ )}
1900
aria-label={
1901
pendingAction === "enable-auto-merge"
1902
? "Enabling..."
1927
- : pendingAutoMergeLabel
1903
+ : inlineConfirm.isArmed("enable-auto-merge")
1904
+ ? "Confirm auto-merge?"
1905
+ : pendingAutoMergeLabel
1906
}
1907
>
1908
<PullRequestGlyph.merged aria-hidden className="size-3.5" />
1931
- <span className="@max-[30rem]/pr-header:hidden">
1932
- {pendingAction === "enable-auto-merge"
1933
- ? "Enabling..."
1934
- : pendingAutoMergeLabel}
1909
+ <span className="inline-grid @max-[30rem]/pr-header:hidden">
1910
+ <span aria-hidden className="invisible col-start-1 row-start-1">
1911
+ {pendingAutoMergeLabel}
1912
+ </span>
1913
+ <span aria-hidden className="invisible col-start-1 row-start-1">
1914
+ Confirm auto-merge?
1915
+ </span>
1916
+ <span className="col-start-1 row-start-1">
1917
+ {pendingAction === "enable-auto-merge"
1918
+ ? "Enabling..."
1919
+ : inlineConfirm.isArmed("enable-auto-merge")
1920
+ ? "Confirm auto-merge?"
1921
+ : pendingAutoMergeLabel}
1922
+ </span>
1923
</span>
1924
</Button>
1925
</span>
1926
}
1927
/>
1928
<TooltipPopup side="top">
1941
- {pendingAction === "enable-auto-merge" ? "Enabling..." : pendingAutoMergeLabel}
1929
+ {pendingAction === "enable-auto-merge"
1930
+ ? "Enabling..."
1931
+ : inlineConfirm.isArmed("enable-auto-merge")
1932
+ ? "Confirm auto-merge?"
1933
+ : pendingAutoMergeLabel}
1934
</TooltipPopup>
1935
</Tooltip>
1936
) : primaryAction === "auto-merge-armed" ? (
@@ -1970,21 +1962,44 @@ export function PullRequestDetailPanel({
1962
size="xs"
1963
variant="default"
1964
disabled={actionPending}
1973
- onClick={() => setConfirmation({ open: true, action: "merge" })}
1965
+ {...inlineConfirm.props(
1966
+ "merge",
1967
+ () => void perform("merge", selectedMergeMethod),
1968
+ )}
1969
aria-label={
1975
- pendingAction === "merge" ? "Merging..." : selectedMergeMethodLabel
1970
+ pendingAction === "merge"
1971
+ ? "Merging..."
1972
+ : inlineConfirm.isArmed("merge")
1973
+ ? "Confirm merge?"
1974
+ : selectedMergeMethodLabel
1975
}
1976
>
1977
<PullRequestGlyph.merged aria-hidden className="size-3.5" />
1979
- <span className="@max-[30rem]/pr-header:hidden">
1980
- {pendingAction === "merge" ? "Merging..." : selectedMergeMethodLabel}
1978
+ <span className="inline-grid @max-[30rem]/pr-header:hidden">
1979
+ <span aria-hidden className="invisible col-start-1 row-start-1">
1980
+ {selectedMergeMethodLabel}
1981
+ </span>
1982
+ <span aria-hidden className="invisible col-start-1 row-start-1">
1983
+ Confirm merge?
1984
+ </span>
1985
+ <span className="col-start-1 row-start-1">
1986
+ {pendingAction === "merge"
1987
+ ? "Merging..."
1988
+ : inlineConfirm.isArmed("merge")
1989
+ ? "Confirm merge?"
1990
+ : selectedMergeMethodLabel}
1991
+ </span>
1992
</span>
1993
</Button>
1994
</span>
1995
}
1996
/>
1997
<TooltipPopup side="top">
1987
- {pendingAction === "merge" ? "Merging..." : selectedMergeMethodLabel}
1998
+ {pendingAction === "merge"
1999
+ ? "Merging..."
2000
+ : inlineConfirm.isArmed("merge")
2001
+ ? "Confirm merge?"
2002
+ : selectedMergeMethodLabel}
2003
</TooltipPopup>
2004
</Tooltip>
2005
) : (primaryAction === "merged" || primaryAction === "closed") &&
@@ -2101,11 +2116,18 @@ export function PullRequestDetailPanel({
2116
) : null}
2117
{showsMergeNow ? (
2118
<MenuItem
2119
+ closeOnClick={inlineConfirm.isArmed("merge")}
2120
+ aria-label={
2121
+ inlineConfirm.isArmed("merge") ? "Confirm merge?" : "Merge now"
2122
+ }
2123
disabled={actionPending}
2105
- onClick={() => setConfirmation({ open: true, action: "merge" })}
2124
+ {...inlineConfirm.props(
2125
+ "merge",
2126
+ () => void perform("merge", selectedMergeMethod),
2127
+ )}
2128
>
2129
<PullRequestGlyph.merged className="size-3.5" />
2108
- Merge now
2130
+ {inlineConfirm.isArmed("merge") ? "Confirm merge?" : "Merge now"}
2131
</MenuItem>
2132
) : null}
2133
{/* The same merge, left with the host to carry out once its requirements
@@ -2121,13 +2143,22 @@ export function PullRequestDetailPanel({
2143
</MenuItem>
2144
) : showsAutoMerge ? (
2145
<MenuItem
2124
- disabled={actionPending}
2125
- onClick={() =>
2126
- setConfirmation({ open: true, action: "enable-auto-merge" })
2146
+ closeOnClick={inlineConfirm.isArmed("enable-auto-merge")}
2147
+ aria-label={
2148
+ inlineConfirm.isArmed("enable-auto-merge")
2149
+ ? "Confirm auto-merge?"
2150
+ : "Enable auto-merge"
2151
}
2152
+ disabled={actionPending}
2153
+ {...inlineConfirm.props(
2154
+ "enable-auto-merge",
2155
+ () => void perform("enable-auto-merge", selectedMergeMethod),
2156
+ )}
2157
>
2158
<PullRequestGlyph.merged className="size-3.5" />
2130
- Enable auto-merge
2159
+ {inlineConfirm.isArmed("enable-auto-merge")
2160
+ ? "Confirm auto-merge?"
2161
+ : "Enable auto-merge"}
2162
</MenuItem>
2163
) : null}
2164
{/* A preference for the merge action rather than a second action, so it
@@ -2200,12 +2231,16 @@ export function PullRequestDetailPanel({
2231
<>
2232
<MenuSeparator />
2233
<MenuItem
2234
+ closeOnClick={inlineConfirm.isArmed("close")}
2235
+ aria-label={
2236
+ inlineConfirm.isArmed("close") ? "Confirm close?" : "Close pull request"
2237
+ }
2238
variant="destructive"
2239
disabled={actionPending}
2205
- onClick={() => setConfirmation({ open: true, action: "close" })}
2240
+ {...inlineConfirm.props("close", () => void perform("close"))}
2241
>
2242
<PullRequestGlyph.closed className="size-3.5" />
2208
- Close pull request
2243
+ {inlineConfirm.isArmed("close") ? "Confirm close?" : "Close pull request"}
2244
</MenuItem>
2245
</>
2246
) : detail.state === "closed" && can("reopen") ? (
@@ -2220,11 +2255,16 @@ export function PullRequestDetailPanel({
2255
<>
2256
<MenuSeparator />
2257
<MenuItem
2258
+ closeOnClick={inlineConfirm.isArmed("revert")}
2259
+ aria-label={
2260
+ inlineConfirm.isArmed("revert") ? "Confirm revert?" : "Revert changes"
2261
+ }
2262
+ variant={inlineConfirm.isArmed("revert") ? "destructive" : "default"}
2263
disabled={actionPending}
2224
- onClick={() => setConfirmation({ open: true, action: "revert" })}
2264
+ {...inlineConfirm.props("revert", () => void perform("revert"))}
2265
>
2266
<RotateCcwIcon className="size-3.5" />
2227
- Revert changes
2267
+ {inlineConfirm.isArmed("revert") ? "Confirm revert?" : "Revert changes"}
2268
</MenuItem>
2269
</>
2270
) : null}
@@ -2553,20 +2593,33 @@ export function PullRequestDetailPanel({
2593
size="xs"
2594
variant="warning-outline"
2595
disabled={actionPending}
2556
- onClick={() =>
2557
- setConfirmation({ open: true, action: "approve-workflows" })
2558
- }
2596
+ {...inlineConfirm.props(
2597
+ "approve-workflows",
2598
+ () => void perform("approve-workflows"),
2599
+ )}
2600
aria-label={
2601
pendingAction === "approve-workflows"
2602
? "Approving..."
2562
- : "Approve workflows to run"
2603
+ : inlineConfirm.isArmed("approve-workflows")
2604
+ ? "Confirm approve?"
2605
+ : "Approve workflows to run"
2606
}
2607
>
2608
<PlayIcon aria-hidden className="size-3.5" />
2566
- <span>
2567
- {pendingAction === "approve-workflows"
2568
- ? "Approving..."
2569
- : "Approve workflows to run"}
2609
+ <span className="inline-grid">
2610
+ <span aria-hidden className="invisible col-start-1 row-start-1">
2611
+ Approve workflows to run
2612
+ </span>
2613
+ <span aria-hidden className="invisible col-start-1 row-start-1">
2614
+ Confirm approve?
2615
+ </span>
2616
+ <span className="col-start-1 row-start-1">
2617
+ {pendingAction === "approve-workflows"
2618
+ ? "Approving..."
2619
+ : inlineConfirm.isArmed("approve-workflows")
2620
+ ? "Confirm approve?"
2621
+ : "Approve workflows to run"}
2622
+ </span>
2623
</span>
2624
</Button>
2625
</span>
@@ -2575,7 +2628,9 @@ export function PullRequestDetailPanel({
2628
<TooltipPopup side="top">
2629
{pendingAction === "approve-workflows"
2630
? "Approving..."
2578
- : "Approve workflows to run"}
2631
+ : inlineConfirm.isArmed("approve-workflows")
2632
+ ? "Confirm approve?"
2633
+ : "Approve workflows to run"}
2634
</TooltipPopup>
2635
</Tooltip>
2636
) : (
@@ -2802,74 +2857,6 @@ export function PullRequestDetailPanel({
2857
/>
2858
</div>
2859
) : null}
2805
-
2806
- <AlertDialog
2807
- open={confirmation.open}
2808
- onOpenChange={(open) => setConfirmation((current) => ({ ...current, open }))}
2809
- onOpenChangeComplete={(open) => {
2810
- if (!open) setConfirmation({ open: false, action: "merge" });
2811
- }}
2812
- >
2813
- <AlertDialogPopup>
2814
- <AlertDialogHeader>
2815
- <AlertDialogTitle>
2816
- {confirmAction === "merge"
2817
- ? "Merge pull request?"
2818
- : confirmAction === "enable-auto-merge"
2819
- ? "Enable auto-merge?"
2820
- : confirmAction === "revert"
2821
- ? "Revert these changes?"
2822
- : confirmAction === "approve-workflows"
2823
- ? "Approve workflows to run?"
2824
- : "Close pull request?"}
2825
- </AlertDialogTitle>
2826
- <AlertDialogDescription>
2827
- {confirmAction === "merge"
2828
- ? `This merges #${reference.number} using ${selectedMergeMethod}.`
2829
- : confirmAction === "enable-auto-merge"
2830
- ? // The host merges this as soon as it considers the pull request ready, which
2831
- // may be immediately — there is no telling from here whether anything is
2832
- // still outstanding.
2833
- `This merges #${reference.number} using ${selectedMergeMethod} as soon as the host considers it ready, which may be immediately.`
2834
- : confirmAction === "revert"
2835
- ? `This opens a new pull request that reverses the changes merged by #${reference.number}.`
2836
- : confirmAction === "approve-workflows"
2837
- ? `This allows ${workflowApprovalsRequired} ${workflowApprovalsRequired === 1 ? "workflow" : "workflows"} from #${reference.number} to run. Review the code and workflow changes first.`
2838
- : `This closes #${reference.number} without merging it.`}
2839
- </AlertDialogDescription>
2840
- </AlertDialogHeader>
2841
- <AlertDialogFooter>
2842
- <AlertDialogClose render={<Button variant="outline" size="sm" />}>
2843
- Cancel
2844
- </AlertDialogClose>
2845
- <Button
2846
- size="sm"
2847
- variant={confirmAction === "close" ? "destructive" : "default"}
2848
- disabled={actionPending}
2849
- onClick={() => {
2850
- const action = confirmAction;
2851
- setConfirmation((current) => ({ ...current, open: false }));
2852
- if (action === "merge") void perform("merge", selectedMergeMethod);
2853
- if (action === "enable-auto-merge")
2854
- void perform("enable-auto-merge", selectedMergeMethod);
2855
- if (action === "revert") void perform("revert");
2856
- if (action === "approve-workflows") void perform("approve-workflows");
2857
- if (action === "close") void perform("close");
2858
- }}
2859
- >
2860
- {confirmAction === "merge"
2861
- ? selectedMergeMethodLabel
2862
- : confirmAction === "enable-auto-merge"
2863
- ? "Enable auto-merge"
2864
- : confirmAction === "revert"
2865
- ? "Create revert PR"
2866
- : confirmAction === "approve-workflows"
2867
- ? "Approve and run"
2868
- : "Close"}
2869
- </Button>
2870
- </AlertDialogFooter>
2871
- </AlertDialogPopup>
2872
- </AlertDialog>
2860
</div>
2861
);
2862
}
apps/web/src/components/pullRequest/useInlineActionConfirm.ts
new
+55
@@ -0,0 +1,55 @@
1
+import { useEffect, useState, type MouseEvent } from "react";
2
+
3
+/** Arms one control at a time, including controls rendered in a menu portal. */
4
+export function useInlineActionConfirm(scopeKey: string) {
5
+ const [armed, setArmed] = useState<{
6
+ scopeKey: string;
7
+ action: string;
8
+ element: HTMLElement;
9
+ } | null>(null);
10
+ const active = armed?.scopeKey === scopeKey ? armed : null;
11
+
12
+ useEffect(() => {
13
+ if (!armed) return;
14
+ const disarm = () => setArmed(null);
15
+ if (armed.scopeKey !== scopeKey) {
16
+ disarm();
17
+ return;
18
+ }
19
+ const onPointerDown = (event: PointerEvent) => {
20
+ if (event.target instanceof Node && !armed.element.contains(event.target)) disarm();
21
+ };
22
+ const onKeyDown = (event: KeyboardEvent) => {
23
+ if (event.key === "Escape") {
24
+ event.preventDefault();
25
+ event.stopPropagation();
26
+ disarm();
27
+ }
28
+ };
29
+ const timeout = window.setTimeout(disarm, 3000);
30
+ document.addEventListener("pointerdown", onPointerDown, true);
31
+ window.addEventListener("keydown", onKeyDown, true);
32
+ window.addEventListener("blur", disarm);
33
+ return () => {
34
+ window.clearTimeout(timeout);
35
+ document.removeEventListener("pointerdown", onPointerDown, true);
36
+ window.removeEventListener("keydown", onKeyDown, true);
37
+ window.removeEventListener("blur", disarm);
38
+ };
39
+ }, [armed, scopeKey]);
40
+
41
+ return {
42
+ isArmed: (action: string) => active?.action === action,
43
+ props: (action: string, onConfirm: () => void) => ({
44
+ onClick: (event: MouseEvent<HTMLElement>) => {
45
+ if (active?.action === action && active.element === event.currentTarget) {
46
+ setArmed(null);
47
+ onConfirm();
48
+ } else {
49
+ setArmed({ scopeKey, action, element: event.currentTarget });
50
+ }
51
+ },
52
+ onBlur: () => setArmed(null),
53
+ }),
54
+ };
55
+}