Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
feat(webui): match session handles in Ctrl+K
chengyongrud14c54c31cf5
diff --git a/webui/browser/loaded-session-search-fixture.tsx b/webui/browser/loaded-session-search-fixture.tsxindex d104fe8f1..26a7e744c 100644--- a/webui/browser/loaded-session-search-fixture.tsx+++ b/webui/browser/loaded-session-search-fixture.tsx@@ -8,6 +8,7 @@ import type { ChatSummary } from "@/lib/types";const sessions: ChatSummary[] = Array.from({ length: 1000 }, (_, index) => ({key: `websocket:topic-${index}`, chatId: `topic-${index}`, channel: "websocket",title: `Topic ${index}`, preview: `Preview ${index}`, createdAt: null, updatedAt: null,+ ...(index === 1 ? { handle: { id: "handle_00000000000000000000000000000001", name: "betu" } } : {}),}));export function LoadedSessionSearchFixture() {diff --git a/webui/browser/loaded-session-search.spec.ts b/webui/browser/loaded-session-search.spec.tsindex d6dced1a6..8f213ce88 100644--- a/webui/browser/loaded-session-search.spec.ts+++ b/webui/browser/loaded-session-search.spec.ts@@ -13,6 +13,12 @@ for (const viewport of [{ width: 1280, height: 800 }, { width: 390, height: 844const dialog = page.getByRole("dialog", { name: "Search", exact: true });const input = dialog.getByRole("textbox", { name: "Search", exact: true });await expect(dialog.getByRole("button")).toHaveCount(24);+ for (const query of ["@betu", "betu", "@BETU", "@be"]) {+ await input.fill(query);+ await expect(dialog.getByRole("button")).toHaveCount(1);+ await expect(dialog.getByText("Topic 1", { exact: true })).toBeVisible();+ await expect(dialog.getByText("Preview 1", { exact: true })).toBeVisible();+ }for (const query of ["权限", "full access", "25%", "session_history.py"]) {await input.fill(query);await expect(dialog.getByRole("button")).toHaveCount(1);diff --git a/webui/src/components/SessionSearchDialog.tsx b/webui/src/components/SessionSearchDialog.tsxindex 62cea5ab2..bbe156b0c 100644--- a/webui/src/components/SessionSearchDialog.tsx+++ b/webui/src/components/SessionSearchDialog.tsx@@ -62,7 +62,8 @@ export function SessionSearchDialog({const searchPending = searchQuery !== normalizedQuery || searchRevision !== messageRevision;const searchableSessions = useMemo(() => sessions.map((session) => ({session,- text: [titleOverrides[session.key], session.title, visibleSessionPreview(session.preview)]+ text: [titleOverrides[session.key], session.title, visibleSessionPreview(session.preview),+ session.handle ? `@${session.handle.name}` : undefined].filter(Boolean).join(" ").toLowerCase(),})), [sessions, titleOverrides]);const sessionResults = useMemo<SessionSearchResult[]>(() => {diff --git a/webui/src/tests/session-search-dialog.test.tsx b/webui/src/tests/session-search-dialog.test.tsxindex a59b71b9e..67aa1a834 100644--- a/webui/src/tests/session-search-dialog.test.tsx+++ b/webui/src/tests/session-search-dialog.test.tsx@@ -119,6 +119,29 @@ describe("SessionSearchDialog", () => {expect(screen.queryByText("Model chat")).not.toBeInTheDocument();});+ it("finds loaded session handles with or without @ and selects the matching session without requests", () => {+ const fetch = vi.fn();+ vi.stubGlobal("fetch", fetch);+ const onSelect = vi.fn();+ render(<SessionSearchDialog open sessions={[+ { ...session(1), handle: { id: "handle_00000000000000000000000000000001", name: "betu" } },+ { ...session(2), handle: { id: "handle_00000000000000000000000000000002", name: "mira" } },+ session(3),+ ]} activeKey={null} loading={false} onOpenChange={() => {}} onSelect={onSelect} />);+ const input = screen.getByRole("textbox", { name: "Search" });+ for (const query of ["@betu", "betu", "@BETU", "@be", "etu"]) {+ fireEvent.change(input, { target: { value: query } });+ expect(screen.getAllByRole("button")).toHaveLength(1);+ expect(screen.getByText("Chat 1")).toBeInTheDocument();+ }+ fireEvent.change(input, { target: { value: "@mira" } });+ expect(screen.getAllByRole("button")).toHaveLength(1);+ expect(screen.getByText("Chat 2")).toBeInTheDocument();+ fireEvent.keyDown(input, { key: "Enter" });+ expect(onSelect).toHaveBeenCalledWith("websocket:chat-2");+ expect(fetch).not.toHaveBeenCalled();+ });+it("finds cached body substrings with a bounded preview and no data requests", () => {const fetch = vi.fn();vi.stubGlobal("fetch", fetch);