refactor(webui): remove session list previews and timestamps (#6189)
* refactor(webui): remove session list previews and timestamps * test(webui): limit legacy coverage to persisted sidebar files * refactor(webui): simplify chat rows and fix gallery states * refactor(webui): flatten chat row title wrapper
This commit is contained in:
1 parent
47f600afc6
commit
cdb6210b45
12 files changed
+62
-97
No files matched your search
@@ -1185,8 +1185,6 @@ describe("webui API helpers", () => {
|
||||
collapsed_groups: {},
|
||||
view: {
|
||||
density: "compact" as const,
|
||||
show_previews: false,
|
||||
show_timestamps: false,
|
||||
show_archived: true,
|
||||
sort: "updated_desc" as const,
|
||||
},
|
||||
|
||||
@@ -1855,8 +1855,7 @@ describe("App layout", () => {
|
||||
schema_version: 1, pinned_keys: [], archived_keys: [], session_order: [],
|
||||
title_overrides: { [key]: "推特大战场" }, project_name_overrides: {},
|
||||
tags_by_key: {}, collapsed_groups: {}, workbench: { version: 1, tabs: {} },
|
||||
view: { density: "comfortable", show_previews: false, show_timestamps: false,
|
||||
show_archived: false, sort: "updated_desc" },
|
||||
view: { density: "comfortable", show_archived: false, sort: "updated_desc" },
|
||||
};
|
||||
mockFetchRoutes({
|
||||
"/api/settings": baseSettingsPayload(),
|
||||
@@ -2591,8 +2590,6 @@ describe("App layout", () => {
|
||||
collapsed_groups: {},
|
||||
view: {
|
||||
density: "comfortable",
|
||||
show_previews: false,
|
||||
show_timestamps: false,
|
||||
show_archived: false,
|
||||
sort: "updated_desc",
|
||||
},
|
||||
@@ -2674,8 +2671,6 @@ describe("App layout", () => {
|
||||
collapsed_groups: {},
|
||||
view: {
|
||||
density: "comfortable",
|
||||
show_previews: false,
|
||||
show_timestamps: false,
|
||||
show_archived: false,
|
||||
sort: "title_asc",
|
||||
},
|
||||
|
||||
@@ -946,16 +946,19 @@ describe("ChatList", () => {
|
||||
onTogglePin={vi.fn()}
|
||||
onRequestRename={vi.fn()}
|
||||
onToggleArchive={vi.fn()}
|
||||
showPreviews
|
||||
/>,
|
||||
);
|
||||
|
||||
const chatsSection = screen.getAllByRole("region")[0];
|
||||
const text = chatsSection.textContent ?? "";
|
||||
const chats = within(chatsSection).getAllByRole("button", {
|
||||
name: /^(Newest|Middle|Older) chat$/,
|
||||
});
|
||||
|
||||
expect(text.indexOf("Newest chat")).toBeLessThan(text.indexOf("Middle chat"));
|
||||
expect(text.indexOf("Middle chat")).toBeLessThan(text.indexOf("Older chat"));
|
||||
expect(screen.queryByText("/model fast")).not.toBeInTheDocument();
|
||||
expect(chats.map((chat) => chat.textContent)).toEqual([
|
||||
"Newest chat",
|
||||
"Middle chat",
|
||||
"Older chat",
|
||||
]);
|
||||
});
|
||||
|
||||
it("shows a pin indicator for pinned chats", () => {
|
||||
@@ -1032,7 +1035,6 @@ describe("ChatList", () => {
|
||||
onRequestRename={vi.fn()}
|
||||
onToggleArchive={vi.fn()}
|
||||
sort="title_asc"
|
||||
showTimestamps
|
||||
runningChatIds={["zeta"]}
|
||||
/>,
|
||||
);
|
||||
@@ -1092,7 +1094,6 @@ describe("ChatList", () => {
|
||||
onRequestRename={vi.fn()}
|
||||
onToggleArchive={vi.fn()}
|
||||
defaultWorkspacePath="/Users/me/.nanobot/workspace"
|
||||
showTimestamps
|
||||
/>,
|
||||
);
|
||||
|
||||
@@ -1444,7 +1445,6 @@ describe("ChatList", () => {
|
||||
onTogglePin={vi.fn()}
|
||||
onRequestRename={vi.fn()}
|
||||
onToggleArchive={vi.fn()}
|
||||
showTimestamps
|
||||
/>,
|
||||
);
|
||||
|
||||
@@ -1500,7 +1500,6 @@ describe("ChatList", () => {
|
||||
onTogglePin={vi.fn()}
|
||||
onRequestRename={vi.fn()}
|
||||
onToggleArchive={vi.fn()}
|
||||
showTimestamps
|
||||
/>,
|
||||
);
|
||||
|
||||
@@ -1550,7 +1549,6 @@ describe("ChatList", () => {
|
||||
onTogglePin={vi.fn()}
|
||||
onRequestRename={vi.fn()}
|
||||
onToggleArchive={vi.fn()}
|
||||
showTimestamps
|
||||
/>,
|
||||
);
|
||||
|
||||
|
||||
@@ -125,6 +125,36 @@ it("submits a message through the actual composer using only local preview state
|
||||
expect(fetch.mock.calls[0][0]).toBe("/__nanobot_components");
|
||||
});
|
||||
|
||||
it("switches the chat list preview between ready, loading, empty and archived states", async () => {
|
||||
const source = "webui/src/components/SidebarSelectionHighlight.tsx";
|
||||
window.history.replaceState({}, "", `/gallery.html#${new URLSearchParams({ component: source })}`);
|
||||
vi.stubGlobal("fetch", vi.fn().mockResolvedValue({ ok: true, json: async () => inventory }));
|
||||
render(<Gallery />);
|
||||
await screen.findByRole("heading", { name: "ChatList · 会话列表" });
|
||||
const preview = within(screen.getByRole("region", { name: "Component preview" }));
|
||||
const setMode = async (mode: string) => {
|
||||
await userEvent.click(preview.getByRole("combobox", { name: "会话列表状态" }));
|
||||
await userEvent.click(screen.getByRole("option", { name: mode, exact: true }));
|
||||
};
|
||||
|
||||
expect(preview.getByRole("button", { name: "@design 组件设计" })).toBeVisible();
|
||||
expect(preview.getByRole("button", { name: "@tests 验证交互" })).toBeVisible();
|
||||
expect(preview.getAllByRole("button", { name: /^@/ })).toHaveLength(2);
|
||||
|
||||
await setMode("loading");
|
||||
expect(preview.getByText("Loading…")).toBeVisible();
|
||||
await setMode("empty");
|
||||
expect(preview.getByText("No sessions yet.")).toBeVisible();
|
||||
await setMode("archived");
|
||||
const archived = within(preview.getByRole("region", { name: "Archived" }));
|
||||
expect(archived.getByRole("button", { name: "@history 历史方案" })).toBeVisible();
|
||||
expect(preview.getAllByRole("button", { name: /^@/ })).toHaveLength(3);
|
||||
|
||||
await setMode("ready");
|
||||
expect(preview.getByRole("button", { name: "@design 组件设计" })).toHaveAttribute("aria-current", "page");
|
||||
expect(preview.getAllByRole("button", { name: /^@/ })).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("edits a pairing route without mounting a client or making a gateway mutation", async () => {
|
||||
const source = "webui/src/components/remote/PairRouteSettingsView.tsx";
|
||||
window.history.replaceState({}, "", `/gallery.html#${new URLSearchParams({ component: source })}`);
|
||||
|
||||
@@ -1328,8 +1328,6 @@ describe("NanobotClient", () => {
|
||||
workbench: { version: 1, tabs: {} },
|
||||
view: {
|
||||
density: "comfortable",
|
||||
show_previews: false,
|
||||
show_timestamps: false,
|
||||
show_archived: false,
|
||||
sort: "manual",
|
||||
},
|
||||
@@ -1392,8 +1390,6 @@ describe("NanobotClient", () => {
|
||||
},
|
||||
view: {
|
||||
density: "comfortable",
|
||||
show_previews: false,
|
||||
show_timestamps: false,
|
||||
show_archived: false,
|
||||
sort: "updated_desc",
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user