Skip to content

Commit 7f9ca04

Browse files
PR Batch Testerclaude
andcommitted
fix(web): Update everything always warns that restarts interrupt running work
The Update everything dialog only mentioned interrupted threads when the client had loaded a running count for the restarting machines, so a remote desktop with no loaded thread snapshot relaunched with no warning. It now says running tasks and tool calls will be interrupted whenever any machine restarts, and keeps the thread counts as extra detail. Provider-only updates stay quiet. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent fcbd3c1 commit 7f9ca04

2 files changed

Lines changed: 77 additions & 10 deletions

File tree

‎apps/web/src/components/sidebar/SidebarUpdatePill.browser.test.tsx‎

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
import type { DesktopUpdateState } from "@t3tools/contracts";
1+
import type { DesktopUpdateState, EnvironmentId } from "@t3tools/contracts";
22
import { describe, expect, it, vi } from "vite-plus/test";
33
import { page, userEvent } from "vite-plus/test/browser";
44

55
import "~/index.css";
66
import { act, render } from "../../../test/render";
77
import { SidebarUpdatePill } from "./SidebarUpdatePill";
8+
import type { RestartingMachine, UpdateEverythingRow } from "./updateEverything.logic";
89

910
const mocks = vi.hoisted(() => {
1011
const listeners = new Set<() => void>();
1112
return {
1213
update: null as DesktopUpdateState | null,
1314
hasUpdates: false,
15+
rows: [] as ReadonlyArray<UpdateEverythingRow>,
16+
restarts: [] as ReadonlyArray<RestartingMachine>,
17+
run: vi.fn(async () => {}),
1418
subscribe: (listener: () => void) => {
1519
listeners.add(listener);
1620
return () => listeners.delete(listener);
@@ -39,8 +43,9 @@ vi.mock("./useUpdateEverything", () => ({
3943
summary: "Update everything",
4044
version: null,
4145
providerCount: 0,
42-
rows: [],
43-
restarts: [],
46+
rows: mocks.rows,
47+
restarts: mocks.restarts,
48+
run: mocks.run,
4449
}),
4550
}));
4651

@@ -69,9 +74,19 @@ const RELEASE_NOTES: DesktopUpdateState["releaseNotes"] = [
6974
{ version: "0.0.50-nightly.2", items: ["Faster sidebar."], totalItems: 1 },
7075
];
7176

72-
function setup(update: DesktopUpdateState | null, { hasUpdates = false } = {}) {
77+
function setup(
78+
update: DesktopUpdateState | null,
79+
{
80+
hasUpdates = false,
81+
rows = [] as ReadonlyArray<UpdateEverythingRow>,
82+
restarts = [] as ReadonlyArray<RestartingMachine>,
83+
} = {},
84+
) {
7385
mocks.update = update;
7486
mocks.hasUpdates = hasUpdates;
87+
mocks.rows = rows;
88+
mocks.restarts = restarts;
89+
mocks.run.mockClear();
7590
}
7691

7792
function publish(update: DesktopUpdateState | null) {
@@ -129,4 +144,51 @@ describe("SidebarUpdatePill update everything", () => {
129144
await userEvent.keyboard("{Escape}");
130145
await vi.waitFor(() => expect(document.activeElement).toBe(button.element()));
131146
});
147+
148+
const studio = "studio" as EnvironmentId;
149+
const interruption = /Running tasks and tool calls will be interrupted/;
150+
151+
it.each([
152+
{ choice: "Cancel", runs: 0 },
153+
{ choice: "Update", runs: 1 },
154+
] as const)(
155+
"warns that a restarting machine with no loaded threads interrupts running work ($choice)",
156+
async ({ choice, runs }) => {
157+
setup(null, {
158+
hasUpdates: true,
159+
rows: [
160+
{
161+
environmentId: studio,
162+
label: "Studio",
163+
app: "desktop-app",
164+
skipped: null,
165+
providers: [],
166+
},
167+
],
168+
restarts: [{ environmentId: studio, continuesThreads: true }],
169+
});
170+
await using screen = await render(<SidebarUpdatePill />);
171+
await userEvent.click(screen.getByRole("button", { name: "Update everything" }));
172+
const dialog = page.getByRole("alertdialog");
173+
await expect.element(dialog.getByText(interruption)).toBeVisible();
174+
175+
await userEvent.click(dialog.getByRole("button", { name: choice, exact: true }));
176+
await vi.waitFor(() => expect(document.querySelector('[role="alertdialog"]')).toBeNull());
177+
await vi.waitFor(() => expect(mocks.run).toHaveBeenCalledTimes(runs));
178+
},
179+
);
180+
181+
it("does not warn about interruptions when only providers update", async () => {
182+
setup(null, {
183+
hasUpdates: true,
184+
rows: [
185+
{ environmentId: studio, label: "Studio", app: null, skipped: null, providers: ["Codex"] },
186+
],
187+
});
188+
await using screen = await render(<SidebarUpdatePill />);
189+
await userEvent.click(screen.getByRole("button", { name: "Update everything" }));
190+
const dialog = page.getByRole("alertdialog");
191+
await expect.element(dialog.getByText("Codex")).toBeVisible();
192+
expect(dialog.getByText(interruption).query()).toBeNull();
193+
});
132194
});

‎apps/web/src/components/sidebar/UpdateEverythingDialog.tsx‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,18 @@ function UpdateEverythingDialogContent({
196196
</div>
197197
</ScrollArea>
198198
<AlertDialogFooter>
199-
{running > 0 ? (
199+
{/* Thread counts come from client snapshots that can still be loading, so the warning
200+
cannot depend on them. */}
201+
{updating.some((row) => row.app !== null) ? (
200202
<p className="self-center text-muted-foreground text-sm max-sm:order-1 max-sm:text-center sm:mr-auto">
201-
{stopped === 0
202-
? `${threads} will be interrupted and can resume after the restart.`
203-
: continuing === 0
204-
? `${threads} will be interrupted.`
205-
: `${threads} will be interrupted. ${continuing} can resume after the restart.`}
203+
Running tasks and tool calls will be interrupted.
204+
{running === 0
205+
? null
206+
: stopped === 0
207+
? ` ${threads} can resume after the restart.`
208+
: continuing === 0
209+
? ` ${threads} will not resume automatically.`
210+
: ` ${continuing} of ${threads} can resume after the restart.`}
206211
</p>
207212
) : null}
208213
<AlertDialogClose ref={cancelRef} render={<Button variant="outline" />}>

0 commit comments

Comments
 (0)