Skip to content

Commit 8f237b6

Browse files
authored
fix(ui): show cloud session startup progress in chat (#130669)
1 parent 110eb78 commit 8f237b6

14 files changed

Lines changed: 196 additions & 175 deletions

‎docs/web/control-ui.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ The folder defaults to the agent workspace. Write-scoped connections can browse,
266266

267267
For a remote target, the Control UI creates the managed-worktree session with an empty initial message and no `execNode`, dispatches it by exact `deviceId`, `autoDevice: true`, or `profileId` (plus an optional cloud machine class), waits for active placement, and then sends the first message and attachments with the same idempotency key used by recovery. Explicit and automatic device dispatch require `operator.write`; cloud profile dispatch requires `operator.admin`. The composer footer chooses the new session's model and reasoning level.
268268

269+
Once the session is created, chat opens immediately. Remote startup uses the same transcript progress indicator and elapsed timer as GitHub workspace preparation, showing provisioning, workspace preparation, startup, and first-message delivery as they happen. The composer stays disabled until the first message is accepted; normal startup is not an error. Startup failures remain visible in the session, with **Retry** when recovery is available.
270+
269271
Canceling or recovering an interrupted remote-placement startup reclaims the placement by session key. Cleanup archives a newly created draft before deleting it with the write-scoped archived-only contract, and any cleanup error remains visible for recovery.
270272

271273
Unsent text and staged attachments can be recovered only in the same browser profile and Gateway credential scope; they are never stored on the Gateway or synced across devices. The browser keeps the 20 most recently edited draft scopes per Gateway credential scope for up to seven days, with at most 25 MiB of attachment data per draft, but it can evict browser storage sooner. A successful send or New Session creation, explicit attachment removal, or confirmed session deletion retires the corresponding browser draft. If cleanup fails after deletion, clear site data for the Control UI origin to remove it. Clearing site data also removes every other browser draft. If a draft's attachments exceed the cap, the current tab keeps them and shows the existing storage warning, but only the text is restart-recoverable. OpenClaw **Incognito** drafts are never durable. In a private browser window, IndexedDB availability and lifetime are controlled by the browser and stored data is normally cleared when the private session ends. The **Incognito** toggle in the new-session page's top-right control rail retires that browser draft and creates a web-only thread whose session entry, transcript, and compaction state stay in memory until the Gateway restarts; OpenClaw also skips its automatic memory flush. The agent keeps its normal tools, so an explicit save request or tool-driven file write can still persist data. The model provider still processes messages, and content-free audit metadata is still recorded. Remote-placement starts persist their model and reasoning choices before dispatching the session to its worker.

‎ui/src/e2e/new-session-page.cloud-dispatch.e2e.test.ts‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ suite.define(() => {
392392
const publishPlacement = async (
393393
state: "requested" | "provisioning" | "syncing" | "starting",
394394
generation: number,
395+
label: string,
395396
includeNeutral = false,
396397
) => {
397398
await gateway.setMethodResponse("sessions.list", {
@@ -427,16 +428,16 @@ suite.define(() => {
427428
ts: Date.now(),
428429
});
429430
await gateway.emitGatewayEvent("sessions.changed", { sessionKey, reason: "dispatch" });
430-
await pollLocatorText(startupStatus).toContain(`Placement: ${state}`);
431+
await pollLocatorText(startupStatus).toContain(label);
431432
};
432433

433-
for (const [state, generation] of [
434-
["requested", 1],
435-
["provisioning", 2],
436-
["syncing", 3],
437-
["starting", 4],
434+
for (const [state, generation, label] of [
435+
["requested", 1, "Provisioning environment…"],
436+
["provisioning", 2, "Provisioning environment…"],
437+
["syncing", 3, "Preparing workspace…"],
438+
["starting", 4, "Starting…"],
438439
] as const) {
439-
await publishPlacement(state, generation, state === "starting");
440+
await publishPlacement(state, generation, label, state === "starting");
440441
expect(await gateway.getRequests("sessions.send")).toHaveLength(0);
441442
}
442443
expect(await gateway.getRequests("sessions.describe")).toHaveLength(
@@ -457,7 +458,7 @@ suite.define(() => {
457458
app.runtime?.context.navigate("chat", { pathname });
458459
}, controlUiSessionPath(sessionKey));
459460
await expect.poll(() => page.url()).toContain(controlUiSessionPath(sessionKey));
460-
await pollLocatorText(startupStatus).toContain("Placement: starting");
461+
await pollLocatorText(startupStatus).toContain("Starting…");
461462
expect(await gateway.getRequests("sessions.abort")).toHaveLength(0);
462463
expect(await gateway.getRequests("environments.destroy")).toHaveLength(0);
463464
expect(await gateway.getRequests("sessions.delete")).toHaveLength(0);

‎ui/src/e2e/new-session-page.cloud-startup-failure.e2e.test.ts‎

Lines changed: 85 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -12,69 +12,92 @@ import {
1212
const suite = createNewSessionPageE2eSuite();
1313

1414
suite.define(() => {
15-
it("keeps a definitive cloud startup failure visible in the created session", async () => {
16-
const context = await suite.browser.newContext({ locale: "en-US", serviceWorkers: "block" });
17-
const page = await context.newPage();
18-
const sessionKey = "agent:cloud:failed-startup-e2e";
19-
const gateway = await installMockGateway(page, {
20-
defaultAgentId: "cloud",
21-
deferredMethods: ["sessions.dispatch"],
22-
featureMethods: ["sessions.create", "sessions.dispatch"],
23-
workspaceGit: true,
24-
methodResponses: {
25-
"agents.list": {
26-
agents: [
27-
{
28-
id: "cloud",
29-
identity: { name: "Cloud" },
30-
name: "Cloud",
31-
workspace: WORKSPACE,
32-
workspaceGit: true,
33-
},
34-
],
35-
defaultId: "cloud",
36-
mainKey: "main",
37-
scope: "agent",
15+
it.each([false, true])(
16+
"keeps cloud startup visible through failure (history fails: %s)",
17+
async (historyFails) => {
18+
const context = await suite.browser.newContext({ locale: "en-US", serviceWorkers: "block" });
19+
const page = await context.newPage();
20+
const sessionKey = "agent:cloud:failed-startup-e2e";
21+
const gateway = await installMockGateway(page, {
22+
defaultAgentId: "cloud",
23+
deferredMethods: ["sessions.dispatch", ...(historyFails ? ["chat.startup"] : [])],
24+
featureMethods: ["sessions.create", "sessions.dispatch", "chat.startup"],
25+
workspaceGit: true,
26+
methodResponses: {
27+
"agents.list": {
28+
agents: [
29+
{
30+
id: "cloud",
31+
identity: { name: "Cloud" },
32+
name: "Cloud",
33+
workspace: WORKSPACE,
34+
workspaceGit: true,
35+
},
36+
],
37+
defaultId: "cloud",
38+
mainKey: "main",
39+
scope: "agent",
40+
},
41+
"environments.list": {
42+
environments: [],
43+
profiles: [{ id: "aws", providerId: "crabbox" }],
44+
},
45+
"worktrees.branches": {
46+
branches: [{ kind: "local", name: "main" }],
47+
defaultBranch: "main",
48+
repositoryStatus: "git",
49+
},
50+
"sessions.create": { key: sessionKey },
51+
"sessions.list": createdSessionListResult(sessionKey),
52+
"sessions.describe": { session: {} },
3853
},
39-
"environments.list": {
40-
environments: [],
41-
profiles: [{ id: "aws", providerId: "crabbox" }],
42-
},
43-
"worktrees.branches": {
44-
branches: [{ kind: "local", name: "main" }],
45-
defaultBranch: "main",
46-
repositoryStatus: "git",
47-
},
48-
"sessions.create": { key: sessionKey },
49-
"sessions.list": createdSessionListResult(sessionKey),
50-
"sessions.describe": { session: {} },
51-
},
52-
});
53-
54-
try {
55-
await page.goto(`${suite.server.baseUrl}new`);
56-
await gateway.waitForRequest("environments.list");
57-
await page.locator("#new-session-where-trigger").click();
58-
await page
59-
.locator("wa-popover.new-session-page__where-popover")
60-
.getByRole("button", { name: "Cloud · aws" })
61-
.click();
62-
await page.locator(".new-session-page__message").fill("surface the failed startup");
63-
await page.getByRole("button", { name: "Start session" }).click();
64-
await gateway.waitForRequest("sessions.dispatch");
65-
await waitForCommittedChatRoute(page);
66-
await gateway.rejectDeferred("sessions.dispatch", {
67-
code: "INVALID_REQUEST",
68-
message: "cloud profile was removed",
6954
});
7055

71-
const alert = page.locator('.chat-cloud-startup-error[role="alert"]');
72-
await pollLocatorText(alert).toContain("cloud profile was removed");
73-
expect(page.url()).toContain(controlUiSessionPath(sessionKey));
74-
expect(await gateway.getRequests("sessions.send")).toHaveLength(0);
75-
expect(await gateway.getRequests("sessions.delete")).toHaveLength(0);
76-
} finally {
77-
await context.close();
78-
}
79-
});
56+
try {
57+
await page.goto(`${suite.server.baseUrl}new`);
58+
await gateway.waitForRequest("environments.list");
59+
await page.locator("#new-session-where-trigger").click();
60+
await page
61+
.locator("wa-popover.new-session-page__where-popover")
62+
.getByRole("button", { name: "Cloud · aws" })
63+
.click();
64+
await page.locator(".new-session-page__message").fill("surface the failed startup");
65+
await page.getByRole("button", { name: "Start session" }).click();
66+
await gateway.waitForRequest("sessions.dispatch");
67+
await waitForCommittedChatRoute(page);
68+
if (historyFails) {
69+
await gateway.waitForRequest("chat.startup");
70+
await gateway.rejectDeferred("chat.startup", {
71+
code: "UNAVAILABLE",
72+
message: "History is temporarily unavailable",
73+
});
74+
await pollLocatorText(page.locator(".chat-history-error--inline")).toContain(
75+
"History is temporarily unavailable",
76+
);
77+
}
78+
const working = page.locator('.chat-thread .chat-working-indicator[role="status"]');
79+
await pollLocatorText(working).toContain("Provisioning environment…");
80+
expect(await working.locator(".chat-reading-indicator").count()).toBe(1);
81+
expect(
82+
await page
83+
.locator('.chat-cloud-startup, .agent-chat__composer-status-band[role="alert"]')
84+
.count(),
85+
).toBe(0);
86+
expect(await page.locator(".chat-send-btn--stop").count()).toBe(0);
87+
await gateway.rejectDeferred("sessions.dispatch", {
88+
code: "INVALID_REQUEST",
89+
message: "cloud profile was removed",
90+
});
91+
92+
const alert = page.locator('.chat-cloud-startup-error[role="alert"]');
93+
await pollLocatorText(alert).toContain("cloud profile was removed");
94+
await expect.poll(() => working.count()).toBe(0);
95+
expect(page.url()).toContain(controlUiSessionPath(sessionKey));
96+
expect(await gateway.getRequests("sessions.send")).toHaveLength(0);
97+
expect(await gateway.getRequests("sessions.delete")).toHaveLength(0);
98+
} finally {
99+
await context.close();
100+
}
101+
},
102+
);
80103
});

‎ui/src/e2e/new-session-page.test-support.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,12 @@ export async function expectPendingSessionPlacementStartupBeforeRuntime(
152152
) {
153153
await waitForCommittedChatRoute(page);
154154
expect(page.url()).toContain(controlUiSessionPath(sessionKey));
155-
const startupStatus = page.locator('.chat-cloud-startup[role="status"]');
155+
const startupStatus = page.locator('.chat-thread .chat-working-indicator[role="status"]');
156156
await expect.poll(() => startupStatus.count()).toBe(1);
157-
await pollLocatorText(startupStatus).toContain("Starting…");
157+
await pollLocatorText(startupStatus).toContain("Provisioning environment…");
158+
expect(await page.locator(".chat-cloud-startup, .agent-chat__composer-status-band").count()).toBe(
159+
0,
160+
);
158161
await expect
159162
.poll(() => page.locator(".agent-chat__composer-combobox textarea").isDisabled())
160163
.toBe(true);

‎ui/src/pages/chat/chat-pane-render.ts‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,13 @@ export class ChatPane extends ChatPaneLayoutRender {
198198
selectedSession.sharingRole === "viewer" &&
199199
isGatewayMethodAdvertised(gatewaySnapshot, "session.suggestions.add") === true &&
200200
isGatewayMethodAdvertised(gatewaySnapshot, "session.suggestions.list") === true;
201-
// Every composer-disabling gate needs a visible reason here or a banner in
202-
// sessionDisabledBanner; a silently disabled composer is a silent failure.
201+
// Placement progress already explains its gate in the transcript. Other
202+
// gates need a reason here or a sessionDisabledBanner.
203203
const disabledReason = modelUnavailable
204204
? `${t("modelSetup.failure.auth")}. ${t("modelSetup.failureGuidance.auth")}`
205205
: sessionParticipationBlocked && !suggestionViewer
206206
? t("chat.sessionSharing.readOnlyNotice")
207-
: placementStartupPending
208-
? t("newSession.starting")
209-
: null;
207+
: null;
210208
const typingEnabled =
211209
multiIdentity &&
212210
hasOperatorWriteAccess(gatewaySnapshot.hello?.auth ?? null) &&

‎ui/src/pages/chat/chat-run-startup.ts‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import type { ChatRunStartupPhase } from "../../../../packages/gateway-protocol/src/index.js";
2+
import type { ApplicationPlacementStartupStatus } from "../../app/session-placement-startup.ts";
3+
import { t } from "../../i18n/index.ts";
24

35
export type { ChatRunStartupPhase } from "../../../../packages/gateway-protocol/src/index.js";
46

@@ -8,6 +10,37 @@ export type ChatRunStartupState =
810

911
export type ChatRunStartupStatus = Extract<ChatRunStartupState, { state: "status" }>;
1012

13+
const STARTUP_LABEL_KEYS = {
14+
preparing_workspace: "chat.startupStatus.preparingWorkspace",
15+
provisioning_environment: "chat.startupStatus.provisioningEnvironment",
16+
preparing_context: "chat.startupStatus.preparingContext",
17+
starting_model: "chat.startupStatus.startingModel",
18+
} as const satisfies Record<ChatRunStartupPhase, Parameters<typeof t>[0]>;
19+
20+
export function chatStartupStatusLabel(
21+
run: ChatRunStartupStatus | null | undefined,
22+
placement: ApplicationPlacementStartupStatus | null | undefined,
23+
): string | undefined {
24+
if (run) {
25+
return t(STARTUP_LABEL_KEYS[run.phase]);
26+
}
27+
switch (placement?.phase) {
28+
case "pending":
29+
case "requested":
30+
case "provisioning":
31+
return t("chat.startupStatus.provisioningEnvironment");
32+
case "syncing":
33+
return t("chat.startupStatus.preparingWorkspace");
34+
case "starting":
35+
return t("newSession.starting");
36+
case "active":
37+
case "sending":
38+
return t("chat.composer.sendingMessage");
39+
default:
40+
return undefined;
41+
}
42+
}
43+
1144
export function activeChatRunStartupStatus(
1245
startup: ChatRunStartupState | null | undefined,
1346
): ChatRunStartupStatus | null {

‎ui/src/pages/chat/chat-view-notices.ts‎

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import type { ApplicationPlacementStartupStatus } from "../../app/session-placem
44
import { icons } from "../../components/icons.ts";
55
import { t } from "../../i18n/index.ts";
66
import { formatBytes } from "../../lib/agents/display.ts";
7-
import { renderPlacementStartupStatus } from "./components/chat-working-indicator.ts";
87
import { renderWorkspaceConflictNotice } from "./components/chat-workspace-conflict.ts";
98
import type { WorkspaceResultConflict } from "./workspace-conflict.ts";
109

@@ -123,6 +122,37 @@ export function renderChatComposerNotices(props: ChatComposerNoticesProps) {
123122
conflict: props.workspaceConflict ?? undefined,
124123
onDismiss: props.onDismissWorkspaceConflict,
125124
})}
126-
${renderPlacementStartupStatus(props.placementStartup, props.onRetrySessionPlacementStartup)}
125+
${renderPlacementStartupError(props.placementStartup, props.onRetrySessionPlacementStartup)}
126+
`;
127+
}
128+
129+
function renderPlacementStartupError(
130+
status: ApplicationPlacementStartupStatus | null | undefined,
131+
onRetry?: () => void,
132+
) {
133+
if (status?.phase !== "failed") {
134+
return nothing;
135+
}
136+
return html`
137+
<div
138+
class="chat-composer-neighbor-card chat-composer-neighbor-card--danger chat-cloud-startup-error"
139+
role="alert"
140+
>
141+
<span class="chat-composer-neighbor-card__icon" aria-hidden="true"
142+
>${icons.alertTriangle}</span
143+
>
144+
<span class="chat-composer-neighbor-card__copy"
145+
><strong
146+
>${t("newSession.placementStartFailed", {
147+
error: status.error ?? t("newSession.createFailed"),
148+
})}</strong
149+
></span
150+
>
151+
${status.retryable && onRetry
152+
? html`<button class="btn btn--sm" type="button" @click=${onRetry}>
153+
${t("common.retry")}
154+
</button>`
155+
: nothing}
156+
</div>
127157
`;
128158
}

‎ui/src/pages/chat/chat-view.ts‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import type { ProviderUsageDisplayProps } from "../../lib/provider-quota-summary
4040
import type { SessionToolOverrides } from "../../lib/sessions/patch.ts";
4141
import type { UiSessionDefaultsHost } from "../../lib/sessions/session-key.ts";
4242
import { getChatHistoryLoadState, retryChatHistoryLoad } from "./chat-history.ts";
43-
import type { ChatRunStartupStatus } from "./chat-run-startup.ts";
43+
import { chatStartupStatusLabel, type ChatRunStartupStatus } from "./chat-run-startup.ts";
4444
import type { ChatState } from "./chat-state-contract.ts";
4545
import {
4646
type ChatPlacementStartupNoticeProps,
@@ -321,20 +321,24 @@ export function renderChat(props: ChatProps) {
321321
? (item: ImageLightboxItem) => openImage?.(item, props.onRequestOpenImage?.())
322322
: undefined;
323323
const attachmentDropHandlers = createChatAttachmentDropHandlers({ ...props, canCompose });
324+
const placementStartup =
325+
props.placementStartup?.phase === "failed" ? null : props.placementStartup;
326+
// Placement is visible work, but does not own an abortable model run yet.
327+
const runWorking = Boolean(placementStartup) || isChatRunWorking(props);
324328
let chatSection: HTMLElement | null = null;
325329
const thread = renderChatThread(
326330
{
327331
paneId: props.paneId,
328332
sessionKey: props.sessionKey,
329333
announceTranscript: props.announceTranscript,
330-
loading: props.loading,
334+
loading: props.loading && !placementStartup,
331335
historyLoading: props.historyPagination?.loading,
332336
messages: props.messages,
333337
toolMessages: props.toolMessages,
334338
guardianNotices: props.guardianNotices,
335339
streamSegments: props.streamSegments,
336340
stream: props.stream,
337-
streamStartedAt: props.streamStartedAt,
341+
streamStartedAt: placementStartup?.startedAt ?? props.streamStartedAt,
338342
runId: props.runId,
339343
runOutputTokens: props.runOutputTokens,
340344
runStatus: props.runStatus,
@@ -343,8 +347,8 @@ export function renderChat(props: ChatProps) {
343347
showToolCalls: props.showToolCalls,
344348
persistCommentary: props.persistCommentary,
345349
runActive: Boolean(props.canAbort),
346-
runWorking: isChatRunWorking(props),
347-
startupStatus: props.startupStatus,
350+
runWorking,
351+
startupLabel: chatStartupStatusLabel(props.startupStatus, placementStartup),
348352
waitingApproval: props.waitingApproval,
349353
questionPrompts: props.gatewayQuestionPrompts,
350354
sessions: props.sessions,
@@ -549,6 +553,7 @@ export function renderChat(props: ChatProps) {
549553
historyLoadState?.phase === "failed" &&
550554
historyLoadState.sessionKey === props.sessionKey;
551555
const transcriptEmpty =
556+
!runWorking &&
552557
props.messages.length === 0 &&
553558
props.toolMessages.length === 0 &&
554559
props.streamSegments.length === 0 &&

0 commit comments

Comments
 (0)