diff --git a/frontend/e2e/chat-groups.spec.ts b/frontend/e2e/chat-groups.spec.ts index a5f927a5..94b49010 100644 --- a/frontend/e2e/chat-groups.spec.ts +++ b/frontend/e2e/chat-groups.spec.ts @@ -63,6 +63,40 @@ test("loads chat groups successfully and files their chats", async ({ page }) => await expect(page.getByText("Research")).toBeVisible(); }); +test("keeps every move destination reachable above the footer in a short drawer", async ({ page }) => { + await page.setViewportSize({ width: 667, height: 375 }); + const groups = Array.from({ length: 12 }, (_, index) => ({ + id: `folder-${index}`, name: `Folder ${index}`, collapsed: true, position: index, + timestamp: "2026-01-01T00:00:00Z", + })); + await stubWorkspace(page, groups); + await page.route("**/api/v1/chats", (route) => route.fulfill({ + json: [{ id: "loose", title: "Loose chat", timestamp: "2026-01-01T00:00:00Z", group_id: null }], + })); + await page.goto("/#bootstrap=launcher-token"); + await page.getByRole("button", { name: "Show chat history" }).click(); + const trigger = page.getByRole("button", { name: "Move Loose chat to a group" }); + await trigger.focus(); + await trigger.press("Enter"); + const menu = page.getByRole("menu"); + const list = page.locator(".chat-list"); + const fits = async () => { + const popup = await menu.boundingBox(); + const area = await list.boundingBox(); + return !!popup && !!area && popup.y >= area.y && popup.y + popup.height <= area.y + area.height; + }; + await expect.poll(fits).toBe(true); + await page.setViewportSize({ width: 667, height: 350 }); + await expect.poll(fits).toBe(true); + await page.keyboard.press("End"); + const destination = page.getByRole("menuitem", { name: "Folder 11" }); + await expect(destination).toBeFocused(); + expect(await destination.evaluate((item) => { + const { x, y, width, height } = item.getBoundingClientRect(); + return item.contains(document.elementFromPoint(x + width / 2, y + height / 2)); + })).toBe(true); +}); + test("does not let a late initial group response erase a group created while loading", async ({ page }) => { let releaseInitialGroups!: () => void; const initialGroups = new Promise((resolve) => { releaseInitialGroups = resolve; }); diff --git a/frontend/src/features/shell/AppShell.test.tsx b/frontend/src/features/shell/AppShell.test.tsx index 664d0a89..4bac0deb 100644 --- a/frontend/src/features/shell/AppShell.test.tsx +++ b/frontend/src/features/shell/AppShell.test.tsx @@ -58,6 +58,27 @@ describe("AppShell", () => { expect(window.location.pathname).toBe("/chat/new"); }); + it("clears a history search and returns focus to the search field", async () => { + const user = userEvent.setup(); + const view = renderShell({ chats: [ + { id: "chat-1", title: "Quarterly planning", timestamp: "2026-01-01T00:00:00Z" }, + { id: "chat-2", title: "Release notes", timestamp: "2026-01-02T00:00:00Z" }, + ] }); + + const field = screen.getByRole("searchbox", { name: "Search chats by title" }); + await user.type(field, "release"); + expect(screen.queryByRole("button", { name: "Quarterly planning" })).not.toBeInTheDocument(); + await user.click(screen.getByRole("button", { name: "Clear chat search" })); + expect(field).toHaveFocus(); + expect(field).toHaveValue(""); + expect(screen.getByRole("button", { name: "Quarterly planning" })).toBeVisible(); + + await user.type(field, "release"); + view.rerender(); + await user.click(screen.getByRole("button", { name: "Clear chat search" })); + expect(screen.getByText("No threads yet.")).toBeVisible(); + }); + it("removes the collapsed sidebar from the accessibility and tab trees", async () => { const user = userEvent.setup(); renderShell(); diff --git a/frontend/src/features/shell/AppShell.tsx b/frontend/src/features/shell/AppShell.tsx index 043d1ff0..289b89cb 100644 --- a/frontend/src/features/shell/AppShell.tsx +++ b/frontend/src/features/shell/AppShell.tsx @@ -1,5 +1,5 @@ import { useEffect, useRef, useState, type FormEvent, type ReactNode } from "react"; -import { FolderCode, Menu, Plus, Search, Settings, Trash2 } from "lucide-react"; +import { ArrowRight, FolderCode, PanelLeft, Plus, Search, Settings, Trash2, X } from "lucide-react"; import type { ChatGroup, ChatSummary, CodeExecutionSourceResponse, ExecutionApprovalDecisionRequest, ExecutionTaskSummary, ModelResponse } from "../../../../contracts/cortex-api"; import { displayChatTitle } from "../../lib/chatTitle"; import { chatPath, parseAppRoute, useNavigate, usePathname } from "../../lib/navigation"; @@ -58,6 +58,7 @@ export function AppShell({ const [renameTarget, setRenameTarget] = useState(null); const [deleteTarget, setDeleteTarget] = useState(null); const [chatQuery, setChatQuery] = useState(""); + const searchRef = useRef(null); const previousPathnameRef = useRef(pathname); const isSettings = parseAppRoute(pathname).kind === "settings"; @@ -122,9 +123,11 @@ export function AppShell({ className="window-control sidebar-toggle" type="button" aria-label={sidebarVisible ? "Hide chat history" : "Show chat history"} + aria-expanded={sidebarVisible} + aria-controls="thread-archive" onClick={() => setSidebarVisible((visible) => !visible)} > -