From 7cf50584f2fac0b12a30c0edfcbdf18bea342833 Mon Sep 17 00:00:00 2001 From: klopez4212 Date: Sun, 5 Jul 2026 09:14:50 +0100 Subject: [PATCH] Work drawer state is purely remembered Auto-open-on-PR kept re-deriving the drawer state on every chat switch, re-animating it open for anyone who had never touched the toggle. The drawer is now a plain persisted boolean (default closed): it renders in the remembered state on every chat with no animation, and only a deliberate toggle changes it. Co-Authored-By: Claude Fable 5 --- desktop/src/features/chats/ui/ChatsScreen.tsx | 6 +++--- desktop/tests/e2e/chats-first-message.spec.ts | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/desktop/src/features/chats/ui/ChatsScreen.tsx b/desktop/src/features/chats/ui/ChatsScreen.tsx index 5fb4be5441..125d2dce85 100644 --- a/desktop/src/features/chats/ui/ChatsScreen.tsx +++ b/desktop/src/features/chats/ui/ChatsScreen.tsx @@ -338,8 +338,8 @@ export function ChatsScreen({ return null; }, [messages]); // The drawer's open state is a single persisted preference — switching - // chats must NOT reset it (the panel used to re-animate open on every - // switch). null = never toggled: auto-open when the chat has a PR. + // chats must NOT reset it or re-derive it (auto-open-on-PR re-animated + // the drawer on every switch). Purely remembered; default closed. const [workPanelPreference, setWorkPanelPreference] = React.useState< boolean | null >(() => { @@ -358,7 +358,7 @@ export function ChatsScreen({ // Best-effort persistence. } }, []); - const isWorkPanelOpen = workPanelPreference ?? agentPullRequestHref !== null; + const isWorkPanelOpen = workPanelPreference ?? false; const startManagedAgentMutation = useStartManagedAgentMutation(); const [isEnsuringDefaultAgent, setIsEnsuringDefaultAgent] = React.useState(false); diff --git a/desktop/tests/e2e/chats-first-message.spec.ts b/desktop/tests/e2e/chats-first-message.spec.ts index 116d84bf2b..d197f3144a 100644 --- a/desktop/tests/e2e/chats-first-message.spec.ts +++ b/desktop/tests/e2e/chats-first-message.spec.ts @@ -184,7 +184,11 @@ test("first message in a new chat is sent and rendered", async ({ page }) => { await expect( page.locator("[data-link-preview='github-pull-request-agent']"), ).toHaveCount(1, { timeout: 10_000 }); + // The drawer is purely a remembered preference (default closed) — open + // it explicitly; the choice persists across chats and restarts. const workPanel = page.getByTestId("chat-work-panel"); + await expect(workPanel).not.toBeVisible(); + await page.getByTestId("toggle-work-panel").click(); await expect(workPanel).toBeVisible(); await expect(workPanel).toContainText("kennylopez-chatmode"); await expect(