From 818d2ee9f383e7787bc981a9bed3a7e4f9388787 Mon Sep 17 00:00:00 2001 From: "paseo-bot[bot]" <266920839+paseo-bot[bot]@users.noreply.github.com> Date: Mon, 2 Nov 2026 21:12:20 +0000 Subject: [PATCH] fix(app): refresh History after unarchiving an agent History reused a cached archived snapshot on every visit because the global query defaults disable mount refetches. Fetch the saved pages when History opens so a completed Unarchive appears without restarting. Co-authored-by: siyxo --- .../browser/archived-codex-agent.real.spec.ts | 46 ++++++++++++++++++- packages/app/src/hooks/use-agent-history.ts | 1 + 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/packages/app/e2e/browser/archived-codex-agent.real.spec.ts b/packages/app/e2e/browser/archived-codex-agent.real.spec.ts index 6d079fe016..68ec0d150e 100644 --- a/packages/app/e2e/browser/archived-codex-agent.real.spec.ts +++ b/packages/app/e2e/browser/archived-codex-agent.real.spec.ts @@ -2,7 +2,8 @@ import { mkdtempSync, realpathSync } from "node:fs"; import { tmpdir } from "node:os"; import path from "node:path"; import { test, expect } from "../support/fixtures"; -import { openSessions } from "../support/helpers/archive-tab"; +import type { Page } from "@playwright/test"; +import { closeWorkspaceAgentTab, openSessions } from "../support/helpers/archive-tab"; import { assertChatTranscript, cleanupRewindFlow, @@ -31,6 +32,15 @@ async function historyContainsAgent(client: SeedDaemonClient, agentId: string): return history.entries.some((entry) => entry.agent.id === agentId); } +async function closeAgentTab(page: Page, agentId: string): Promise { + await page + .getByTestId(`workspace-tab-agent_${agentId}`) + .filter({ visible: true }) + .first() + .hover(); + await closeWorkspaceAgentTab(page, agentId); +} + test.describe("archived Codex agent recovery", () => { test.setTimeout(600_000); @@ -112,4 +122,38 @@ test.describe("archived Codex agent recovery", () => { await cleanupRewindFlow({ handle, cwd }); } }); + + test("refreshes cached History after unarchiving without restarting", async ({ page }) => { + const cwd = realpathSync(mkdtempSync(path.join(tmpdir(), "paseo-unarchive-history-"))); + let handle: AgentHandle | undefined; + try { + handle = await launchAgent({ + page, + provider: "codex", + providerConfig: { model: "gpt-5.6-sol" }, + cwd, + mode: "full-access", + }); + await sendMessage(handle, INITIAL_PROMPT); + await assertChatTranscript(handle, [ + { role: "user", text: INITIAL_PROMPT }, + { role: "assistant", text: INITIAL_REPLY }, + ]); + await closeAgentTab(page, handle.agentId); + await openSessions(page); + const row = page.getByTestId(`agent-row-${getServerId()}-${handle.agentId}`); + await expect(row.getByText("Archived", { exact: true })).toBeVisible(); + await row.click(); + await page.getByRole("button", { name: "Unarchive", exact: true }).click(); + await expect(page.getByRole("textbox", { name: "Message agent..." })).toBeVisible({ + timeout: 60_000, + }); + await openSessions(page); + await expect(row.getByText("Archived", { exact: true })).toHaveCount(0); + await row.click(); + await expect(page.getByRole("textbox", { name: "Message agent..." })).toBeEditable(); + } finally { + await cleanupRewindFlow({ handle, cwd }); + } + }); }); diff --git a/packages/app/src/hooks/use-agent-history.ts b/packages/app/src/hooks/use-agent-history.ts index 96b0395e76..22315f6e96 100644 --- a/packages/app/src/hooks/use-agent-history.ts +++ b/packages/app/src/hooks/use-agent-history.ts @@ -296,6 +296,7 @@ export function useAgentHistory(options: { queryKey, enabled: Boolean(enabled && targetHosts.length > 0), staleTime: 30_000, + refetchOnMount: "always", initialPageParam: null, getNextPageParam: getNextAgentHistoryPageParam, queryFn: async ({ pageParam }) => {