feat(webui): improve sidebar performance
This commit is contained in:
@@ -992,6 +992,73 @@ describe("App layout", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("opens search from the keyboard shortcut", async () => {
|
||||
mockSessions = [
|
||||
{
|
||||
key: "websocket:chat-a",
|
||||
channel: "websocket",
|
||||
chatId: "chat-a",
|
||||
createdAt: "2026-04-16T10:00:00Z",
|
||||
updatedAt: "2026-04-16T10:00:00Z",
|
||||
preview: "Existing chat",
|
||||
},
|
||||
];
|
||||
|
||||
render(<App />);
|
||||
|
||||
await waitFor(() => expect(connectSpy).toHaveBeenCalled());
|
||||
fireEvent.keyDown(window, { key: "k", metaKey: true });
|
||||
|
||||
const dialog = await screen.findByRole("dialog", { name: "Search" });
|
||||
expect(within(dialog).queryByText("Global actions")).not.toBeInTheDocument();
|
||||
expect(within(dialog).getByText("Existing chat")).toBeInTheDocument();
|
||||
|
||||
const textbox = within(dialog).getByRole("textbox", { name: "Search" });
|
||||
fireEvent.change(textbox, { target: { value: "missing" } });
|
||||
expect(within(dialog).queryByText("Existing chat")).not.toBeInTheDocument();
|
||||
|
||||
fireEvent.change(textbox, { target: { value: "existing" } });
|
||||
expect(within(dialog).getByText("Existing chat")).toBeInTheDocument();
|
||||
|
||||
fireEvent.keyDown(textbox, { key: "Enter" });
|
||||
await waitFor(() =>
|
||||
expect(screen.queryByRole("dialog", { name: "Search" })).not.toBeInTheDocument(),
|
||||
);
|
||||
expect(createChatSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("keeps large sidebars light while search still covers every chat", async () => {
|
||||
mockSessions = Array.from({ length: 170 }, (_, index) => {
|
||||
const chatId = `chat-${index}`;
|
||||
return {
|
||||
key: `websocket:${chatId}`,
|
||||
channel: "websocket" as const,
|
||||
chatId,
|
||||
createdAt: new Date(Date.UTC(2026, 3, 16, 12, 0 - index)).toISOString(),
|
||||
updatedAt: new Date(Date.UTC(2026, 3, 16, 12, 0 - index)).toISOString(),
|
||||
title: index === 169 ? "Hidden target" : `Bulk chat ${index}`,
|
||||
preview: "",
|
||||
};
|
||||
});
|
||||
|
||||
render(<App />);
|
||||
|
||||
await waitFor(() => expect(connectSpy).toHaveBeenCalled());
|
||||
const sidebar = screen.getByRole("navigation", { name: "Sidebar navigation" });
|
||||
await waitFor(() =>
|
||||
expect(within(sidebar).getByRole("button", { name: "Bulk chat 0" })).toBeInTheDocument(),
|
||||
);
|
||||
expect(within(sidebar).queryByText("Hidden target")).not.toBeInTheDocument();
|
||||
expect(within(sidebar).getByRole("button", { name: "Show 10 more" })).toBeInTheDocument();
|
||||
|
||||
fireEvent.click(within(sidebar).getByRole("button", { name: "Search" }));
|
||||
const dialog = await screen.findByRole("dialog", { name: "Search" });
|
||||
fireEvent.change(within(dialog).getByRole("textbox", { name: "Search" }), {
|
||||
target: { value: "hidden" },
|
||||
});
|
||||
expect(within(dialog).getByText("Hidden target")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("opens a blank start page without creating an empty chat", async () => {
|
||||
mockSessions = [
|
||||
{
|
||||
|
||||
@@ -78,6 +78,7 @@ describe("webui i18n", () => {
|
||||
const common = resource.common;
|
||||
expect(common.app.system.restarting).toBeTruthy();
|
||||
expect(common.sidebar.settings).toBeTruthy();
|
||||
expect(common.chat.showMore).toBeTruthy();
|
||||
expect(common.settings.sidebar.title).toBeTruthy();
|
||||
expect(common.settings.backToChat).toBeTruthy();
|
||||
for (const key of SETTINGS_NAV_KEYS) {
|
||||
|
||||
Reference in New Issue
Block a user