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 23, 00:30 UTC
fix(web): show idle server updates on environment controls (#21950)
Julius Marminge committed
Oct 19, 2026 at 16:16 UTC
89f0946efbc79cf6d4cb3259fb5042956b75dd27
10 files changed
+441
-145
apps/web/src/components/BranchToolbar.logic.test.ts
+31
@@ -439,6 +439,37 @@ describe("shouldShowEnvironmentIndicator", () => {
439
});
440
441
describe("shouldShowComposerContextStrip", () => {
442
+ it("keeps a sole primary server update reachable in a non-Git draft", () => {
443
+ const environment = {
444
+ activeEnvironment: { isPrimary: true },
445
+ canPickEnvironment: false,
446
+ serverUpdateAvailable: true,
447
+ };
448
+ const showEnvironmentIndicator = shouldShowEnvironmentIndicator(environment);
449
+ expect(showEnvironmentIndicator).toBe(true);
450
+ expect(
451
+ shouldShowComposerContextStrip({
452
+ isDraftHeroState: true,
453
+ persistInActiveThreads: false,
454
+ hasActiveProject: true,
455
+ isGitRepo: false,
456
+ showEnvironmentIndicator,
457
+ hostsRestingComposerControls: false,
458
+ }),
459
+ ).toBe(true);
460
+ expect(
461
+ shouldShowComposerContextStrip({
462
+ isDraftHeroState: false,
463
+ persistInActiveThreads: false,
464
+ hasActiveProject: true,
465
+ isGitRepo: false,
466
+ showEnvironmentIndicator,
467
+ serverUpdateAvailable: true,
468
+ hostsRestingComposerControls: false,
469
+ }),
470
+ ).toBe(true);
471
+ });
472
+
473
it.each([false, true])(
474
"honors the active-thread preference with resting controls %s",
475
(hostsRestingComposerControls) => {
apps/web/src/components/BranchToolbar.logic.ts
+6
-2
@@ -55,8 +55,9 @@ export function resolveEnvironmentOptionLabel(input: {
55
export function shouldShowEnvironmentIndicator(input: {
56
activeEnvironment: Pick<EnvironmentOption, "isPrimary"> | null;
57
canPickEnvironment: boolean;
58
+ serverUpdateAvailable?: boolean;
59
}): boolean {
59
- if (input.canPickEnvironment) return true;
60
+ if (input.canPickEnvironment || input.serverUpdateAvailable) return true;
61
return input.activeEnvironment !== null && !input.activeEnvironment.isPrimary;
62
}
63
@@ -67,10 +68,13 @@ export function shouldShowComposerContextStrip(input: {
68
isGitRepo: boolean;
69
showEnvironmentIndicator: boolean;
70
hostsRestingComposerControls: boolean;
71
+ serverUpdateAvailable?: boolean;
72
}): boolean {
73
return (
74
input.hasActiveProject &&
73
- (input.isDraftHeroState || input.persistInActiveThreads) &&
75
+ (input.isDraftHeroState ||
76
+ input.persistInActiveThreads ||
77
+ input.serverUpdateAvailable === true) &&
78
(input.isGitRepo || input.showEnvironmentIndicator || input.hostsRestingComposerControls)
79
);
80
}
apps/web/src/components/BranchToolbar.panel.browser.test.tsx
+73
-13
@@ -19,6 +19,10 @@ vi.mock(import("../localApi"), async (original) => ({
19
vi.mock(import("../hooks/useCopyToClipboard"), async (original) => ({
20
...(await original()),
21
writeTextToClipboard: state.writeTextToClipboard,
22
+ useCopyToClipboard: ((options: { target: string }) => ({
23
+ copyToClipboard: (command: string) => state.writeTextToClipboard(command, options.target),
24
+ isCopied: false,
25
+ })) as never,
26
}));
27
vi.mock(import("./BranchToolbarBranchSelector"), async (original) => ({
28
...(await original()),
@@ -36,6 +40,8 @@ vi.mock(import("../state/entities"), async (original) => ({
40
}));
41
42
import { BranchToolbar } from "./BranchToolbar";
43
+import { ComposerSurface } from "./chat/ComposerSurface";
44
+import type { ServerUpdateTarget } from "./ServerUpdateAction";
45
46
let root: Root;
47
let container: HTMLDivElement;
@@ -59,19 +65,21 @@ afterEach(async () => {
65
function render(props: Partial<ComponentProps<typeof BranchToolbar>>) {
66
return act(async () =>
67
root.render(
62
- <BranchToolbar
63
- layout="panel"
64
- panelSection="workspace"
65
- environmentId={EnvironmentId.make("local")}
66
- threadId={ThreadId.make("thread")}
67
- showGitControls
68
- envMode="local"
69
- envLocked={false}
70
- startFromOrigin={false}
71
- onStartFromOriginChange={vi.fn()}
72
- onEnvModeChange={vi.fn()}
73
- {...props}
74
- />,
68
+ <ComposerSurface.Shell>
69
+ <BranchToolbar
70
+ layout="panel"
71
+ panelSection="workspace"
72
+ environmentId={EnvironmentId.make("local")}
73
+ threadId={ThreadId.make("thread")}
74
+ showGitControls
75
+ envMode="local"
76
+ envLocked={false}
77
+ startFromOrigin={false}
78
+ onStartFromOriginChange={vi.fn()}
79
+ onEnvModeChange={vi.fn()}
80
+ {...props}
81
+ />
82
+ </ComposerSurface.Shell>,
83
),
84
);
85
}
@@ -146,3 +154,55 @@ it.each([
154
}
155
},
156
);
157
+
158
+it.each([
159
+ { layout: "wide Git", width: 900, showGitControls: true },
160
+ { layout: "narrow Git", width: 360, showGitControls: true },
161
+ { layout: "sole primary non-Git", width: 360, showGitControls: false },
162
+])(
163
+ "copies the pending update from the $layout composer chip",
164
+ async ({ width, showGitControls }) => {
165
+ await page.viewport(1000, 700);
166
+ container.style.width = `${width}px`;
167
+ container.style.setProperty("--chat-content-max-width", `${width}px`);
168
+ const serverUpdate = {
169
+ environmentId: EnvironmentId.make("local"),
170
+ serverLabel: "Build box",
171
+ serverVersion: "0.0.30",
172
+ targetVersion: "0.0.31",
173
+ selfUpdate: null,
174
+ installation: { kind: "npm-global", prefix: "/opt/node" },
175
+ } satisfies ServerUpdateTarget & { serverVersion: string };
176
+ await render({
177
+ layout: "composer",
178
+ envLocked: showGitControls,
179
+ showGitControls,
180
+ availableEnvironments: [
181
+ {
182
+ environmentId: serverUpdate.environmentId,
183
+ projectId: ProjectId.make("project"),
184
+ label: serverUpdate.serverLabel,
185
+ isPrimary: true,
186
+ machine: "server",
187
+ },
188
+ ],
189
+ serverUpdate,
190
+ });
191
+
192
+ expect(
193
+ container.querySelector('[data-slot="composer-shell"]')!.getBoundingClientRect().width,
194
+ ).toBe(width);
195
+ const chip = page.getByRole("button", { name: /Build box|Copy update command/ });
196
+ await expect.element(chip).toBeVisible();
197
+ await userEvent.hover(chip);
198
+ await expect.element(page.getByRole("tooltip")).toMatchTextContent("0.0.30");
199
+ await expect.element(page.getByRole("tooltip")).toMatchTextContent("0.0.31");
200
+ await userEvent.click(chip);
201
+ await vi.waitFor(() =>
202
+ expect(state.writeTextToClipboard).toHaveBeenCalledWith(
203
+ "npm install --global --prefix '/opt/node' t3@0.0.31",
204
+ "update command",
205
+ ),
206
+ );
207
+ },
208
+);
apps/web/src/components/BranchToolbar.tsx
+28
-11
@@ -42,6 +42,7 @@ import {
42
type BranchToolbarBranchSelectorHandle,
43
} from "./BranchToolbarBranchSelector";
44
import { BranchToolbarEnvironmentSelector } from "./BranchToolbarEnvironmentSelector";
45
+import type { PendingServerUpdate } from "./ServerUpdateAction";
46
import { BranchToolbarEnvModeSelector } from "./BranchToolbarEnvModeSelector";
47
import { PreviousWorktreeItemContent } from "./PreviousWorktreeItemContent";
48
import { ThreadDetailsControl } from "./chat/ThreadDetailsControl";
@@ -99,6 +100,7 @@ interface BranchToolbarProps {
100
onEnvironmentChange?: (environmentId: EnvironmentId) => void;
101
composerControlsHostRef?: (element: HTMLDivElement | null) => void;
102
contextStripVisible?: boolean;
103
+ serverUpdate?: PendingServerUpdate | null;
104
}
105
106
function showWorkspaceContextMenu(event: ReactMouseEvent, workspacePath: string) {
@@ -586,6 +588,7 @@ export const BranchToolbar = memo(function BranchToolbar({
588
onEnvironmentChange,
589
composerControlsHostRef,
590
contextStripVisible = true,
591
+ serverUpdate = null,
592
}: BranchToolbarProps) {
593
const branchSelectorRef = useRef<BranchToolbarBranchSelectorHandle>(null);
594
const threadRef = scopeThreadRef(environmentId, threadId);
@@ -659,6 +662,7 @@ export const BranchToolbar = memo(function BranchToolbar({
662
const showEnvironmentIndicator = shouldShowEnvironmentIndicator({
663
activeEnvironment: activeEnvironmentOption,
664
canPickEnvironment: hasMultipleEnvironments,
665
+ serverUpdateAvailable: serverUpdate !== null,
666
});
667
const [stripElement, setStripElement] = useState<HTMLDivElement | null>(null);
668
const labelsOverflow = useLabelsOverflow(stripElement);
@@ -723,6 +727,17 @@ export const BranchToolbar = memo(function BranchToolbar({
727
!contextStripVisible && "pointer-events-none invisible absolute inset-x-0 top-full",
728
)}
729
>
730
+ {serverUpdate && availableEnvironments ? (
731
+ <BranchToolbarEnvironmentSelector
732
+ autoEnvironmentLabel={autoEnvironmentLabel}
733
+ onAutoEnvironment={onAutoEnvironment}
734
+ envLocked={envLocked}
735
+ environmentId={environmentId}
736
+ availableEnvironments={availableEnvironments}
737
+ {...(showEnvironmentPicker ? { onEnvironmentChange } : {})}
738
+ serverUpdate={serverUpdate}
739
+ />
740
+ ) : null}
741
{showGitControls ? (
742
<div className="contents @3xl/composer-surface:hidden">
743
<RunContextSelector
@@ -733,8 +748,8 @@ export const BranchToolbar = memo(function BranchToolbar({
748
envModeLocked={envModeLocked}
749
environmentId={environmentId}
750
availableEnvironments={availableEnvironments}
736
- showEnvironmentPicker={showEnvironmentPicker}
737
- showEnvironmentIndicator={showEnvironmentIndicator}
751
+ showEnvironmentPicker={showEnvironmentPicker && serverUpdate === null}
752
+ showEnvironmentIndicator={showEnvironmentIndicator && serverUpdate === null}
753
onEnvironmentChange={onEnvironmentChange}
754
effectiveEnvMode={effectiveEnvMode}
755
activeWorktreePath={activeWorktreePath}
@@ -745,7 +760,7 @@ export const BranchToolbar = memo(function BranchToolbar({
760
/>
761
</div>
762
) : null}
748
- {showGitControls || showEnvironmentIndicator ? (
763
+ {showGitControls || (showEnvironmentIndicator && serverUpdate === null) ? (
764
<div
765
className={cn(
766
"min-h-7 min-w-10 items-center gap-1 sm:min-h-6",
@@ -755,14 +770,16 @@ export const BranchToolbar = memo(function BranchToolbar({
770
>
771
{showEnvironmentIndicator && availableEnvironments && (
772
<>
758
- <BranchToolbarEnvironmentSelector
759
- autoEnvironmentLabel={autoEnvironmentLabel}
760
- onAutoEnvironment={onAutoEnvironment}
761
- envLocked={envLocked}
762
- environmentId={environmentId}
763
- availableEnvironments={availableEnvironments}
764
- {...(showEnvironmentPicker ? { onEnvironmentChange } : {})}
765
- />
773
+ {serverUpdate === null ? (
774
+ <BranchToolbarEnvironmentSelector
775
+ autoEnvironmentLabel={autoEnvironmentLabel}
776
+ onAutoEnvironment={onAutoEnvironment}
777
+ envLocked={envLocked}
778
+ environmentId={environmentId}
779
+ availableEnvironments={availableEnvironments}
780
+ {...(showEnvironmentPicker ? { onEnvironmentChange } : {})}
781
+ />
782
+ ) : null}
783
{showGitControls ? (
784
<Separator
785
orientation="vertical"
apps/web/src/components/BranchToolbarEnvironmentSelector.tsx
+119
-28
@@ -1,14 +1,19 @@
1
-import { ComposerSelectControl } from "./chat/ComposerControl";
1
+import { ComposerControl, ComposerSelectControl } from "./chat/ComposerControl";
2
import { ComposerContextLabel } from "./ComposerContextLabel";
3
import { Tooltip, TooltipTrigger, TooltipPopup } from "./ui/tooltip";
4
import { useAtomValue } from "@effect/atom-react";
5
import { shortcutLabelForCommand } from "../keybindings";
6
import { primaryServerKeybindingsAtom } from "../state/server";
7
import type { EnvironmentId } from "@t3tools/contracts";
8
-import { ScaleIcon } from "lucide-react";
8
+import { CircleArrowUpIcon, ScaleIcon } from "lucide-react";
9
import { memo } from "react";
10
11
import type { EnvironmentOption } from "./BranchToolbar.logic";
12
+import {
13
+ ServerUpdateAction,
14
+ type PendingServerUpdate,
15
+ type ServerUpdateControl,
16
+} from "./ServerUpdateAction";
17
import { EnvironmentMachineIcon } from "./EnvironmentMachineIcon";
18
import { useComposerMenuProps } from "./chat/composerEventScope";
19
import {
@@ -27,16 +32,39 @@ interface BranchToolbarEnvironmentSelectorProps {
32
environmentId: EnvironmentId;
33
availableEnvironments: readonly EnvironmentOption[];
34
onEnvironmentChange?: (environmentId: EnvironmentId) => void;
35
+ serverUpdate?: PendingServerUpdate | null;
36
}
37
32
-export const BranchToolbarEnvironmentSelector = memo(function BranchToolbarEnvironmentSelector({
38
+// Action values cannot collide with server-minted environment IDs.
39
+const AUTO_VALUE = "action:auto";
40
+const UPDATE_VALUE = "action:update";
41
+const environmentValue = (id: EnvironmentId) => `env:${id}`;
42
+
43
+export const BranchToolbarEnvironmentSelector = memo(function BranchToolbarEnvironmentSelector(
44
+ props: BranchToolbarEnvironmentSelectorProps,
45
+) {
46
+ return props.serverUpdate ? (
47
+ <ServerUpdateAction
48
+ {...props.serverUpdate}
49
+ render={(updateControl) => <EnvironmentSelector {...props} updateControl={updateControl} />}
50
+ />
51
+ ) : (
52
+ <EnvironmentSelector {...props} updateControl={null} />
53
+ );
54
+});
55
+
56
+function EnvironmentSelector({
57
autoEnvironmentLabel,
58
onAutoEnvironment,
59
envLocked,
60
environmentId,
61
availableEnvironments,
62
onEnvironmentChange,
39
-}: BranchToolbarEnvironmentSelectorProps) {
63
+ serverUpdate,
64
+ updateControl,
65
+}: BranchToolbarEnvironmentSelectorProps & {
66
+ updateControl: ServerUpdateControl | null;
67
+}) {
68
const composerFloatingLayerProps = useComposerMenuProps();
69
const shortcutLabel = shortcutLabelForCommand(
70
useAtomValue(primaryServerKeybindingsAtom),
@@ -47,13 +75,39 @@ export const BranchToolbarEnvironmentSelector = memo(function BranchToolbarEnvir
75
76
const environmentItems = [
77
...(onAutoEnvironment
50
- ? [{ value: "auto", label: autoEnvironmentLabel ?? "Auto balance" }]
78
+ ? [{ value: AUTO_VALUE, label: autoEnvironmentLabel ?? "Auto balance" }]
79
: []),
80
...availableEnvironments.map((env) => ({
53
- value: env.environmentId,
81
+ value: environmentValue(env.environmentId),
82
label: env.label,
83
})),
84
+ ...(serverUpdate && updateControl
85
+ ? [{ value: UPDATE_VALUE, label: `${updateControl.label} ${serverUpdate.serverLabel}` }]
86
+ : []),
87
];
88
+ const updateTooltip = serverUpdate
89
+ ? `${serverUpdate.serverLabel} ${serverUpdate.serverVersion} → ${serverUpdate.targetVersion}. ${
90
+ serverUpdate.selfUpdate === "desktop-managed" && !serverUpdate.desktopAppUpdate
91
+ ? "Update the desktop app on that machine."
92
+ : (updateControl?.label ?? "Update")
93
+ }`
94
+ : null;
95
+ const environmentIcon = serverUpdate ? (
96
+ <CircleArrowUpIcon aria-hidden="true" className="size-3 shrink-0" />
97
+ ) : (
98
+ <EnvironmentMachineIcon
99
+ kind={activeEnvironment?.machine ?? "server"}
100
+ className="size-3 shrink-0"
101
+ />
102
+ );
103
+ const chipBody = (
104
+ <>
105
+ {environmentIcon}
106
+ <ComposerContextLabel>
107
+ {activeEnvironment?.label ?? serverUpdate?.serverLabel ?? "Run on"}
108
+ </ComposerContextLabel>
109
+ </>
110
+ );
111
112
// The static label carries the xs control's height (h-7 sm:h-6) as well as
113
// its padding: the composer context strip has no min-height of its own, and
@@ -61,22 +115,41 @@ export const BranchToolbarEnvironmentSelector = memo(function BranchToolbarEnvir
115
// a shorter label would drag the seam out of line whenever this label is the
116
// only thing in the strip.
117
if (envLocked || onEnvironmentChange === undefined) {
64
- const lockedRow = (
118
+ const lockedRow = updateControl ? (
119
+ <ComposerControl
120
+ size="xs"
121
+ className="min-w-0 max-w-full"
122
+ aria-label={`${updateControl.label} ${serverUpdate?.serverLabel}`}
123
+ disabled={updateControl.disabled}
124
+ onClick={updateControl.onClick}
125
+ data-composer-context-control
126
+ >
127
+ {chipBody}
128
+ </ComposerControl>
129
+ ) : (
130
<span
131
className="inline-flex h-7 min-w-0 max-w-full items-center gap-1 border border-transparent px-1.75 font-normal text-muted-foreground/70 text-xs sm:h-6"
132
data-composer-context-control
133
>
69
- <EnvironmentMachineIcon
70
- kind={activeEnvironment?.machine ?? "server"}
71
- className="size-3 shrink-0"
72
- />
73
- <ComposerContextLabel>{activeEnvironment?.label ?? "Run on"}</ComposerContextLabel>
134
+ {chipBody}
135
</span>
136
);
137
return (
138
<Tooltip>
78
- <TooltipTrigger render={lockedRow} />
79
- <TooltipPopup>{activeEnvironment?.label ?? "Run on"}</TooltipPopup>
139
+ <TooltipTrigger
140
+ render={
141
+ updateControl?.disabled ? (
142
+ <span className="inline-flex min-w-0 max-w-full" data-composer-context-control>
143
+ {lockedRow}
144
+ </span>
145
+ ) : (
146
+ lockedRow
147
+ )
148
+ }
149
+ />
150
+ <TooltipPopup role={serverUpdate ? "tooltip" : undefined}>
151
+ {updateTooltip ?? activeEnvironment?.label ?? "Run on"}
152
+ </TooltipPopup>
153
</Tooltip>
154
);
155
}
@@ -84,10 +157,16 @@ export const BranchToolbarEnvironmentSelector = memo(function BranchToolbarEnvir
157
return (
158
<Select
159
modal={false}
87
- value={autoEnvironmentLabel ? "auto" : environmentId}
88
- onValueChange={(value) =>
89
- value === "auto" ? onAutoEnvironment?.() : onEnvironmentChange(value as EnvironmentId)
90
- }
160
+ value={autoEnvironmentLabel ? AUTO_VALUE : environmentValue(environmentId)}
161
+ onValueChange={(value) => {
162
+ if (value === UPDATE_VALUE) {
163
+ updateControl?.onClick();
164
+ } else if (value === AUTO_VALUE) {
165
+ onAutoEnvironment?.();
166
+ } else if (value?.startsWith("env:")) {
167
+ onEnvironmentChange(value.slice(4) as EnvironmentId);
168
+ }
169
+ }}
170
items={environmentItems}
171
>
172
<Tooltip>
@@ -105,17 +184,14 @@ export const BranchToolbarEnvironmentSelector = memo(function BranchToolbarEnvir
184
{autoEnvironmentLabel ? (
185
<ScaleIcon className="size-3 shrink-0" aria-hidden="true" />
186
) : (
108
- <EnvironmentMachineIcon
109
- kind={activeEnvironment?.machine ?? "server"}
110
- className="size-3 shrink-0"
111
- />
187
+ environmentIcon
188
)}
189
<ComposerContextLabel>
190
<SelectValue />
191
</ComposerContextLabel>
192
</TooltipTrigger>
117
- <TooltipPopup>
118
- {autoEnvironmentLabel ?? activeEnvironment?.label ?? "Run on"}
193
+ <TooltipPopup role={serverUpdate ? "tooltip" : undefined}>
194
+ {updateTooltip ?? autoEnvironmentLabel ?? activeEnvironment?.label ?? "Run on"}
195
{shortcutLabel ? ` · ${shortcutLabel}` : null}
196
</TooltipPopup>
197
</Tooltip>
@@ -124,7 +200,7 @@ export const BranchToolbarEnvironmentSelector = memo(function BranchToolbarEnvir
200
<SelectGroupLabel>Run on</SelectGroupLabel>
201
{onAutoEnvironment && (
202
<SelectItem
127
- value="auto"
203
+ value={AUTO_VALUE}
204
onClick={() => {
205
if (autoEnvironmentLabel) onAutoEnvironment?.();
206
}}
@@ -136,15 +212,30 @@ export const BranchToolbarEnvironmentSelector = memo(function BranchToolbarEnvir
212
</SelectItem>
213
)}
214
{availableEnvironments.map((env) => (
139
- <SelectItem key={env.environmentId} value={env.environmentId}>
215
+ <SelectItem key={env.environmentId} value={environmentValue(env.environmentId)}>
216
<span className="inline-flex items-center gap-1.5">
141
- <EnvironmentMachineIcon kind={env.machine} className="size-3" />
217
+ {serverUpdate?.environmentId === env.environmentId ? (
218
+ <CircleArrowUpIcon aria-hidden="true" className="size-3" />
219
+ ) : (
220
+ <EnvironmentMachineIcon kind={env.machine} className="size-3" />
221
+ )}
222
{env.label}
223
</span>
224
</SelectItem>
225
))}
226
</SelectGroup>
227
+ {serverUpdate && updateControl ? (
228
+ <SelectGroup>
229
+ <SelectGroupLabel>Server update</SelectGroupLabel>
230
+ <SelectItem value={UPDATE_VALUE} disabled={updateControl.disabled}>
231
+ <span className="inline-flex items-center gap-1.5">
232
+ <CircleArrowUpIcon aria-hidden="true" className="size-3" />
233
+ {updateControl.label} {serverUpdate.serverLabel}
234
+ </span>
235
+ </SelectItem>
236
+ </SelectGroup>
237
+ ) : null}
238
</SelectPopup>
239
</Select>
240
);
150
-});
241
+}
apps/web/src/components/ChatView.tsx
+41
-66
@@ -548,14 +548,10 @@ import {
548
ComposerServerUpdateStatus,
549
} from "./chat/ComposerServerUpdateStatus";
550
import {
551
- buildVersionMismatchDismissalKey,
551
dismissServerUpdateFailure,
553
- dismissVersionMismatch,
552
isServerUpdateFailureDismissed,
555
- isVersionMismatchDismissed,
553
resolveServerConfigVersionMismatch,
554
resolveServerSelfUpdateCapability,
558
- serverUpdateGuidance,
555
supportsDesktopAppUpdate,
556
supportsServerUpdateThreadContinuation,
557
} from "../versionSkew";
@@ -2066,10 +2062,6 @@ export default function ChatView(props: ChatViewProps) {
2062
logicalProjectEnvironments.find(
2063
(environment) => environment.environmentId === activeThread?.environmentId,
2064
) ?? null;
2069
- const showComposerEnvironmentIndicator = shouldShowEnvironmentIndicator({
2070
- activeEnvironment: activeEnvironmentOption,
2071
- canPickEnvironment: hasMultipleEnvironments,
2072
- });
2065
const openPullRequestDialog = (reference?: string) => {
2066
if (!canCheckoutPullRequestIntoThread) {
2067
return;
@@ -2220,18 +2212,6 @@ export default function ChatView(props: ChatViewProps) {
2212
: EMPTY_AUTO_UPDATE_ENVIRONMENTS;
2213
const autoBalanceUpdateBanner = useAutoBalanceUpdateBanner(autoUpdateEnvironments);
2214
const versionMismatch = resolveServerConfigVersionMismatch(serverConfig);
2223
- const versionMismatchDismissKey =
2224
- versionMismatch && activeThread
2225
- ? buildVersionMismatchDismissalKey(activeThread.environmentId, versionMismatch)
2226
- : null;
2227
- const [dismissedVersionMismatchKey, setDismissedVersionMismatchKey] = useState<string | null>(
2228
- null,
2229
- );
2230
- const versionMismatchDismissed =
2231
- versionMismatchDismissKey === dismissedVersionMismatchKey ||
2232
- isVersionMismatchDismissed(versionMismatchDismissKey);
2233
- const showVersionMismatchBanner =
2234
- versionMismatch !== null && versionMismatchDismissKey !== null && !versionMismatchDismissed;
2215
const hasMultipleRegisteredEnvironments = environments.length > 1;
2216
const versionMismatchServerLabel =
2217
hasMultipleRegisteredEnvironments && activeThread
@@ -2251,6 +2231,30 @@ export default function ChatView(props: ChatViewProps) {
2231
const serverUpdateFailureDismissed =
2232
serverUpdateState === dismissedServerUpdateState ||
2233
isServerUpdateFailureDismissed(serverUpdateState);
2234
+ const activeServerUpdate =
2235
+ !automaticEnvironment &&
2236
+ serverUpdateEnvironmentId &&
2237
+ versionMismatch &&
2238
+ serverUpdateState.status === "idle"
2239
+ ? {
2240
+ environmentId: serverUpdateEnvironmentId,
2241
+ serverLabel:
2242
+ activeEnvironmentOption?.label ??
2243
+ serverConfig?.environment.label ??
2244
+ versionMismatchServerLabel,
2245
+ serverVersion: versionMismatch.serverVersion,
2246
+ targetVersion: versionMismatch.clientVersion,
2247
+ selfUpdate: versionMismatchSelfUpdate,
2248
+ installation: versionMismatchInstallation,
2249
+ desktopAppUpdate: versionMismatchDesktopAppUpdate,
2250
+ threadContinuation: versionMismatchThreadContinuation,
2251
+ }
2252
+ : null;
2253
+ const showComposerEnvironmentIndicator = shouldShowEnvironmentIndicator({
2254
+ activeEnvironment: activeEnvironmentOption,
2255
+ canPickEnvironment: hasMultipleEnvironments,
2256
+ serverUpdateAvailable: activeServerUpdate !== null,
2257
+ });
2258
const systemComposerBannerItems = (() => {
2259
const items: ComposerBannerStackItem[] = [];
2260
const updateRunning = serverUpdateState.status === "running";
@@ -2306,9 +2310,8 @@ export default function ChatView(props: ChatViewProps) {
2310
if (
2311
!automaticEnvironment &&
2312
serverUpdateEnvironmentId &&
2309
- (serverUpdateState.status === "idle"
2310
- ? showVersionMismatchBanner
2311
- : !serverUpdateFailureDismissed)
2313
+ serverUpdateState.status !== "idle" &&
2314
+ !serverUpdateFailureDismissed
2315
) {
2316
const updateInProgress = serverUpdateState.status === "running";
2317
const updateFailed = serverUpdateState.status === "failed";
@@ -2317,39 +2320,12 @@ export default function ChatView(props: ChatViewProps) {
2320
variant: updateFailed ? "error" : "default",
2321
priority: updateInProgress ? "urgent" : "notice",
2322
icon: <ComposerServerUpdateIcon status={serverUpdateState.status} />,
2320
- title:
2321
- updateInProgress || updateFailed ? (
2322
- <ComposerServerUpdateStatus
2323
- state={serverUpdateState}
2324
- serverLabel={versionMismatchServerLabel}
2325
- />
2326
- ) : versionMismatch ? (
2327
- <Tooltip>
2328
- <TooltipTrigger
2329
- render={
2330
- <button
2331
- type="button"
2332
- className="block max-w-full cursor-help truncate rounded-sm text-left"
2333
- >
2334
- Server update available
2335
- </button>
2336
- }
2337
- />
2338
- <TooltipPopup side="top">
2339
- {versionMismatchServerLabel} {versionMismatch.serverVersion}{" "}
2340
- <span aria-hidden="true">→</span> {versionMismatch.clientVersion}
2341
- </TooltipPopup>
2342
- </Tooltip>
2343
- ) : (
2344
- "Server update available"
2345
- ),
2346
- description:
2347
- !updateInProgress &&
2348
- !updateFailed &&
2349
- versionMismatchSelfUpdate !== null &&
2350
- (versionMismatchSelfUpdate !== "desktop-managed" || !versionMismatchDesktopAppUpdate)
2351
- ? serverUpdateGuidance(versionMismatchSelfUpdate)
2352
- : undefined,
2323
+ title: (
2324
+ <ComposerServerUpdateStatus
2325
+ state={serverUpdateState}
2326
+ serverLabel={versionMismatchServerLabel}
2327
+ />
2328
+ ),
2329
actions: updateInProgress ? (
2330
disconnectAction
2331
) : !versionMismatch ||
@@ -2367,19 +2343,15 @@ export default function ChatView(props: ChatViewProps) {
2343
variant="ghost"
2344
/>
2345
),
2370
- ...(updateInProgress || (!updateFailed && !versionMismatchDismissKey)
2371
- ? {}
2372
- : {
2346
+ ...(updateFailed
2347
+ ? {
2348
dismissLabel: "Dismiss update notice",
2349
onDismiss: () => {
2375
- if (updateFailed) {
2376
- dismissServerUpdateFailure(serverUpdateState);
2377
- setDismissedServerUpdateState(serverUpdateState);
2378
- }
2379
- dismissVersionMismatch(versionMismatchDismissKey);
2380
- setDismissedVersionMismatchKey(versionMismatchDismissKey);
2350
+ dismissServerUpdateFailure(serverUpdateState);
2351
+ setDismissedServerUpdateState(serverUpdateState);
2352
},
2382
- }),
2353
+ }
2354
+ : {}),
2355
});
2356
}
2357
if (autoBalanceUpdateBanner) items.push(autoBalanceUpdateBanner);
@@ -3081,6 +3053,7 @@ export default function ChatView(props: ChatViewProps) {
3053
hasActiveProject: activeProject !== null && !showProviderSubagentBar,
3054
isGitRepo,
3055
showEnvironmentIndicator: showComposerEnvironmentIndicator,
3056
+ serverUpdateAvailable: activeServerUpdate !== null,
3057
hostsRestingComposerControls: routeKind === "server",
3058
});
3059
const showComposerContextStrip = shouldShowComposerContextStrip({
@@ -3089,6 +3062,7 @@ export default function ChatView(props: ChatViewProps) {
3062
hasActiveProject: activeProject !== null && !showProviderSubagentBar,
3063
isGitRepo,
3064
showEnvironmentIndicator: showComposerEnvironmentIndicator,
3065
+ serverUpdateAvailable: activeServerUpdate !== null,
3066
hostsRestingComposerControls: routeKind === "server" && restingComposerControlsVisible,
3067
});
3068
const mountComposerModelStrip =
@@ -8458,6 +8432,7 @@ export default function ChatView(props: ChatViewProps) {
8432
availableEnvironments={logicalProjectEnvironments}
8433
composerControlsHostRef={setRestingComposerControlsHost}
8434
contextStripVisible={showComposerContextStrip}
8435
+ serverUpdate={activeServerUpdate}
8436
/>
8437
</div>
8438
)}
apps/web/src/components/ServerUpdateAction.browser.test.tsx
+109
-1
@@ -3,9 +3,12 @@ import { AuthSessionState, type EnvironmentId, type ServerInstallation } from "@
3
import * as Cause from "effect/Cause";
4
import * as Schema from "effect/Schema";
5
import { AsyncResult, Atom } from "effect/reactivity";
6
-import { act, type ReactNode } from "react";
6
+import { act, useState, type ReactNode } from "react";
7
import { createRoot, type Root } from "react-dom/client";
8
import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
9
+import { page, userEvent } from "vite-plus/test/browser";
10
+
11
+import "~/index.css";
12
13
type SessionResult = AsyncResult.AsyncResult<AuthSessionState, Error>;
14
const testState = vi.hoisted(() => ({
@@ -56,6 +59,7 @@ vi.mock(import("./ui/toast"), async (original) => {
59
});
60
61
import {
62
+ completeConfirmDialogClose,
63
readConfirmDialogState,
64
registerConfirmDialogHost,
65
resetConfirmDialogForTests,
@@ -69,6 +73,8 @@ import {
73
type ServerUpdateTarget,
74
} from "./ServerUpdateAction";
75
76
+import { BranchToolbarEnvironmentSelector } from "./BranchToolbarEnvironmentSelector";
77
+
78
const decodeSessionState = Schema.decodeUnknownSync(AuthSessionState);
79
80
const legacyAuth = {
@@ -509,3 +515,105 @@ describe("ServerUpdateProgress", () => {
515
);
516
});
517
});
518
+
519
+describe("server updates from the environment selector", () => {
520
+ const localId = "env-test" as EnvironmentId;
521
+ const otherId = "update-server" as EnvironmentId;
522
+ const availableEnvironments = [
523
+ { environmentId: localId, label: "Build box", isPrimary: true },
524
+ { environmentId: otherId, label: "Other machine", isPrimary: false },
525
+ ].map((environment) => ({ ...environment, projectId: null, machine: "server" as const }));
526
+ const serverUpdate = {
527
+ environmentId: localId,
528
+ serverLabel: "Build box",
529
+ serverVersion: "0.0.30",
530
+ targetVersion: "0.0.31",
531
+ selfUpdate: "desktop-managed",
532
+ desktopAppUpdate: true,
533
+ } satisfies ServerUpdateTarget & { serverVersion: string };
534
+
535
+ it("confirms a locked chip update and honors cancellation before updating", async () => {
536
+ registerConfirmDialogHost();
537
+ testState.updateServer.mockResolvedValue(success("desktop-app"));
538
+ await render(
539
+ <BranchToolbarEnvironmentSelector
540
+ environmentId={localId}
541
+ availableEnvironments={availableEnvironments}
542
+ envLocked
543
+ serverUpdate={serverUpdate}
544
+ />,
545
+ );
546
+ const chip = page.getByRole("button", { name: /Build box|Update/ });
547
+ await userEvent.click(chip);
548
+ expect(readConfirmDialogState()).toMatchObject({
549
+ status: "confirming",
550
+ message: expect.stringContaining("Build box"),
551
+ });
552
+ expect(testState.updateServer).not.toHaveBeenCalled();
553
+ await act(async () => {
554
+ respondToConfirmDialog(false);
555
+ completeConfirmDialogClose();
556
+ });
557
+ expect(testState.updateServer).not.toHaveBeenCalled();
558
+ await userEvent.click(chip);
559
+ await act(async () => respondToConfirmDialog(true));
560
+ expect(testState.updateServer).toHaveBeenCalledExactlyOnceWith({
561
+ environmentId: localId,
562
+ input: { targetVersion: "0.0.31" },
563
+ });
564
+ });
565
+
566
+ it("copies from the picker without switching machines and still selects an action-like environment ID", async () => {
567
+ const update = { ...serverUpdate, selfUpdate: null, installation: { kind: "npx" } } as const;
568
+ function Picker() {
569
+ const [environmentId, setEnvironmentId] = useState(localId);
570
+ return (
571
+ <BranchToolbarEnvironmentSelector
572
+ environmentId={environmentId}
573
+ availableEnvironments={availableEnvironments}
574
+ envLocked={false}
575
+ onEnvironmentChange={setEnvironmentId}
576
+ serverUpdate={environmentId === localId ? update : null}
577
+ />
578
+ );
579
+ }
580
+ await render(<Picker />);
581
+ const picker = page.getByRole("combobox", { name: "Run on" });
582
+ await userEvent.click(picker);
583
+ await expect.element(page.getByRole("option", { name: "Other machine" })).toBeVisible();
584
+ expect(testState.clipboard).not.toHaveBeenCalled();
585
+ await userEvent.click(page.getByRole("option", { name: /Copy relaunch command/ }));
586
+ expect(testState.clipboard).toHaveBeenCalledExactlyOnceWith("npx t3@0.0.31");
587
+ expect(testState.updateServer).not.toHaveBeenCalled();
588
+ await expect.element(picker).toHaveTextContent("Build box");
589
+ await userEvent.click(picker);
590
+ await expect
591
+ .element(page.getByRole("option", { name: "Build box", exact: true }))
592
+ .toHaveAttribute("aria-selected", "true");
593
+ await userEvent.click(page.getByRole("option", { name: "Other machine" }));
594
+ await expect.element(picker).toHaveTextContent("Other machine");
595
+ expect(testState.clipboard).toHaveBeenCalledTimes(1);
596
+ expect(testState.updateServer).not.toHaveBeenCalled();
597
+ });
598
+
599
+ it("explains an unsupported desktop update in the picker without offering a runnable action", async () => {
600
+ registerConfirmDialogHost();
601
+ await render(
602
+ <BranchToolbarEnvironmentSelector
603
+ environmentId={localId}
604
+ availableEnvironments={availableEnvironments}
605
+ envLocked={false}
606
+ onEnvironmentChange={vi.fn()}
607
+ serverUpdate={{ ...serverUpdate, desktopAppUpdate: false }}
608
+ />,
609
+ );
610
+ await userEvent.click(page.getByRole("combobox", { name: "Run on" }));
611
+ const instruction = page.getByRole("option", { name: /Update the desktop app/ });
612
+ await expect.element(instruction).toBeVisible();
613
+ await expect.element(instruction).toHaveAttribute("aria-disabled", "true");
614
+ await userEvent.click(instruction, { force: true });
615
+ expect(readConfirmDialogState().status).toBe("idle");
616
+ expect(testState.updateServer).not.toHaveBeenCalled();
617
+ expect(testState.clipboard).not.toHaveBeenCalled();
618
+ });
619
+});
apps/web/src/components/ServerUpdateAction.tsx
+34
-14
@@ -18,7 +18,7 @@ import {
18
squashAtomCommandFailure,
19
} from "@t3tools/client-runtime/state/runtime";
20
import { CircleArrowUpIcon } from "lucide-react";
21
-import { type ComponentProps, useRef, useState } from "react";
21
+import { type ComponentProps, type ReactNode, useRef, useState } from "react";
22
23
import { requestConfirmDialog } from "~/confirmDialog";
24
import { useCopyToClipboard } from "~/hooks/useCopyToClipboard";
@@ -57,6 +57,16 @@ export interface ServerUpdateTarget {
57
readonly continueThreadsAfterServerUpdate?: boolean;
58
}
59
60
+export type PendingServerUpdate = Omit<ServerUpdateTarget, "continueThreadsAfterServerUpdate"> & {
61
+ readonly serverVersion: string;
62
+};
63
+
64
+export interface ServerUpdateControl {
65
+ readonly label: string;
66
+ readonly disabled: boolean;
67
+ readonly onClick: () => void;
68
+}
69
+
70
type UpdateButtonProps = Pick<ComponentProps<typeof Button>, "variant" | "size" | "className"> & {
71
readonly label?: string;
72
readonly appearance?: "button" | "icon";
@@ -215,8 +225,13 @@ export function ServerUpdateAction({
225
size = "xs",
226
className,
227
appearance = "button",
218
-}: Omit<ServerUpdateTarget, "continueThreadsAfterServerUpdate"> & UpdateButtonProps) {
228
+ render,
229
+}: Omit<ServerUpdateTarget, "continueThreadsAfterServerUpdate"> &
230
+ UpdateButtonProps & {
231
+ readonly render?: (control: ServerUpdateControl) => ReactNode;
232
+ }) {
233
const isDesktopAppUpdate = selfUpdate === "desktop-managed";
234
+ const unsupportedDesktopUpdate = isDesktopAppUpdate && !desktopAppUpdate;
235
const sessionStateAtom = environmentSession.sessionStateAtom(environmentId);
236
const canUpdate = canUpdateServer(useAtomValue(sessionStateAtom));
237
const continueThreadsAfterServerUpdate = useEnvironmentSettings(
@@ -248,6 +263,7 @@ export function ServerUpdateAction({
263
264
const handleUpdate = async () => {
265
if (
266
+ unsupportedDesktopUpdate ||
267
!canUpdateServer(appAtomRegistry.get(sessionStateAtom)) ||
268
pendingUpdateEnvironmentIds.has(environmentId)
269
) {
@@ -274,18 +290,11 @@ export function ServerUpdateAction({
290
});
291
};
292
277
- if (selfUpdate === "desktop-managed" && !desktopAppUpdate) {
278
- return (
279
- <span className="text-muted-foreground text-xs">
280
- Update the desktop app on that machine to update this server.
281
- </span>
282
- );
283
- }
284
-
293
const manualCommand =
294
selfUpdate === null ? manualServerUpdateCommand(targetVersion, installation) : null;
287
- const actionLabel =
288
- manualCommand !== null
295
+ const actionLabel = unsupportedDesktopUpdate
296
+ ? "Update the desktop app on"
297
+ : manualCommand !== null
298
? installation?.kind === "npm-global"
299
? "Copy update command"
300
: "Copy relaunch command"
@@ -294,6 +303,17 @@ export function ServerUpdateAction({
303
manualCommand !== null
304
? () => copyToClipboard(manualCommand, { command: manualCommand })
305
: () => void handleUpdate();
306
+ const disabled = unsupportedDesktopUpdate || (manualCommand === null && !canUpdate);
307
+
308
+ if (render) return render({ label: actionLabel, disabled, onClick });
309
+
310
+ if (unsupportedDesktopUpdate) {
311
+ return (
312
+ <span className="text-muted-foreground text-xs">
313
+ Update the desktop app on that machine to update this server.
314
+ </span>
315
+ );
316
+ }
317
318
if (appearance === "icon") {
319
return (
@@ -305,7 +325,7 @@ export function ServerUpdateAction({
325
variant="ghost-muted"
326
className={className}
327
aria-label={`${actionLabel} for ${serverLabel}`}
308
- disabled={manualCommand === null && !canUpdate}
328
+ disabled={disabled}
329
onClick={onClick}
330
/>
331
}
@@ -322,7 +342,7 @@ export function ServerUpdateAction({
342
size={size}
343
variant={variant}
344
className={className}
325
- disabled={manualCommand === null && !canUpdate}
345
+ disabled={disabled}
346
onClick={onClick}
347
>
348
{actionLabel}
apps/web/src/versionSkew.test.ts
-6
@@ -17,7 +17,6 @@ import {
17
resolveServerConfigVersionMismatch,
18
resolveServerSelfUpdateCapability,
19
resolveVersionMismatch,
20
- serverUpdateGuidance,
20
supportsDesktopAppUpdate,
21
} from "./versionSkew";
22
@@ -236,9 +235,4 @@ describe("versionSkew", () => {
235
expect(supportsDesktopAppUpdate(descriptor())).toBe(false);
236
expect(supportsDesktopAppUpdate(null)).toBe(false);
237
});
239
-
240
- it("matches version-drift guidance to the advertised update path", () => {
241
- expect(serverUpdateGuidance("respawn")).toBe("Update to stay in sync");
242
- expect(serverUpdateGuidance("desktop-managed")).toBe("Update the desktop app");
243
- });
238
});
apps/web/src/versionSkew.ts
-4
@@ -114,10 +114,6 @@ export function manualServerUpdateCommand(
114
return `${runner} t3@${targetVersion}`;
115
}
116
117
-export function serverUpdateGuidance(capability: ServerSelfUpdateCapability): string {
118
- return capability === "desktop-managed" ? "Update the desktop app" : "Update to stay in sync";
119
-}
120
-
117
export function buildVersionMismatchDismissalKey(
118
environmentId: EnvironmentId,
119
mismatch: Pick<VersionMismatch, "clientVersion" | "serverVersion">,