






















@@ -1463,6 +1463,58 @@ describe("chat session controls", () => {
14631463});
14641464});
146514651466+it("keeps picker options clickable after blurring an empty search input", async () => {
1467+const { state } = createChatHeaderState();
1468+state.sessionsIncludeGlobal = false;
1469+state.sessionsIncludeUnknown = false;
1470+const rows: GatewaySessionRow[] = [
1471+{ key: "main", kind: "direct", label: "Main", updatedAt: 2 },
1472+{ key: "agent:main:work", kind: "direct", label: "Work", updatedAt: 1 },
1473+];
1474+state.sessionsResult = createSessionsResultFromRows(rows);
1475+const request = vi.fn((method: string) => {
1476+if (method === "sessions.list") {
1477+return Promise.resolve(createSessionsResultFromRows(rows));
1478+}
1479+throw new Error(`Unexpected request: ${method}`);
1480+});
1481+state.client = { request } as unknown as GatewayBrowserClient;
1482+const onSwitchSession = vi.fn();
1483+const container = document.createElement("div");
1484+render(renderChatSessionSelect(state, onSwitchSession), container);
1485+1486+container.querySelector<HTMLButtonElement>('button[data-chat-session-select="true"]')!.click();
1487+await vi.waitFor(() => expect(state.chatSessionPickerResult).not.toBeNull());
1488+render(renderChatSessionSelect(state, onSwitchSession), container);
1489+const pickerResultBefore = state.chatSessionPickerResult;
1490+const requestCountBefore = request.mock.calls.length;
1491+1492+const input = container.querySelector<HTMLInputElement>(
1493+'input[data-chat-session-picker-search="true"]',
1494+);
1495+expect(input!.value).toBe("");
1496+input!.dispatchEvent(new FocusEvent("blur", { bubbles: false }));
1497+render(renderChatSessionSelect(state, onSwitchSession), container);
1498+1499+expect(state.chatSessionPickerResult).toBe(pickerResultBefore);
1500+expect(state.chatSessionPickerAppliedQuery).toBe("");
1501+expect(state.chatSessionPickerOpen).toBe(true);
1502+expect(request).toHaveBeenCalledTimes(requestCountBefore);
1503+const options = container.querySelectorAll<HTMLButtonElement>(
1504+'button[data-chat-session-picker-option="true"]',
1505+);
1506+const target = [...options].find(
1507+(button) => button.dataset.sessionKey && button.dataset.sessionKey !== state.sessionKey,
1508+);
1509+if (!target?.dataset.sessionKey) {
1510+throw new Error("expected another session option");
1511+}
1512+const targetSessionKey = target.dataset.sessionKey;
1513+target.click();
1514+1515+expect(onSwitchSession).toHaveBeenCalledWith(state, targetSessionKey);
1516+});
1517+14661518it("clears applied chat session picker search when the input is cleared", async () => {
14671519const { state } = createChatHeaderState();
14681520state.sessionsIncludeGlobal = false;
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。