@devries-cameron20 / t3code-1 / commits / 5bc19ac641
Fork 0

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

fix(web): dialogs keep their content while they close (#21960)

oliver committed Oct 20, 2026 at 18:12 UTC 5bc19ac641e9835eeaff28b424168b04c2d8c8ad
5 files changed +59 -22
apps/web/src/components/GitActionsControl.tsx
+5 -9
@@ -1008,8 +1008,6 @@ export default function GitActionsControl({
1008 const [inlineSuccess, setInlineSuccess] = useState<InlineGitActionSuccess | null>(null);
1009 const [pendingDefaultBranchAction, setPendingDefaultBranchAction] =
1010 useState<PendingDefaultBranchAction | null>(null);
1011 - // Keep the payload until the dialog finishes closing.
1012 - const [isDefaultBranchDialogOpen, setIsDefaultBranchDialogOpen] = useState(false);
1011 const sourceControlScope = { environmentId: activeEnvironmentId, cwd: gitCwd };
1012 const vcsActionState = useAtomValue(vcsActionManager.stateAtom(sourceControlScope));
1013 const visibleInlineSuccess = inlineSuccess?.scopeKey === successScopeKey ? inlineSuccess : null;
@@ -1252,7 +1250,6 @@ export default function GitActionsControl({
1250 ...(onConfirmed ? { onConfirmed } : {}),
1251 ...(filePaths ? { filePaths } : {}),
1252 });
1255 - setIsDefaultBranchDialogOpen(true);
1253 return;
1254 }
1255 onConfirmed?.();
@@ -1363,11 +1360,11 @@ export default function GitActionsControl({
1360 }
1361
1362 const continuePendingDefaultBranchAction = (featureBranch: boolean) => {
1366 - if (!isDefaultBranchDialogOpen || !pendingDefaultBranchAction || !canWriteSourceControl) return;
1363 + if (!pendingDefaultBranchAction || !canWriteSourceControl) return;
1364 if (featureBranch && (!canChangeThreadBranch || featureBranchUnavailableReason !== null))
1365 return;
1366 const { action, commitMessage, onConfirmed, filePaths } = pendingDefaultBranchAction;
1370 - setIsDefaultBranchDialogOpen(false);
1367 + setPendingDefaultBranchAction(null);
1368 void runGitActionWithToast({
1369 action,
1370 ...(commitMessage ? { commitMessage } : {}),
@@ -2033,9 +2030,8 @@ export default function GitActionsControl({
2030 />
2031
2032 <Dialog
2036 - open={isDefaultBranchDialogOpen}
2037 - onOpenChange={setIsDefaultBranchDialogOpen}
2038 - onOpenChangeComplete={(open) => {
2033 + open={pendingDefaultBranchAction !== null}
2034 + onOpenChange={(open) => {
2035 if (!open) setPendingDefaultBranchAction(null);
2036 }}
2037 >
@@ -2054,7 +2050,7 @@ export default function GitActionsControl({
2050 className="w-full sm:mr-auto sm:w-auto"
2051 variant="outline"
2052 size="sm"
2057 - onClick={() => setIsDefaultBranchDialogOpen(false)}
2053 + onClick={() => setPendingDefaultBranchAction(null)}
2054 >
2055 Abort
2056 </Button>
apps/web/src/components/settings/ConnectionsSettings.tsx
+5 -10
@@ -2206,7 +2206,6 @@ export function ConnectionsSettings() {
2206 const [removingSavedEnvironmentId, setRemovingSavedEnvironmentId] =
2207 useState<EnvironmentId | null>(null);
2208 const [isUpdatingDesktopServerExposure, setIsUpdatingDesktopServerExposure] = useState(false);
2209 - const [isDesktopServerExposureDialogOpen, setIsDesktopServerExposureDialogOpen] = useState(false);
2209 const [isUpdatingTailscaleServe, setIsUpdatingTailscaleServe] = useState(false);
2210 const [isUpdatingWslBackend, setIsUpdatingWslBackend] = useState(false);
2211 const [desktopWslMutationError, setDesktopWslMutationError] = useState<string | null>(null);
@@ -2354,11 +2353,11 @@ export function ConnectionsSettings() {
2353 try {
2354 await desktopBridge.setServerExposureMode(checked ? "network-accessible" : "local-only");
2355 refreshDesktopNetworkAccessState();
2357 - setIsDesktopServerExposureDialogOpen(false);
2356 + setPendingDesktopServerExposureMode(null);
2357 setIsUpdatingDesktopServerExposure(false);
2358 } catch (error) {
2359 const message = error instanceof Error ? error.message : "Failed to update network exposure.";
2361 - setIsDesktopServerExposureDialogOpen(false);
2360 + setPendingDesktopServerExposureMode(null);
2361 setDesktopServerExposureMutationError(message);
2362 toastManager.add(
2363 stackedThreadToast({
@@ -3073,7 +3072,6 @@ export function ConnectionsSettings() {
3072 disabled={!desktopServerExposureState || isUpdatingDesktopServerExposure}
3073 onCheckedChange={(checked) => {
3074 setPendingDesktopServerExposureMode(checked ? "network-accessible" : "local-only");
3076 - setIsDesktopServerExposureDialogOpen(true);
3075 }}
3076 aria-label="Enable network access"
3077 />
@@ -3632,13 +3630,10 @@ export function ConnectionsSettings() {
3630 </FoldedSettingsSection>
3631 ) : null}
3632 <AlertDialog
3635 - open={isDesktopServerExposureDialogOpen && canManageLocalBackend}
3633 + open={pendingDesktopServerExposureMode !== null && canManageLocalBackend}
3634 onOpenChange={(open) => {
3637 - if (isUpdatingDesktopServerExposure) return;
3638 - setIsDesktopServerExposureDialogOpen(open);
3639 - }}
3640 - onOpenChangeComplete={(open) => {
3641 - if (!open) setPendingDesktopServerExposureMode(null);
3635 + if (!open && !isUpdatingDesktopServerExposure)
3636 + setPendingDesktopServerExposureMode(null);
3637 }}
3638 >
3639 <AlertDialogPopup>
apps/web/src/components/ui/alert-dialog.tsx
+9 -1
@@ -8,8 +8,15 @@ import {
8 DIALOG_MOBILE_SHEET_CLASS,
9 DIALOG_POPUP_CLASS,
10 } from "~/components/ui/dialog-styles";
11 +import { ControlledOpenContext, renderRetainedPopup } from "~/components/ui/dialog";
12
12 -const AlertDialog = AlertDialogPrimitive.Root;
13 +function AlertDialog<Payload>(props: AlertDialogPrimitive.Root.Props<Payload>) {
14 + return (
15 + <ControlledOpenContext value={props.open}>
16 + <AlertDialogPrimitive.Root {...props} />
17 + </ControlledOpenContext>
18 + );
19 +}
20
21 const AlertDialogPortal = AlertDialogPrimitive.Portal;
22
@@ -60,6 +67,7 @@ function AlertDialogPopup({
67 className,
68 )}
69 data-slot="alert-dialog-popup"
70 + render={renderRetainedPopup}
71 {...props}
72 />
73 </AlertDialogViewport>
apps/web/src/components/ui/dialog.tsx
+31 -1
@@ -2,6 +2,7 @@
2
3 import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
4 import { XIcon } from "lucide-react";
5 +import { type ComponentProps, createContext, type ReactNode, use, useState } from "react";
6 import { cn } from "~/lib/utils";
7 import { Button } from "~/components/ui/button";
8 import {
@@ -13,7 +14,33 @@ import {
14 } from "~/components/ui/dialog-styles";
15 import { ScrollArea } from "~/components/ui/scroll-area";
16
16 -const Dialog = DialogPrimitive.Root;
17 +const ControlledOpenContext = createContext<boolean | undefined>(undefined);
18 +
19 +function RetainedWhileClosed({ open, children }: { open: boolean; children: ReactNode }) {
20 + const controlledOpen = use(ControlledOpenContext);
21 + const isOpen = open && controlledOpen !== false;
22 + const [retained, setRetained] = useState(children);
23 + if (isOpen && retained !== children) {
24 + setRetained(children);
25 + }
26 + return isOpen ? children : retained;
27 +}
28 +
29 +function renderRetainedPopup(props: ComponentProps<"div">, state: { open: boolean }) {
30 + return (
31 + <div {...props}>
32 + <RetainedWhileClosed open={state.open}>{props.children}</RetainedWhileClosed>
33 + </div>
34 + );
35 +}
36 +
37 +function Dialog<Payload>(props: DialogPrimitive.Root.Props<Payload>) {
38 + return (
39 + <ControlledOpenContext value={props.open}>
40 + <DialogPrimitive.Root {...props} />
41 + </ControlledOpenContext>
42 + );
43 +}
44
45 const DialogPortal = DialogPrimitive.Portal;
46
@@ -88,6 +115,7 @@ function DialogPopup({
115 className,
116 )}
117 data-slot="dialog-popup"
118 + render={renderRetainedPopup}
119 {...props}
120 >
121 {children}
@@ -180,6 +208,8 @@ function DialogPanel({
208 }
209
210 export {
211 + ControlledOpenContext,
212 + renderRetainedPopup,
213 Dialog,
214 DialogTrigger,
215 DialogPortal,
apps/web/src/components/ui/sheet.tsx
+9 -1
@@ -5,8 +5,15 @@ import { XIcon } from "lucide-react";
5 import type { CSSProperties } from "react";
6 import { cn } from "~/lib/utils";
7 import { Button } from "~/components/ui/button";
8 +import { ControlledOpenContext, renderRetainedPopup } from "~/components/ui/dialog";
9
9 -const Sheet = SheetPrimitive.Root;
10 +function Sheet<Payload>(props: SheetPrimitive.Root.Props<Payload>) {
11 + return (
12 + <ControlledOpenContext value={props.open}>
13 + <SheetPrimitive.Root {...props} />
14 + </ControlledOpenContext>
15 + );
16 +}
17
18 const SheetPortal = SheetPrimitive.Portal;
19
@@ -101,6 +108,7 @@ function SheetPopup({
108 className,
109 )}
110 data-slot="sheet-popup"
111 + render={keepMounted ? undefined : renderRetainedPopup}
112 style={{ ...transitionStyle, ...style }}
113 {...props}
114 >