Skip to content
TypeScript

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

Theo Browne5547d7c13cf7
diff --git a/apps/web/src/components/BranchToolbar.logic.test.ts b/apps/web/src/components/BranchToolbar.logic.test.ts
index 33dd09d60c0..7493ba2b795 100644
--- a/apps/web/src/components/BranchToolbar.logic.test.ts
+++ b/apps/web/src/components/BranchToolbar.logic.test.ts
@@ -424,37 +424,6 @@ describe("shouldShowEnvironmentIndicator", () => {
});
describe("shouldShowComposerContextStrip", () => {
- it("keeps a sole primary server update reachable in a non-Git draft", () => {
- const environment = {
- activeEnvironment: { isPrimary: true },
- canPickEnvironment: false,
- serverUpdateAvailable: true,
- };
- const showEnvironmentIndicator = shouldShowEnvironmentIndicator(environment);
- expect(showEnvironmentIndicator).toBe(true);
- expect(
- shouldShowComposerContextStrip({
- isDraftHeroState: true,
- persistInActiveThreads: false,
- hasActiveProject: true,
- isGitRepo: false,
- showEnvironmentIndicator,
- hostsRestingComposerControls: false,
- }),
- ).toBe(true);
- expect(
- shouldShowComposerContextStrip({
- isDraftHeroState: false,
- persistInActiveThreads: false,
- hasActiveProject: true,
- isGitRepo: false,
- showEnvironmentIndicator,
- serverUpdateAvailable: true,
- hostsRestingComposerControls: false,
- }),
- ).toBe(true);
- });
-
it.each([false, true])(
"honors the active-thread preference with resting controls %s",
(hostsRestingComposerControls) => {
diff --git a/apps/web/src/components/BranchToolbar.logic.ts b/apps/web/src/components/BranchToolbar.logic.ts
index 55ac56e0996..24db217304a 100644
--- a/apps/web/src/components/BranchToolbar.logic.ts
+++ b/apps/web/src/components/BranchToolbar.logic.ts
@@ -59,9 +59,8 @@ export function resolveEnvironmentOptionLabel(input: {
export function shouldShowEnvironmentIndicator(input: {
activeEnvironment: Pick<EnvironmentOption, "isPrimary"> | null;
canPickEnvironment: boolean;
- serverUpdateAvailable?: boolean;
}): boolean {
- if (input.canPickEnvironment || input.serverUpdateAvailable) return true;
+ if (input.canPickEnvironment) return true;
return input.activeEnvironment !== null && !input.activeEnvironment.isPrimary;
}
@@ -72,13 +71,10 @@ export function shouldShowComposerContextStrip(input: {
isGitRepo: boolean;
showEnvironmentIndicator: boolean;
hostsRestingComposerControls: boolean;
- serverUpdateAvailable?: boolean;
}): boolean {
return (
input.hasActiveProject &&
- (input.isDraftHeroState ||
- input.persistInActiveThreads ||
- input.serverUpdateAvailable === true) &&
+ (input.isDraftHeroState || input.persistInActiveThreads) &&
(input.isGitRepo || input.showEnvironmentIndicator || input.hostsRestingComposerControls)
);
}
diff --git a/apps/web/src/components/BranchToolbar.panel.browser.test.tsx b/apps/web/src/components/BranchToolbar.panel.browser.test.tsx
index 51ce200a53e..affead3c169 100644
--- a/apps/web/src/components/BranchToolbar.panel.browser.test.tsx
+++ b/apps/web/src/components/BranchToolbar.panel.browser.test.tsx
@@ -19,10 +19,6 @@ vi.mock(import("../localApi"), async (original) => ({
vi.mock(import("../hooks/useCopyToClipboard"), async (original) => ({
...(await original()),
writeTextToClipboard: state.writeTextToClipboard,
- useCopyToClipboard: ((options: { target: string }) => ({
- copyToClipboard: (command: string) => state.writeTextToClipboard(command, options.target),
- isCopied: false,
- })) as never,
}));
vi.mock(import("./BranchToolbarBranchSelector"), async (original) => ({
...(await original()),
@@ -35,8 +31,6 @@ vi.mock(import("../state/entities"), async (original) => ({
}));
import { BranchToolbar } from "./BranchToolbar";
-import { ComposerSurface } from "./chat/ComposerSurface";
-import type { ServerUpdateTarget } from "./ServerUpdateAction";
let root: Root;
let container: HTMLDivElement;
@@ -60,24 +54,22 @@ afterEach(async () => {
function render(props: Partial<ComponentProps<typeof BranchToolbar>>) {
return act(async () =>
root.render(
- <ComposerSurface.Shell>
- <BranchToolbar
- layout="panel"
- panelSection="workspace"
- environmentId={EnvironmentId.make("local")}
- threadId={ThreadId.make("thread")}
- projectId={ProjectId.make("project")}
- worktreePath={state.worktreePath}
- isServerThread
- showGitControls
- envMode="local"
- envLocked={false}
- startFromOrigin={false}
- onStartFromOriginChange={vi.fn()}
- onEnvModeChange={vi.fn()}
- {...props}
- />
- </ComposerSurface.Shell>,
+ <BranchToolbar
+ layout="panel"
+ panelSection="workspace"
+ environmentId={EnvironmentId.make("local")}
+ threadId={ThreadId.make("thread")}
+ projectId={ProjectId.make("project")}
+ worktreePath={state.worktreePath}
+ isServerThread
+ showGitControls
+ envMode="local"
+ envLocked={false}
+ startFromOrigin={false}
+ onStartFromOriginChange={vi.fn()}
+ onEnvModeChange={vi.fn()}
+ {...props}
+ />,
),
);
}
@@ -153,55 +145,3 @@ it.each([
}
},
);
-
-it.each([
- { layout: "wide Git", width: 900, showGitControls: true },
- { layout: "narrow Git", width: 360, showGitControls: true },
- { layout: "sole primary non-Git", width: 360, showGitControls: false },
-])(
- "copies the pending update from the $layout composer chip",
- async ({ width, showGitControls }) => {
- await page.viewport(1000, 700);
- container.style.width = `${width}px`;
- container.style.setProperty("--chat-content-max-width", `${width}px`);
- const serverUpdate = {
- environmentId: EnvironmentId.make("local"),
- serverLabel: "Build box",
- serverVersion: "0.0.30",
- targetVersion: "0.0.31",
- selfUpdate: null,
- installation: { kind: "npm-global", prefix: "/opt/node" },
- } satisfies ServerUpdateTarget & { serverVersion: string };
- await render({
- layout: "composer",
- envLocked: showGitControls,
- showGitControls,
- availableEnvironments: [
- {
- environmentId: serverUpdate.environmentId,
- projectId: ProjectId.make("project"),
- label: serverUpdate.serverLabel,
- isPrimary: true,
- machine: "server",
- },
- ],
- serverUpdate,
- });
-
- expect(
- container.querySelector('[data-slot="composer-shell"]')!.getBoundingClientRect().width,
- ).toBe(width);
- const chip = page.getByRole("button", { name: /Build box|Copy update command/ });
- await expect.element(chip).toBeVisible();
- await userEvent.hover(chip);
- await expect.element(page.getByRole("tooltip")).toMatchTextContent("0.0.30");
- await expect.element(page.getByRole("tooltip")).toMatchTextContent("0.0.31");
- await userEvent.click(chip);
- await vi.waitFor(() =>
- expect(state.writeTextToClipboard).toHaveBeenCalledWith(
- "npm install --global --prefix '/opt/node' [email protected]",
- "update command",
- ),
- );
- },
-);
diff --git a/apps/web/src/components/BranchToolbar.tsx b/apps/web/src/components/BranchToolbar.tsx
index 2447ae3e1eb..d4116565c8a 100644
--- a/apps/web/src/components/BranchToolbar.tsx
+++ b/apps/web/src/components/BranchToolbar.tsx
@@ -47,7 +47,6 @@ import {
import { BranchToolbarEnvironmentSelector } from "./BranchToolbarEnvironmentSelector";
import { openAddProjectToMachine } from "./AddProjectToMachineDialog";
import { type AddProjectTarget, useAddProjectTargets } from "../hooks/useAddProjectTargets";
-import type { PendingServerUpdate } from "./ServerUpdateAction";
import { BranchToolbarEnvModeSelector } from "./BranchToolbarEnvModeSelector";
import { PreviousWorktreeItemContent } from "./PreviousWorktreeItemContent";
import { ThreadDetailsControl } from "./chat/ThreadDetailsControl";
@@ -112,7 +111,6 @@ interface BranchToolbarProps {
onEnvironmentChange?: (environmentId: EnvironmentId) => void;
composerControlsHostRef?: (element: HTMLDivElement | null) => void;
contextStripVisible?: boolean;
- serverUpdate?: PendingServerUpdate | null;
}
function showWorkspaceContextMenu(event: ReactMouseEvent, workspacePath: string) {
@@ -634,7 +632,6 @@ export const BranchToolbar = memo(function BranchToolbar({
onEnvironmentChange,
composerControlsHostRef,
contextStripVisible = true,
- serverUpdate = null,
}: BranchToolbarProps) {
const branchSelectorRef = useRef<BranchToolbarBranchSelectorHandle>(null);
const threadRef = scopeThreadRef(environmentId, threadId);
@@ -700,7 +697,6 @@ export const BranchToolbar = memo(function BranchToolbar({
const showEnvironmentIndicator = shouldShowEnvironmentIndicator({
activeEnvironment: activeEnvironmentOption,
canPickEnvironment: hasMultipleEnvironments,
- serverUpdateAvailable: serverUpdate !== null,
});
const [stripElement, setStripElement] = useState<HTMLDivElement | null>(null);
const labelsOverflow = useLabelsOverflow(stripElement);
@@ -767,18 +763,6 @@ export const BranchToolbar = memo(function BranchToolbar({
!contextStripVisible && "pointer-events-none invisible absolute inset-x-0 top-full",
)}
>
- {serverUpdate && availableEnvironments ? (
- <BranchToolbarEnvironmentSelector
- autoEnvironmentLabel={autoEnvironmentLabel}
- onAutoEnvironment={onAutoEnvironment}
- envLocked={envLocked}
- environmentId={environmentId}
- availableEnvironments={availableEnvironments}
- {...(showEnvironmentPicker ? { onEnvironmentChange } : {})}
- {...(addTargets.length > 0 ? { onAddToMachine: () => onAddToMachine(null) } : {})}
- serverUpdate={serverUpdate}
- />
- ) : null}
{showGitControls ? (
<div className="contents @3xl/composer-surface:hidden">
<RunContextSelector
@@ -789,8 +773,8 @@ export const BranchToolbar = memo(function BranchToolbar({
envModeLocked={envModeLocked}
environmentId={environmentId}
availableEnvironments={availableEnvironments}
- showEnvironmentPicker={showEnvironmentPicker && serverUpdate === null}
- showEnvironmentIndicator={showEnvironmentIndicator && serverUpdate === null}
+ showEnvironmentPicker={showEnvironmentPicker}
+ showEnvironmentIndicator={showEnvironmentIndicator}
onEnvironmentChange={onEnvironmentChange}
effectiveEnvMode={effectiveEnvMode}
activeWorktreePath={activeWorktreePath}
@@ -803,7 +787,7 @@ export const BranchToolbar = memo(function BranchToolbar({
/>
</div>
) : null}
- {showGitControls || (showEnvironmentIndicator && serverUpdate === null) ? (
+ {showGitControls || showEnvironmentIndicator ? (
<div
className={cn(
"min-h-7 min-w-10 items-center gap-1 sm:min-h-6",
@@ -813,17 +797,15 @@ export const BranchToolbar = memo(function BranchToolbar({
>
{showEnvironmentIndicator && availableEnvironments && (
<>
- {serverUpdate === null ? (
- <BranchToolbarEnvironmentSelector
- autoEnvironmentLabel={autoEnvironmentLabel}
- onAutoEnvironment={onAutoEnvironment}
- envLocked={envLocked}
- environmentId={environmentId}
- availableEnvironments={availableEnvironments}
- {...(showEnvironmentPicker ? { onEnvironmentChange } : {})}
- {...(addTargets.length > 0 ? { onAddToMachine: () => onAddToMachine(null) } : {})}
- />
- ) : null}
+ <BranchToolbarEnvironmentSelector
+ autoEnvironmentLabel={autoEnvironmentLabel}
+ onAutoEnvironment={onAutoEnvironment}
+ envLocked={envLocked}
+ environmentId={environmentId}
+ availableEnvironments={availableEnvironments}
+ {...(showEnvironmentPicker ? { onEnvironmentChange } : {})}
+ {...(addTargets.length > 0 ? { onAddToMachine: () => onAddToMachine(null) } : {})}
+ />
{showGitControls ? (
<Separator
orientation="vertical"
diff --git a/apps/web/src/components/BranchToolbarEnvironmentSelector.tsx b/apps/web/src/components/BranchToolbarEnvironmentSelector.tsx
index d505cdecae7..b2f4d09f13f 100644
--- a/apps/web/src/components/BranchToolbarEnvironmentSelector.tsx
+++ b/apps/web/src/components/BranchToolbarEnvironmentSelector.tsx
@@ -1,19 +1,14 @@
-import { ComposerControl, ComposerSelectControl } from "./chat/ComposerControl";
+import { ComposerSelectControl } from "./chat/ComposerControl";
import { ComposerContextLabel } from "./ComposerContextLabel";
import { Tooltip, TooltipTrigger, TooltipPopup } from "./ui/tooltip";
import { useAtomValue } from "@effect/atom-react";
import { shortcutLabelForCommand } from "../keybindings";
import { primaryServerKeybindingsAtom } from "../state/server";
import type { EnvironmentId } from "@t3tools/contracts";
-import { CircleArrowUpIcon, PlusIcon, ScaleIcon } from "lucide-react";
+import { PlusIcon, ScaleIcon } from "lucide-react";
import { memo } from "react";
import { ADD_TO_MACHINE_LABEL_CLASS, type EnvironmentOption } from "./BranchToolbar.logic";
-import {
- ServerUpdateAction,
- type PendingServerUpdate,
- type ServerUpdateControl,
-} from "./ServerUpdateAction";
import { EnvironmentMachineIcon } from "./EnvironmentMachineIcon";
import { useComposerMenuProps } from "./chat/composerEventScope";
import {
@@ -33,29 +28,14 @@ interface BranchToolbarEnvironmentSelectorProps {
availableEnvironments: readonly EnvironmentOption[];
onEnvironmentChange?: (environmentId: EnvironmentId) => void;
onAddToMachine?: (() => void) | undefined;
- serverUpdate?: PendingServerUpdate | null;
}
// Action values cannot collide with server-minted environment IDs.
const AUTO_VALUE = "action:auto";
-const UPDATE_VALUE = "action:update";
const ADD_MACHINE_VALUE = "action:add-machine";
const environmentValue = (id: EnvironmentId) => `env:${id}`;
-export const BranchToolbarEnvironmentSelector = memo(function BranchToolbarEnvironmentSelector(
- props: BranchToolbarEnvironmentSelectorProps,
-) {
- return props.serverUpdate ? (
- <ServerUpdateAction
- {...props.serverUpdate}
- render={(updateControl) => <EnvironmentSelector {...props} updateControl={updateControl} />}
- />
- ) : (
- <EnvironmentSelector {...props} updateControl={null} />
- );
-});
-
-function EnvironmentSelector({
+export const BranchToolbarEnvironmentSelector = memo(function BranchToolbarEnvironmentSelector({
autoEnvironmentLabel,
onAutoEnvironment,
envLocked,
@@ -63,11 +43,7 @@ function EnvironmentSelector({
availableEnvironments,
onEnvironmentChange,
onAddToMachine,
- serverUpdate,
- updateControl,
-}: BranchToolbarEnvironmentSelectorProps & {
- updateControl: ServerUpdateControl | null;
-}) {
+}: BranchToolbarEnvironmentSelectorProps) {
const composerFloatingLayerProps = useComposerMenuProps();
const shortcutLabel = shortcutLabelForCommand(
useAtomValue(primaryServerKeybindingsAtom),
@@ -84,34 +60,8 @@ function EnvironmentSelector({
value: environmentValue(env.environmentId),
label: env.label,
})),
- ...(serverUpdate && updateControl
- ? [{ value: UPDATE_VALUE, label: `${updateControl.label} ${serverUpdate.serverLabel}` }]
- : []),
...(onAddToMachine ? [{ value: ADD_MACHINE_VALUE, label: "Add to another machine" }] : []),
];
- const updateTooltip = serverUpdate
- ? `${serverUpdate.serverLabel} ${serverUpdate.serverVersion} → ${serverUpdate.targetVersion}. ${
- serverUpdate.selfUpdate === "desktop-managed" && !serverUpdate.desktopAppUpdate
- ? "Update the desktop app on that machine."
- : (updateControl?.label ?? "Update")
- }`
- : null;
- const environmentIcon = serverUpdate ? (
- <CircleArrowUpIcon aria-hidden="true" className="size-3 shrink-0" />
- ) : (
- <EnvironmentMachineIcon
- kind={activeEnvironment?.machine ?? "server"}
- className="size-3 shrink-0"
- />
- );
- const chipBody = (
- <>
- {environmentIcon}
- <ComposerContextLabel>
- {activeEnvironment?.label ?? serverUpdate?.serverLabel ?? "Run on"}
- </ComposerContextLabel>
- </>
- );
// The static label carries the xs control's height (h-7 sm:h-6) as well as
// its padding: the composer context strip has no min-height of its own, and
@@ -119,41 +69,22 @@ function EnvironmentSelector({
// a shorter label would drag the seam out of line whenever this label is the
// only thing in the strip.
if (envLocked || (onEnvironmentChange === undefined && onAddToMachine === undefined)) {
- const lockedRow = updateControl ? (
- <ComposerControl
- size="xs"
- className="min-w-0 max-w-full"
- aria-label={`${updateControl.label} ${serverUpdate?.serverLabel}`}
- disabled={updateControl.disabled}
- onClick={updateControl.onClick}
- data-composer-context-control
- >
- {chipBody}
- </ComposerControl>
- ) : (
+ const lockedRow = (
<span
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"
data-composer-context-control
>
- {chipBody}
+ <EnvironmentMachineIcon
+ kind={activeEnvironment?.machine ?? "server"}
+ className="size-3 shrink-0"
+ />
+ <ComposerContextLabel>{activeEnvironment?.label ?? "Run on"}</ComposerContextLabel>
</span>
);
return (
<Tooltip>
- <TooltipTrigger
- render={
- updateControl?.disabled ? (
- <span className="inline-flex min-w-0 max-w-full" data-composer-context-control>
- {lockedRow}
- </span>
- ) : (
- lockedRow
- )
- }
- />
- <TooltipPopup role={serverUpdate ? "tooltip" : undefined}>
- {updateTooltip ?? activeEnvironment?.label ?? "Run on"}
- </TooltipPopup>
+ <TooltipTrigger render={lockedRow} />
+ <TooltipPopup>{activeEnvironment?.label ?? "Run on"}</TooltipPopup>
</Tooltip>
);
}
@@ -163,9 +94,7 @@ function EnvironmentSelector({
modal={false}
value={autoEnvironmentLabel ? AUTO_VALUE : environmentValue(environmentId)}
onValueChange={(value) => {
- if (value === UPDATE_VALUE) {
- updateControl?.onClick();
- } else if (value === ADD_MACHINE_VALUE) {
+ if (value === ADD_MACHINE_VALUE) {
onAddToMachine?.();
} else if (value === AUTO_VALUE) {
onAutoEnvironment?.();
@@ -190,14 +119,17 @@ function EnvironmentSelector({
{autoEnvironmentLabel ? (
<ScaleIcon className="size-3 shrink-0" aria-hidden="true" />
) : (
- environmentIcon
+ <EnvironmentMachineIcon
+ kind={activeEnvironment?.machine ?? "server"}
+ className="size-3 shrink-0"
+ />
)}
<ComposerContextLabel>
<SelectValue />
</ComposerContextLabel>
</TooltipTrigger>
- <TooltipPopup role={serverUpdate ? "tooltip" : undefined}>
- {updateTooltip ?? autoEnvironmentLabel ?? activeEnvironment?.label ?? "Run on"}
+ <TooltipPopup>
+ {autoEnvironmentLabel ?? activeEnvironment?.label ?? "Run on"}
{shortcutLabel ? ` · ${shortcutLabel}` : null}
</TooltipPopup>
</Tooltip>
@@ -224,11 +156,7 @@ function EnvironmentSelector({
disabled={onEnvironmentChange === undefined && env.environmentId !== environmentId}
>
<span className="inline-flex items-center gap-1.5">
- {serverUpdate?.environmentId === env.environmentId ? (
- <CircleArrowUpIcon aria-hidden="true" className="size-3" />
- ) : (
- <EnvironmentMachineIcon kind={env.machine} className="size-3" />
- )}
+ <EnvironmentMachineIcon kind={env.machine} className="size-3" />
{env.label}
</span>
</SelectItem>
@@ -242,18 +170,7 @@ function EnvironmentSelector({
</SelectItem>
) : null}
</SelectGroup>
- {serverUpdate && updateControl ? (
- <SelectGroup>
- <SelectGroupLabel>Server update</SelectGroupLabel>
- <SelectItem value={UPDATE_VALUE} disabled={updateControl.disabled}>
- <span className="inline-flex items-center gap-1.5">
- <CircleArrowUpIcon aria-hidden="true" className="size-3" />
- {updateControl.label} {serverUpdate.serverLabel}
- </span>
- </SelectItem>
- </SelectGroup>
- ) : null}
</SelectPopup>
</Select>
);
-}
+});
diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx
index 05a6bec7fa9..f7e72a6c3ea 100644
--- a/apps/web/src/components/ChatView.tsx
+++ b/apps/web/src/components/ChatView.tsx
@@ -553,10 +553,14 @@ import { ServerUpdateAction, serverUpdateStageLabel } from "./ServerUpdateAction
import { useAutoBalanceUpdateBanner } from "./chat/useAutoBalanceUpdateBanner";
import { ComposerServerUpdateIcon } from "./chat/ComposerServerUpdateStatus";
import {
+ buildVersionMismatchDismissalKey,
dismissServerUpdateFailure,
+ dismissVersionMismatch,
isServerUpdateFailureDismissed,
+ isVersionMismatchDismissed,
resolveServerConfigVersionMismatch,
resolveServerSelfUpdateCapability,
+ serverUpdateGuidance,
supportsDesktopAppUpdate,
supportsServerUpdateThreadContinuation,
} from "../versionSkew";
@@ -2125,6 +2129,10 @@ export default function ChatView(props: ChatViewProps) {
logicalProjectEnvironments.find(
(environment) => environment.environmentId === activeThread?.environmentId,
) ?? null;
+ const showComposerEnvironmentIndicator = shouldShowEnvironmentIndicator({
+ activeEnvironment: activeEnvironmentOption,
+ canPickEnvironment: hasMultipleEnvironments,
+ });
const openPullRequestDialog = (reference?: string) => {
if (!canCheckoutPullRequestIntoThread) {
return;
@@ -2275,6 +2283,18 @@ export default function ChatView(props: ChatViewProps) {
: EMPTY_AUTO_UPDATE_ENVIRONMENTS;
const autoBalanceUpdateBanner = useAutoBalanceUpdateBanner(autoUpdateEnvironments);
const versionMismatch = resolveServerConfigVersionMismatch(serverConfig);
+ const versionMismatchDismissKey =
+ versionMismatch && activeThread
+ ? buildVersionMismatchDismissalKey(activeThread.environmentId, versionMismatch)
+ : null;
+ const [dismissedVersionMismatchKey, setDismissedVersionMismatchKey] = useState<string | null>(
+ null,
+ );
+ const versionMismatchDismissed =
+ versionMismatchDismissKey === dismissedVersionMismatchKey ||
+ isVersionMismatchDismissed(versionMismatchDismissKey);
+ const showVersionMismatchBanner =
+ versionMismatch !== null && versionMismatchDismissKey !== null && !versionMismatchDismissed;
const hasMultipleRegisteredEnvironments = environments.length > 1;
const versionMismatchServerLabel =
hasMultipleRegisteredEnvironments && activeThread
@@ -2294,30 +2314,6 @@ export default function ChatView(props: ChatViewProps) {
const serverUpdateFailureDismissed =
serverUpdateState === dismissedServerUpdateState ||
isServerUpdateFailureDismissed(serverUpdateState);
- const activeServerUpdate =
- !automaticEnvironment &&
- serverUpdateEnvironmentId &&
- versionMismatch &&
- serverUpdateState.status === "idle"
- ? {
- environmentId: serverUpdateEnvironmentId,
- serverLabel:
- activeEnvironmentOption?.label ??
- serverConfig?.environment.label ??
- versionMismatchServerLabel,
- serverVersion: versionMismatch.serverVersion,
- targetVersion: versionMismatch.clientVersion,
- selfUpdate: versionMismatchSelfUpdate,
- installation: versionMismatchInstallation,
- desktopAppUpdate: versionMismatchDesktopAppUpdate,
- threadContinuation: versionMismatchThreadContinuation,
- }
- : null;
- const showComposerEnvironmentIndicator = shouldShowEnvironmentIndicator({
- activeEnvironment: activeEnvironmentOption,
- canPickEnvironment: hasMultipleEnvironments,
- serverUpdateAvailable: activeServerUpdate !== null,
- });
const systemComposerBannerItems = (() => {
const items: ComposerBannerStackItem[] = [];
const updateRunning = serverUpdateState.status === "running";
@@ -2376,8 +2372,9 @@ export default function ChatView(props: ChatViewProps) {
if (
!automaticEnvironment &&
serverUpdateEnvironmentId &&
- serverUpdateState.status !== "idle" &&
- !serverUpdateFailureDismissed
+ (serverUpdateState.status === "idle"
+ ? showVersionMismatchBanner
+ : !serverUpdateFailureDismissed)
) {
const updateInProgress = serverUpdateState.status === "running";
const updateFailed = serverUpdateState.status === "failed";
@@ -2386,11 +2383,39 @@ export default function ChatView(props: ChatViewProps) {
variant: updateFailed ? "error" : "default",
priority: updateInProgress ? "urgent" : "notice",
icon: <ComposerServerUpdateIcon status={serverUpdateState.status} />,
- title: `${updateFailed ? "Could not update" : "Updating"} ${versionMismatchServerLabel}`,
+ title:
+ updateInProgress || updateFailed ? (
+ `${updateFailed ? "Could not update" : "Updating"} ${versionMismatchServerLabel}`
+ ) : versionMismatch ? (
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <button
+ type="button"
+ className="block max-w-full cursor-help truncate rounded-sm text-left"
+ >
+ Server update available
+ </button>
+ }
+ />
+ <TooltipPopup side="top">
+ {versionMismatchServerLabel} {versionMismatch.serverVersion}{" "}
+ <span aria-hidden="true">→</span> {versionMismatch.clientVersion}
+ </TooltipPopup>
+ </Tooltip>
+ ) : (
+ "Server update available"
+ ),
description:
serverUpdateState.status === "failed"
? serverUpdateState.message
- : serverUpdateStageLabel(serverUpdateState.stage),
+ : serverUpdateState.status === "running"
+ ? serverUpdateStageLabel(serverUpdateState.stage)
+ : versionMismatchSelfUpdate !== null &&
+ (versionMismatchSelfUpdate !== "desktop-managed" ||
+ !versionMismatchDesktopAppUpdate)
+ ? serverUpdateGuidance(versionMismatchSelfUpdate)
+ : undefined,
actions: updateInProgress ? (
disconnectAction
) : !versionMismatch ||
@@ -2408,15 +2433,19 @@ export default function ChatView(props: ChatViewProps) {
variant="ghost"
/>
),
- ...(updateFailed
- ? {
+ ...(updateInProgress || (!updateFailed && !versionMismatchDismissKey)
+ ? {}
+ : {
dismissLabel: "Dismiss update notice",
onDismiss: () => {
- dismissServerUpdateFailure(serverUpdateState);
- setDismissedServerUpdateState(serverUpdateState);
+ if (updateFailed) {
+ dismissServerUpdateFailure(serverUpdateState);
+ setDismissedServerUpdateState(serverUpdateState);
+ }
+ dismissVersionMismatch(versionMismatchDismissKey);
+ setDismissedVersionMismatchKey(versionMismatchDismissKey);
},
- }
- : {}),
+ }),
});
}
if (autoBalanceUpdateBanner) items.push(autoBalanceUpdateBanner);
@@ -3158,7 +3187,6 @@ export default function ChatView(props: ChatViewProps) {
hasActiveProject: activeProject !== null && !showProviderSubagentBar,
isGitRepo,
showEnvironmentIndicator: showComposerEnvironmentIndicator,
- serverUpdateAvailable: activeServerUpdate !== null,
hostsRestingComposerControls: routeKind === "server",
});
const showComposerContextStrip = shouldShowComposerContextStrip({
@@ -3167,7 +3195,6 @@ export default function ChatView(props: ChatViewProps) {
hasActiveProject: activeProject !== null && !showProviderSubagentBar,
isGitRepo,
showEnvironmentIndicator: showComposerEnvironmentIndicator,
- serverUpdateAvailable: activeServerUpdate !== null,
hostsRestingComposerControls: routeKind === "server" && restingComposerControlsVisible,
});
const mountComposerModelStrip =
@@ -8626,7 +8653,6 @@ export default function ChatView(props: ChatViewProps) {
availableEnvironments={logicalProjectEnvironments}
composerControlsHostRef={setRestingComposerControlsHost}
contextStripVisible={showComposerContextStrip}
- serverUpdate={activeServerUpdate}
/>
</div>
)}
diff --git a/apps/web/src/components/ServerUpdateAction.browser.test.tsx b/apps/web/src/components/ServerUpdateAction.browser.test.tsx
index 25d56d69dff..8a86d2d37bb 100644
--- a/apps/web/src/components/ServerUpdateAction.browser.test.tsx
+++ b/apps/web/src/components/ServerUpdateAction.browser.test.tsx
@@ -3,12 +3,9 @@ import { AuthSessionState, type EnvironmentId, type ServerInstallation } from "@
import * as Cause from "effect/Cause";
import * as Schema from "effect/Schema";
import { AsyncResult, Atom } from "effect/reactivity";
-import { act, useState, type ReactNode } from "react";
+import { act, type ReactNode } from "react";
import { createRoot, type Root } from "react-dom/client";
import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
-import { page, userEvent } from "vite-plus/test/browser";
-
-import "~/index.css";
type SessionResult = AsyncResult.AsyncResult<AuthSessionState, Error>;
const testState = vi.hoisted(() => ({
@@ -59,7 +56,6 @@ vi.mock(import("./ui/toast"), async (original) => {
});
import {
- completeConfirmDialogClose,
readConfirmDialogState,
registerConfirmDialogHost,
resetConfirmDialogForTests,
@@ -73,8 +69,6 @@ import {
type ServerUpdateTarget,
} from "./ServerUpdateAction";
-import { BranchToolbarEnvironmentSelector } from "./BranchToolbarEnvironmentSelector";
-
const decodeSessionState = Schema.decodeUnknownSync(AuthSessionState);
const legacyAuth = {
@@ -515,105 +509,3 @@ describe("ServerUpdateProgress", () => {
);
});
});
-
-describe("server updates from the environment selector", () => {
- const localId = "env-test" as EnvironmentId;
- const otherId = "update-server" as EnvironmentId;
- const availableEnvironments = [
- { environmentId: localId, label: "Build box", isPrimary: true },
- { environmentId: otherId, label: "Other machine", isPrimary: false },
- ].map((environment) => ({ ...environment, projectId: null, machine: "server" as const }));
- const serverUpdate = {
- environmentId: localId,
- serverLabel: "Build box",
- serverVersion: "0.0.30",
- targetVersion: "0.0.31",
- selfUpdate: "desktop-managed",
- desktopAppUpdate: true,
- } satisfies ServerUpdateTarget & { serverVersion: string };
-
- it("confirms a locked chip update and honors cancellation before updating", async () => {
- registerConfirmDialogHost();
- testState.updateServer.mockResolvedValue(success("desktop-app"));
- await render(
- <BranchToolbarEnvironmentSelector
- environmentId={localId}
- availableEnvironments={availableEnvironments}
- envLocked
- serverUpdate={serverUpdate}
- />,
- );
- const chip = page.getByRole("button", { name: /Build box|Update/ });
- await userEvent.click(chip);
- expect(readConfirmDialogState()).toMatchObject({
- status: "confirming",
- message: expect.stringContaining("Build box"),
- });
- expect(testState.updateServer).not.toHaveBeenCalled();
- await act(async () => {
- respondToConfirmDialog(false);
- completeConfirmDialogClose();
- });
- expect(testState.updateServer).not.toHaveBeenCalled();
- await userEvent.click(chip);
- await act(async () => respondToConfirmDialog(true));
- expect(testState.updateServer).toHaveBeenCalledExactlyOnceWith({
- environmentId: localId,
- input: { targetVersion: "0.0.31" },
- });
- });
-
- it("copies from the picker without switching machines and still selects an action-like environment ID", async () => {
- const update = { ...serverUpdate, selfUpdate: null, installation: { kind: "npx" } } as const;
- function Picker() {
- const [environmentId, setEnvironmentId] = useState(localId);
- return (
- <BranchToolbarEnvironmentSelector
- environmentId={environmentId}
- availableEnvironments={availableEnvironments}
- envLocked={false}
- onEnvironmentChange={setEnvironmentId}
- serverUpdate={environmentId === localId ? update : null}
- />
- );
- }
- await render(<Picker />);
- const picker = page.getByRole("combobox", { name: "Run on" });
- await userEvent.click(picker);
- await expect.element(page.getByRole("option", { name: "Other machine" })).toBeVisible();
- expect(testState.clipboard).not.toHaveBeenCalled();
- await userEvent.click(page.getByRole("option", { name: /Copy relaunch command/ }));
- expect(testState.clipboard).toHaveBeenCalledExactlyOnceWith("npx [email protected]");
- expect(testState.updateServer).not.toHaveBeenCalled();
- await expect.element(picker).toHaveTextContent("Build box");
- await userEvent.click(picker);
- await expect
- .element(page.getByRole("option", { name: "Build box", exact: true }))
- .toHaveAttribute("aria-selected", "true");
- await userEvent.click(page.getByRole("option", { name: "Other machine" }));
- await expect.element(picker).toHaveTextContent("Other machine");
- expect(testState.clipboard).toHaveBeenCalledTimes(1);
- expect(testState.updateServer).not.toHaveBeenCalled();
- });
-
- it("explains an unsupported desktop update in the picker without offering a runnable action", async () => {
- registerConfirmDialogHost();
- await render(
- <BranchToolbarEnvironmentSelector
- environmentId={localId}
- availableEnvironments={availableEnvironments}
- envLocked={false}
- onEnvironmentChange={vi.fn()}
- serverUpdate={{ ...serverUpdate, desktopAppUpdate: false }}
- />,
- );
- await userEvent.click(page.getByRole("combobox", { name: "Run on" }));
- const instruction = page.getByRole("option", { name: /Update the desktop app/ });
- await expect.element(instruction).toBeVisible();
- await expect.element(instruction).toHaveAttribute("aria-disabled", "true");
- await userEvent.click(instruction, { force: true });
- expect(readConfirmDialogState().status).toBe("idle");
- expect(testState.updateServer).not.toHaveBeenCalled();
- expect(testState.clipboard).not.toHaveBeenCalled();
- });
-});
diff --git a/apps/web/src/components/ServerUpdateAction.tsx b/apps/web/src/components/ServerUpdateAction.tsx
index dd9ff5a147c..3d809655e28 100644
--- a/apps/web/src/components/ServerUpdateAction.tsx
+++ b/apps/web/src/components/ServerUpdateAction.tsx
@@ -18,7 +18,7 @@ import {
squashAtomCommandFailure,
} from "@t3tools/client-runtime/state/runtime";
import { CircleArrowUpIcon } from "lucide-react";
-import { type ComponentProps, type ReactNode, useRef, useState } from "react";
+import { type ComponentProps, useRef, useState } from "react";
import { requestConfirmDialog } from "~/confirmDialog";
import { useCopyToClipboard } from "~/hooks/useCopyToClipboard";
@@ -57,16 +57,6 @@ export interface ServerUpdateTarget {
readonly continueThreadsAfterServerUpdate?: boolean;
}
-export type PendingServerUpdate = Omit<ServerUpdateTarget, "continueThreadsAfterServerUpdate"> & {
- readonly serverVersion: string;
-};
-
-export interface ServerUpdateControl {
- readonly label: string;
- readonly disabled: boolean;
- readonly onClick: () => void;
-}
-
type UpdateButtonProps = Pick<ComponentProps<typeof Button>, "variant" | "size" | "className"> & {
readonly label?: string;
readonly appearance?: "button" | "icon";
@@ -225,13 +215,8 @@ export function ServerUpdateAction({
size = "xs",
className,
appearance = "button",
- render,
-}: Omit<ServerUpdateTarget, "continueThreadsAfterServerUpdate"> &
- UpdateButtonProps & {
- readonly render?: (control: ServerUpdateControl) => ReactNode;
- }) {
+}: Omit<ServerUpdateTarget, "continueThreadsAfterServerUpdate"> & UpdateButtonProps) {
const isDesktopAppUpdate = selfUpdate === "desktop-managed";
- const unsupportedDesktopUpdate = isDesktopAppUpdate && !desktopAppUpdate;
const sessionStateAtom = environmentSession.sessionStateAtom(environmentId);
const canUpdate = canUpdateServer(useAtomValue(sessionStateAtom));
const continueThreadsAfterServerUpdate = useEnvironmentSettings(
@@ -263,7 +248,6 @@ export function ServerUpdateAction({
const handleUpdate = async () => {
if (
- unsupportedDesktopUpdate ||
!canUpdateServer(appAtomRegistry.get(sessionStateAtom)) ||
pendingUpdateEnvironmentIds.has(environmentId)
) {
@@ -290,11 +274,18 @@ export function ServerUpdateAction({
});
};
+ if (selfUpdate === "desktop-managed" && !desktopAppUpdate) {
+ return (
+ <span className="text-muted-foreground text-xs">
+ Update the desktop app on that machine to update this server.
+ </span>
+ );
+ }
+
const manualCommand =
selfUpdate === null ? manualServerUpdateCommand(targetVersion, installation) : null;
- const actionLabel = unsupportedDesktopUpdate
- ? "Update the desktop app on"
- : manualCommand !== null
+ const actionLabel =
+ manualCommand !== null
? installation?.kind === "npm-global"
? "Copy update command"
: "Copy relaunch command"
@@ -303,17 +294,6 @@ export function ServerUpdateAction({
manualCommand !== null
? () => copyToClipboard(manualCommand, { command: manualCommand })
: () => void handleUpdate();
- const disabled = unsupportedDesktopUpdate || (manualCommand === null && !canUpdate);
-
- if (render) return render({ label: actionLabel, disabled, onClick });
-
- if (unsupportedDesktopUpdate) {
- return (
- <span className="text-muted-foreground text-xs">
- Update the desktop app on that machine to update this server.
- </span>
- );
- }
if (appearance === "icon") {
return (
@@ -325,7 +305,7 @@ export function ServerUpdateAction({
variant="ghost-muted"
className={className}
aria-label={`${actionLabel} for ${serverLabel}`}
- disabled={disabled}
+ disabled={manualCommand === null && !canUpdate}
onClick={onClick}
/>
}
@@ -342,7 +322,7 @@ export function ServerUpdateAction({
size={size}
variant={variant}
className={className}
- disabled={disabled}
+ disabled={manualCommand === null && !canUpdate}
onClick={onClick}
>
{actionLabel}
diff --git a/apps/web/src/versionSkew.test.ts b/apps/web/src/versionSkew.test.ts
index 3a3e27d0fb8..bfed9b8e081 100644
--- a/apps/web/src/versionSkew.test.ts
+++ b/apps/web/src/versionSkew.test.ts
@@ -17,6 +17,7 @@ import {
resolveServerConfigVersionMismatch,
resolveServerSelfUpdateCapability,
resolveVersionMismatch,
+ serverUpdateGuidance,
supportsDesktopAppUpdate,
} from "./versionSkew";
@@ -235,4 +236,9 @@ describe("versionSkew", () => {
expect(supportsDesktopAppUpdate(descriptor())).toBe(false);
expect(supportsDesktopAppUpdate(null)).toBe(false);
});
+
+ it("matches version-drift guidance to the advertised update path", () => {
+ expect(serverUpdateGuidance("respawn")).toBe("Update to stay in sync");
+ expect(serverUpdateGuidance("desktop-managed")).toBe("Update the desktop app");
+ });
});
diff --git a/apps/web/src/versionSkew.ts b/apps/web/src/versionSkew.ts
index ec7118a2f69..bcf4a27b6cc 100644
--- a/apps/web/src/versionSkew.ts
+++ b/apps/web/src/versionSkew.ts
@@ -114,6 +114,10 @@ export function manualServerUpdateCommand(
return `${runner} t3@${targetVersion}`;
}
+export function serverUpdateGuidance(capability: ServerSelfUpdateCapability): string {
+ return capability === "desktop-managed" ? "Update the desktop app" : "Update to stay in sync";
+}
+
export function buildVersionMismatchDismissalKey(
environmentId: EnvironmentId,
mismatch: Pick<VersionMismatch, "clientVersion" | "serverVersion">,