Skip to content

Commit c1843d0

Browse files
committed
feat(ui): add cloud worker machine picker
1 parent 694ccc2 commit c1843d0

33 files changed

Lines changed: 1880 additions & 31 deletions
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"startupJsGzipBytes": 335452,
3-
"reason": "chat delivery failures surface globally: toast + session-display naming joins startup chat path",
2+
"startupJsGzipBytes": 337511,
3+
"reason": "cloud worker settings navigation and machine selection",
44
"updatedAt": "2026-08-16"
55
}

‎ui/src/app-navigation.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ describe("navigationIconForRoute", () => {
110110
plugins: "puzzle",
111111
"skill-workshop": "wrench",
112112
devices: "monitorSmartphone",
113+
"cloud-workers": "server",
113114
profile: "circleUser",
114115
communications: "send",
115116
appearance: "palette",
@@ -233,6 +234,7 @@ describe("titleForRoute", () => {
233234
plugins: "Plugins",
234235
"skill-workshop": "Skill Workshop",
235236
devices: "Devices",
237+
"cloud-workers": "Cloud workers",
236238
profile: "Profile",
237239
communications: "Communications",
238240
appearance: "Appearance",
@@ -284,6 +286,7 @@ describe("subtitleForRoute", () => {
284286
plugins: "Install and manage optional capabilities.",
285287
"skill-workshop": "Review, refine, and apply proposals before they become live skills.",
286288
devices: "Paired devices, pairing approvals, and exec bindings.",
289+
"cloud-workers": "Profiles and machine sizes for cloud sessions.",
287290
profile: "Your display name, avatar, and identity on this gateway.",
288291
communications: "Messages and text-to-speech settings.",
289292
appearance: "Theme, UI, and setup wizard settings.",
@@ -322,6 +325,7 @@ describe("pathForRoute", () => {
322325
expect(pathForRoute("plugins")).toBe("/settings/plugins");
323326
expect(pathForRoute("approvals")).toBe("/settings/approvals");
324327
expect(pathForRoute("labs")).toBe("/settings/labs");
328+
expect(pathForRoute("cloud-workers")).toBe("/settings/cloud-workers");
325329
});
326330

327331
it("prepends base path", () => {
@@ -543,6 +547,7 @@ describe("SIDEBAR_NAV_ROUTES", () => {
543547
"communications",
544548
"talk",
545549
"devices",
550+
"cloud-workers",
546551
"agents",
547552
"labs",
548553
"model-providers",

‎ui/src/app-navigation.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ export const SETTINGS_NAVIGATION_GROUPS = [
182182
{ labelKey: null, routes: ["custodian", "profile", "appearance", "notifications"] },
183183
{
184184
labelKey: "nav.settingsGroupConnections",
185-
routes: ["connection", "channels", "communications", "talk", "devices"],
185+
routes: ["connection", "channels", "communications", "talk", "devices", "cloud-workers"],
186186
},
187187
{
188188
labelKey: "nav.settingsGroupAgents",
@@ -237,6 +237,7 @@ const NAVIGATION_ICONS: NavigationItem = {
237237
plugins: "puzzle",
238238
"skill-workshop": "wrench",
239239
devices: "monitorSmartphone",
240+
"cloud-workers": "server",
240241
chat: "messageSquare",
241242
dashboard: "layoutDashboard",
242243
dashboards: "layoutDashboard",
@@ -349,6 +350,10 @@ const NAVIGATION_COPY: Record<NavigationRouteId, { titleKey: string; subtitleKey
349350
subtitleKey: "subtitles.skillWorkshop",
350351
},
351352
devices: { titleKey: "tabs.devices", subtitleKey: "subtitles.devices" },
353+
"cloud-workers": {
354+
titleKey: "tabs.cloudWorkers",
355+
subtitleKey: "subtitles.cloudWorkers",
356+
},
352357
chat: { titleKey: "tabs.chat", subtitleKey: "subtitles.chat" },
353358
dashboard: { titleKey: "tabs.chat", subtitleKey: "subtitles.chat" },
354359
dashboards: { titleKey: "tabs.dashboards", subtitleKey: "subtitles.dashboards" },

‎ui/src/app-route-paths.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ const APP_ROUTE_DEFINITIONS = {
6969
cron: { path: "/automations", aliases: ["/cron"] },
7070
tasks: { path: "/tasks" },
7171
devices: { path: "/settings/devices", aliases: ["/nodes"] },
72+
"cloud-workers": { path: "/settings/cloud-workers" },
7273
plugin: { path: "/plugin" },
7374
} as const;
7475

‎ui/src/app-routes.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { page as approvalsPage } from "./pages/approvals/route.ts";
3131
import { page as appsPage } from "./pages/apps/route.ts";
3232
import { page as channelsPage } from "./pages/channels/route.ts";
3333
import { pages as chatPages } from "./pages/chat/route.ts";
34+
import { page as cloudWorkersPage } from "./pages/cloud-workers/route.ts";
3435
import { pages as configPages } from "./pages/config/route.ts";
3536
import { page as connectionPage } from "./pages/connection/route.ts";
3637
import { page as cronPage } from "./pages/cron/route.ts";
@@ -85,6 +86,7 @@ const APP_ROUTE_TREE = [
8586
agentsPage,
8687
approvalsPage,
8788
channelsPage,
89+
cloudWorkersPage,
8890
connectionPage,
8991
labsPage,
9092
aboutPage,

‎ui/src/components/settings-sidebar.test.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,14 @@ describe("settings sidebar search", () => {
378378
expect(labels()).toEqual(["Appearance"]);
379379

380380
enterQuery("connections");
381-
expect(labels()).toEqual(["Gateway", "Channels", "Communications", "Talk", "Devices"]);
381+
expect(labels()).toEqual([
382+
"Gateway",
383+
"Channels",
384+
"Communications",
385+
"Talk",
386+
"Devices",
387+
"Cloud workers",
388+
]);
382389

383390
enterQuery("does-not-exist");
384391
expect(labels()).toEqual([]);
Lines changed: 273 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,273 @@
1+
import { expect, it } from "vitest";
2+
import {
3+
installMockGateway,
4+
type MockGatewayRequest,
5+
waitForConfirmModal,
6+
} from "../test-helpers/control-ui-e2e.ts";
7+
import { createControlUiE2eSuite } from "./control-ui-e2e-suite.test-support.ts";
8+
9+
const suite = createControlUiE2eSuite({
10+
name: "Control UI cloud workers settings mocked Gateway E2E",
11+
startServerBeforeBrowser: true,
12+
unavailableMessage: (executablePath) => `Playwright Chromium is unavailable at ${executablePath}`,
13+
});
14+
15+
function configResponse(config: Record<string, unknown>, hash: string) {
16+
return {
17+
appliedConfigHash: hash,
18+
config,
19+
sourceConfig: config,
20+
hash,
21+
issues: [],
22+
raw: JSON.stringify(config),
23+
valid: true,
24+
};
25+
}
26+
27+
function requestRaw(request: MockGatewayRequest): Record<string, unknown> {
28+
if (!request.params || typeof request.params !== "object" || Array.isArray(request.params)) {
29+
throw new Error("Expected config.patch params");
30+
}
31+
return JSON.parse(String((request.params as Record<string, unknown>).raw)) as Record<
32+
string,
33+
unknown
34+
>;
35+
}
36+
37+
suite.define(() => {
38+
it("adds and edits profiles while distinguishing advertised state", async () => {
39+
const context = await suite.browser.newContext({
40+
locale: "en-US",
41+
serviceWorkers: "block",
42+
viewport: { height: 1_000, width: 1_440 },
43+
});
44+
const page = await context.newPage();
45+
const gateway = await installMockGateway(page, {
46+
featureMethods: ["config.patch", "environments.list"],
47+
methodResponses: {
48+
"config.get": configResponse({}, "cloud-workers-1"),
49+
"environments.list": {
50+
environments: [],
51+
profiles: [{ id: "build-fleet", providerId: "crabbox" }],
52+
},
53+
},
54+
});
55+
56+
try {
57+
expect((await page.goto(`${suite.server.baseUrl}settings/cloud-workers`))?.status()).toBe(
58+
200,
59+
);
60+
await gateway.waitForRequest("environments.list");
61+
await page.getByText("No cloud worker profiles are configured.", { exact: true }).waitFor();
62+
63+
await page.getByRole("button", { name: "Add profile" }).click();
64+
await page.getByLabel("Profile ID").fill("build-fleet");
65+
await page.getByLabel("Crabbox backend").fill("hetzner");
66+
await gateway.deferNext("config.patch");
67+
await page.getByRole("button", { name: "Save" }).click();
68+
const addPatch = requestRaw(await gateway.waitForRequest("config.patch"));
69+
expect(addPatch).toEqual({
70+
cloudWorkers: {
71+
profiles: {
72+
"build-fleet": {
73+
provider: "crabbox",
74+
install: "bundle",
75+
settings: {
76+
provider: "hetzner",
77+
class: "standard",
78+
ttl: "8h",
79+
idleTimeout: "45m",
80+
setup: null,
81+
desktop: null,
82+
binary: null,
83+
},
84+
},
85+
},
86+
},
87+
});
88+
const buildFleet = {
89+
provider: "crabbox",
90+
install: "bundle",
91+
settings: {
92+
provider: "hetzner",
93+
class: "standard",
94+
ttl: "8h",
95+
idleTimeout: "45m",
96+
},
97+
};
98+
await gateway.resolveDeferred("config.patch", {
99+
ok: true,
100+
hash: "cloud-workers-2",
101+
config: { cloudWorkers: { profiles: { "build-fleet": buildFleet } } },
102+
});
103+
await page.getByText("Advertised", { exact: true }).waitFor();
104+
await page.getByText("Gateway restart required.", { exact: true }).waitFor();
105+
106+
await page.getByRole("button", { name: "Edit" }).click();
107+
await page.getByLabel("Machine class").selectOption("custom");
108+
await page.getByLabel("Custom machine class").fill("ccx53");
109+
await page.getByLabel("Max lifetime").fill("12h");
110+
await page
111+
.locator(".settings-row")
112+
.filter({ hasText: "Desktop" })
113+
.locator("wa-switch")
114+
.click();
115+
await page.getByLabel("Crabbox binary").fill("/opt/bin/crabbox");
116+
await gateway.deferNext("config.patch");
117+
await page.getByRole("button", { name: "Save" }).click();
118+
const editPatch = requestRaw(await gateway.waitForRequest("config.patch"));
119+
expect(editPatch).toMatchObject({
120+
cloudWorkers: {
121+
profiles: {
122+
"build-fleet": {
123+
provider: "crabbox",
124+
install: "bundle",
125+
settings: {
126+
provider: "hetzner",
127+
class: "ccx53",
128+
ttl: "12h",
129+
idleTimeout: "45m",
130+
setup: null,
131+
desktop: true,
132+
binary: "/opt/bin/crabbox",
133+
},
134+
},
135+
},
136+
},
137+
});
138+
const editedFleet = {
139+
provider: "crabbox",
140+
install: "bundle",
141+
settings: {
142+
provider: "hetzner",
143+
class: "ccx53",
144+
ttl: "12h",
145+
idleTimeout: "45m",
146+
desktop: true,
147+
binary: "/opt/bin/crabbox",
148+
},
149+
};
150+
await gateway.resolveDeferred("config.patch", {
151+
ok: true,
152+
hash: "cloud-workers-3",
153+
config: { cloudWorkers: { profiles: { "build-fleet": editedFleet } } },
154+
});
155+
await page.getByText(/Class: ccx53/).waitFor();
156+
157+
await page.getByRole("button", { name: "Add profile" }).click();
158+
await page.getByLabel("Profile ID").fill("pending");
159+
await page.getByLabel("Crabbox backend").fill("aws");
160+
await gateway.deferNext("config.patch");
161+
await page.getByRole("button", { name: "Save" }).click();
162+
const pendingPatch = requestRaw(await gateway.waitForRequest("config.patch"));
163+
expect(pendingPatch).toMatchObject({
164+
cloudWorkers: {
165+
profiles: {
166+
"build-fleet": editedFleet,
167+
pending: {
168+
provider: "crabbox",
169+
install: "bundle",
170+
settings: { provider: "aws", class: "standard" },
171+
},
172+
},
173+
},
174+
});
175+
const pending = {
176+
provider: "crabbox",
177+
install: "bundle",
178+
settings: {
179+
provider: "aws",
180+
class: "standard",
181+
ttl: "8h",
182+
idleTimeout: "45m",
183+
},
184+
};
185+
await gateway.resolveDeferred("config.patch", {
186+
ok: true,
187+
hash: "cloud-workers-4",
188+
config: {
189+
cloudWorkers: { profiles: { "build-fleet": editedFleet, pending } },
190+
},
191+
});
192+
await page.getByText("Restart required", { exact: true }).waitFor();
193+
} finally {
194+
await context.close();
195+
}
196+
});
197+
198+
it("deletes a profile only after confirmation", async () => {
199+
const context = await suite.browser.newContext({ locale: "en-US", serviceWorkers: "block" });
200+
const page = await context.newPage();
201+
const pending = {
202+
provider: "crabbox",
203+
install: "bundle",
204+
settings: {
205+
provider: "aws",
206+
class: "standard",
207+
ttl: "8h",
208+
idleTimeout: "45m",
209+
},
210+
};
211+
const initialConfig = { cloudWorkers: { profiles: { pending } } };
212+
const gateway = await installMockGateway(page, {
213+
featureMethods: ["config.patch", "environments.list"],
214+
methodResponses: {
215+
"config.get": configResponse(initialConfig, "cloud-workers-delete-1"),
216+
"config.patch": {
217+
ok: true,
218+
hash: "cloud-workers-delete-2",
219+
config: { cloudWorkers: { profiles: {} } },
220+
},
221+
"environments.list": { environments: [], profiles: [] },
222+
},
223+
});
224+
225+
try {
226+
await page.goto(`${suite.server.baseUrl}settings/cloud-workers`);
227+
const pendingRow = page.locator(".settings-row").filter({
228+
has: page.locator("code", { hasText: /^pending$/ }),
229+
});
230+
await pendingRow.getByRole("button", { name: "Delete" }).click();
231+
const confirmation = await waitForConfirmModal(page);
232+
await expect.poll(() => confirmation.textContent()).toContain("Delete profile pending?");
233+
expect(await gateway.getRequests("config.patch")).toHaveLength(0);
234+
await confirmation.getByRole("button", { name: "Delete", exact: true }).click();
235+
await expect.poll(async () => (await gateway.getRequests("config.patch")).length).toBe(1);
236+
const deleteRequest = (await gateway.getRequests("config.patch"))[0];
237+
if (!deleteRequest) {
238+
throw new Error("Expected delete config.patch request");
239+
}
240+
expect(requestRaw(deleteRequest)).toEqual({
241+
cloudWorkers: { profiles: { pending: null } },
242+
});
243+
await expect.poll(() => pendingRow.count()).toBe(0);
244+
} finally {
245+
await context.close();
246+
}
247+
});
248+
249+
it("keeps profile mutations admin-scoped", async () => {
250+
const context = await suite.browser.newContext({ locale: "en-US", serviceWorkers: "block" });
251+
const page = await context.newPage();
252+
await installMockGateway(page, {
253+
operatorScopes: ["operator.read"],
254+
featureMethods: ["config.patch", "environments.list"],
255+
methodResponses: {
256+
"config.get": configResponse({}, "cloud-workers-read-only"),
257+
"environments.list": { environments: [], profiles: [] },
258+
},
259+
});
260+
261+
try {
262+
await page.goto(`${suite.server.baseUrl}settings/cloud-workers`);
263+
await page
264+
.getByText("Administrator access is required to manage cloud worker profiles.", {
265+
exact: true,
266+
})
267+
.waitFor();
268+
expect(await page.getByRole("button", { name: "Add profile" }).count()).toBe(0);
269+
} finally {
270+
await context.close();
271+
}
272+
});
273+
});

0 commit comments

Comments
 (0)