@devries-cameron20 / t3code Mirror · read-only / commits / 91992bd5d4
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 14:30 UTC

fix(web): update dialog shows one row per machine (#26210)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Theo Browne committed Oct 27, 2026 at 19:51 UTC 91992bd5d464d6a01b2a5c1e7926e68ad09ea40e
6 files changed +229 -50
apps/web/src/components/sidebar/SidebarUpdatePill.browser.test.tsx
+3 -2
@@ -37,9 +37,10 @@ vi.mock("./useUpdateEverything", () => ({
37 useUpdateEverything: () => ({
38 hasUpdates: mocks.hasUpdates,
39 summary: "Update everything",
40 - lines: [],
40 + version: null,
41 + providerCount: 0,
42 + rows: [],
43 restarts: [],
42 - skipped: [],
44 }),
45 }));
46
apps/web/src/components/sidebar/SidebarUpdatePill.tsx
+3 -3
@@ -396,10 +396,10 @@ function SidebarUpdateControl() {
396 <UpdateEverythingDialog
397 open={isConfirmingEverything}
398 onOpenChange={setIsConfirmingEverything}
399 - summary={everything.summary}
400 - lines={everything.lines}
399 + version={everything.version}
400 + providerCount={everything.providerCount}
401 + rows={everything.rows}
402 restarts={everything.restarts}
402 - skipped={everything.skipped}
403 onConfirm={() => void runEverything()}
404 />
405 );
apps/web/src/components/sidebar/UpdateEverythingDialog.tsx
+127 -23
@@ -1,6 +1,8 @@
1 import { useAtomValue } from "@effect/atom-react";
2 import { EnvironmentId } from "@t3tools/contracts";
3 import { Atom } from "effect/reactivity";
4 +import { ChevronRightIcon } from "lucide-react";
5 +import { Fragment, type RefObject, useRef } from "react";
6
7 import { environmentThreadShells } from "~/state/threads";
8 import {
@@ -13,7 +15,10 @@ import {
15 AlertDialogTitle,
16 } from "../ui/alert-dialog";
17 import { Button } from "../ui/button";
16 -import type { RestartingMachine, SkippedMachine } from "./updateEverything.logic";
18 +import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from "../ui/collapsible";
19 +import { MiddleTruncate } from "../ui/middle-truncate";
20 +import { ScrollArea } from "../ui/scroll-area";
21 +import type { RestartingMachine, UpdateEverythingRow } from "./updateEverything.logic";
22
23 const isRunning = (status: string) =>
24 status === "preparing" || status === "starting" || status === "running";
@@ -37,35 +42,54 @@ const runningThreadCountAtom = Atom.family((environmentIds: string) =>
42 interface UpdateEverythingDialogProps {
43 readonly open: boolean;
44 readonly onOpenChange: (open: boolean) => void;
40 - readonly summary: string;
41 - readonly lines: ReadonlyArray<string>;
45 + readonly version: string | null;
46 + readonly providerCount: number;
47 + readonly rows: ReadonlyArray<UpdateEverythingRow>;
48 readonly restarts: ReadonlyArray<RestartingMachine>;
43 - readonly skipped: ReadonlyArray<SkippedMachine>;
49 readonly onConfirm: () => void;
50 }
51
52 +type UpdateEverythingDialogContentProps = Omit<
53 + UpdateEverythingDialogProps,
54 + "open" | "onOpenChange"
55 +> & {
56 + readonly cancelRef: RefObject<HTMLButtonElement | null>;
57 +};
58 +
59 export function UpdateEverythingDialog({
60 open,
61 onOpenChange,
62 ...content
63 }: UpdateEverythingDialogProps) {
64 + const cancelRef = useRef<HTMLButtonElement>(null);
65 return (
66 <AlertDialog open={open} onOpenChange={onOpenChange}>
67 {/* Refocusing the trigger after a pointer close shows its focus ring and opens its tooltip. */}
55 - <AlertDialogPopup finalFocus={(closeType) => closeType === "keyboard"}>
56 - <UpdateEverythingDialogContent {...content} />
68 + <AlertDialogPopup
69 + className="sm:max-w-xl"
70 + initialFocus={cancelRef}
71 + finalFocus={(closeType) => closeType === "keyboard"}
72 + >
73 + <UpdateEverythingDialogContent {...content} cancelRef={cancelRef} />
74 </AlertDialogPopup>
75 </AlertDialog>
76 );
77 }
78
79 +const APP_LABELS = {
80 + "this-app": "This app",
81 + server: "Server",
82 + "desktop-app": "Desktop app",
83 +} as const;
84 +
85 function UpdateEverythingDialogContent({
63 - summary,
64 - lines,
86 + version,
87 + providerCount,
88 + rows,
89 restarts,
66 - skipped,
90 onConfirm,
68 -}: Omit<UpdateEverythingDialogProps, "open" | "onOpenChange">) {
91 + cancelRef,
92 +}: UpdateEverythingDialogContentProps) {
93 const stopped = useAtomValue(
94 runningThreadCountAtom(
95 restarts
@@ -84,16 +108,96 @@ function UpdateEverythingDialogContent({
108 );
109 const running = stopped + continuing;
110 const threads = `${running} running ${running === 1 ? "thread" : "threads"}`;
111 + const restarting = new Set(restarts.map((machine) => machine.environmentId));
112 + const updating = rows.filter((row) => row.app !== null || row.providers.length > 0);
113 + const skipped = rows.filter((row) => row.skipped !== null);
114
115 return (
116 <>
90 - <AlertDialogHeader>
91 - <AlertDialogTitle>{summary}?</AlertDialogTitle>
92 - <AlertDialogDescription className="whitespace-pre-line">
93 - {lines.join("\n")}
117 + <AlertDialogHeader className="shrink-0">
118 + <AlertDialogTitle>
119 + Update {updating.length} {updating.length === 1 ? "machine" : "machines"}?
120 + </AlertDialogTitle>
121 + <AlertDialogDescription>
122 + {version !== null ? (
123 + <>
124 + T3 Code <span className="font-mono text-xs">{version}</span>
125 + </>
126 + ) : null}
127 + {version !== null && providerCount > 0 ? " · " : null}
128 + {providerCount > 0
129 + ? `${providerCount} provider ${providerCount === 1 ? "update" : "updates"}`
130 + : null}
131 </AlertDialogDescription>
132 + </AlertDialogHeader>
133 + <ScrollArea scrollFade>
134 + <div className="flex flex-col gap-3 px-6 pb-4">
135 + {/* Machine names truncate first. Provider lists wrap between names, never inside one. */}
136 + <div className="grid grid-cols-[minmax(4rem,max-content)_max-content_minmax(min-content,1fr)_max-content] gap-x-4 text-sm">
137 + <div className="col-span-full grid grid-cols-subgrid border-b pb-1.5 text-muted-foreground text-xs">
138 + <span>Machine</span>
139 + <span>T3 Code</span>
140 + <span>Providers</span>
141 + <span />
142 + </div>
143 + {updating.map((row) => (
144 + <div
145 + key={row.environmentId ?? "this-app"}
146 + className="col-span-full grid grid-cols-subgrid border-b border-border/50 py-1.5 last:border-b-0"
147 + >
148 + <span className="max-w-32 min-w-0">
149 + <MiddleTruncate value={row.label} />
150 + </span>
151 + <span>
152 + {row.app !== null ? APP_LABELS[row.app] : null}
153 + {row.app === null && row.skipped !== null ? (
154 + <span className="text-muted-foreground">Skipped</span>
155 + ) : null}
156 + {row.app === "this-app" ? (
157 + <span className="block text-muted-foreground text-xs">restarts last</span>
158 + ) : null}
159 + </span>
160 + <span>
161 + {row.providers.map((provider, index) => (
162 + <Fragment key={provider}>
163 + <span className="whitespace-nowrap">{provider}</span>
164 + {index < row.providers.length - 1 ? ", " : null}
165 + </Fragment>
166 + ))}
167 + </span>
168 + <span className="text-right">
169 + {row.environmentId !== null && restarting.has(row.environmentId) ? (
170 + <RunningThreads environmentId={row.environmentId} />
171 + ) : null}
172 + </span>
173 + </div>
174 + ))}
175 + </div>
176 + {skipped.length > 0 ? (
177 + <Collapsible>
178 + <CollapsibleTrigger className="flex items-center gap-1 text-muted-foreground text-xs hover:text-foreground data-panel-open:[&_svg]:rotate-90">
179 + <ChevronRightIcon className="size-3.5 transition-transform" aria-hidden />
180 + {skipped.length} skipped
181 + </CollapsibleTrigger>
182 + <CollapsiblePanel>
183 + <div className="grid grid-cols-[minmax(0,max-content)_1fr] gap-x-3 gap-y-0.5 pt-1.5 ps-4.5 text-muted-foreground text-xs">
184 + {skipped.map((row) => (
185 + <Fragment key={row.environmentId ?? "this-app"}>
186 + <span className="max-w-32 min-w-0">
187 + <MiddleTruncate value={row.label} />
188 + </span>
189 + <span className="wrap-anywhere">{row.skipped}</span>
190 + </Fragment>
191 + ))}
192 + </div>
193 + </CollapsiblePanel>
194 + </Collapsible>
195 + ) : null}
196 + </div>
197 + </ScrollArea>
198 + <AlertDialogFooter>
199 {running > 0 ? (
96 - <p className="pt-2 text-sm">
200 + <p className="self-center text-muted-foreground text-sm max-sm:order-1 max-sm:text-center sm:mr-auto">
201 {stopped === 0
202 ? `${threads} will be interrupted and can resume after the restart.`
203 : continuing === 0
@@ -101,16 +205,16 @@ function UpdateEverythingDialogContent({
205 : `${threads} will be interrupted. ${continuing} can resume after the restart.`}
206 </p>
207 ) : null}
104 - {skipped.length > 0 ? (
105 - <p className="whitespace-pre-line pt-2 text-sm">
106 - {skipped.map((machine) => `Skips ${machine.label}: ${machine.reason}`).join("\n")}
107 - </p>
108 - ) : null}
109 - </AlertDialogHeader>
110 - <AlertDialogFooter>
111 - <AlertDialogClose render={<Button variant="outline" />}>Cancel</AlertDialogClose>
208 + <AlertDialogClose ref={cancelRef} render={<Button variant="outline" />}>
209 + Cancel
210 + </AlertDialogClose>
211 <Button onClick={onConfirm}>Update</Button>
212 </AlertDialogFooter>
213 </>
214 );
215 }
216 +
217 +function RunningThreads({ environmentId }: { readonly environmentId: EnvironmentId }) {
218 + const count = useAtomValue(runningThreadCountAtom(environmentId));
219 + return count > 0 ? <span className="whitespace-nowrap text-warning">{count} running</span> : null;
220 +}
apps/web/src/components/sidebar/updateEverything.logic.test.ts
+41
@@ -4,6 +4,7 @@ import { describe, expect, it } from "vite-plus/test";
4 import {
5 collectRestartingMachines,
6 collectServerUpdateTargets,
7 + describeUpdateEverything,
8 runUpdateEverything,
9 type UpdateEverythingMachine,
10 } from "./updateEverything.logic";
@@ -136,3 +137,43 @@ describe("runUpdateEverything", () => {
137 expect(result.localReady).toBe(false);
138 });
139 });
140 +
141 +describe("describeUpdateEverything", () => {
142 + it("gives each machine one row with its T3 Code and provider updates", () => {
143 + const id = EnvironmentId.make;
144 + const { rows } = describeUpdateEverything({
145 + localVersion: "1.1.0",
146 + localMachines: [
147 + { environmentId: id("local"), label: "Mainbook" },
148 + { environmentId: id("wsl"), label: "Mainbook WSL" },
149 + ],
150 + servers: [
151 + {
152 + environmentId: id("npm"),
153 + serverLabel: "bb-1",
154 + selfUpdate: "respawn",
155 + targetVersion: "1.1.0",
156 + },
157 + ],
158 + providerMachines: [
159 + { environmentId: id("npm"), label: "bb-1", providers: ["Codex", "Claude"] },
160 + { environmentId: id("local"), label: "Mainbook", providers: ["Codex"] },
161 + { environmentId: id("manual"), label: "alvin", providers: ["Claude"] },
162 + ],
163 + skipped: [
164 + { environmentId: id("manual"), label: "alvin", reason: "needs a manual update" },
165 + { environmentId: id("offline"), label: "TheoRoom", reason: "not connected" },
166 + ],
167 + });
168 +
169 + expect(
170 + rows.map(({ label, app, skipped, providers }) => [label, app, skipped, providers]),
171 + ).toEqual([
172 + ["Mainbook", "this-app", null, ["Codex"]],
173 + ["Mainbook WSL", "this-app", null, []],
174 + ["bb-1", "server", null, ["Codex", "Claude"]],
175 + ["alvin", null, "needs a manual update", ["Claude"]],
176 + ["TheoRoom", null, "not connected", []],
177 + ]);
178 + });
179 +});
apps/web/src/components/sidebar/updateEverything.logic.ts
+51 -18
@@ -351,6 +351,11 @@ export function getUpdateEverythingToastView(
351
352 export interface UpdateEverythingPlan {
353 readonly localVersion: string | null;
354 + /** Machines whose servers this app hosts; this app's update restarts them. */
355 + readonly localMachines: ReadonlyArray<{
356 + readonly environmentId: EnvironmentId;
357 + readonly label: string;
358 + }>;
359 readonly servers: ReadonlyArray<
360 Pick<ServerUpdateTarget, "environmentId" | "serverLabel" | "selfUpdate" | "targetVersion">
361 >;
@@ -359,6 +364,15 @@ export interface UpdateEverythingPlan {
364 readonly label: string;
365 readonly providers: ReadonlyArray<string>;
366 }>;
367 + readonly skipped: ReadonlyArray<SkippedMachine>;
368 +}
369 +
370 +export interface UpdateEverythingRow {
371 + readonly environmentId: EnvironmentId | null;
372 + readonly label: string;
373 + readonly app: "this-app" | "server" | "desktop-app" | null;
374 + readonly skipped: string | null;
375 + readonly providers: ReadonlyArray<string>;
376 }
377
378 function countLabel(count: number, noun: string): string | null {
@@ -370,9 +384,12 @@ function joinList(parts: ReadonlyArray<string>): string {
384 return `${parts.slice(0, -1).join(", ")}, and ${parts.at(-1)}`;
385 }
386
387 +/** One row per machine: this app's machines first, then servers, provider-only, and skipped. */
388 export function describeUpdateEverything(plan: UpdateEverythingPlan): {
389 readonly summary: string;
375 - readonly lines: ReadonlyArray<string>;
390 + readonly version: string | null;
391 + readonly providerCount: number;
392 + readonly rows: ReadonlyArray<UpdateEverythingRow>;
393 } {
394 const providerCount = plan.providerMachines.reduce(
395 (count, machine) => count + machine.providers.length,
@@ -386,30 +403,46 @@ export function describeUpdateEverything(plan: UpdateEverythingPlan): {
403 ].filter((part) => part !== null),
404 )}`;
405
389 - const machines = new Map<EnvironmentId, { label: string; items: string[] }>();
390 - const itemsFor = (environmentId: EnvironmentId, label: string) => {
391 - const existing = machines.get(environmentId);
392 - if (existing) return existing.items;
393 - const items: string[] = [];
394 - machines.set(environmentId, { label, items });
395 - return items;
406 + const rows = new Map<EnvironmentId | null, UpdateEverythingRow>();
407 + const update = (
408 + environmentId: EnvironmentId | null,
409 + label: string,
410 + change: Partial<UpdateEverythingRow>,
411 + ) => {
412 + const row = rows.get(environmentId) ?? {
413 + environmentId,
414 + label,
415 + app: null,
416 + skipped: null,
417 + providers: [],
418 + };
419 + rows.set(environmentId, { ...row, ...change });
420 };
421 + if (plan.localVersion) {
422 + if (plan.localMachines.length === 0) update(null, "This app", { app: "this-app" });
423 + for (const machine of plan.localMachines) {
424 + update(machine.environmentId, machine.label, { app: "this-app" });
425 + }
426 + }
427 for (const server of plan.servers) {
398 - itemsFor(server.environmentId, server.serverLabel).push(
399 - server.selfUpdate === "desktop-managed"
400 - ? "desktop app update"
401 - : `server to ${server.targetVersion}`,
402 - );
428 + update(server.environmentId, server.serverLabel, {
429 + app: server.selfUpdate === "desktop-managed" ? "desktop-app" : "server",
430 + });
431 }
432 for (const machine of plan.providerMachines) {
405 - itemsFor(machine.environmentId, machine.label).push(...machine.providers);
433 + update(machine.environmentId, machine.label, { providers: machine.providers });
434 + }
435 + for (const machine of plan.skipped) {
436 + update(machine.environmentId, machine.label, { skipped: machine.reason });
437 }
438
439 return {
440 summary,
410 - lines: [
411 - ...(plan.localVersion ? [`This app: ${plan.localVersion}, restarts last`] : []),
412 - ...Array.from(machines.values(), ({ label, items }) => `${label}: ${items.join(", ")}`),
413 - ],
441 + version:
442 + plan.localVersion ??
443 + plan.servers.find((server) => server.selfUpdate !== "desktop-managed")?.targetVersion ??
444 + null,
445 + providerCount,
446 + rows: Array.from(rows.values()),
447 };
448 }
apps/web/src/components/sidebar/useUpdateEverything.ts
+4 -4
@@ -78,9 +78,11 @@ export function useUpdateEverything(localUpdateVersion: string | null) {
78 const providers = useProviderUpdates();
79 const updateServer = useServerUpdate();
80
81 - const { summary, lines } = describeUpdateEverything({
81 + const view = describeUpdateEverything({
82 localVersion: localUpdateVersion,
83 + localMachines: machines.filter((machine) => machine.hostedByThisApp),
84 servers,
85 + skipped,
86 providerMachines: providers.machines.map((machine) => ({
87 environmentId: machine.environmentId,
88 label: machine.label,
@@ -92,10 +94,8 @@ export function useUpdateEverything(localUpdateVersion: string | null) {
94
95 return {
96 hasUpdates: servers.length > 0 || providers.machines.length > 0,
95 - summary,
96 - lines,
97 + ...view,
98 restarts,
98 - skipped,
99 run: async ({
100 downloadLocal,
101 installLocal,