fix(agent): 会话列表换成一行的紧凑分页
整页表格的分页放进 17rem 左栏和抽屉历史弹层会折成三行,弹层只露出 3 条会话。 改成「共 N 条 · ‹ 1/3 ›」一行,每页条数沿用全站设置,翻页时列表回到顶部。 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
This commit is contained in:
1 parent
f5234cbcb9
commit
164a27fd80
2 files changed
+79
-3
No files matched your search
@@ -1,6 +1,9 @@
|
||||
import { createElement } from "react";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { runGroup } from "~/api/agent.ts";
|
||||
import { agentListHref, agentRunHref, groupFromSearch, resolveGroup, revealScrollTop } from "./agent-nav.ts";
|
||||
import { CompactPager } from "./agent-session-list.tsx";
|
||||
import { isAgentPage, outletKey } from "./agent-store.ts";
|
||||
|
||||
// 智能体页面切换的状态逻辑:整页重挂载 key、分栏与 URL、草稿、滚动策略、快捷键在智能体页面的行为。
|
||||
@@ -60,3 +63,24 @@ describe("当前会话滚进可见区", () => {
|
||||
expect(revealScrollTop({ top: 600, height: 40 }, vp)).toBe(340);
|
||||
});
|
||||
});
|
||||
|
||||
describe("会话列表分页(窄列表一行)", () => {
|
||||
const pager = (p: Partial<Parameters<typeof CompactPager>[0]>) =>
|
||||
renderToStaticMarkup(
|
||||
createElement(CompactPager, { page: 1, pageSize: 20, total: 0, onPageChange: () => {}, ...p }),
|
||||
);
|
||||
it("只有一页不显示", () => {
|
||||
expect(pager({ total: 12 })).toBe("");
|
||||
});
|
||||
it("多页:总数 + 当前页 / 页数,没有每页条数选择", () => {
|
||||
const html = pager({ total: 48, page: 2 });
|
||||
expect(html).toContain("共 48 条");
|
||||
expect(html).toContain("2 / 3");
|
||||
expect(html).not.toContain("每页");
|
||||
});
|
||||
it("还能往后加载时标出已加载条数和「+」", () => {
|
||||
const html = pager({ total: 20, hasMore: true });
|
||||
expect(html).toContain("已加载 20 条");
|
||||
expect(html).toContain("1 / 1+");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user