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 <noreply@anthropic.com>
This commit is contained in:
klopez4212
2026-07-05 09:14:50 +01:00
parent d416f45ca8
commit 7cf50584f2
2 changed files with 7 additions and 3 deletions

View File

@@ -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);

View File

@@ -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(