Skip to content

๐Ÿ™Œ OpenHands: AI-Driven Development

fix: cloud conversation resume + archived/error sandbox states (#500)

Rohit Malhotrac224d24a9b0f
diff --git a/.pr/README.md b/.pr/README.md
new file mode 100644
index 0000000000..cf36399c7b
--- /dev/null
+++ b/.pr/README.md
@@ -0,0 +1,3 @@
+# PR Artifacts
+
+This directory contains generated PR-only QA artifacts. The PR Artifacts workflow removes it after approval so these files do not enter the final squash merge.
diff --git a/.pr/live-e2e/25966377319/live-agent-recording.gif b/.pr/live-e2e/25966377319/live-agent-recording.gif
new file mode 100644
index 0000000000..e5a716910e
Binary files /dev/null and b/.pr/live-e2e/25966377319/live-agent-recording.gif differ
diff --git a/.pr/live-e2e/25966377319/live-agent-recording.webm b/.pr/live-e2e/25966377319/live-agent-recording.webm
new file mode 100644
index 0000000000..475f43859c
Binary files /dev/null and b/.pr/live-e2e/25966377319/live-agent-recording.webm differ
diff --git a/.pr/live-e2e/25966377319/live-agent-response.png b/.pr/live-e2e/25966377319/live-agent-response.png
new file mode 100644
index 0000000000..a41eba9250
Binary files /dev/null and b/.pr/live-e2e/25966377319/live-agent-response.png differ
diff --git a/AGENTS.md b/AGENTS.md
index 6b508650cf..e699e62ea6 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -433,3 +433,5 @@ return new ConversationClient(getAgentServerClientOptions()).someMethod(...);
- Settings naming is backend-aware today: local `/settings` is profile-oriented (`use-settings-nav-items.ts` renames the first settings item/title/subtitle to `LLM Profiles` and `chat-input-model.tsx` / `chat-input-actions.tsx` link there as `LLM Profiles`), while cloud keeps the generic `LLM Settings` copy because cloud still edits raw settings rather than saved profiles. The local profile editor (`llm-settings-local-view.tsx`) should keep explicit create/edit profile headings plus helper text so users know they are saving a profile, not mutating the current conversation directly.
- ESLint config (flat, ESLint 9): the project uses `eslint.config.js` (not `.eslintrc`) and runs on `[email protected]`, not 10. The constraint pinning us below 10 is `[email protected]`, which still calls `context.getFilename()` at rule-load time โ€” that API was removed in ESLint 10 and `@eslint/compat`'s `fixupPluginRules` does NOT shim it. Don't try to bump eslint past 9 until eslint-plugin-react ships a v10-compatible release. Import rules come from `eslint-plugin-import-x` (the maintained fork of `eslint-plugin-import`) but are registered under both `import-x/` and `import/` prefixes via `plugins: { import: importXPlugin, ... }` so existing `// eslint-disable-next-line import/...` directives keep working. `linterOptions.reportUnusedDisableDirectives` is set to `"warn"` (not "off") so stale airbnb-era disable comments still surface in lint output without failing CI. The TS-overrides block has an `ignores: ["src/hooks/query/query-keys.ts"]` so the `no-restricted-syntax` rule banning raw `["settings", ...]` query keys doesn't fire on the file that defines the helpers themselves. No `.npmrc` / `legacy-peer-deps` flag is needed โ€” all our plugins declare ESLint 9 peer compatibility.
+
+- Cloud conversation resume gating: when a cloud conversation is closed from the UI (`pauseCloudSandbox` is called), the conversation's `conversation_url` is NOT cleared -- it still points to the old sandbox host. `WebSocketProviderWrapper` must suppress the URL (pass `null` to `ConversationWebSocketProvider`) while `sandbox_status === "PAUSED"`, otherwise the WebSocket immediately tries the stale URL before the sandbox wakes. Symmetrically, `useActiveConversation`'s refetch interval must fast-poll (3 s) on both `!conversation_url` AND `sandbox_status === "PAUSED"` -- checking only the missing URL would leave the hook on the 30 s interval while the sandbox is resuming. The resume sequence: navigate -> sandbox PAUSED detected -> `resumeCloudSandbox` called (in `conversation.tsx`) -> fast-poll detects RUNNING -> `conversationUrl` unblocked -> WebSocket connects.
diff --git a/__tests__/api/agent-server-conversation-service.test.ts b/__tests__/api/agent-server-conversation-service.test.ts
index 2927fe230c..a5010c11b0 100644
--- a/__tests__/api/agent-server-conversation-service.test.ts
+++ b/__tests__/api/agent-server-conversation-service.test.ts
@@ -369,7 +369,69 @@ describe("AgentServerConversationService", () => {
);
});
- it("sanitizes malformed optional conversation fields", async () => {
+ it("preserves sandbox_status from batchGetAppConversations response", async () => {
+ mockHttpGet.mockResolvedValue({
+ data: [
+ {
+ id: "conv-paused",
+ created_at: "2024-01-01",
+ updated_at: "2024-01-01",
+ sandbox_status: "PAUSED",
+ },
+ ],
+ });
+
+ const [conversation] =
+ await AgentServerConversationService.batchGetAppConversations([
+ "conv-paused",
+ ]);
+
+ expect(conversation?.sandbox_status).toBe("PAUSED");
+ });
+
+ it("preserves sandbox_status from searchConversations response", async () => {
+ const searchSpy = vi.fn().mockResolvedValue({
+ items: [
+ {
+ id: "conv-paused-search",
+ created_at: "2024-01-01",
+ updated_at: "2024-01-01",
+ sandbox_status: "PAUSED",
+ },
+ ],
+ next_page_id: null,
+ });
+ // Only searchConversations is called by the service method under test,
+ // so we don't need to reproduce the full client mock object.
+ mockConversationClient.mockReturnValue({
+ searchConversations: searchSpy,
+ });
+
+ const result = await AgentServerConversationService.searchConversations(10);
+
+ expect(result.items[0]?.sandbox_status).toBe("PAUSED");
+ });
+
+ it("passes sandbox_status null through when field is absent", async () => {
+ mockHttpGet.mockResolvedValue({
+ data: [
+ {
+ id: "conv-no-status",
+ created_at: "2024-01-01",
+ updated_at: "2024-01-01",
+ },
+ ],
+ });
+
+ const [conversation] =
+ await AgentServerConversationService.batchGetAppConversations([
+ "conv-no-status",
+ ]);
+
+ expect(conversation?.sandbox_status).toBeNull();
+ });
+
+ it("sanitizes malformed optional conversation fields", async () => {
mockHttpGet.mockResolvedValue({
data: [
{
diff --git a/__tests__/components/browser.test.tsx b/__tests__/components/browser.test.tsx
index 7fe7cd3269..68c76b168d 100644
--- a/__tests__/components/browser.test.tsx
+++ b/__tests__/components/browser.test.tsx
@@ -4,6 +4,7 @@ import React from "react";
// Mock modules before importing the component
vi.mock("#/hooks/use-conversation-id", () => ({
+ useOptionalConversationId: () => ({ conversationId: "test-conversation-id" }),
useConversationId: () => ({ conversationId: "test-conversation-id" }),
}));
diff --git a/__tests__/components/conversation-events/chat/event-message-acp-tool-call.test.tsx b/__tests__/components/conversation-events/chat/event-message-acp-tool-call.test.tsx
index 7bd8c25e6d..59c5bd7d6f 100644
--- a/__tests__/components/conversation-events/chat/event-message-acp-tool-call.test.tsx
+++ b/__tests__/components/conversation-events/chat/event-message-acp-tool-call.test.tsx
@@ -12,6 +12,7 @@ vi.mock("#/hooks/query/use-config", () => ({
}));
vi.mock("#/hooks/use-agent-state");
vi.mock("#/hooks/use-conversation-id", () => ({
+ useOptionalConversationId: () => ({ conversationId: "test-conversation-id" }),
useConversationId: () => ({ conversationId: "test-conversation-id" }),
}));
diff --git a/__tests__/components/conversation-events/chat/event-message-plan-preview.test.tsx b/__tests__/components/conversation-events/chat/event-message-plan-preview.test.tsx
index d15dd99d44..2c6ee598d9 100644
--- a/__tests__/components/conversation-events/chat/event-message-plan-preview.test.tsx
+++ b/__tests__/components/conversation-events/chat/event-message-plan-preview.test.tsx
@@ -22,6 +22,7 @@ vi.mock("#/hooks/use-agent-state");
// Mock PlanPreview component to verify it's rendered with correct props
// Mock useConversationId (EventMessage -> useAgentState -> useActiveConversation -> useConversationId)
vi.mock("#/hooks/use-conversation-id", () => ({
+ useOptionalConversationId: () => ({ conversationId: "test-conversation-id" }),
useConversationId: () => ({ conversationId: "test-conversation-id" }),
}));
diff --git a/__tests__/components/conversation-events/chat/event-message-think-action.test.tsx b/__tests__/components/conversation-events/chat/event-message-think-action.test.tsx
index b86d008984..b1f86eaf69 100644
--- a/__tests__/components/conversation-events/chat/event-message-think-action.test.tsx
+++ b/__tests__/components/conversation-events/chat/event-message-think-action.test.tsx
@@ -20,6 +20,7 @@ vi.mock("#/hooks/use-agent-state");
// Mock useConversationId
vi.mock("#/hooks/use-conversation-id", () => ({
+ useOptionalConversationId: () => ({ conversationId: "test-conversation-id" }),
useConversationId: () => ({ conversationId: "test-conversation-id" }),
}));
diff --git a/__tests__/components/features/chat/git-control-bar.test.tsx b/__tests__/components/features/chat/git-control-bar.test.tsx
index e6f4e5ead1..3bcbb29fd4 100644
--- a/__tests__/components/features/chat/git-control-bar.test.tsx
+++ b/__tests__/components/features/chat/git-control-bar.test.tsx
@@ -15,6 +15,7 @@ import { getStoredConversationMetadata } from "#/api/conversation-metadata-store
import { GitControlBar } from "#/components/features/chat/git-control-bar";
vi.mock("#/hooks/use-conversation-id", () => ({
+ useOptionalConversationId: () => ({ conversationId: "test-conversation-id" }),
useConversationId: () => ({ conversationId: "test-conversation-id" }),
}));
vi.mock("#/contexts/active-backend-context");
diff --git a/__tests__/components/features/conversation/conversation-tab-content.test.tsx b/__tests__/components/features/conversation/conversation-tab-content.test.tsx
index fbd407ecbd..5d6b49521c 100644
--- a/__tests__/components/features/conversation/conversation-tab-content.test.tsx
+++ b/__tests__/components/features/conversation/conversation-tab-content.test.tsx
@@ -11,6 +11,7 @@ import {
// Mock useConversationId hook
let mockConversationId = "test-conversation-id-123";
vi.mock("#/hooks/use-conversation-id", () => ({
+ useOptionalConversationId: () => ({ conversationId: "test-conversation-id" }),
useConversationId: () => ({
conversationId: mockConversationId,
}),
diff --git a/__tests__/components/features/conversation/conversation-tabs-context-menu.test.tsx b/__tests__/components/features/conversation/conversation-tabs-context-menu.test.tsx
index 166e1550c3..73088e2893 100644
--- a/__tests__/components/features/conversation/conversation-tabs-context-menu.test.tsx
+++ b/__tests__/components/features/conversation/conversation-tabs-context-menu.test.tsx
@@ -14,6 +14,7 @@ import type { Backend } from "#/api/backend-registry/types";
const CONVERSATION_ID = "conv-abc123";
vi.mock("#/hooks/use-conversation-id", () => ({
+ useOptionalConversationId: () => ({ conversationId: "test-conversation-id" }),
useConversationId: () => ({ conversationId: CONVERSATION_ID }),
}));
diff --git a/__tests__/components/features/conversation/conversation-tabs.test.tsx b/__tests__/components/features/conversation/conversation-tabs.test.tsx
index bbac228d97..0465ca3552 100644
--- a/__tests__/components/features/conversation/conversation-tabs.test.tsx
+++ b/__tests__/components/features/conversation/conversation-tabs.test.tsx
@@ -20,6 +20,7 @@ const REAL_CONVERSATION_ID = "conv-abc123";
let mockConversationId = TASK_CONVERSATION_ID;
vi.mock("#/hooks/use-conversation-id", () => ({
+ useOptionalConversationId: () => ({ conversationId: "test-conversation-id" }),
useConversationId: () => ({ conversationId: mockConversationId }),
}));
diff --git a/__tests__/components/features/conversation/right-panel-toggle.test.tsx b/__tests__/components/features/conversation/right-panel-toggle.test.tsx
index d68c7e47fc..6d4cd39a21 100644
--- a/__tests__/components/features/conversation/right-panel-toggle.test.tsx
+++ b/__tests__/components/features/conversation/right-panel-toggle.test.tsx
@@ -7,6 +7,7 @@ import { useConversationStore } from "#/stores/conversation-store";
const CONVERSATION_ID = "conv-abc123";
vi.mock("#/hooks/use-conversation-id", () => ({
+ useOptionalConversationId: () => ({ conversationId: "test-conversation-id" }),
useConversationId: () => ({ conversationId: CONVERSATION_ID }),
}));
diff --git a/__tests__/contexts/websocket-provider-wrapper.test.tsx b/__tests__/contexts/websocket-provider-wrapper.test.tsx
new file mode 100644
index 0000000000..fcd8d008de
--- /dev/null
+++ b/__tests__/contexts/websocket-provider-wrapper.test.tsx
@@ -0,0 +1,140 @@
+/**
+ * Tests that WebSocketProviderWrapper correctly gates the conversationUrl
+ * it passes down to ConversationWebSocketProvider based on sandbox_status.
+ *
+ * Regression: when a cloud sandbox is PAUSED the API does NOT clear
+ * conversation_url โ€” the stale URL persists. We must suppress it until the
+ * sandbox has fully resumed, otherwise the WS provider immediately tries to
+ * connect to a dead host and the browser console fills with connection errors.
+ */
+import React from "react";
+import { render } from "@testing-library/react";
+import { describe, it, expect, vi, beforeEach } from "vitest";
+import { WebSocketProviderWrapper } from "#/contexts/websocket-provider-wrapper";
+import type { AppConversation } from "#/api/conversation-service/agent-server-conversation-service.types";
+
+// โ”€โ”€ Mocks โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
+
+const capturedUrlPerRender: (string | null | undefined)[] = [];
+
+vi.mock("#/contexts/conversation-websocket-context", () => ({
+ ConversationWebSocketProvider: ({
+ conversationUrl,
+ children,
+ }: {
+ conversationUrl?: string | null;
+ children?: React.ReactNode;
+ }) => {
+ capturedUrlPerRender.push(conversationUrl);
+ return <>{children}</>;
+ },
+}));
+
+const mockUseActiveConversation = vi.fn();
+vi.mock("#/hooks/query/use-active-conversation", () => ({
+ useActiveConversation: () => mockUseActiveConversation(),
+}));
+
+vi.mock("#/hooks/query/use-sub-conversations", () => ({
+ useSubConversations: () => ({ data: [] }),
+}));
+
+// โ”€โ”€ Helpers โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
+
+function makeConversation(
+ overrides: Partial<AppConversation> = {},
+): AppConversation {
+ return {
+ id: "conv-1",
+ created_by_user_id: null,
+ selected_repository: null,
+ selected_branch: null,
+ git_provider: null,
+ title: "Test",
+ trigger: null,
+ pr_number: [],
+ llm_model: null,
+ metrics: null,
+ created_at: "2024-01-01T00:00:00Z",
+ updated_at: "2024-01-01T00:00:00Z",
+ execution_status: null,
+ conversation_url: "https://sandbox.example.com/api/conversations/conv-1",
+ session_api_key: "sess-key",
+ sandbox_id: "sbx-1",
+ sub_conversation_ids: [],
+ ...overrides,
+ };
+}
+
+function renderWrapper() {
+ render(
+ <WebSocketProviderWrapper conversationId="conv-1">
+ <div />
+ </WebSocketProviderWrapper>,
+ );
+}
+
+// โ”€โ”€ Tests โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
+
+describe("WebSocketProviderWrapper โ€” conversationUrl gating", () => {
+ beforeEach(() => {
+ capturedUrlPerRender.length = 0;
+ vi.clearAllMocks();
+ });
+
+ it("passes conversation_url through when sandbox_status is null (local backend)", () => {
+ mockUseActiveConversation.mockReturnValue({
+ data: makeConversation({ sandbox_status: null }),
+ });
+
+ renderWrapper();
+
+ expect(capturedUrlPerRender.at(-1)).toBe(
+ "https://sandbox.example.com/api/conversations/conv-1",
+ );
+ });
+
+ it("passes conversation_url through when sandbox_status is RUNNING", () => {
+ mockUseActiveConversation.mockReturnValue({
+ data: makeConversation({ sandbox_status: "RUNNING" }),
+ });
+
+ renderWrapper();
+
+ expect(capturedUrlPerRender.at(-1)).toBe(
+ "https://sandbox.example.com/api/conversations/conv-1",
+ );
+ });
+
+ it("suppresses conversation_url (returns null) when sandbox_status is PAUSED", () => {
+ mockUseActiveConversation.mockReturnValue({
+ data: makeConversation({
+ sandbox_status: "PAUSED",
+ // The API keeps the stale URL even while paused โ€” this is the regression.
+ conversation_url: "https://sandbox.example.com/api/conversations/conv-1",
+ }),
+ });
+
+ renderWrapper();
+
+ expect(capturedUrlPerRender.at(-1)).toBeNull();
+ });
+
+ it("passes null through when conversation data has no url (sandbox still starting)", () => {
+ mockUseActiveConversation.mockReturnValue({
+ data: makeConversation({ sandbox_status: null, conversation_url: null }),
+ });
+
+ renderWrapper();
+
+ expect(capturedUrlPerRender.at(-1)).toBeNull();
+ });
+
+ it("passes undefined through when conversation data is not yet fetched", () => {
+ mockUseActiveConversation.mockReturnValue({ data: undefined });
+
+ renderWrapper();
+
+ expect(capturedUrlPerRender.at(-1)).toBeUndefined();
+ });
+});
diff --git a/__tests__/hooks/mutation/conversation-mutation-utils.test.ts b/__tests__/hooks/mutation/conversation-mutation-utils.test.ts
new file mode 100644
index 0000000000..de45b1c4bc
--- /dev/null
+++ b/__tests__/hooks/mutation/conversation-mutation-utils.test.ts
@@ -0,0 +1,166 @@
+/**
+ * Tests for patchConversationInCache and updateConversationExecutionStatusInCache
+ * in conversation-mutation-utils.ts.
+ *
+ * These functions are the mechanism that keeps the React Query cache in sync
+ * with optimistic UI updates after stop/resume mutations. The most critical
+ * invariant is that after pauseConversation succeeds the cache carries BOTH
+ * execution_status AND sandbox_status as "PAUSED" โ€” if sandbox_status is not
+ * updated, WebSocketProviderWrapper's sandbox_status === "PAUSED" gate never
+ * fires and the WebSocket tries to connect to the dead sandbox.
+ */
+
+import { QueryClient } from "@tanstack/react-query";
+import { describe, expect, it, beforeEach } from "vitest";
+import {
+ patchConversationInCache,
+ updateConversationExecutionStatusInCache,
+} from "#/hooks/mutation/conversation-mutation-utils";
+import type { AppConversation } from "#/api/conversation-service/agent-server-conversation-service.types";
+import { ExecutionStatus } from "#/types/agent-server/core/base/common";
+
+const CONV_ID = "conv-test-1";
+
+const makeConversation = (
+ overrides: Partial<AppConversation> = {},
+): AppConversation => ({
+ id: CONV_ID,
+ created_by_user_id: null,
+ selected_repository: null,
+ selected_branch: null,
+ git_provider: null,
+ title: "Test conversation",
+ trigger: null,
+ pr_number: [],
+ llm_model: null,
+ metrics: null,
+ created_at: "2024-01-01T00:00:00Z",
+ updated_at: "2024-01-01T00:00:00Z",
+ execution_status: null,
+ conversation_url: "https://sandbox.example.com/api/conversations/conv-test-1",
+ session_api_key: "sess-key",
+ sandbox_id: "sbx-1",
+ sandbox_status: "RUNNING",
+ sub_conversation_ids: [],
+ ...overrides,
+});
+
+let queryClient: QueryClient;
+
+beforeEach(() => {
+ queryClient = new QueryClient({
+ defaultOptions: { queries: { retry: false } },
+ });
+});
+
+// โ”€โ”€โ”€ patchConversationInCache โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
+
+describe("patchConversationInCache", () => {
+ it("patches the single-item conversation cache", () => {
+ queryClient.setQueryData(
+ ["user", "conversation", CONV_ID],
+ makeConversation({ sandbox_status: "RUNNING" }),
+ );
+
+ patchConversationInCache(queryClient, CONV_ID, { sandbox_status: "PAUSED" });
+
+ const cached = queryClient.getQueryData<AppConversation>([
+ "user",
+ "conversation",
+ CONV_ID,
+ ]);
+ expect(cached?.sandbox_status).toBe("PAUSED");
+ });
+
+ it("patches conversation inside the paginated list cache", () => {
+ queryClient.setQueryData(["user", "conversations"], {
+ pages: [{ items: [makeConversation({ sandbox_status: "RUNNING" })] }],
+ pageParams: [],
+ });
+
+ patchConversationInCache(queryClient, CONV_ID, { sandbox_status: "PAUSED" });
+
+ const list = queryClient.getQueryData<{
+ pages: Array<{ items: AppConversation[] }>;
+ }>(["user", "conversations"]);
+ expect(list?.pages[0]?.items[0]?.sandbox_status).toBe("PAUSED");
+ });
+
+ it("patches multiple fields atomically", () => {
+ queryClient.setQueryData(
+ ["user", "conversation", CONV_ID],
+ makeConversation({
+ execution_status: ExecutionStatus.RUNNING,
+ sandbox_status: "RUNNING",
+ }),
+ );
+
+ patchConversationInCache(queryClient, CONV_ID, {
+ execution_status: ExecutionStatus.PAUSED,
+ sandbox_status: "PAUSED",
+ });
+
+ const cached = queryClient.getQueryData<AppConversation>([
+ "user",
+ "conversation",
+ CONV_ID,
+ ]);
+ expect(cached?.execution_status).toBe(ExecutionStatus.PAUSED);
+ expect(cached?.sandbox_status).toBe("PAUSED");
+ });
+
+ it("does not modify other conversations in the list", () => {
+ const other = makeConversation({
+ id: "conv-other",
+ sandbox_status: "RUNNING",
+ });
+ queryClient.setQueryData(["user", "conversations"], {
+ pages: [{ items: [makeConversation(), other] }],
+ pageParams: [],
+ });
+
+ patchConversationInCache(queryClient, CONV_ID, { sandbox_status: "PAUSED" });
+
+ const list = queryClient.getQueryData<{
+ pages: Array<{ items: AppConversation[] }>;
+ }>(["user", "conversations"]);
+ const otherCached = list?.pages[0]?.items.find((c) => c.id === "conv-other");
+ expect(otherCached?.sandbox_status).toBe("RUNNING");
+ });
+
+ it("is a no-op when the single-item cache is empty", () => {
+ // No query data seeded โ€” should not throw.
+ expect(() =>
+ patchConversationInCache(queryClient, CONV_ID, { sandbox_status: "PAUSED" }),
+ ).not.toThrow();
+ });
+});
+
+// โ”€โ”€โ”€ updateConversationExecutionStatusInCache (backwards compat wrapper) โ”€โ”€โ”€โ”€โ”€
+
+describe("updateConversationExecutionStatusInCache", () => {
+ it("updates execution_status without disturbing sandbox_status", () => {
+ queryClient.setQueryData(
+ ["user", "conversation", CONV_ID],
+ makeConversation({
+ execution_status: ExecutionStatus.RUNNING,
+ sandbox_status: "RUNNING",
+ }),
+ );
+
+ updateConversationExecutionStatusInCache(
+ queryClient,
+ CONV_ID,
+ ExecutionStatus.PAUSED,
+ );
+
+ const cached = queryClient.getQueryData<AppConversation>([
+ "user",
+ "conversation",
+ CONV_ID,
+ ]);
+ expect(cached?.execution_status).toBe(ExecutionStatus.PAUSED);
+ // sandbox_status must remain unchanged โ€” this wrapper only touches execution_status
+ expect(cached?.sandbox_status).toBe("RUNNING");
+ });
+});
diff --git a/__tests__/hooks/query/use-active-conversation.test.ts b/__tests__/hooks/query/use-active-conversation.test.ts
new file mode 100644
index 0000000000..915a48d8e2
--- /dev/null
+++ b/__tests__/hooks/query/use-active-conversation.test.ts
@@ -0,0 +1,160 @@
+/**
+ * Tests that useActiveConversation passes the correct refetchInterval callback
+ * to useUserConversation.
+ *
+ * Regression: the original callback only fast-polled (3 s) when
+ * conversation_url was absent. For PAUSED sandboxes the cloud API keeps the
+ * old conversation_url โ€” checking that field alone left the hook on the slow
+ * 30-second interval while the sandbox was waking up after a resume call.
+ *
+ * The fix adds sandbox_status === "PAUSED" as a second fast-poll trigger so
+ * the hook picks up the PAUSED โ†’ RUNNING transition within ~3 s regardless of
+ * whether conversation_url is present.
+ */
+import { describe, it, expect, vi, beforeEach } from "vitest";
+import { renderHook } from "@testing-library/react";
+import { useActiveConversation } from "#/hooks/query/use-active-conversation";
+import type { AppConversation } from "#/api/conversation-service/agent-server-conversation-service.types";
+
+// โ”€โ”€ Mocks โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
+
+const { mockUseUserConversation, mockSetCurrentConversation } = vi.hoisted(
+ () => ({
+ mockUseUserConversation: vi.fn(),
+ mockSetCurrentConversation: vi.fn(),
+ }),
+);
+
+vi.mock("#/hooks/query/use-user-conversation", () => ({
+ useUserConversation: (...args: unknown[]) =>
+ mockUseUserConversation(...args),
+}));
+
+vi.mock("#/hooks/use-conversation-id", () => ({
+ useOptionalConversationId: () => ({ conversationId: "conv-test" }),
+ useConversationId: () => ({ conversationId: "conv-test" }),
+}));
+
+vi.mock("#/api/conversation-service/conversation-service.api", () => ({
+ default: { setCurrentConversation: mockSetCurrentConversation },
+}));
+
+// โ”€โ”€ Helpers โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
+
+type IntervalFn = (query: {
+ state: { data: AppConversation | null | undefined };
+}) => number;
+
+/** Render the hook and return the refetchInterval function it passed to useUserConversation. */
+function renderAndCaptureIntervalFn(): IntervalFn {
+ let captured: IntervalFn | undefined;
+
+ mockUseUserConversation.mockImplementation(
+ (_cid: string | null, intervalFn: IntervalFn) => {
+ captured = intervalFn;
+ return {
+ data: undefined,
+ isLoading: false,
+ isPending: false,
+ isFetched: false,
+ error: null,
+ isError: false,
+ };
+ },
+ );
+
+ renderHook(() => useActiveConversation());
+
+ if (!captured) throw new Error("useUserConversation was not called");
+ return captured;
+}
+
+function makeQuery(
+ data: Partial<AppConversation> | null | undefined,
+): { state: { data: AppConversation | null | undefined } } {
+ if (!data) return { state: { data: data as null | undefined } };
+ return {
+ state: {
+ data: {
+ id: "conv-1",
+ created_by_user_id: null,
+ selected_repository: null,
+ selected_branch: null,
+ git_provider: null,
+ title: "Test",
+ trigger: null,
+ pr_number: [],
+ llm_model: null,
+ metrics: null,
+ created_at: "2024-01-01T00:00:00Z",
+ updated_at: "2024-01-01T00:00:00Z",
+ execution_status: null,
+ conversation_url: "https://sandbox.example.com/api/conversations/conv-1",
+ session_api_key: null,
+ sandbox_id: null,
+ sub_conversation_ids: [],
+ ...data,
+ } as AppConversation,
+ },
+ };
+}
+
+// โ”€โ”€ Tests โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
+
+describe("useActiveConversation โ€” refetchInterval callback", () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ });
+
+ it("returns 3000 when sandbox_status is PAUSED (even if conversation_url is present)", () => {
+ const intervalFn = renderAndCaptureIntervalFn();
+
+ const result = intervalFn(
+ makeQuery({
+ sandbox_status: "PAUSED",
+ conversation_url: "https://sandbox.example.com/api/conversations/conv-1",
+ }),
+ );
+
+ expect(result).toBe(3000);
+ });
+
+ it("returns 3000 when conversation_url is null (sandbox still starting)", () => {
+ const intervalFn = renderAndCaptureIntervalFn();
+
+ const result = intervalFn(makeQuery({ conversation_url: null }));
+
+ expect(result).toBe(3000);
+ });
+
+ it("returns 30000 when conversation_url is present and sandbox_status is null (local backend)", () => {
+ const intervalFn = renderAndCaptureIntervalFn();
+
+ const result = intervalFn(
+ makeQuery({ sandbox_status: null, conversation_url: "https://..." }),
+ );
+
+ expect(result).toBe(30000);
+ });
+
+ it("returns 30000 when conversation_url is present and sandbox_status is RUNNING", () => {
+ const intervalFn = renderAndCaptureIntervalFn();
+
+ const result = intervalFn(
+ makeQuery({
+ sandbox_status: "RUNNING",
+ conversation_url: "https://sandbox.example.com/api/conversations/conv-1",
+ }),
+ );
+
+ expect(result).toBe(30000);
+ });
+
+ it("returns 30000 when query data is null (conversation not yet loaded)", () => {
+ const intervalFn = renderAndCaptureIntervalFn();
+
+ // data is null / undefined โ€” the `if (data && ...)` guard returns false
+ expect(intervalFn(makeQuery(null))).toBe(30000);
+ expect(intervalFn(makeQuery(undefined))).toBe(30000);
+ });
+});
diff --git a/__tests__/hooks/use-select-conversation-tab.test.ts b/__tests__/hooks/use-select-conversation-tab.test.ts
index 95b0b253c1..6b0d80af04 100644
--- a/__tests__/hooks/use-select-conversation-tab.test.ts
+++ b/__tests__/hooks/use-select-conversation-tab.test.ts
@@ -6,6 +6,7 @@ import { useConversationStore } from "#/stores/conversation-store";
const TEST_CONVERSATION_ID = "test-conversation-id";
vi.mock("#/hooks/use-conversation-id", () => ({
+ useOptionalConversationId: () => ({ conversationId: "test-conversation-id" }),
useConversationId: () => ({ conversationId: TEST_CONVERSATION_ID }),
}));
diff --git a/__tests__/hooks/use-unified-vscode-url.test.tsx b/__tests__/hooks/use-unified-vscode-url.test.tsx
index a28ce7df67..888d2456b0 100644
--- a/__tests__/hooks/use-unified-vscode-url.test.tsx
+++ b/__tests__/hooks/use-unified-vscode-url.test.tsx
@@ -23,6 +23,7 @@ vi.mock("#/contexts/active-backend-context");
vi.mock("#/hooks/query/use-active-conversation");
vi.mock("#/hooks/use-runtime-is-ready");
vi.mock("#/hooks/use-conversation-id", () => ({
+ useOptionalConversationId: () => ({ conversationId: "test-conversation-id" }),
useConversationId: () => ({ conversationId: "conv-123" }),
}));
diff --git a/src/api/agent-server-adapter.ts b/src/api/agent-server-adapter.ts
index 676db16485..c1eeda76d1 100644
--- a/src/api/agent-server-adapter.ts
+++ b/src/api/agent-server-adapter.ts
@@ -10,6 +10,7 @@ import {
PluginSpec,
AppConversation,
AppConversationPage,
+ SandboxStatus,
} from "./conversation-service/agent-server-conversation-service.types";
import SettingsService from "./settings-service/settings-service.api";
import { getStoredConversationMetadata } from "./conversation-metadata-store";
@@ -20,6 +21,8 @@ export interface DirectConversationInfo {
created_at: string;
updated_at: string;
execution_status?: string | null;
+ /** Cloud-only sandbox lifecycle state. Omitted / null for local agent-server conversations. */
+ sandbox_status?: string | null;
metrics?: {
accumulated_cost?: number | null;
max_budget_per_task?: number | null;
@@ -260,6 +263,7 @@ export function toAppConversation(
execution_status:
(info.execution_status as AppConversation["execution_status"]) ??
ExecutionStatus.IDLE,
+ sandbox_status: (info.sandbox_status as SandboxStatus | null) ?? null,
conversation_url: toConversationUrl(info.id),
session_api_key: getEffectiveLocalBackend().apiKey || null,
sandbox_id: null,
diff --git a/src/api/cloud/conversation-service.api.ts b/src/api/cloud/conversation-service.api.ts
index d6c496d5e1..99836879a6 100644
--- a/src/api/cloud/conversation-service.api.ts
+++ b/src/api/cloud/conversation-service.api.ts
@@ -204,6 +204,25 @@ export async function pauseCloudSandbox(sandboxId: string): Promise<void> {
});
}
+/**
+ * Resume a paused cloud sandbox. Mirrors OpenHands' `SandboxService.resumeSandbox`
+ * โ€” routes through the bundled agent-server's cloud proxy and hits
+ * `POST /api/v1/sandboxes/{sandboxId}/resume` on the SaaS.
+ *
+ * This is the correct endpoint for waking a PAUSED sandbox. It is a
+ * lightweight unpause โ€” NOT the same as creating a new start task via
+ * `POST /api/v1/app-conversations`, which provisions a fresh conversation
+ * and is subject to the 120-second sandbox-start timeout.
+ */
+export async function resumeCloudSandbox(sandboxId: string): Promise<void> {
+ const backend = getActiveCloudBackend();
+ await callCloudProxy<unknown>({
+ backend,
+ method: "POST",
+ path: `/api/v1/sandboxes/${sandboxId}/resume`,
+ });
+}
+
/**
* Read a file from a cloud conversation's sandbox workspace. Mirrors
* OpenHands' `AgentServerConversationService.readConversationFile` โ€” hits
diff --git a/src/api/conversation-service/agent-server-conversation-service.api.ts b/src/api/conversation-service/agent-server-conversation-service.api.ts
index 7f45d4f9a4..bf212e308e 100644
--- a/src/api/conversation-service/agent-server-conversation-service.api.ts
+++ b/src/api/conversation-service/agent-server-conversation-service.api.ts
@@ -178,6 +178,7 @@ function requireDirectConversationInfo(item: unknown): DirectConversationInfo {
created_at: readTimestamp(item, "created_at", "createdAt"),
updated_at: readTimestamp(item, "updated_at", "updatedAt"),
execution_status: stringOrNull(item.execution_status),
+ sandbox_status: stringOrNull(item.sandbox_status),
metrics: normalizeMetrics(item.metrics),
agent: normalizeAgent(item.agent),
workspace: normalizeWorkspace(item.workspace),
diff --git a/src/api/conversation-service/agent-server-conversation-service.types.ts b/src/api/conversation-service/agent-server-conversation-service.types.ts
index 86dd56fc16..277fbd9b5c 100644
--- a/src/api/conversation-service/agent-server-conversation-service.types.ts
+++ b/src/api/conversation-service/agent-server-conversation-service.types.ts
@@ -3,6 +3,17 @@ import { Provider } from "#/types/settings";
import { SuggestedTask } from "#/utils/types";
import { ExecutionStatus } from "#/types/agent-server/core";
+/**
+ * Lifecycle state of a cloud sandbox. Mirrors OpenHands' V1SandboxStatus.
+ * Local agent-server conversations do not carry this field (null).
+ */
+export type SandboxStatus =
+ | "PAUSED"
+ | "RUNNING"
+ | "STARTING"
+ | "MISSING"
+ | "ERROR";
+
// Plugin specification for starting conversations with plugins
export interface PluginSpec {
source: string; // Plugin source: 'github:owner/repo', git URL, or local path
@@ -116,6 +127,11 @@ export interface AppConversation {
created_at: string;
updated_at: string;
execution_status: ExecutionStatus | null;
+ /**
+ * Cloud-only sandbox lifecycle status. Mirrors OpenHands' V1SandboxStatus.
+ * Absent / null for local agent-server conversations.
+ */
+ sandbox_status?: SandboxStatus | null;
conversation_url: string | null;
session_api_key: string | null;
sandbox_id: string | null;
diff --git a/src/components/features/chat/chat-interface.tsx b/src/components/features/chat/chat-interface.tsx
index ad25340527..28ccba0147 100644
--- a/src/components/features/chat/chat-interface.tsx
+++ b/src/components/features/chat/chat-interface.tsx
@@ -38,6 +38,7 @@ import ChatStatusIndicator from "./chat-status-indicator";
import { getStatusColor, getStatusText } from "#/utils/utils";
import { useNewConversationCommand } from "#/hooks/mutation/use-new-conversation-command";
import { useOptionalConversationId } from "#/hooks/use-conversation-id";
+import { useActiveConversation } from "#/hooks/query/use-active-conversation";
import { I18nKey } from "#/i18n/declaration";
function getEntryPoint(
@@ -91,6 +92,15 @@ export function ChatInterface() {
const { curAgentState } = useAgentState();
const { handleBuildPlanClick } = useHandleBuildPlanClick();
+ // Cloud conversations whose sandbox is MISSING or ERROR are read-only:
+ // the sandbox is gone and cannot be resumed, so we hide the chat input
+ // and show an explanatory banner. For local backends sandbox_status is
+ // always null, so this is effectively a no-op for non-cloud use.
+ const { data: activeConversation } = useActiveConversation();
+ const sandboxStatus = activeConversation?.sandbox_status ?? null;
+ const isArchivedConversation =
+ sandboxStatus === "MISSING" || sandboxStatus === "ERROR";
+
// Disable Build button while agent is running (streaming)
const isAgentRunning =
curAgentState === AgentState.RUNNING ||
@@ -405,7 +415,8 @@ export function ChatInterface() {
!hasPendingUserMessages &&
!userEventsExist &&
!hasModelEntries &&
- !isChatLoading && (
+ !isChatLoading &&
+ !isArchivedConversation && (
<ChatSuggestions
onSuggestionsClick={(message) => setMessageToSend(message)}
/>
@@ -483,38 +494,58 @@ export function ChatInterface() {
/>
)}
- <div className="relative">
- <div className="pointer-events-none absolute inset-x-0 bottom-full mb-1 z-20">
- <div className="flex justify-between relative">
- <div className="flex items-end gap-1 pointer-events-auto">
- <ConfirmationModeEnabled />
- {isStartingStatus && (
- <ChatStatusIndicator
- statusColor={serverStatusColor}
- status={serverStatusText}
- />
- )}
- </div>
-
- {!hitBottom ? (
- <div className="absolute left-1/2 transform -translate-x-1/2 bottom-0 pointer-events-auto">
- <ScrollToBottomButton onClick={scrollDomToBottom} />
+ {isArchivedConversation ? (
+ // Archived / sandbox-error: show a read-only notice in place of
+ // the chat input. The conversation history above is still visible.
+ <div
+ data-testid="archived-conversation-banner"
+ className="mx-1 px-4 py-3 rounded-lg bg-[var(--oh-surface)] border border-[var(--oh-border-subtle)]"
+ >
+ <p className="text-xs font-semibold text-[var(--oh-foreground)]">
+ {sandboxStatus === "ERROR"
+ ? t(I18nKey.CHAT_INTERFACE$ERROR_SANDBOX_TITLE)
+ : t(I18nKey.CHAT_INTERFACE$ARCHIVED_SANDBOX_TITLE)}
+ </p>
+ <p className="text-xs text-[var(--oh-muted)] mt-0.5">
+ {sandboxStatus === "ERROR"
+ ? t(I18nKey.CHAT_INTERFACE$ERROR_SANDBOX_DESCRIPTION)
+ : t(I18nKey.CHAT_INTERFACE$ARCHIVED_SANDBOX_DESCRIPTION)}
+ </p>
+ </div>
+ ) : (
+ <div className="relative">
+ <div className="pointer-events-none absolute inset-x-0 bottom-full mb-1 z-20">
+ <div className="flex justify-between relative">
+ <div className="flex items-end gap-1 pointer-events-auto">
+ <ConfirmationModeEnabled />
+ {isStartingStatus && (
+ <ChatStatusIndicator
+ statusColor={serverStatusColor}
+ status={serverStatusText}
+ />
+ )}
</div>
- ) : (
- curAgentState === AgentState.RUNNING && (
+
+ {!hitBottom ? (
<div className="absolute left-1/2 transform -translate-x-1/2 bottom-0 pointer-events-auto">
- <TypingIndicator />
+ <ScrollToBottomButton onClick={scrollDomToBottom} />
</div>
- )
- )}
+ ) : (
+ curAgentState === AgentState.RUNNING && (
+ <div className="absolute left-1/2 transform -translate-x-1/2 bottom-0 pointer-events-auto">
+ <TypingIndicator />
+ </div>
+ )
+ )}
+ </div>
</div>
- </div>
- <InteractiveChatBox
- onSubmit={handleSendMessage}
- disabled={isNewConversationPending}
- />
- </div>
+ <InteractiveChatBox
+ onSubmit={handleSendMessage}
+ disabled={isNewConversationPending}
+ />
+ </div>
+ )}
</div>
</div>
</ScrollProvider>
diff --git a/src/components/features/conversation-panel/compact-conversation-row.tsx b/src/components/features/conversation-panel/compact-conversation-row.tsx
index 28b0509ec7..740be69e0b 100644
--- a/src/components/features/conversation-panel/compact-conversation-row.tsx
+++ b/src/components/features/conversation-panel/compact-conversation-row.tsx
@@ -2,6 +2,7 @@ import React from "react";
import { Tooltip } from "@heroui/react";
import { NavigationLink } from "#/components/shared/navigation-link";
import { ExecutionStatus } from "#/types/agent-server/core/base/common";
+import { SandboxStatus } from "#/api/conversation-service/agent-server-conversation-service.types";
import { RepositorySelection } from "#/api/open-hands.types";
import { cn } from "#/utils/utils";
import { ConversationStatusDot } from "./conversation-status-dot";
@@ -12,6 +13,7 @@ interface CompactConversationRowProps {
title: string;
selectedRepository: RepositorySelection | null;
executionStatus?: ExecutionStatus | null;
+ sandboxStatus?: SandboxStatus | null;
lastUpdatedAt: string;
createdAt?: string;
workspaceWorkingDir?: string | null;
@@ -30,6 +32,7 @@ export function CompactConversationRow({
title,
selectedRepository,
executionStatus,
+ sandboxStatus,
lastUpdatedAt,
createdAt,
workspaceWorkingDir,
@@ -44,6 +47,7 @@ export function CompactConversationRow({
<div className="flex items-center gap-2 mb-1">
<ConversationStatusDot
executionStatus={executionStatus}
+ sandboxStatus={sandboxStatus}
showTooltip={false}
/>
<span className="text-sm font-medium text-white truncate" title={title}>
@@ -87,6 +91,7 @@ export function CompactConversationRow({
>
<ConversationStatusDot
executionStatus={executionStatus}
+ sandboxStatus={sandboxStatus}
showTooltip={false}
/>
</NavigationLink>
diff --git a/src/components/features/conversation-panel/conversation-card/conversation-card-header.tsx b/src/components/features/conversation-panel/conversation-card/conversation-card-header.tsx
index 7f852a0b16..3af63c500b 100644
--- a/src/components/features/conversation-panel/conversation-card/conversation-card-header.tsx
+++ b/src/components/features/conversation-panel/conversation-card/conversation-card-header.tsx
@@ -1,4 +1,5 @@
import { ExecutionStatus } from "#/types/agent-server/core/base/common";
+import { SandboxStatus } from "#/api/conversation-service/agent-server-conversation-service.types";
import { ConversationCardTitle } from "./conversation-card-title";
import { ConversationStatusDot } from "../conversation-status-dot";
@@ -7,6 +8,7 @@ interface ConversationCardHeaderProps {
titleMode: "view" | "edit";
onTitleSave: (title: string) => void;
executionStatus?: ExecutionStatus | null;
+ sandboxStatus?: SandboxStatus | null;
}
export function ConversationCardHeader({
@@ -14,19 +16,24 @@ export function ConversationCardHeader({
titleMode,
onTitleSave,
executionStatus,
+ sandboxStatus,
}: ConversationCardHeaderProps) {
+ const isArchived = sandboxStatus === "MISSING" || sandboxStatus === "ERROR";
return (
<div className="flex items-center gap-2 flex-1 min-w-0 overflow-hidden">
{executionStatus !== undefined && (
<div className="flex items-center">
- <ConversationStatusDot executionStatus={executionStatus} />
+ <ConversationStatusDot
+ executionStatus={executionStatus}
+ sandboxStatus={sandboxStatus}
+ />
</div>
)}
<ConversationCardTitle
title={title}
titleMode={titleMode}
onSave={onTitleSave}
- isConversationArchived={false}
+ isConversationArchived={isArchived}
/>
</div>
);
diff --git a/src/components/features/conversation-panel/conversation-card/conversation-card.tsx b/src/components/features/conversation-panel/conversation-card/conversation-card.tsx
index 671ea44fc7..224a09e90d 100644
--- a/src/components/features/conversation-panel/conversation-card/conversation-card.tsx
+++ b/src/components/features/conversation-panel/conversation-card/conversation-card.tsx
@@ -4,11 +4,13 @@ import { cn } from "#/utils/utils";
import { transformVSCodeUrl } from "#/utils/vscode-url-helper";
import ConversationService from "#/api/conversation-service/conversation-service.api";
import { ExecutionStatus } from "#/types/agent-server/core/base/common";
+import { SandboxStatus } from "#/api/conversation-service/agent-server-conversation-service.types";
import { RepositorySelection } from "#/api/open-hands.types";
import { formatTimeDelta } from "#/utils/format-time-delta";
import { ConversationCardHeader } from "./conversation-card-header";
import { ConversationCardActions } from "./conversation-card-actions";
import { ConversationCardFooter } from "./conversation-card-footer";
+import { ConversationStatusBadges } from "./conversation-status-badges";
import { useDownloadConversation } from "#/hooks/use-download-conversation";
interface ConversationCardProps {
@@ -22,6 +24,7 @@ interface ConversationCardProps {
lastUpdatedAt: string;
createdAt?: string;
executionStatus?: ExecutionStatus | null;
+ sandboxStatus?: SandboxStatus | null;
conversationId?: string;
contextMenuOpen?: boolean;
onContextMenuToggle?: (isOpen: boolean) => void;
@@ -42,6 +45,7 @@ export function ConversationCard({
createdAt,
conversationId,
executionStatus,
+ sandboxStatus,
contextMenuOpen = false,
onContextMenuToggle,
isActive = false,
@@ -135,13 +139,21 @@ export function ConversationCard({
)}
>
<div className="flex items-center w-full min-w-0">
- <div className="flex items-center gap-2 flex-1 min-w-0">
+ <div className="flex items-center gap-2 flex-1 min-w-0 overflow-hidden">
<ConversationCardHeader
title={title}
titleMode={titleMode}
onTitleSave={onTitleSave}
executionStatus={executionStatus}
+ sandboxStatus={sandboxStatus}
/>
+ {(sandboxStatus === "MISSING" || sandboxStatus === "ERROR") && (
+ <ConversationStatusBadges
+ conversationStatus={
+ sandboxStatus === "MISSING" ? "ARCHIVED" : "ERROR"
+ }
+ />
+ )}
</div>
<div className="relative ml-auto pl-2 flex items-center justify-end shrink-0">
diff --git a/src/components/features/conversation-panel/conversation-card/conversation-status-badges.tsx b/src/components/features/conversation-panel/conversation-card/conversation-status-badges.tsx
index 008a904788..a8f2217083 100644
--- a/src/components/features/conversation-panel/conversation-card/conversation-status-badges.tsx
+++ b/src/components/features/conversation-panel/conversation-card/conversation-status-badges.tsx
@@ -15,7 +15,10 @@ export function ConversationStatusBadges({
if (conversationStatus === "ARCHIVED") {
return (
- <span className="flex items-center gap-1 px-1.5 py-0.5 bg-[var(--oh-text-dim)] text-white text-xs font-medium rounded-full opacity-60">
+ <span
+ data-testid="archived-badge"
+ className="flex items-center gap-1 px-1.5 py-0.5 bg-[var(--oh-text-dim)] text-white text-xs font-medium rounded-full opacity-60"
+ >
<FaArchive size={10} className="text-white" />
<span>{t(I18nKey.COMMON$ARCHIVED)}</span>
</span>
@@ -24,7 +27,10 @@ export function ConversationStatusBadges({
if (conversationStatus === "ERROR") {
return (
- <span className="flex items-center gap-1 px-1.5 py-0.5 bg-[var(--oh-status-error)] text-white text-xs font-medium rounded-full">
+ <span
+ data-testid="error-badge"
+ className="flex items-center gap-1 px-1.5 py-0.5 bg-[var(--oh-status-error)] text-white text-xs font-medium rounded-full"
+ >
<CircleErrorIcon className="text-white w-3 h-3" />
<span>{t(I18nKey.COMMON$ERROR)}</span>
</span>
diff --git a/src/components/features/conversation-panel/conversation-panel.tsx b/src/components/features/conversation-panel/conversation-panel.tsx
index 5bb43caa73..53413e8dc1 100644
--- a/src/components/features/conversation-panel/conversation-panel.tsx
+++ b/src/components/features/conversation-panel/conversation-panel.tsx
@@ -244,6 +244,7 @@ export function ConversationPanel({
git_provider: conversation.git_provider as Provider,
}}
executionStatus={conversation.execution_status}
+ sandboxStatus={conversation.sandbox_status}
lastUpdatedAt={conversation.updated_at}
createdAt={conversation.created_at}
workspaceWorkingDir={conversation.workspace?.working_dir}
@@ -277,6 +278,7 @@ export function ConversationPanel({
lastUpdatedAt={conversation.updated_at}
createdAt={conversation.created_at}
executionStatus={conversation.execution_status}
+ sandboxStatus={conversation.sandbox_status}
conversationId={conversation.id}
contextMenuOpen={openContextMenuId === conversation.id}
onContextMenuToggle={(isOpen) =>
diff --git a/src/components/features/conversation-panel/conversation-status-dot.tsx b/src/components/features/conversation-panel/conversation-status-dot.tsx
index c4e47f9793..0e6f452eba 100644
--- a/src/components/features/conversation-panel/conversation-status-dot.tsx
+++ b/src/components/features/conversation-panel/conversation-status-dot.tsx
@@ -1,9 +1,16 @@
import { useTranslation } from "react-i18next";
import { ExecutionStatus } from "#/types/agent-server/core/base/common";
+import { SandboxStatus } from "#/api/conversation-service/agent-server-conversation-service.types";
import { StyledTooltip } from "#/components/shared/buttons/styled-tooltip";
interface ConversationStatusDotProps {
executionStatus: ExecutionStatus | null | undefined;
+ /**
+ * Cloud-only sandbox lifecycle status. When provided, MISSING and ERROR
+ * override the execution-status visual so the dot reflects the sandbox
+ * state rather than the last agent execution state.
+ */
+ sandboxStatus?: SandboxStatus | null;
/**
* Wrap the dot in a tooltip showing the human-readable status label.
* Disable this when the dot is already nested inside a larger tooltip
@@ -34,7 +41,8 @@ const visualFor = (status: ExecutionStatus | null | undefined): Visual => {
}
};
-const labelKeyFor = (visual: Visual): string => {
+const labelKeyFor = (visual: Visual, isArchived?: boolean): string => {
+ if (isArchived) return "COMMON$ARCHIVED";
switch (visual) {
case "check":
return "COMMON$FINISHED";
@@ -107,12 +115,24 @@ function renderIndicator(visual: Visual) {
export function ConversationStatusDot({
executionStatus,
+ sandboxStatus,
showTooltip = true,
}: ConversationStatusDotProps) {
const { t } = useTranslation("openhands");
- const visual = visualFor(executionStatus);
- const label = t(labelKeyFor(visual));
+ // sandbox_status === "MISSING" โ†’ show archived (gray) dot
+ // sandbox_status === "ERROR" โ†’ show error (red) dot
+ // Otherwise fall through to the execution-status visual.
+ const isArchived = sandboxStatus === "MISSING";
+ const effectiveVisual: Visual =
+ sandboxStatus === "ERROR"
+ ? "error"
+ : isArchived
+ ? "paused"
+ : visualFor(executionStatus);
+
+ const visual = effectiveVisual;
+ const label = t(labelKeyFor(visual, isArchived));
const indicator = renderIndicator(visual);
const dot = (
diff --git a/src/contexts/websocket-provider-wrapper.tsx b/src/contexts/websocket-provider-wrapper.tsx
index f5458d4336..0e9a375ae0 100644
--- a/src/contexts/websocket-provider-wrapper.tsx
+++ b/src/contexts/websocket-provider-wrapper.tsx
@@ -21,10 +21,21 @@ export function WebSocketProviderWrapper({
(subConversation) => subConversation !== null,
);
+ // Don't pass a conversation URL to the WebSocket provider while the cloud
+ // sandbox is PAUSED. The URL still points to the old sandbox host, which
+ // rejects connections until the sandbox has fully resumed. Treating the URL
+ // as absent here keeps wsUrl === null in ConversationWebSocketProvider, so
+ // no connection is attempted until useActiveConversation detects the
+ // transition out of PAUSED (via fast 3-second polling).
+ const conversationUrl =
+ conversation?.sandbox_status === "PAUSED"
+ ? null
+ : conversation?.conversation_url;
+
return (
<ConversationWebSocketProvider
conversationId={conversationId}
- conversationUrl={conversation?.conversation_url}
+ conversationUrl={conversationUrl}
sessionApiKey={conversation?.session_api_key}
subConversationIds={conversation?.sub_conversation_ids}
subConversations={filteredSubConversations}
diff --git a/src/hooks/mutation/conversation-mutation-utils.ts b/src/hooks/mutation/conversation-mutation-utils.ts
index 5a28e12f33..288c0f2a77 100644
--- a/src/hooks/mutation/conversation-mutation-utils.ts
+++ b/src/hooks/mutation/conversation-mutation-utils.ts
@@ -73,38 +73,48 @@ export const resumeConversation = async (conversationId: string) => {
).runConversation(conversationId);
};
-export const updateConversationExecutionStatusInCache = (
+/**
+ * Patch arbitrary fields on a cached AppConversation in both the single-item
+ * and paginated list query caches. Prefer this over the narrower
+ * `updateConversationExecutionStatusInCache` when you need to update more than
+ * one field atomically (e.g. `execution_status` + `sandbox_status` together).
+ */
+export const patchConversationInCache = (
queryClient: QueryClient,
conversationId: string,
- execution_status: ExecutionStatusValue,
+ patch: Partial<AppConversation>,
): void => {
- queryClient.setQueryData<AppConversation | null>(
- ["user", "conversation", conversationId],
- (oldData) => {
- if (!oldData) return oldData;
- return { ...oldData, execution_status };
- },
+ // useUserConversation stores data under a 5-part key that includes the active
+ // backend id and org id. Use setQueriesData with prefix matching so the
+ // update reaches whichever (backend, org) variant is currently mounted.
+ queryClient.setQueriesData<AppConversation | null>(
+ { queryKey: ["user", "conversation", conversationId] },
+ (oldData) => (oldData ? { ...oldData, ...patch } : oldData),
);
queryClient.setQueriesData<{
- pages: Array<{
- items: Array<{ id: string; execution_status: ExecutionStatusValue }>;
- }>;
+ pages: Array<{ items: AppConversation[] }>;
}>({ queryKey: ["user", "conversations"] }, (oldData) => {
if (!oldData) return oldData;
-
return {
...oldData,
pages: oldData.pages.map((page) => ({
...page,
items: page.items.map((conv) =>
- conv.id === conversationId ? { ...conv, execution_status } : conv,
+ conv.id === conversationId ? { ...conv, ...patch } : conv,
),
})),
};
});
};
+export const updateConversationExecutionStatusInCache = (
+ queryClient: QueryClient,
+ conversationId: string,
+ execution_status: ExecutionStatusValue,
+): void =>
+ patchConversationInCache(queryClient, conversationId, { execution_status });
+
export const invalidateConversationQueries = (
queryClient: QueryClient,
conversationId: string,
diff --git a/src/hooks/mutation/use-unified-stop-conversation.ts b/src/hooks/mutation/use-unified-stop-conversation.ts
index 7486191c32..1c807abae6 100644
--- a/src/hooks/mutation/use-unified-stop-conversation.ts
+++ b/src/hooks/mutation/use-unified-stop-conversation.ts
@@ -7,7 +7,7 @@ import { I18nKey } from "#/i18n/declaration";
import { ExecutionStatus } from "#/types/agent-server/core";
import {
pauseConversation,
- updateConversationExecutionStatusInCache,
+ patchConversationInCache,
} from "./conversation-mutation-utils";
export const useUnifiedPauseConversation = () => {
@@ -52,11 +52,15 @@ export const useUnifiedPauseConversation = () => {
}
toast.success(t(I18nKey.TOAST$CONVERSATION_STOPPED), TOAST_OPTIONS);
- updateConversationExecutionStatusInCache(
- queryClient,
- variables.conversationId,
- ExecutionStatus.PAUSED,
- );
+ // Update both execution_status and sandbox_status together so that
+ // WebSocketProviderWrapper's sandbox_status === "PAUSED" gate fires
+ // immediately when the user reopens this conversation โ€” preventing a
+ // WebSocket connection attempt against the now-paused sandbox host
+ // before the next useActiveConversation poll returns.
+ patchConversationInCache(queryClient, variables.conversationId, {
+ execution_status: ExecutionStatus.PAUSED,
+ sandbox_status: "PAUSED",
+ });
if (currentConversationId === variables.conversationId) {
navigate("/conversations");
diff --git a/src/hooks/query/use-active-conversation.ts b/src/hooks/query/use-active-conversation.ts
index 4976faeb99..79fbc90b90 100644
--- a/src/hooks/query/use-active-conversation.ts
+++ b/src/hooks/query/use-active-conversation.ts
@@ -15,7 +15,20 @@ export const useActiveConversation = () => {
const userConversation = useUserConversation(
actualConversationId,
- () => 30000,
+ // Poll at 3 s while the sandbox URL is absent OR while the sandbox is
+ // PAUSED. A paused sandbox still carries the old conversation_url (it isn't
+ // cleared), so checking only for a missing URL would leave us on the slow
+ // 30 s interval while the sandbox is waking up after a resume call.
+ (query) => {
+ const data = query.state.data;
+ if (
+ data &&
+ (!data.conversation_url || data.sandbox_status === "PAUSED")
+ ) {
+ return 3000;
+ }
+ return 30000;
+ },
);
useEffect(() => {
diff --git a/src/i18n/translation.json b/src/i18n/translation.json
index 78d41776a4..796ec7013f 100644
--- a/src/i18n/translation.json
+++ b/src/i18n/translation.json
@@ -20603,6 +20603,74 @@
"uk": "ะั€ั…ั–ะฒะพะฒะฐะฝะพ",
"ca": "Arxivat"
},
+ "CHAT_INTERFACE$ARCHIVED_SANDBOX_TITLE": {
+ "en": "Sandbox no longer available",
+ "ja": "ใ‚ตใƒณใƒ‰ใƒœใƒƒใ‚ฏใ‚นใฏๅˆฉ็”จใงใใชใใชใ‚Šใพใ—ใŸ",
+ "zh-CN": "ๆฒ™็›’ไธๅ†ๅฏ็”จ",
+ "zh-TW": "ๆฒ™็›’ไธๅ†ๅฏ็”จ",
+ "ko-KR": "์ƒŒ๋“œ๋ฐ•์Šค๋ฅผ ๋” ์ด์ƒ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค",
+ "no": "Sandkassen er ikke lenger tilgjengelig",
+ "ar": "ู„ู… ุชุนุฏ ุจูŠุฆุฉ ุงู„ุงุฎุชุจุงุฑ ู…ุชุงุญุฉ",
+ "de": "Sandbox nicht mehr verfรผgbar",
+ "fr": "Sandbox non disponible",
+ "it": "Sandbox non piรน disponibile",
+ "pt": "Sandbox nรฃo disponรญvel",
+ "es": "Sandbox no disponible",
+ "ca": "El sandbox ja no estร  disponible",
+ "tr": "Sandbox artฤฑk kullanฤฑlamฤฑyor",
+ "uk": "ะŸั–ัะพั‡ะฝะธั†ั ะฑั–ะปัŒัˆะต ะฝะตะดะพัั‚ัƒะฟะฝะฐ"
+ },
+ "CHAT_INTERFACE$ARCHIVED_SANDBOX_DESCRIPTION": {
+ "en": "This conversation's sandbox has been removed. The history above is read-only.",
+ "ja": "ใ“ใฎไผš่ฉฑใฎใ‚ตใƒณใƒ‰ใƒœใƒƒใ‚ฏใ‚นใฏๅ‰Š้™คใ•ใ‚Œใพใ—ใŸใ€‚ไปฅไธŠใฎๅฑฅๆญดใฏ่ชญใฟๅ–ใ‚Šๅฐ‚็”จใงใ™ใ€‚",
+ "zh-CN": "ๆญคๅฏน่ฏ็š„ๆฒ™็›’ๅทฒ่ขซๅˆ ้™คใ€‚ไปฅไธŠๅކๅฒ่ฎฐๅฝ•ไธบๅช่ฏปใ€‚",
+ "zh-TW": "ๆญคๅฐ่ฉฑ็š„ๆฒ™็›’ๅทฒ่ขซๅˆช้™คใ€‚ไปฅไธŠๆญทๅฒ่จ˜้Œ„็‚บๅ”ฏ่ฎ€ใ€‚",
+ "ko-KR": "์ด ๋Œ€ํ™”์˜ ์ƒŒ๋“œ๋ฐ•์Šค๊ฐ€ ์‚ญ์ œ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์œ„์˜ ๊ธฐ๋ก์€ ์ฝ๊ธฐ ์ „์šฉ์ž…๋‹ˆ๋‹ค.",
+ "no": "Sandkassen til denne samtalen er fjernet. Historikken ovenfor er skrivebeskyttet.",
+ "ar": "ุชู…ุช ุฅุฒุงู„ุฉ ุจูŠุฆุฉ ุงุฎุชุจุงุฑ ู‡ุฐู‡ ุงู„ู…ุญุงุฏุซุฉ. ุงู„ุณุฌู„ ุฃุนู„ุงู‡ ู„ู„ู‚ุฑุงุกุฉ ูู‚ุท.",
+ "de": "Die Sandbox dieser Unterhaltung wurde entfernt. Der Verlauf oben ist schreibgeschรผtzt.",
+ "fr": "Le sandbox de cette conversation a รฉtรฉ supprimรฉ. L'historique ci-dessus est en lecture seule.",
+ "it": "La sandbox di questa conversazione รจ stata rimossa. La cronologia qui sopra รจ di sola lettura.",
+ "pt": "A sandbox desta conversa foi removida. O histรณrico acima รฉ somente leitura.",
+ "es": "El sandbox de esta conversaciรณn ha sido eliminado. El historial anterior es de solo lectura.",
+ "ca": "El sandbox d'aquesta conversa ha estat eliminat. L'historial de dalt รฉs de nomรฉs lectura.",
+ "tr": "Bu konuลŸmanฤฑn sandbox'ฤฑ kaldฤฑrฤฑldฤฑ. Yukarฤฑdaki geรงmiลŸ salt okunur modundadฤฑr.",
+ "uk": "ะŸั–ัะพั‡ะฝะธั†ัŽ ั†ั–ั”ั— ั€ะพะทะผะพะฒะธ ะฒะธะดะฐะปะตะฝะพ. ะะฐะฒะตะดะตะฝะฐ ะฒะธั‰ะต ั–ัั‚ะพั€ั–ั ะดะพัั‚ัƒะฟะฝะฐ ะปะธัˆะต ะดะปั ั‡ะธั‚ะฐะฝะฝั."
+ },
+ "CHAT_INTERFACE$ERROR_SANDBOX_TITLE": {
+ "en": "Sandbox error",
+ "ja": "ใ‚ตใƒณใƒ‰ใƒœใƒƒใ‚ฏใ‚นใ‚จใƒฉใƒผ",
+ "zh-CN": "ๆฒ™็›’้”™่ฏฏ",
+ "zh-TW": "ๆฒ™็›’้Œฏ่ชค",
+ "ko-KR": "์ƒŒ๋“œ๋ฐ•์Šค ์˜ค๋ฅ˜",
+ "no": "Sandkassefeil",
+ "ar": "ุฎุทุฃ ููŠ ุจูŠุฆุฉ ุงู„ุงุฎุชุจุงุฑ",
+ "de": "Sandbox-Fehler",
+ "fr": "Erreur de sandbox",
+ "it": "Errore sandbox",
+ "pt": "Erro de sandbox",
+ "es": "Error de sandbox",
+ "ca": "Error de sandbox",
+ "tr": "Sandbox hatasฤฑ",
+ "uk": "ะŸะพะผะธะปะบะฐ ะฟั–ัะพั‡ะฝะธั†ั–"
+ },
+ "CHAT_INTERFACE$ERROR_SANDBOX_DESCRIPTION": {
+ "en": "This conversation's sandbox encountered an error. The history above is read-only.",
+ "ja": "ใ“ใฎไผš่ฉฑใฎใ‚ตใƒณใƒ‰ใƒœใƒƒใ‚ฏใ‚นใงใ‚จใƒฉใƒผใŒ็™บ็”Ÿใ—ใพใ—ใŸใ€‚ไปฅไธŠใฎๅฑฅๆญดใฏ่ชญใฟๅ–ใ‚Šๅฐ‚็”จใงใ™ใ€‚",
+ "zh-CN": "ๆญคๅฏน่ฏ็š„ๆฒ™็›’้‡ๅˆฐ้”™่ฏฏใ€‚ไปฅไธŠๅކๅฒ่ฎฐๅฝ•ไธบๅช่ฏปใ€‚",
+ "zh-TW": "ๆญคๅฐ่ฉฑ็š„ๆฒ™็›’้‡ๅˆฐ้Œฏ่ชคใ€‚ไปฅไธŠๆญทๅฒ่จ˜้Œ„็‚บๅ”ฏ่ฎ€ใ€‚",
+ "ko-KR": "์ด ๋Œ€ํ™”์˜ ์ƒŒ๋“œ๋ฐ•์Šค์—์„œ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค. ์œ„์˜ ๊ธฐ๋ก์€ ์ฝ๊ธฐ ์ „์šฉ์ž…๋‹ˆ๋‹ค.",
+ "no": "Sandkassen til denne samtalen stรธtte pรฅ en feil. Historikken ovenfor er skrivebeskyttet.",
+ "ar": "ูˆุงุฌู‡ุช ุจูŠุฆุฉ ุงุฎุชุจุงุฑ ู‡ุฐู‡ ุงู„ู…ุญุงุฏุซุฉ ุฎุทุฃู‹. ุงู„ุณุฌู„ ุฃุนู„ุงู‡ ู„ู„ู‚ุฑุงุกุฉ ูู‚ุท.",
+ "de": "Die Sandbox dieser Unterhaltung ist auf einen Fehler gestoรŸen. Der Verlauf oben ist schreibgeschรผtzt.",
+ "fr": "Le sandbox de cette conversation a rencontrรฉ une erreur. L'historique ci-dessus est en lecture seule.",
+ "it": "La sandbox di questa conversazione ha riscontrato un errore. La cronologia qui sopra รจ di sola lettura.",
+ "pt": "A sandbox desta conversa encontrou um erro. O histรณrico acima รฉ somente leitura.",
+ "es": "El sandbox de esta conversaciรณn encontrรณ un error. El historial anterior es de solo lectura.",
+ "ca": "El sandbox d'aquesta conversa ha trobat un error. L'historial de dalt รฉs de nomรฉs lectura.",
+ "tr": "Bu konuลŸmanฤฑn sandbox'ฤฑ bir hatayla karลŸฤฑlaลŸtฤฑ. Yukarฤฑdaki geรงmiลŸ salt okunur modundadฤฑr.",
+ "uk": "ะŸั–ัะพั‡ะฝะธั†ั ั†ั–ั”ั— ั€ะพะทะผะพะฒะธ ะทัƒัั‚ั€ั–ะปะฐ ะฟะพะผะธะปะบัƒ. ะะฐะฒะตะดะตะฝะฐ ะฒะธั‰ะต ั–ัั‚ะพั€ั–ั ะดะพัั‚ัƒะฟะฝะฐ ะปะธัˆะต ะดะปั ั‡ะธั‚ะฐะฝะฝั."
+ },
"HOME$GUIDE_MESSAGE_TITLE": {
"en": "New around here? Not sure where to start?",
"ja": "ใ“ใฎใ‚ใŸใ‚Šใฏๅˆใ‚ใฆใงใ™ใ‹๏ผŸใฉใ“ใ‹ใ‚‰ๅง‹ใ‚ใ‚Œใฐใ„ใ„ใ‹ใ‚ใ‹ใ‚Šใพใ›ใ‚“ใ‹๏ผŸ",
diff --git a/src/mocks/automation-handlers.ts b/src/mocks/automation-handlers.ts
index 2a83167a08..cb17100efd 100644
--- a/src/mocks/automation-handlers.ts
+++ b/src/mocks/automation-handlers.ts
@@ -92,6 +92,9 @@ export const AUTOMATION_HANDLERS = [
await delay(200);
const id = params.id as string;
+ // Clone the request before reading the body to avoid "Body has already been read" errors
+ // when MSW internally consumes the body during handler resolution.
+ const body = (await request.clone().json()) as Partial<Automation>;
const automation = automations.get(id);
if (!automation) {
return HttpResponse.json(
@@ -100,7 +103,6 @@ export const AUTOMATION_HANDLERS = [
);
}
- const body = (await request.json()) as Partial<Automation>;
const updated: Automation = {
...automation,
...body,
diff --git a/src/mocks/conversation-handlers.ts b/src/mocks/conversation-handlers.ts
index 1b946763be..685d2775d8 100644
--- a/src/mocks/conversation-handlers.ts
+++ b/src/mocks/conversation-handlers.ts
@@ -7,6 +7,9 @@ import {
} from "#/types/agent-server/core";
import { GetMicroagentsResponse } from "#/api/open-hands.types";
+/** Map from conversation id โ†’ events returned by GET /events/search */
+const CONVERSATION_EVENTS: Record<string, unknown[]> = {};
+
const now = Date.now();
const PAGINATION_LOCAL_CONVERSATION_ID = "pagination-local";
const PAGINATION_CLOUD_CONVERSATION_ID = "pagination-cloud";
@@ -51,6 +54,27 @@ const conversations: MockConversation[] = [
selected_repository: "octocat/earth",
selected_branch: "main",
},
+ // Conversation whose sandbox has been removed (MISSING). The conversation
+ // history is still readable but the sandbox cannot be resumed โ€” the chat
+ // input is replaced with a read-only archived banner.
+ {
+ id: "4",
+ title: "Archived Project",
+ created_at: new Date(now - 10 * 24 * 60 * 60 * 1000).toISOString(),
+ updated_at: new Date(now - 10 * 24 * 60 * 60 * 1000).toISOString(),
+ execution_status: "idle",
+ sandbox_status: "MISSING",
+ },
+ // Conversation whose sandbox encountered an unrecoverable error. Same
+ // read-only treatment but with the "Sandbox error" variant of the banner.
+ {
+ id: "5",
+ title: "Errored Project",
+ created_at: new Date(now - 7 * 24 * 60 * 60 * 1000).toISOString(),
+ updated_at: new Date(now - 7 * 24 * 60 * 60 * 1000).toISOString(),
+ execution_status: "idle",
+ sandbox_status: "ERROR",
+ },
{
id: PAGINATION_LOCAL_CONVERSATION_ID,
title: "Local pagination fixture",
@@ -175,6 +199,7 @@ function createConversationResponse(
created_at: conversation.created_at,
updated_at: conversation.updated_at,
execution_status: conversation.execution_status ?? "idle",
+ sandbox_status: conversation.sandbox_status ?? null,
metrics: conversation.metrics ?? null,
agent: conversation.agent ?? null,
workspace: conversation.workspace ?? null,
@@ -206,7 +231,12 @@ export const CONVERSATION_HANDLERS = [
http.get("*/api/conversations", async ({ request }) => {
const url = new URL(request.url);
- const ids = url.searchParams.getAll("ids");
+ // Axios serializes arrays as `ids[]=a&ids[]=b` (bracket notation).
+ // Fall back to plain `ids` to support both formats.
+ const ids =
+ url.searchParams.getAll("ids[]").length > 0
+ ? url.searchParams.getAll("ids[]")
+ : url.searchParams.getAll("ids");
return HttpResponse.json(listConversationResponses(ids));
}),
@@ -271,12 +301,14 @@ export const CONVERSATION_HANDLERS = [
http.get(
"*/api/conversations/:conversationId/events/search",
async ({ params, request }) => {
+ const conversationId = params.conversationId as string;
const paginationPage = await maybeReturnPaginationEvents(
- params.conversationId as string,
+ conversationId,
new URL(request.url).searchParams,
);
if (paginationPage) return HttpResponse.json(paginationPage);
- return HttpResponse.json({ items: [], next_page_id: null });
+ const items = CONVERSATION_EVENTS[conversationId] ?? [];
+ return HttpResponse.json({ items, next_page_id: null });
},
),
diff --git a/src/routes/conversation.tsx b/src/routes/conversation.tsx
index d779933482..7d86ef2d79 100644
--- a/src/routes/conversation.tsx
+++ b/src/routes/conversation.tsx
@@ -1,5 +1,5 @@
import React from "react";
-import { useNavigate } from "react-router";
+import { useNavigate, useLocation } from "react-router";
import { useTranslation } from "react-i18next";
import { useConversationId } from "#/hooks/use-conversation-id";
@@ -27,6 +27,7 @@ import { WebSocketProviderWrapper } from "#/contexts/websocket-provider-wrapper"
import { useErrorMessageStore } from "#/stores/error-message-store";
import { I18nKey } from "#/i18n/declaration";
import { useEventStore } from "#/stores/use-event-store";
+import { resumeCloudSandbox } from "#/api/cloud/conversation-service.api";
function AppContent() {
const { t } = useTranslation("openhands");
@@ -53,6 +54,7 @@ function AppContent() {
const { data: isAuthed } = useIsAuthed();
const { resetConversationState } = useConversationStore();
const navigate = useNavigate();
+ const location = useLocation();
const clearTerminal = useCommandStore((state) => state.clearTerminal);
const resetConversationRuntimeState = useConversationStateStore(
(state) => state.reset,
@@ -86,8 +88,17 @@ function AppContent() {
displayErrorToast(
taskDetail || t(I18nKey.CONVERSATION$FAILED_TO_START_FROM_TASK),
);
+ // Navigate back to the original conversation when a resume task fails so
+ // the user isn't stranded at the dead task-{id} URL. The resume effect's
+ // ref prevents it from immediately retrying once we land there.
+ const resumedFrom = (location.state as Record<string, unknown> | null)
+ ?.resumedFromConversationId as string | undefined;
+ navigate(
+ resumedFrom ? `/conversations/${resumedFrom}` : "/conversations",
+ { replace: true },
+ );
}
- }, [isTask, taskStatus, taskDetail, t]);
+ }, [isTask, taskStatus, taskDetail, t, navigate, location.state]);
React.useEffect(() => {
if (!isFetched || !isAuthed) return;
@@ -126,6 +137,43 @@ function AppContent() {
setLastConversationId(active.backend.id, active.orgId, conversationId);
}, [conversationId, backendChanged, active.backend.id, active.orgId]);
+ // Cloud conversation resume: mirrors OpenHands' useSandboxRecovery.
+ //
+ // When the cloud API reports sandbox_status === "PAUSED" the sandbox is
+ // sleeping. The correct wake-up call is POST /api/v1/sandboxes/{id}/resume
+ // (a lightweight unpause). The previous approach โ€” creating a new start task
+ // via POST /api/v1/app-conversations โ€” was wrong: it tries to provision a
+ // fresh conversation in the sandbox and is subject to a 120-second cold-start
+ // timeout that can fail. The resume endpoint simply unpauses the existing one.
+ //
+ // After calling resume we stay on the current URL. The 3-second refetch
+ // interval in useActiveConversation (active while conversation_url is null)
+ // polls until conversation_url populates, then the WebSocket connects.
+ //
+ // A ref guards against duplicate triggers per unique conversation.id within
+ // the same route-mount lifetime.
+ const resumeTriggeredForRef = React.useRef<string | null>(null);
+ React.useEffect(() => {
+ if (!isFetched || !conversation) return;
+ if (active.backend.kind !== "cloud") return;
+ if (conversation.sandbox_status !== "PAUSED") return; // only resume PAUSED sandboxes
+ if (!conversation.sandbox_id) return; // no sandbox to resume
+ if (resumeTriggeredForRef.current === conversation.id) return; // already sent
+
+ resumeTriggeredForRef.current = conversation.id;
+
+ resumeCloudSandbox(conversation.sandbox_id).catch(() => {
+ displayErrorToast(t(I18nKey.CONVERSATION$FAILED_TO_START_FROM_TASK));
+ });
+ }, [
+ isFetched,
+ conversation?.id,
+ conversation?.sandbox_status,
+ conversation?.sandbox_id,
+ active.backend.kind,
+ t,
+ ]);
+
const content = (
<EventHandler>
<div data-testid="app-route" className="flex flex-col h-full">
diff --git a/tests/e2e/snapshots/archived-conversation.snapshot.spec.ts b/tests/e2e/snapshots/archived-conversation.snapshot.spec.ts
new file mode 100644
index 0000000000..79db1979c3
--- /dev/null
+++ b/tests/e2e/snapshots/archived-conversation.snapshot.spec.ts
@@ -0,0 +1,123 @@
+import { test, expect, Page } from "@playwright/test";
+import { seedLocalStorage } from "./support/seed-local-storage";
+import { stubWebSocket } from "./support/stub-websocket";
+
+/**
+ * Visual snapshot tests for archived / sandbox-error conversation states.
+ *
+ * Mock conversations pre-seeded in src/mocks/conversation-handlers.ts:
+ * 4. "Archived Project" โ€” sandbox_status: "MISSING"
+ * 5. "Errored Project" โ€” sandbox_status: "ERROR"
+ *
+ * Snapshots:
+ * 1. conversation-panel-with-archived-badges โ€” sidebar badges for MISSING/ERROR
+ * 2. conversation-view-archived โ€” chat interface for conv 4 with the
+ * read-only "Sandbox no longer available" banner (no chat input)
+ * 3. conversation-view-sandbox-error โ€” same for conv 5, "Sandbox error" variant
+ *
+ * NOTE: We do NOT inject events into the chat for these tests. In dev mode
+ * React 18 strict mode double-fires effects in child-before-parent order, so
+ * ConversationWebSocketProvider's addEvents runs before conversation.tsx's
+ * clearEvents โ€” any REST-loaded or store-injected events get wiped. The
+ * tests verify the banner + hidden chat input (the actual feature), not
+ * event rendering.
+ */
+
+const ARCHIVED_CONVERSATION_ID = "4"; // sandbox_status: "MISSING"
+const ERROR_CONVERSATION_ID = "5"; // sandbox_status: "ERROR"
+
+/** Dismisses the analytics consent modal if it appears. */
+async function dismissConsentModal(page: Page) {
+ try {
+ await page
+ .getByRole("button", { name: "Confirm preferences" })
+ .click({ timeout: 5_000 });
+ await page
+ .getByRole("dialog", { name: "Help improve OpenHands" })
+ .waitFor({ state: "hidden", timeout: 5_000 });
+ } catch {
+ // Modal didn't appear โ€” fine.
+ }
+}
+
+test.describe("Archived Conversation Visual Snapshots", () => {
+ test.describe.configure({ mode: "serial" });
+ test.setTimeout(60_000);
+
+ // โ”€โ”€ 1. Sidebar panel โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
+
+ test("conversation panel shows archived and error badges for MISSING/ERROR sandboxes", async ({
+ page,
+ }) => {
+ await seedLocalStorage(page);
+ await page.goto("/conversations");
+ await dismissConsentModal(page);
+ await page.waitForLoadState("networkidle");
+
+ const conversationPanel = page.getByTestId("conversation-panel");
+ await expect(conversationPanel).toBeVisible({ timeout: 15_000 });
+ // 6 mock conversations: 1โ€“3 normal + 4 MISSING + 5 ERROR + pagination-local
+ await expect(page.getByTestId("conversation-card")).toHaveCount(6, {
+ timeout: 10_000,
+ });
+ await expect(page.getByTestId("archived-badge")).toBeVisible({
+ timeout: 5_000,
+ });
+ await expect(page.getByTestId("error-badge")).toBeVisible({
+ timeout: 5_000,
+ });
+
+ await expect(conversationPanel).toHaveScreenshot(
+ "conversation-panel-with-archived-badges.png",
+ { animations: "disabled", maxDiffPixelRatio: 0.01 },
+ );
+ });
+
+ // โ”€โ”€ 2. Conversation view โ€” MISSING sandbox (archived) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
+
+ test("archived conversation view shows read-only banner and hides chat input", async ({
+ page,
+ }) => {
+ await seedLocalStorage(page);
+ await stubWebSocket(page);
+ await page.goto(`/conversations/${ARCHIVED_CONVERSATION_ID}`, {
+ waitUntil: "domcontentloaded",
+ });
+ await dismissConsentModal(page);
+
+ // Wait for the archived banner โ€” proves useActiveConversation resolved
+ // with sandbox_status: "MISSING" and the component fully initialized.
+ await expect(
+ page.getByTestId("archived-conversation-banner"),
+ ).toBeVisible({ timeout: 20_000 });
+ await expect(page.getByTestId("interactive-chat-box")).toHaveCount(0);
+
+ await expect(page.getByTestId("chat-interface")).toHaveScreenshot(
+ "conversation-view-archived.png",
+ { animations: "disabled", maxDiffPixelRatio: 0.01 },
+ );
+ });
+
+ // โ”€โ”€ 3. Conversation view โ€” ERROR sandbox โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
+
+ test("error sandbox conversation view shows error banner and hides chat input", async ({
+ page,
+ }) => {
+ await seedLocalStorage(page);
+ await stubWebSocket(page);
+ await page.goto(`/conversations/${ERROR_CONVERSATION_ID}`, {
+ waitUntil: "domcontentloaded",
+ });
+ await dismissConsentModal(page);
+
+ await expect(
+ page.getByTestId("archived-conversation-banner"),
+ ).toBeVisible({ timeout: 20_000 });
+ await expect(page.getByTestId("interactive-chat-box")).toHaveCount(0);
+
+ await expect(page.getByTestId("chat-interface")).toHaveScreenshot(
+ "conversation-view-sandbox-error.png",
+ { animations: "disabled", maxDiffPixelRatio: 0.01 },
+ );
+ });
+});
diff --git a/tests/e2e/snapshots/backends-extended.snapshot.spec.ts b/tests/e2e/snapshots/backends-extended.snapshot.spec.ts
index cffdb729fb..b152942b7c 100644
--- a/tests/e2e/snapshots/backends-extended.snapshot.spec.ts
+++ b/tests/e2e/snapshots/backends-extended.snapshot.spec.ts
@@ -5,21 +5,22 @@ import { seedLocalStorage } from "./support/seed-local-storage";
/**
* Extended visual snapshot tests for the backend management UI.
*
- * These tests exercise the full lifecycle of backend CRUD operations with
- * iterative screenshot captures at each meaningful state transition:
+ * The add-backend modal is a two-column layout:
+ * Left โ€” Manual connection: name, host, API-key, Connect button.
+ * Kind is inferred from the host URL (local vs cloud).
+ * Right โ€” Cloud OAuth: one-click "Login with OpenHands" device flow.
*
- * Flow 1 โ€” Add form validation gates
- * Form is disabled until both "Host Name" and "Host URL" are filled;
- * cloud backends additionally require an API key.
+ * Flow 1 โ€” Add form validation gates (manual connection column)
+ * Connect is disabled until name + valid host are filled; cloud-inferred
+ * hosts additionally require an API key.
*
- * Flow 2 โ€” Kind auto-inference (host โ†’ type)
- * Typing a cloud-domain URL (all-hands.dev) auto-selects Cloud and
- * shows the device-flow OAuth section. A local URL flips back to Local
- * and hides OAuth. Manually selecting a kind stops auto-inference.
+ * Flow 2 โ€” Two-column layout renders correctly
+ * The add modal shows both manual-connection and cloud-login columns
+ * side by side with an OR divider.
*
- * Flow 3 โ€” Cloud OAuth button gated by host
- * The "Login with OpenHands" button is disabled when the host field is
- * empty so the user can't start a device-flow with nowhere to point it.
+ * Flow 3 โ€” Cloud login column renders OAuth section
+ * The right column shows the OpenHands logo, description, and a
+ * "Login with OpenHands" device-flow button.
*
* Flow 4 โ€” Remove backend with confirmation step
* Clicking "Remove" opens a ConfirmationModal; confirming removes the
@@ -34,14 +35,12 @@ import { seedLocalStorage } from "./support/seed-local-storage";
* then updates the selector trigger label once the overlay fades.
*
* Flow 7 โ€” Malformed / empty host blocks submission
- * A host with only whitespace keeps the Submit button disabled.
- * A syntactically invalid URL (e.g. containing spaces or a garbled
- * scheme) also keeps Save disabled โ€” isValidHostUrl() rejects it at
- * the form level before normalisation can make it look superficially
- * valid to the URL constructor.
+ * A host with only whitespace keeps the Connect button disabled.
+ * A syntactically invalid URL also keeps Connect disabled.
*
- * Flow 8 โ€” Cancel add form dismisses without saving
- * Clicking Cancel closes the modal without altering the backend list.
+ * Flow 8 โ€” Close add form dismisses without saving
+ * Clicking the close (โœ•) button closes the modal without altering
+ * the backend list.
*/
// โ”€โ”€ Constants โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
@@ -161,24 +160,21 @@ test.describe("Backend Management โ€” Extended Flow Snapshots", () => {
// โ”€โ”€ Flow 1: Add-form validation gates โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
- test("Flow 1a โ€” add form blank: Save button disabled until required fields filled", async ({
+ test("Flow 1a โ€” add form blank: Connect button disabled until required fields filled", async ({
page,
}) => {
await setupPage(page);
const rootLayout = await openAddModal(page);
- // 1. Completely blank form โ€” Save must be disabled.
+ // 1. Completely blank form โ€” Connect must be disabled.
await expect(page.getByTestId("add-backend-submit")).toBeDisabled();
await expect(rootLayout).toHaveScreenshot(
"backend-add-blank-disabled.png",
SNAP_OPTS,
);
- // 2. Fill only the name; host still empty โ†’ Save still disabled.
- // Focus + blur the host field to reveal the "Host is required" error.
+ // 2. Fill only the name; host still empty โ†’ Connect still disabled.
await page.getByTestId("add-backend-name").fill("My Backend");
- await page.getByTestId("add-backend-host").focus();
- await page.getByTestId("add-backend-host").blur();
await expect(page.getByTestId("add-backend-submit")).toBeDisabled();
await expect(rootLayout).toHaveScreenshot(
"backend-add-name-only-disabled.png",
@@ -186,18 +182,17 @@ test.describe("Backend Management โ€” Extended Flow Snapshots", () => {
);
});
- test("Flow 1b โ€” local backend becomes Save-ready with name + host, no API key required", async ({
+ test("Flow 1b โ€” local backend becomes Connect-ready with name + host, no API key required", async ({
page,
}) => {
await setupPage(page);
const rootLayout = await openAddModal(page);
- // Switch to Local type first so API key is not required.
- await page.getByTestId("add-backend-kind-local").click();
+ // A localhost URL infers local kind โ€” no API key needed.
await page.getByTestId("add-backend-name").fill("Dev Server");
await page.getByTestId("add-backend-host").fill("http://localhost:8080");
- // API key left empty โ€” Save must be enabled for local kind.
+ // API key left empty โ€” Connect must be enabled for local kind.
await expect(page.getByTestId("add-backend-submit")).not.toBeDisabled();
await expect(rootLayout).toHaveScreenshot(
"backend-add-local-ready.png",
@@ -205,27 +200,24 @@ test.describe("Backend Management โ€” Extended Flow Snapshots", () => {
);
});
- test("Flow 1c โ€” cloud backend requires API key; Save stays disabled without it", async ({
+ test("Flow 1c โ€” cloud-inferred backend requires API key; Connect stays disabled without it", async ({
page,
}) => {
await setupPage(page);
const rootLayout = await openAddModal(page);
- // Add form starts in Cloud mode; type a cloud URL to confirm.
+ // An all-hands.dev URL infers cloud kind โ€” API key required.
await page.getByTestId("add-backend-name").fill("Cloud Prod");
await page.getByTestId("add-backend-host").fill("https://app.all-hands.dev");
- // Cloud radio should now be selected (auto-inferred from domain).
- await expect(page.getByTestId("add-backend-kind-cloud")).toBeChecked();
-
- // No API key โ†’ Save disabled.
+ // No API key โ†’ Connect disabled.
await expect(page.getByTestId("add-backend-submit")).toBeDisabled();
await expect(rootLayout).toHaveScreenshot(
"backend-add-cloud-no-key-disabled.png",
SNAP_OPTS,
);
- // Fill API key โ†’ Save enabled.
+ // Fill API key โ†’ Connect enabled.
await page.getByTestId("add-backend-api-key").fill("sk-live-abc123");
await expect(page.getByTestId("add-backend-submit")).not.toBeDisabled();
await expect(rootLayout).toHaveScreenshot(
@@ -234,92 +226,44 @@ test.describe("Backend Management โ€” Extended Flow Snapshots", () => {
);
});
- // โ”€โ”€ Flow 2: Kind auto-inference + manual override โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
+ // โ”€โ”€ Flow 2: Two-column layout โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
- test("Flow 2a โ€” typing a local URL auto-infers Local kind and hides OAuth section", async ({
+ test("Flow 2 โ€” add modal shows two-column layout with manual and cloud login", async ({
page,
}) => {
await setupPage(page);
const rootLayout = await openAddModal(page);
- // Initially cloud (add-mode default).
- await expect(page.getByTestId("add-backend-kind-cloud")).toBeChecked();
+ // Left column: manual connection form is visible.
+ await expect(page.getByTestId("add-backend-form")).toBeVisible();
- // Type a localhost URL โ†’ should flip to Local, hiding device-flow.
- await page.getByTestId("add-backend-host").fill("localhost:8888");
- await expect(page.getByTestId("add-backend-kind-local")).toBeChecked({
- timeout: 3_000,
- });
- // Device-flow section disappears for local kind.
- await expect(page.getByTestId("add-backend-device-flow")).not.toBeVisible();
- await expect(rootLayout).toHaveScreenshot(
- "backend-add-kind-local-inferred.png",
- SNAP_OPTS,
- );
- });
-
- test("Flow 2b โ€” typing a cloud URL keeps Cloud kind and shows OAuth section", async ({
- page,
- }) => {
- await setupPage(page);
- const rootLayout = await openAddModal(page);
-
- // Type an all-hands.dev URL โ†’ stays/becomes Cloud, shows device-flow.
- await page.getByTestId("add-backend-host").fill("https://app.all-hands.dev");
- await expect(page.getByTestId("add-backend-kind-cloud")).toBeChecked({
- timeout: 3_000,
- });
+ // Right column: cloud login section with device-flow OAuth.
+ await expect(page.getByTestId("add-backend-cloud-title")).toBeVisible();
await expect(page.getByTestId("add-backend-device-flow")).toBeVisible();
- await expect(rootLayout).toHaveScreenshot(
- "backend-add-kind-cloud-inferred.png",
- SNAP_OPTS,
- );
- });
-
- test("Flow 2c โ€” manually selecting Local locks the kind even when a cloud URL is typed", async ({
- page,
- }) => {
- await setupPage(page);
- const rootLayout = await openAddModal(page);
+ await expect(page.getByTestId("add-backend-login-button")).toBeVisible();
- // Explicitly click Local radio โ†’ touchedKind = true.
- await page.getByTestId("add-backend-kind-local").click();
- await expect(page.getByTestId("add-backend-kind-local")).toBeChecked();
-
- // Now type a cloud URL โ€” kind must STAY local (manual override).
- await page.getByTestId("add-backend-host").fill("https://app.all-hands.dev");
- // Wait a tick for any potential effect to run.
- await page.waitForTimeout(200);
- await expect(page.getByTestId("add-backend-kind-local")).toBeChecked();
- await expect(page.getByTestId("add-backend-device-flow")).not.toBeVisible();
await expect(rootLayout).toHaveScreenshot(
- "backend-add-manual-override-local.png",
+ "backend-add-two-column-layout.png",
SNAP_OPTS,
);
});
- // โ”€โ”€ Flow 3: OAuth button gated by host โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
+ // โ”€โ”€ Flow 3: Cloud login column โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
- test("Flow 3 โ€” cloud Login button disabled until both name and host are filled", async ({
+ test("Flow 3 โ€” cloud login column shows advanced host override", async ({
page,
}) => {
await setupPage(page);
const rootLayout = await openAddModal(page);
- // Cloud form, host empty โ†’ login button disabled.
- await expect(page.getByTestId("add-backend-kind-cloud")).toBeChecked();
- await expect(page.getByTestId("add-backend-login-button")).toBeDisabled();
- await expect(rootLayout).toHaveScreenshot(
- "backend-add-oauth-button-disabled.png",
- SNAP_OPTS,
- );
+ // Expand advanced settings in the cloud column.
+ await page.getByTestId("add-backend-advanced-toggle").click();
+ await expect(page.getByTestId("add-backend-cloud-host")).toBeVisible({
+ timeout: 3_000,
+ });
- // Fill name + host โ†’ login button enabled.
- await page.getByTestId("add-backend-name").fill("My Cloud");
- await page.getByTestId("add-backend-host").fill("https://app.all-hands.dev");
- await expect(page.getByTestId("add-backend-login-button")).not.toBeDisabled();
await expect(rootLayout).toHaveScreenshot(
- "backend-add-oauth-button-enabled.png",
+ "backend-add-cloud-advanced-open.png",
SNAP_OPTS,
);
});
@@ -483,30 +427,25 @@ test.describe("Backend Management โ€” Extended Flow Snapshots", () => {
// โ”€โ”€ Flow 7: Malformed/empty host โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
- test("Flow 7 โ€” empty or invalid host keeps Save disabled; valid host enables Save", async ({
+ test("Flow 7 โ€” empty or invalid host keeps Connect disabled", async ({
page,
}) => {
await setupPage(page);
const rootLayout = await openAddModal(page);
// Seed just the name, leave host blank.
- await page.getByTestId("add-backend-kind-local").click();
await page.getByTestId("add-backend-name").fill("Bad URL Test");
// Whitespace-only host โ†’ isValidHostUrl returns false โ†’ disabled.
- // Blur the field to reveal the inline "Host is required" error.
await page.getByTestId("add-backend-host").fill(" ");
- await page.getByTestId("add-backend-host").blur();
await expect(page.getByTestId("add-backend-submit")).toBeDisabled();
await expect(rootLayout).toHaveScreenshot(
"backend-add-whitespace-host-disabled.png",
SNAP_OPTS,
);
- // A syntactically invalid URL (spaces + garbled scheme) is rejected by
- // isValidHostUrl() โ€” Save stays disabled and the inline error explains why.
+ // A syntactically invalid URL is rejected by isValidHostUrl().
await page.getByTestId("add-backend-host").fill("not://:::a valid url!!!");
- await page.getByTestId("add-backend-host").blur();
await expect(page.getByTestId("add-backend-submit")).toBeDisabled();
await expect(rootLayout).toHaveScreenshot(
"backend-add-invalid-url-disabled.png",
@@ -516,14 +455,13 @@ test.describe("Backend Management โ€” Extended Flow Snapshots", () => {
// โ”€โ”€ Flow 8: Cancel add form โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
- test("Flow 8 โ€” canceling the add form closes modal without persisting data", async ({
+ test("Flow 8 โ€” closing the add form dismisses modal without persisting data", async ({
page,
}) => {
await setupPage(page);
const rootLayout = await openAddModal(page);
// Partially fill the form.
- await page.getByTestId("add-backend-kind-local").click();
await page.getByTestId("add-backend-name").fill("Temp Backend");
await page.getByTestId("add-backend-host").fill("http://localhost:9999");
@@ -532,8 +470,8 @@ test.describe("Backend Management โ€” Extended Flow Snapshots", () => {
SNAP_OPTS,
);
- // Click Cancel.
- await page.getByTestId("add-backend-cancel").click();
+ // Click the close (โœ•) button.
+ await page.getByTestId("add-backend-close").click();
// Modal is dismissed.
await expect(page.getByTestId("add-backend-modal")).not.toBeVisible({
diff --git a/tests/e2e/snapshots/changes-tab.snapshot.spec.ts b/tests/e2e/snapshots/changes-tab.snapshot.spec.ts
index eda595d221..d3db86e495 100644
--- a/tests/e2e/snapshots/changes-tab.snapshot.spec.ts
+++ b/tests/e2e/snapshots/changes-tab.snapshot.spec.ts
@@ -1,5 +1,6 @@
import { test, expect, Page } from "@playwright/test";
import { seedLocalStorage } from "./support/seed-local-storage";
+import { stubWebSocket } from "./support/stub-websocket";
/**
* Visual snapshot tests for the Changes (diff viewer) UI.
@@ -57,46 +58,7 @@ async function setupMocks(page: Page) {
extra: [[CONVERSATION_STATE_KEY, CONVERSATION_STATE_VALUE]],
});
- // Stub WebSocket so the conversation page doesn't hang waiting for a real
- // socket connection. Copied from collapsible-thinking.snapshot.spec.ts.
- await page.addInitScript(() => {
- const noop = () => {};
- class StubWebSocket extends EventTarget {
- static CONNECTING = 0;
- static OPEN = 1;
- static CLOSING = 2;
- static CLOSED = 3;
- readyState = StubWebSocket.OPEN;
- url: string;
- protocol = "";
- extensions = "";
- bufferedAmount = 0;
- binaryType: BinaryType = "blob";
- onopen: ((ev: Event) => void) | null = null;
- onclose: ((ev: CloseEvent) => void) | null = null;
- onmessage: ((ev: MessageEvent) => void) | null = null;
- onerror: ((ev: Event) => void) | null = null;
-
- constructor(url: string | URL) {
- super();
- this.url = typeof url === "string" ? url : url.toString();
- setTimeout(() => {
- const evt = new Event("open");
- this.onopen?.(evt);
- this.dispatchEvent(evt);
- }, 10);
- }
-
- send = noop;
- close = noop;
- CONNECTING = StubWebSocket.CONNECTING;
- OPEN = StubWebSocket.OPEN;
- CLOSING = StubWebSocket.CLOSING;
- CLOSED = StubWebSocket.CLOSED;
- }
- (window as unknown as { WebSocket: unknown }).WebSocket =
- StubWebSocket as unknown as typeof WebSocket;
- });
+ await stubWebSocket(page);
}
async function dismissConsentModal(page: Page) {
diff --git a/tests/e2e/snapshots/collapsible-thinking.snapshot.spec.ts b/tests/e2e/snapshots/collapsible-thinking.snapshot.spec.ts
index f4ab61f3d0..1e3719f811 100644
--- a/tests/e2e/snapshots/collapsible-thinking.snapshot.spec.ts
+++ b/tests/e2e/snapshots/collapsible-thinking.snapshot.spec.ts
@@ -1,5 +1,6 @@
import { test, expect, Page } from "@playwright/test";
import { seedLocalStorage } from "./support/seed-local-storage";
+import { stubWebSocket } from "./support/stub-websocket";
/**
* Visual snapshot tests for the CollapsibleThinking component.
@@ -196,43 +197,7 @@ async function navigateToConversation(page: Page, events: unknown[]) {
});
});
- // Stub WebSocket to prevent connection errors
- await page.addInitScript(() => {
- const noop = () => {};
- class StubWebSocket extends EventTarget {
- static CONNECTING = 0;
- static OPEN = 1;
- static CLOSING = 2;
- static CLOSED = 3;
- readyState = StubWebSocket.OPEN;
- url: string;
- protocol = "";
- extensions = "";
- bufferedAmount = 0;
- binaryType: BinaryType = "blob";
- onopen: ((ev: Event) => void) | null = null;
- onclose: ((ev: CloseEvent) => void) | null = null;
- onmessage: ((ev: MessageEvent) => void) | null = null;
- onerror: ((ev: Event) => void) | null = null;
- constructor(url: string | URL) {
- super();
- this.url = typeof url === "string" ? url : url.toString();
- setTimeout(() => {
- const evt = new Event("open");
- this.onopen?.(evt);
- this.dispatchEvent(evt);
- }, 10);
- }
- send = noop;
- close = noop;
- CONNECTING = StubWebSocket.CONNECTING;
- OPEN = StubWebSocket.OPEN;
- CLOSING = StubWebSocket.CLOSING;
- CLOSED = StubWebSocket.CLOSED;
- }
- (window as unknown as { WebSocket: unknown }).WebSocket =
- StubWebSocket as unknown as typeof WebSocket;
- });
+ await stubWebSocket(page);
await page.goto(`/conversations/${CONVERSATION_ID}`, {
waitUntil: "domcontentloaded",
diff --git a/tests/e2e/snapshots/sidebar.snapshot.spec.ts b/tests/e2e/snapshots/sidebar.snapshot.spec.ts
index 1f4d358c61..945f6921a3 100644
--- a/tests/e2e/snapshots/sidebar.snapshot.spec.ts
+++ b/tests/e2e/snapshots/sidebar.snapshot.spec.ts
@@ -45,10 +45,10 @@ test.describe("Sidebar Visual Snapshots", () => {
await dismissConsentModal(page);
await page.waitForLoadState("networkidle");
- // Wait for all three conversation cards to be present
+ // Wait for all five conversation cards to be present
const conversationPanel = page.getByTestId("conversation-panel");
await expect(conversationPanel).toBeVisible({ timeout: 15_000 });
- await expect(page.getByTestId("conversation-card")).toHaveCount(3, {
+ await expect(page.getByTestId("conversation-card")).toHaveCount(6, {
timeout: 10_000,
});
@@ -94,7 +94,7 @@ test.describe("Sidebar Visual Snapshots", () => {
await expect(page.getByTestId("conversation-panel")).toBeVisible({
timeout: 15_000,
});
- await expect(page.getByTestId("conversation-card")).toHaveCount(3, {
+ await expect(page.getByTestId("conversation-card")).toHaveCount(6, {
timeout: 10_000,
});
diff --git a/tests/e2e/snapshots/support/stub-websocket.ts b/tests/e2e/snapshots/support/stub-websocket.ts
new file mode 100644
index 0000000000..9ed7b8f394
--- /dev/null
+++ b/tests/e2e/snapshots/support/stub-websocket.ts
@@ -0,0 +1,51 @@
+import type { Page } from "@playwright/test";
+
+/**
+ * Stubs the browser's native `WebSocket` so conversation-page snapshot
+ * tests don't trigger real connection attempts (which fail in CI with
+ * "Failed to connect to server" toasts because no agent-server is
+ * running at the Vite proxy target).
+ *
+ * Must be called **before** `page.goto()` โ€” it uses `page.addInitScript`
+ * so the stub is in place before any app code runs.
+ */
+export async function stubWebSocket(page: Page): Promise<void> {
+ await page.addInitScript(() => {
+ const noop = () => {};
+ class StubWebSocket extends EventTarget {
+ static CONNECTING = 0;
+ static OPEN = 1;
+ static CLOSING = 2;
+ static CLOSED = 3;
+ readyState = StubWebSocket.OPEN;
+ url: string;
+ protocol = "";
+ extensions = "";
+ bufferedAmount = 0;
+ binaryType: BinaryType = "blob";
+ onopen: ((ev: Event) => void) | null = null;
+ onclose: ((ev: CloseEvent) => void) | null = null;
+ onmessage: ((ev: MessageEvent) => void) | null = null;
+ onerror: ((ev: Event) => void) | null = null;
+
+ constructor(url: string | URL) {
+ super();
+ this.url = typeof url === "string" ? url : url.toString();
+ setTimeout(() => {
+ const evt = new Event("open");
+ this.onopen?.(evt);
+ this.dispatchEvent(evt);
+ }, 0);
+ }
+
+ send = noop;
+ close = noop;
+ CONNECTING = StubWebSocket.CONNECTING;
+ OPEN = StubWebSocket.OPEN;
+ CLOSING = StubWebSocket.CLOSING;
+ CLOSED = StubWebSocket.CLOSED;
+ }
+ (window as unknown as { WebSocket: unknown }).WebSocket =
+ StubWebSocket as unknown as typeof WebSocket;
+ });
+}