@devries-cameron20 / t3code Mirror · read-only / commits / 5547d7c13c
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, 22:00 UTC

revert: "fix(web): show idle server updates on environment controls" (#21950) (#22233)

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

Theo Browne committed Oct 20, 2026 at 02:03 UTC 5547d7c13cf7298a7ccef05ad6325f687f9a40a3
10 files changed +139 -427
apps/web/src/components/BranchToolbar.logic.test.ts
-31
@@ -424,37 +424,6 @@ describe("shouldShowEnvironmentIndicator", () => {
424 });
425
426 describe("shouldShowComposerContextStrip", () => {
427 - it("keeps a sole primary server update reachable in a non-Git draft", () => {
428 - const environment = {
429 - activeEnvironment: { isPrimary: true },
430 - canPickEnvironment: false,
431 - serverUpdateAvailable: true,
432 - };
433 - const showEnvironmentIndicator = shouldShowEnvironmentIndicator(environment);
434 - expect(showEnvironmentIndicator).toBe(true);
435 - expect(
436 - shouldShowComposerContextStrip({
437 - isDraftHeroState: true,
438 - persistInActiveThreads: false,
439 - hasActiveProject: true,
440 - isGitRepo: false,
441 - showEnvironmentIndicator,
442 - hostsRestingComposerControls: false,
443 - }),
444 - ).toBe(true);
445 - expect(
446 - shouldShowComposerContextStrip({
447 - isDraftHeroState: false,
448 - persistInActiveThreads: false,
449 - hasActiveProject: true,
450 - isGitRepo: false,
451 - showEnvironmentIndicator,
452 - serverUpdateAvailable: true,
453 - hostsRestingComposerControls: false,
454 - }),
455 - ).toBe(true);
456 - });
457 -
427 it.each([false, true])(
428 "honors the active-thread preference with resting controls %s",
429 (hostsRestingComposerControls) => {
apps/web/src/components/BranchToolbar.logic.ts
+2 -6
@@ -59,9 +59,8 @@ export function resolveEnvironmentOptionLabel(input: {
59 export function shouldShowEnvironmentIndicator(input: {
60 activeEnvironment: Pick<EnvironmentOption, "isPrimary"> | null;
61 canPickEnvironment: boolean;
62 - serverUpdateAvailable?: boolean;
62 }): boolean {
64 - if (input.canPickEnvironment || input.serverUpdateAvailable) return true;
63 + if (input.canPickEnvironment) return true;
64 return input.activeEnvironment !== null && !input.activeEnvironment.isPrimary;
65 }
66
@@ -72,13 +71,10 @@ export function shouldShowComposerContextStrip(input: {
71 isGitRepo: boolean;
72 showEnvironmentIndicator: boolean;
73 hostsRestingComposerControls: boolean;
75 - serverUpdateAvailable?: boolean;
74 }): boolean {
75 return (
76 input.hasActiveProject &&
79 - (input.isDraftHeroState ||
80 - input.persistInActiveThreads ||
81 - input.serverUpdateAvailable === true) &&
77 + (input.isDraftHeroState || input.persistInActiveThreads) &&
78 (input.isGitRepo || input.showEnvironmentIndicator || input.hostsRestingComposerControls)
79 );
80 }
apps/web/src/components/BranchToolbar.panel.browser.test.tsx
+16 -76
@@ -19,10 +19,6 @@ 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,
22 }));
23 vi.mock(import("./BranchToolbarBranchSelector"), async (original) => ({
24 ...(await original()),
@@ -35,8 +31,6 @@ vi.mock(import("../state/entities"), async (original) => ({
31 }));
32
33 import { BranchToolbar } from "./BranchToolbar";
38 -import { ComposerSurface } from "./chat/ComposerSurface";
39 -import type { ServerUpdateTarget } from "./ServerUpdateAction";
34
35 let root: Root;
36 let container: HTMLDivElement;
@@ -60,24 +54,22 @@ afterEach(async () => {
54 function render(props: Partial<ComponentProps<typeof BranchToolbar>>) {
55 return act(async () =>
56 root.render(
63 - <ComposerSurface.Shell>
64 - <BranchToolbar
65 - layout="panel"
66 - panelSection="workspace"
67 - environmentId={EnvironmentId.make("local")}
68 - threadId={ThreadId.make("thread")}
69 - projectId={ProjectId.make("project")}
70 - worktreePath={state.worktreePath}
71 - isServerThread
72 - showGitControls
73 - envMode="local"
74 - envLocked={false}
75 - startFromOrigin={false}
76 - onStartFromOriginChange={vi.fn()}
77 - onEnvModeChange={vi.fn()}
78 - {...props}
79 - />
80 - </ComposerSurface.Shell>,
57 + <BranchToolbar
58 + layout="panel"
59 + panelSection="workspace"
60 + environmentId={EnvironmentId.make("local")}
61 + threadId={ThreadId.make("thread")}
62 + projectId={ProjectId.make("project")}
63 + worktreePath={state.worktreePath}
64 + isServerThread
65 + showGitControls
66 + envMode="local"
67 + envLocked={false}
68 + startFromOrigin={false}
69 + onStartFromOriginChange={vi.fn()}
70 + onEnvModeChange={vi.fn()}
71 + {...props}
72 + />,
73 ),
74 );
75 }
@@ -153,55 +145,3 @@ it.each([
145 }
146 },
147 );
156 -
157 -it.each([
158 - { layout: "wide Git", width: 900, showGitControls: true },
159 - { layout: "narrow Git", width: 360, showGitControls: true },
160 - { layout: "sole primary non-Git", width: 360, showGitControls: false },
161 -])(
162 - "copies the pending update from the $layout composer chip",
163 - async ({ width, showGitControls }) => {
164 - await page.viewport(1000, 700);
165 - container.style.width = `${width}px`;
166 - container.style.setProperty("--chat-content-max-width", `${width}px`);
167 - const serverUpdate = {
168 - environmentId: EnvironmentId.make("local"),
169 - serverLabel: "Build box",
170 - serverVersion: "0.0.30",
171 - targetVersion: "0.0.31",
172 - selfUpdate: null,
173 - installation: { kind: "npm-global", prefix: "/opt/node" },
174 - } satisfies ServerUpdateTarget & { serverVersion: string };
175 - await render({
176 - layout: "composer",
177 - envLocked: showGitControls,
178 - showGitControls,
179 - availableEnvironments: [
180 - {
181 - environmentId: serverUpdate.environmentId,
182 - projectId: ProjectId.make("project"),
183 - label: serverUpdate.serverLabel,
184 - isPrimary: true,
185 - machine: "server",
186 - },
187 - ],
188 - serverUpdate,
189 - });
190 -
191 - expect(
192 - container.querySelector('[data-slot="composer-shell"]')!.getBoundingClientRect().width,
193 - ).toBe(width);
194 - const chip = page.getByRole("button", { name: /Build box|Copy update command/ });
195 - await expect.element(chip).toBeVisible();
196 - await userEvent.hover(chip);
197 - await expect.element(page.getByRole("tooltip")).toMatchTextContent("0.0.30");
198 - await expect.element(page.getByRole("tooltip")).toMatchTextContent("0.0.31");
199 - await userEvent.click(chip);
200 - await vi.waitFor(() =>
201 - expect(state.writeTextToClipboard).toHaveBeenCalledWith(
202 - "npm install --global --prefix '/opt/node' t3@0.0.31",
203 - "update command",
204 - ),
205 - );
206 - },
207 -);
apps/web/src/components/BranchToolbar.tsx
+12 -30
@@ -47,7 +47,6 @@ import {
47 import { BranchToolbarEnvironmentSelector } from "./BranchToolbarEnvironmentSelector";
48 import { openAddProjectToMachine } from "./AddProjectToMachineDialog";
49 import { type AddProjectTarget, useAddProjectTargets } from "../hooks/useAddProjectTargets";
50 -import type { PendingServerUpdate } from "./ServerUpdateAction";
50 import { BranchToolbarEnvModeSelector } from "./BranchToolbarEnvModeSelector";
51 import { PreviousWorktreeItemContent } from "./PreviousWorktreeItemContent";
52 import { ThreadDetailsControl } from "./chat/ThreadDetailsControl";
@@ -112,7 +111,6 @@ interface BranchToolbarProps {
111 onEnvironmentChange?: (environmentId: EnvironmentId) => void;
112 composerControlsHostRef?: (element: HTMLDivElement | null) => void;
113 contextStripVisible?: boolean;
115 - serverUpdate?: PendingServerUpdate | null;
114 }
115
116 function showWorkspaceContextMenu(event: ReactMouseEvent, workspacePath: string) {
@@ -634,7 +632,6 @@ export const BranchToolbar = memo(function BranchToolbar({
632 onEnvironmentChange,
633 composerControlsHostRef,
634 contextStripVisible = true,
637 - serverUpdate = null,
635 }: BranchToolbarProps) {
636 const branchSelectorRef = useRef<BranchToolbarBranchSelectorHandle>(null);
637 const threadRef = scopeThreadRef(environmentId, threadId);
@@ -700,7 +697,6 @@ export const BranchToolbar = memo(function BranchToolbar({
697 const showEnvironmentIndicator = shouldShowEnvironmentIndicator({
698 activeEnvironment: activeEnvironmentOption,
699 canPickEnvironment: hasMultipleEnvironments,
703 - serverUpdateAvailable: serverUpdate !== null,
700 });
701 const [stripElement, setStripElement] = useState<HTMLDivElement | null>(null);
702 const labelsOverflow = useLabelsOverflow(stripElement);
@@ -767,18 +763,6 @@ export const BranchToolbar = memo(function BranchToolbar({
763 !contextStripVisible && "pointer-events-none invisible absolute inset-x-0 top-full",
764 )}
765 >
770 - {serverUpdate && availableEnvironments ? (
771 - <BranchToolbarEnvironmentSelector
772 - autoEnvironmentLabel={autoEnvironmentLabel}
773 - onAutoEnvironment={onAutoEnvironment}
774 - envLocked={envLocked}
775 - environmentId={environmentId}
776 - availableEnvironments={availableEnvironments}
777 - {...(showEnvironmentPicker ? { onEnvironmentChange } : {})}
778 - {...(addTargets.length > 0 ? { onAddToMachine: () => onAddToMachine(null) } : {})}
779 - serverUpdate={serverUpdate}
780 - />
781 - ) : null}
766 {showGitControls ? (
767 <div className="contents @3xl/composer-surface:hidden">
768 <RunContextSelector
@@ -789,8 +773,8 @@ export const BranchToolbar = memo(function BranchToolbar({
773 envModeLocked={envModeLocked}
774 environmentId={environmentId}
775 availableEnvironments={availableEnvironments}
792 - showEnvironmentPicker={showEnvironmentPicker && serverUpdate === null}
793 - showEnvironmentIndicator={showEnvironmentIndicator && serverUpdate === null}
776 + showEnvironmentPicker={showEnvironmentPicker}
777 + showEnvironmentIndicator={showEnvironmentIndicator}
778 onEnvironmentChange={onEnvironmentChange}
779 effectiveEnvMode={effectiveEnvMode}
780 activeWorktreePath={activeWorktreePath}
@@ -803,7 +787,7 @@ export const BranchToolbar = memo(function BranchToolbar({
787 />
788 </div>
789 ) : null}
806 - {showGitControls || (showEnvironmentIndicator && serverUpdate === null) ? (
790 + {showGitControls || showEnvironmentIndicator ? (
791 <div
792 className={cn(
793 "min-h-7 min-w-10 items-center gap-1 sm:min-h-6",
@@ -813,17 +797,15 @@ export const BranchToolbar = memo(function BranchToolbar({
797 >
798 {showEnvironmentIndicator && availableEnvironments && (
799 <>
816 - {serverUpdate === null ? (
817 - <BranchToolbarEnvironmentSelector
818 - autoEnvironmentLabel={autoEnvironmentLabel}
819 - onAutoEnvironment={onAutoEnvironment}
820 - envLocked={envLocked}
821 - environmentId={environmentId}
822 - availableEnvironments={availableEnvironments}
823 - {...(showEnvironmentPicker ? { onEnvironmentChange } : {})}
824 - {...(addTargets.length > 0 ? { onAddToMachine: () => onAddToMachine(null) } : {})}
825 - />
826 - ) : null}
800 + <BranchToolbarEnvironmentSelector
801 + autoEnvironmentLabel={autoEnvironmentLabel}
802 + onAutoEnvironment={onAutoEnvironment}
803 + envLocked={envLocked}
804 + environmentId={environmentId}
805 + availableEnvironments={availableEnvironments}
806 + {...(showEnvironmentPicker ? { onEnvironmentChange } : {})}
807 + {...(addTargets.length > 0 ? { onAddToMachine: () => onAddToMachine(null) } : {})}
808 + />
809 {showGitControls ? (
810 <Separator
811 orientation="vertical"
apps/web/src/components/BranchToolbarEnvironmentSelector.tsx
+21 -104
@@ -1,19 +1,14 @@
1 -import { ComposerControl, ComposerSelectControl } from "./chat/ComposerControl";
1 +import { 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 { CircleArrowUpIcon, PlusIcon, ScaleIcon } from "lucide-react";
8 +import { PlusIcon, ScaleIcon } from "lucide-react";
9 import { memo } from "react";
10
11 import { ADD_TO_MACHINE_LABEL_CLASS, type EnvironmentOption } from "./BranchToolbar.logic";
12 -import {
13 - ServerUpdateAction,
14 - type PendingServerUpdate,
15 - type ServerUpdateControl,
16 -} from "./ServerUpdateAction";
12 import { EnvironmentMachineIcon } from "./EnvironmentMachineIcon";
13 import { useComposerMenuProps } from "./chat/composerEventScope";
14 import {
@@ -33,29 +28,14 @@ interface BranchToolbarEnvironmentSelectorProps {
28 availableEnvironments: readonly EnvironmentOption[];
29 onEnvironmentChange?: (environmentId: EnvironmentId) => void;
30 onAddToMachine?: (() => void) | undefined;
36 - serverUpdate?: PendingServerUpdate | null;
31 }
32
33 // Action values cannot collide with server-minted environment IDs.
34 const AUTO_VALUE = "action:auto";
41 -const UPDATE_VALUE = "action:update";
35 const ADD_MACHINE_VALUE = "action:add-machine";
36 const environmentValue = (id: EnvironmentId) => `env:${id}`;
37
45 -export const BranchToolbarEnvironmentSelector = memo(function BranchToolbarEnvironmentSelector(
46 - props: BranchToolbarEnvironmentSelectorProps,
47 -) {
48 - return props.serverUpdate ? (
49 - <ServerUpdateAction
50 - {...props.serverUpdate}
51 - render={(updateControl) => <EnvironmentSelector {...props} updateControl={updateControl} />}
52 - />
53 - ) : (
54 - <EnvironmentSelector {...props} updateControl={null} />
55 - );
56 -});
57 -
58 -function EnvironmentSelector({
38 +export const BranchToolbarEnvironmentSelector = memo(function BranchToolbarEnvironmentSelector({
39 autoEnvironmentLabel,
40 onAutoEnvironment,
41 envLocked,
@@ -63,11 +43,7 @@ function EnvironmentSelector({
43 availableEnvironments,
44 onEnvironmentChange,
45 onAddToMachine,
66 - serverUpdate,
67 - updateControl,
68 -}: BranchToolbarEnvironmentSelectorProps & {
69 - updateControl: ServerUpdateControl | null;
70 -}) {
46 +}: BranchToolbarEnvironmentSelectorProps) {
47 const composerFloatingLayerProps = useComposerMenuProps();
48 const shortcutLabel = shortcutLabelForCommand(
49 useAtomValue(primaryServerKeybindingsAtom),
@@ -84,34 +60,8 @@ function EnvironmentSelector({
60 value: environmentValue(env.environmentId),
61 label: env.label,
62 })),
87 - ...(serverUpdate && updateControl
88 - ? [{ value: UPDATE_VALUE, label: `${updateControl.label} ${serverUpdate.serverLabel}` }]
89 - : []),
63 ...(onAddToMachine ? [{ value: ADD_MACHINE_VALUE, label: "Add to another machine" }] : []),
64 ];
92 - const updateTooltip = serverUpdate
93 - ? `${serverUpdate.serverLabel} ${serverUpdate.serverVersion} → ${serverUpdate.targetVersion}. ${
94 - serverUpdate.selfUpdate === "desktop-managed" && !serverUpdate.desktopAppUpdate
95 - ? "Update the desktop app on that machine."
96 - : (updateControl?.label ?? "Update")
97 - }`
98 - : null;
99 - const environmentIcon = serverUpdate ? (
100 - <CircleArrowUpIcon aria-hidden="true" className="size-3 shrink-0" />
101 - ) : (
102 - <EnvironmentMachineIcon
103 - kind={activeEnvironment?.machine ?? "server"}
104 - className="size-3 shrink-0"
105 - />
106 - );
107 - const chipBody = (
108 - <>
109 - {environmentIcon}
110 - <ComposerContextLabel>
111 - {activeEnvironment?.label ?? serverUpdate?.serverLabel ?? "Run on"}
112 - </ComposerContextLabel>
113 - </>
114 - );
65
66 // The static label carries the xs control's height (h-7 sm:h-6) as well as
67 // its padding: the composer context strip has no min-height of its own, and
@@ -119,41 +69,22 @@ function EnvironmentSelector({
69 // a shorter label would drag the seam out of line whenever this label is the
70 // only thing in the strip.
71 if (envLocked || (onEnvironmentChange === undefined && onAddToMachine === undefined)) {
122 - const lockedRow = updateControl ? (
123 - <ComposerControl
124 - size="xs"
125 - className="min-w-0 max-w-full"
126 - aria-label={`${updateControl.label} ${serverUpdate?.serverLabel}`}
127 - disabled={updateControl.disabled}
128 - onClick={updateControl.onClick}
129 - data-composer-context-control
130 - >
131 - {chipBody}
132 - </ComposerControl>
133 - ) : (
72 + const lockedRow = (
73 <span
74 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"
75 data-composer-context-control
76 >
138 - {chipBody}
77 + <EnvironmentMachineIcon
78 + kind={activeEnvironment?.machine ?? "server"}
79 + className="size-3 shrink-0"
80 + />
81 + <ComposerContextLabel>{activeEnvironment?.label ?? "Run on"}</ComposerContextLabel>
82 </span>
83 );
84 return (
85 <Tooltip>
143 - <TooltipTrigger
144 - render={
145 - updateControl?.disabled ? (
146 - <span className="inline-flex min-w-0 max-w-full" data-composer-context-control>
147 - {lockedRow}
148 - </span>
149 - ) : (
150 - lockedRow
151 - )
152 - }
153 - />
154 - <TooltipPopup role={serverUpdate ? "tooltip" : undefined}>
155 - {updateTooltip ?? activeEnvironment?.label ?? "Run on"}
156 - </TooltipPopup>
86 + <TooltipTrigger render={lockedRow} />
87 + <TooltipPopup>{activeEnvironment?.label ?? "Run on"}</TooltipPopup>
88 </Tooltip>
89 );
90 }
@@ -163,9 +94,7 @@ function EnvironmentSelector({
94 modal={false}
95 value={autoEnvironmentLabel ? AUTO_VALUE : environmentValue(environmentId)}
96 onValueChange={(value) => {
166 - if (value === UPDATE_VALUE) {
167 - updateControl?.onClick();
168 - } else if (value === ADD_MACHINE_VALUE) {
97 + if (value === ADD_MACHINE_VALUE) {
98 onAddToMachine?.();
99 } else if (value === AUTO_VALUE) {
100 onAutoEnvironment?.();
@@ -190,14 +119,17 @@ function EnvironmentSelector({
119 {autoEnvironmentLabel ? (
120 <ScaleIcon className="size-3 shrink-0" aria-hidden="true" />
121 ) : (
193 - environmentIcon
122 + <EnvironmentMachineIcon
123 + kind={activeEnvironment?.machine ?? "server"}
124 + className="size-3 shrink-0"
125 + />
126 )}
127 <ComposerContextLabel>
128 <SelectValue />
129 </ComposerContextLabel>
130 </TooltipTrigger>
199 - <TooltipPopup role={serverUpdate ? "tooltip" : undefined}>
200 - {updateTooltip ?? autoEnvironmentLabel ?? activeEnvironment?.label ?? "Run on"}
131 + <TooltipPopup>
132 + {autoEnvironmentLabel ?? activeEnvironment?.label ?? "Run on"}
133 {shortcutLabel ? ` · ${shortcutLabel}` : null}
134 </TooltipPopup>
135 </Tooltip>
@@ -224,11 +156,7 @@ function EnvironmentSelector({
156 disabled={onEnvironmentChange === undefined && env.environmentId !== environmentId}
157 >
158 <span className="inline-flex items-center gap-1.5">
227 - {serverUpdate?.environmentId === env.environmentId ? (
228 - <CircleArrowUpIcon aria-hidden="true" className="size-3" />
229 - ) : (
230 - <EnvironmentMachineIcon kind={env.machine} className="size-3" />
231 - )}
159 + <EnvironmentMachineIcon kind={env.machine} className="size-3" />
160 {env.label}
161 </span>
162 </SelectItem>
@@ -242,18 +170,7 @@ function EnvironmentSelector({
170 </SelectItem>
171 ) : null}
172 </SelectGroup>
245 - {serverUpdate && updateControl ? (
246 - <SelectGroup>
247 - <SelectGroupLabel>Server update</SelectGroupLabel>
248 - <SelectItem value={UPDATE_VALUE} disabled={updateControl.disabled}>
249 - <span className="inline-flex items-center gap-1.5">
250 - <CircleArrowUpIcon aria-hidden="true" className="size-3" />
251 - {updateControl.label} {serverUpdate.serverLabel}
252 - </span>
253 - </SelectItem>
254 - </SelectGroup>
255 - ) : null}
173 </SelectPopup>
174 </Select>
175 );
259 -}
176 +});
apps/web/src/components/ChatView.tsx
+63 -37
@@ -553,10 +553,14 @@ import { ServerUpdateAction, serverUpdateStageLabel } from "./ServerUpdateAction
553 import { useAutoBalanceUpdateBanner } from "./chat/useAutoBalanceUpdateBanner";
554 import { ComposerServerUpdateIcon } from "./chat/ComposerServerUpdateStatus";
555 import {
556 + buildVersionMismatchDismissalKey,
557 dismissServerUpdateFailure,
558 + dismissVersionMismatch,
559 isServerUpdateFailureDismissed,
560 + isVersionMismatchDismissed,
561 resolveServerConfigVersionMismatch,
562 resolveServerSelfUpdateCapability,
563 + serverUpdateGuidance,
564 supportsDesktopAppUpdate,
565 supportsServerUpdateThreadContinuation,
566 } from "../versionSkew";
@@ -2125,6 +2129,10 @@ export default function ChatView(props: ChatViewProps) {
2129 logicalProjectEnvironments.find(
2130 (environment) => environment.environmentId === activeThread?.environmentId,
2131 ) ?? null;
2132 + const showComposerEnvironmentIndicator = shouldShowEnvironmentIndicator({
2133 + activeEnvironment: activeEnvironmentOption,
2134 + canPickEnvironment: hasMultipleEnvironments,
2135 + });
2136 const openPullRequestDialog = (reference?: string) => {
2137 if (!canCheckoutPullRequestIntoThread) {
2138 return;
@@ -2275,6 +2283,18 @@ export default function ChatView(props: ChatViewProps) {
2283 : EMPTY_AUTO_UPDATE_ENVIRONMENTS;
2284 const autoBalanceUpdateBanner = useAutoBalanceUpdateBanner(autoUpdateEnvironments);
2285 const versionMismatch = resolveServerConfigVersionMismatch(serverConfig);
2286 + const versionMismatchDismissKey =
2287 + versionMismatch && activeThread
2288 + ? buildVersionMismatchDismissalKey(activeThread.environmentId, versionMismatch)
2289 + : null;
2290 + const [dismissedVersionMismatchKey, setDismissedVersionMismatchKey] = useState<string | null>(
2291 + null,
2292 + );
2293 + const versionMismatchDismissed =
2294 + versionMismatchDismissKey === dismissedVersionMismatchKey ||
2295 + isVersionMismatchDismissed(versionMismatchDismissKey);
2296 + const showVersionMismatchBanner =
2297 + versionMismatch !== null && versionMismatchDismissKey !== null && !versionMismatchDismissed;
2298 const hasMultipleRegisteredEnvironments = environments.length > 1;
2299 const versionMismatchServerLabel =
2300 hasMultipleRegisteredEnvironments && activeThread
@@ -2294,30 +2314,6 @@ export default function ChatView(props: ChatViewProps) {
2314 const serverUpdateFailureDismissed =
2315 serverUpdateState === dismissedServerUpdateState ||
2316 isServerUpdateFailureDismissed(serverUpdateState);
2297 - const activeServerUpdate =
2298 - !automaticEnvironment &&
2299 - serverUpdateEnvironmentId &&
2300 - versionMismatch &&
2301 - serverUpdateState.status === "idle"
2302 - ? {
2303 - environmentId: serverUpdateEnvironmentId,
2304 - serverLabel:
2305 - activeEnvironmentOption?.label ??
2306 - serverConfig?.environment.label ??
2307 - versionMismatchServerLabel,
2308 - serverVersion: versionMismatch.serverVersion,
2309 - targetVersion: versionMismatch.clientVersion,
2310 - selfUpdate: versionMismatchSelfUpdate,
2311 - installation: versionMismatchInstallation,
2312 - desktopAppUpdate: versionMismatchDesktopAppUpdate,
2313 - threadContinuation: versionMismatchThreadContinuation,
2314 - }
2315 - : null;
2316 - const showComposerEnvironmentIndicator = shouldShowEnvironmentIndicator({
2317 - activeEnvironment: activeEnvironmentOption,
2318 - canPickEnvironment: hasMultipleEnvironments,
2319 - serverUpdateAvailable: activeServerUpdate !== null,
2320 - });
2317 const systemComposerBannerItems = (() => {
2318 const items: ComposerBannerStackItem[] = [];
2319 const updateRunning = serverUpdateState.status === "running";
@@ -2376,8 +2372,9 @@ export default function ChatView(props: ChatViewProps) {
2372 if (
2373 !automaticEnvironment &&
2374 serverUpdateEnvironmentId &&
2379 - serverUpdateState.status !== "idle" &&
2380 - !serverUpdateFailureDismissed
2375 + (serverUpdateState.status === "idle"
2376 + ? showVersionMismatchBanner
2377 + : !serverUpdateFailureDismissed)
2378 ) {
2379 const updateInProgress = serverUpdateState.status === "running";
2380 const updateFailed = serverUpdateState.status === "failed";
@@ -2386,11 +2383,39 @@ export default function ChatView(props: ChatViewProps) {
2383 variant: updateFailed ? "error" : "default",
2384 priority: updateInProgress ? "urgent" : "notice",
2385 icon: <ComposerServerUpdateIcon status={serverUpdateState.status} />,
2389 - title: `${updateFailed ? "Could not update" : "Updating"} ${versionMismatchServerLabel}`,
2386 + title:
2387 + updateInProgress || updateFailed ? (
2388 + `${updateFailed ? "Could not update" : "Updating"} ${versionMismatchServerLabel}`
2389 + ) : versionMismatch ? (
2390 + <Tooltip>
2391 + <TooltipTrigger
2392 + render={
2393 + <button
2394 + type="button"
2395 + className="block max-w-full cursor-help truncate rounded-sm text-left"
2396 + >
2397 + Server update available
2398 + </button>
2399 + }
2400 + />
2401 + <TooltipPopup side="top">
2402 + {versionMismatchServerLabel} {versionMismatch.serverVersion}{" "}
2403 + <span aria-hidden="true">→</span> {versionMismatch.clientVersion}
2404 + </TooltipPopup>
2405 + </Tooltip>
2406 + ) : (
2407 + "Server update available"
2408 + ),
2409 description:
2410 serverUpdateState.status === "failed"
2411 ? serverUpdateState.message
2393 - : serverUpdateStageLabel(serverUpdateState.stage),
2412 + : serverUpdateState.status === "running"
2413 + ? serverUpdateStageLabel(serverUpdateState.stage)
2414 + : versionMismatchSelfUpdate !== null &&
2415 + (versionMismatchSelfUpdate !== "desktop-managed" ||
2416 + !versionMismatchDesktopAppUpdate)
2417 + ? serverUpdateGuidance(versionMismatchSelfUpdate)
2418 + : undefined,
2419 actions: updateInProgress ? (
2420 disconnectAction
2421 ) : !versionMismatch ||
@@ -2408,15 +2433,19 @@ export default function ChatView(props: ChatViewProps) {
2433 variant="ghost"
2434 />
2435 ),
2411 - ...(updateFailed
2412 - ? {
2436 + ...(updateInProgress || (!updateFailed && !versionMismatchDismissKey)
2437 + ? {}
2438 + : {
2439 dismissLabel: "Dismiss update notice",
2440 onDismiss: () => {
2415 - dismissServerUpdateFailure(serverUpdateState);
2416 - setDismissedServerUpdateState(serverUpdateState);
2441 + if (updateFailed) {
2442 + dismissServerUpdateFailure(serverUpdateState);
2443 + setDismissedServerUpdateState(serverUpdateState);
2444 + }
2445 + dismissVersionMismatch(versionMismatchDismissKey);
2446 + setDismissedVersionMismatchKey(versionMismatchDismissKey);
2447 },
2418 - }
2419 - : {}),
2448 + }),
2449 });
2450 }
2451 if (autoBalanceUpdateBanner) items.push(autoBalanceUpdateBanner);
@@ -3158,7 +3187,6 @@ export default function ChatView(props: ChatViewProps) {
3187 hasActiveProject: activeProject !== null && !showProviderSubagentBar,
3188 isGitRepo,
3189 showEnvironmentIndicator: showComposerEnvironmentIndicator,
3161 - serverUpdateAvailable: activeServerUpdate !== null,
3190 hostsRestingComposerControls: routeKind === "server",
3191 });
3192 const showComposerContextStrip = shouldShowComposerContextStrip({
@@ -3167,7 +3195,6 @@ export default function ChatView(props: ChatViewProps) {
3195 hasActiveProject: activeProject !== null && !showProviderSubagentBar,
3196 isGitRepo,
3197 showEnvironmentIndicator: showComposerEnvironmentIndicator,
3170 - serverUpdateAvailable: activeServerUpdate !== null,
3198 hostsRestingComposerControls: routeKind === "server" && restingComposerControlsVisible,
3199 });
3200 const mountComposerModelStrip =
@@ -8626,7 +8653,6 @@ export default function ChatView(props: ChatViewProps) {
8653 availableEnvironments={logicalProjectEnvironments}
8654 composerControlsHostRef={setRestingComposerControlsHost}
8655 contextStripVisible={showComposerContextStrip}
8629 - serverUpdate={activeServerUpdate}
8656 />
8657 </div>
8658 )}
apps/web/src/components/ServerUpdateAction.browser.test.tsx
+1 -109
@@ -3,12 +3,9 @@ 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, useState, type ReactNode } from "react";
6 +import { act, 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";
9
10 type SessionResult = AsyncResult.AsyncResult<AuthSessionState, Error>;
11 const testState = vi.hoisted(() => ({
@@ -59,7 +56,6 @@ vi.mock(import("./ui/toast"), async (original) => {
56 });
57
58 import {
62 - completeConfirmDialogClose,
59 readConfirmDialogState,
60 registerConfirmDialogHost,
61 resetConfirmDialogForTests,
@@ -73,8 +69,6 @@ import {
69 type ServerUpdateTarget,
70 } from "./ServerUpdateAction";
71
76 -import { BranchToolbarEnvironmentSelector } from "./BranchToolbarEnvironmentSelector";
77 -
72 const decodeSessionState = Schema.decodeUnknownSync(AuthSessionState);
73
74 const legacyAuth = {
@@ -515,105 +509,3 @@ describe("ServerUpdateProgress", () => {
509 );
510 });
511 });
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
+14 -34
@@ -18,7 +18,7 @@ import {
18 squashAtomCommandFailure,
19 } from "@t3tools/client-runtime/state/runtime";
20 import { CircleArrowUpIcon } from "lucide-react";
21 -import { type ComponentProps, type ReactNode, useRef, useState } from "react";
21 +import { type ComponentProps, useRef, useState } from "react";
22
23 import { requestConfirmDialog } from "~/confirmDialog";
24 import { useCopyToClipboard } from "~/hooks/useCopyToClipboard";
@@ -57,16 +57,6 @@ 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 -
60 type UpdateButtonProps = Pick<ComponentProps<typeof Button>, "variant" | "size" | "className"> & {
61 readonly label?: string;
62 readonly appearance?: "button" | "icon";
@@ -225,13 +215,8 @@ export function ServerUpdateAction({
215 size = "xs",
216 className,
217 appearance = "button",
228 - render,
229 -}: Omit<ServerUpdateTarget, "continueThreadsAfterServerUpdate"> &
230 - UpdateButtonProps & {
231 - readonly render?: (control: ServerUpdateControl) => ReactNode;
232 - }) {
218 +}: Omit<ServerUpdateTarget, "continueThreadsAfterServerUpdate"> & UpdateButtonProps) {
219 const isDesktopAppUpdate = selfUpdate === "desktop-managed";
234 - const unsupportedDesktopUpdate = isDesktopAppUpdate && !desktopAppUpdate;
220 const sessionStateAtom = environmentSession.sessionStateAtom(environmentId);
221 const canUpdate = canUpdateServer(useAtomValue(sessionStateAtom));
222 const continueThreadsAfterServerUpdate = useEnvironmentSettings(
@@ -263,7 +248,6 @@ export function ServerUpdateAction({
248
249 const handleUpdate = async () => {
250 if (
266 - unsupportedDesktopUpdate ||
251 !canUpdateServer(appAtomRegistry.get(sessionStateAtom)) ||
252 pendingUpdateEnvironmentIds.has(environmentId)
253 ) {
@@ -290,11 +274,18 @@ export function ServerUpdateAction({
274 });
275 };
276
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 +
285 const manualCommand =
286 selfUpdate === null ? manualServerUpdateCommand(targetVersion, installation) : null;
295 - const actionLabel = unsupportedDesktopUpdate
296 - ? "Update the desktop app on"
297 - : manualCommand !== null
287 + const actionLabel =
288 + manualCommand !== null
289 ? installation?.kind === "npm-global"
290 ? "Copy update command"
291 : "Copy relaunch command"
@@ -303,17 +294,6 @@ export function ServerUpdateAction({
294 manualCommand !== null
295 ? () => copyToClipboard(manualCommand, { command: manualCommand })
296 : () => 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 - }
297
298 if (appearance === "icon") {
299 return (
@@ -325,7 +305,7 @@ export function ServerUpdateAction({
305 variant="ghost-muted"
306 className={className}
307 aria-label={`${actionLabel} for ${serverLabel}`}
328 - disabled={disabled}
308 + disabled={manualCommand === null && !canUpdate}
309 onClick={onClick}
310 />
311 }
@@ -342,7 +322,7 @@ export function ServerUpdateAction({
322 size={size}
323 variant={variant}
324 className={className}
345 - disabled={disabled}
325 + disabled={manualCommand === null && !canUpdate}
326 onClick={onClick}
327 >
328 {actionLabel}
apps/web/src/versionSkew.test.ts
+6
@@ -17,6 +17,7 @@ import {
17 resolveServerConfigVersionMismatch,
18 resolveServerSelfUpdateCapability,
19 resolveVersionMismatch,
20 + serverUpdateGuidance,
21 supportsDesktopAppUpdate,
22 } from "./versionSkew";
23
@@ -235,4 +236,9 @@ describe("versionSkew", () => {
236 expect(supportsDesktopAppUpdate(descriptor())).toBe(false);
237 expect(supportsDesktopAppUpdate(null)).toBe(false);
238 });
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 + });
244 });
apps/web/src/versionSkew.ts
+4
@@ -114,6 +114,10 @@ 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 +
121 export function buildVersionMismatchDismissalKey(
122 environmentId: EnvironmentId,
123 mismatch: Pick<VersionMismatch, "clientVersion" | "serverVersion">,