Skip to content

Commit 5547d7c

Browse files
t3dotggclaude
andauthored
revert: "fix(web): show idle server updates on environment controls" (pingdotgg#21950) (pingdotgg#22233)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 23dd7e7 commit 5547d7c

10 files changed

Lines changed: 139 additions & 427 deletions

‎apps/web/src/components/BranchToolbar.logic.test.ts‎

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -424,37 +424,6 @@ describe("shouldShowEnvironmentIndicator", () => {
424424
});
425425

426426
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-
458427
it.each([false, true])(
459428
"honors the active-thread preference with resting controls %s",
460429
(hostsRestingComposerControls) => {

‎apps/web/src/components/BranchToolbar.logic.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@ export function resolveEnvironmentOptionLabel(input: {
5959
export function shouldShowEnvironmentIndicator(input: {
6060
activeEnvironment: Pick<EnvironmentOption, "isPrimary"> | null;
6161
canPickEnvironment: boolean;
62-
serverUpdateAvailable?: boolean;
6362
}): boolean {
64-
if (input.canPickEnvironment || input.serverUpdateAvailable) return true;
63+
if (input.canPickEnvironment) return true;
6564
return input.activeEnvironment !== null && !input.activeEnvironment.isPrimary;
6665
}
6766

@@ -72,13 +71,10 @@ export function shouldShowComposerContextStrip(input: {
7271
isGitRepo: boolean;
7372
showEnvironmentIndicator: boolean;
7473
hostsRestingComposerControls: boolean;
75-
serverUpdateAvailable?: boolean;
7674
}): boolean {
7775
return (
7876
input.hasActiveProject &&
79-
(input.isDraftHeroState ||
80-
input.persistInActiveThreads ||
81-
input.serverUpdateAvailable === true) &&
77+
(input.isDraftHeroState || input.persistInActiveThreads) &&
8278
(input.isGitRepo || input.showEnvironmentIndicator || input.hostsRestingComposerControls)
8379
);
8480
}

‎apps/web/src/components/BranchToolbar.panel.browser.test.tsx‎

Lines changed: 16 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ vi.mock(import("../localApi"), async (original) => ({
1919
vi.mock(import("../hooks/useCopyToClipboard"), async (original) => ({
2020
...(await original()),
2121
writeTextToClipboard: state.writeTextToClipboard,
22-
useCopyToClipboard: ((options: { target: string }) => ({
23-
copyToClipboard: (command: string) => state.writeTextToClipboard(command, options.target),
24-
isCopied: false,
25-
})) as never,
2622
}));
2723
vi.mock(import("./BranchToolbarBranchSelector"), async (original) => ({
2824
...(await original()),
@@ -35,8 +31,6 @@ vi.mock(import("../state/entities"), async (original) => ({
3531
}));
3632

3733
import { BranchToolbar } from "./BranchToolbar";
38-
import { ComposerSurface } from "./chat/ComposerSurface";
39-
import type { ServerUpdateTarget } from "./ServerUpdateAction";
4034

4135
let root: Root;
4236
let container: HTMLDivElement;
@@ -60,24 +54,22 @@ afterEach(async () => {
6054
function render(props: Partial<ComponentProps<typeof BranchToolbar>>) {
6155
return act(async () =>
6256
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+
/>,
8173
),
8274
);
8375
}
@@ -153,55 +145,3 @@ it.each([
153145
}
154146
},
155147
);
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' [email protected]",
203-
"update command",
204-
),
205-
);
206-
},
207-
);

‎apps/web/src/components/BranchToolbar.tsx‎

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ import {
4747
import { BranchToolbarEnvironmentSelector } from "./BranchToolbarEnvironmentSelector";
4848
import { openAddProjectToMachine } from "./AddProjectToMachineDialog";
4949
import { type AddProjectTarget, useAddProjectTargets } from "../hooks/useAddProjectTargets";
50-
import type { PendingServerUpdate } from "./ServerUpdateAction";
5150
import { BranchToolbarEnvModeSelector } from "./BranchToolbarEnvModeSelector";
5251
import { PreviousWorktreeItemContent } from "./PreviousWorktreeItemContent";
5352
import { ThreadDetailsControl } from "./chat/ThreadDetailsControl";
@@ -112,7 +111,6 @@ interface BranchToolbarProps {
112111
onEnvironmentChange?: (environmentId: EnvironmentId) => void;
113112
composerControlsHostRef?: (element: HTMLDivElement | null) => void;
114113
contextStripVisible?: boolean;
115-
serverUpdate?: PendingServerUpdate | null;
116114
}
117115

118116
function showWorkspaceContextMenu(event: ReactMouseEvent, workspacePath: string) {
@@ -634,7 +632,6 @@ export const BranchToolbar = memo(function BranchToolbar({
634632
onEnvironmentChange,
635633
composerControlsHostRef,
636634
contextStripVisible = true,
637-
serverUpdate = null,
638635
}: BranchToolbarProps) {
639636
const branchSelectorRef = useRef<BranchToolbarBranchSelectorHandle>(null);
640637
const threadRef = scopeThreadRef(environmentId, threadId);
@@ -700,7 +697,6 @@ export const BranchToolbar = memo(function BranchToolbar({
700697
const showEnvironmentIndicator = shouldShowEnvironmentIndicator({
701698
activeEnvironment: activeEnvironmentOption,
702699
canPickEnvironment: hasMultipleEnvironments,
703-
serverUpdateAvailable: serverUpdate !== null,
704700
});
705701
const [stripElement, setStripElement] = useState<HTMLDivElement | null>(null);
706702
const labelsOverflow = useLabelsOverflow(stripElement);
@@ -767,18 +763,6 @@ export const BranchToolbar = memo(function BranchToolbar({
767763
!contextStripVisible && "pointer-events-none invisible absolute inset-x-0 top-full",
768764
)}
769765
>
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}
782766
{showGitControls ? (
783767
<div className="contents @3xl/composer-surface:hidden">
784768
<RunContextSelector
@@ -789,8 +773,8 @@ export const BranchToolbar = memo(function BranchToolbar({
789773
envModeLocked={envModeLocked}
790774
environmentId={environmentId}
791775
availableEnvironments={availableEnvironments}
792-
showEnvironmentPicker={showEnvironmentPicker && serverUpdate === null}
793-
showEnvironmentIndicator={showEnvironmentIndicator && serverUpdate === null}
776+
showEnvironmentPicker={showEnvironmentPicker}
777+
showEnvironmentIndicator={showEnvironmentIndicator}
794778
onEnvironmentChange={onEnvironmentChange}
795779
effectiveEnvMode={effectiveEnvMode}
796780
activeWorktreePath={activeWorktreePath}
@@ -803,7 +787,7 @@ export const BranchToolbar = memo(function BranchToolbar({
803787
/>
804788
</div>
805789
) : null}
806-
{showGitControls || (showEnvironmentIndicator && serverUpdate === null) ? (
790+
{showGitControls || showEnvironmentIndicator ? (
807791
<div
808792
className={cn(
809793
"min-h-7 min-w-10 items-center gap-1 sm:min-h-6",
@@ -813,17 +797,15 @@ export const BranchToolbar = memo(function BranchToolbar({
813797
>
814798
{showEnvironmentIndicator && availableEnvironments && (
815799
<>
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+
/>
827809
{showGitControls ? (
828810
<Separator
829811
orientation="vertical"

0 commit comments

Comments
 (0)