Files
paseo/packages/app/e2e/browser/worktree-codex-restore.real.spec.ts
Mohamed Boudra a7ce602c83 fix(agents): restore archived Codex workspaces without losing focus (#4736)
* fix(agents): restore archived Codex workspaces without losing focus

History selection must survive without cached agent records, and reading an archived Codex thread must not acquire an interactive writer. Keep workspace restore explicit, serialize native lifecycle transitions, and leave transcript lifetime with its owner.

* test(app): express Codex restore specs as user journeys

* test(app): finish restore fixture cleanup after teardown errors

* test(app): align restore coverage and await fixture readiness

Workspace restore leaves agents archived until explicit Unarchive. Keep that distinction covered for multiple agents. Compile the recovery fixture before its interaction test starts, and wait for sidebar agent hydration before asserting tab presence.
2026-09-12 08:47:44 +02:00

64 lines
2.7 KiB
TypeScript

import { test } from "../support/helpers/codex-workspace-restore";
test.use({
e2eDaemonConfig: { version: 1, daemon: { mcp: { enabled: true } } },
trace: "on",
video: "on",
});
test.describe.configure({ timeout: 600_000 });
test("a fresh client restores an archived Codex agent across a reload without agent cache", async ({
codexRestore,
}) => {
await test.step("Create, finish, and archive Codex before this browser connects", async () => {
await codexRestore.createWorktreeWithCodex();
await codexRestore.archiveBeforeBrowserConnects();
});
await test.step("Connect the fresh browser, open History, and restore the workspace", async () => {
await codexRestore.connectFreshBrowser();
await codexRestore.openArchivedWorkspaceFromHistory();
await codexRestore.restoreWorkspace();
await codexRestore.expectArchivedAgentSelectedWithHistory();
});
await test.step("Reload without cached agent data and keep the selected archived agent", async () => {
await codexRestore.reloadWithoutAgentCache();
await codexRestore.waitForWorkspaceHydration();
await codexRestore.expectArchivedAgentSelectedWithHistory();
});
await test.step("Unarchive the agent and keep its idle composer after another cache-empty reload", async () => {
await codexRestore.unarchiveAgent();
await codexRestore.reloadWithoutAgentCache();
await codexRestore.expectIdleAgentWithVisibleComposer();
});
});
test("restore an archived worktree, then unarchive its completed Codex agent", async ({
codexRestore,
}) => {
await test.step("1. Create a managed worktree with a real Codex agent through Paseo MCP", async () => {
await codexRestore.createWorktreeWithCodex();
});
await test.step("2. Wait for Codex to finish and show its reply", async () => {
await codexRestore.waitForCompletedReply();
});
await test.step("3. Archive the workspace from its sidebar menu", async () => {
await codexRestore.archiveWorkspaceFromSidebar();
});
await test.step("4. Assert workspace and agent are archived and the worktree is removed", async () => {
await codexRestore.expectWorkspaceAndAgentArchived();
});
await test.step("5. Open the archived workspace from History", async () => {
await codexRestore.openArchivedWorkspaceFromHistory();
});
await test.step("6. Restore the workspace", async () => {
await codexRestore.restoreWorkspace();
await codexRestore.expectWorktreeRestoredWithArchivedAgentSelected();
});
await test.step("7. Click Unarchive on the agent", async () => {
await codexRestore.unarchiveAgent();
});
await test.step("8. Expect an idle agent with a visible editable composer", async () => {
await codexRestore.expectIdleAgentWithVisibleComposer(60_000);
});
});