fix(agent): 抽屉与整页之间的切换

- 在智能体页面按 Ctrl+J / 点智能体入口聚焦页面输入框,不再在抽屉里叠一份同一会话
- 会话页统计行右侧加「在侧边打开」:回到进智能体页面之前的页面,会话在抽屉里接着看
- 窄屏顶栏按钮与快捷键、悬浮按钮共用同一套切换
- 抽屉关闭钮放进标题栏按钮行(原来绝对定位,比其它按钮低 5px)
- 关闭抽屉后焦点回到打开前的元素(快捷键打开没有触发元素,原来落到 body)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
This commit is contained in:
rootandClaude Opus 5.5 committed 2026-10-06 18:07:21 +08:00
1 parent 93a5341688
commit a87c2c19c4
6 files changed
+150 -25

No files matched your search

@@ -17,7 +17,7 @@ import {
writeDraft,
} from "./agent-nav.ts";
import { CompactPager } from "./agent-session-list.tsx";
import { isAgentPage, outletKey } from "./agent-store.ts";
import { agentReturnPath, isAgentPage, noteAgentReturnPath, outletKey, toggleAction } from "./agent-store.ts";
import { cachedRunEvents, cacheRunEvents } from "./use-agent-stream.ts";
// 智能体页面切换的状态逻辑:整页重挂载 key、分栏与 URL、草稿、滚动策略、快捷键在智能体页面的行为。
@@ -150,3 +150,29 @@ describe("切回看过的会话:事件缓存", () => {
expect(cachedRunEvents("live:n29")).toHaveLength(1);
});
});
describe("Ctrl+J / 智能体入口在不同页面", () => {
it("抽屉开着:收起", () => {
expect(toggleAction({ open: true, runId: "r" }, "/console/library")).toBe("close");
expect(toggleAction({ open: true, runId: null }, "/console/agent/r")).toBe("close");
});
it("已在智能体页面:聚焦页面输入框,不在抽屉里再开一份同一会话", () => {
expect(toggleAction({ open: false, runId: "r" }, "/console/agent/r")).toBe("focus-page");
expect(toggleAction({ open: false, runId: null }, "/console/agent")).toBe("focus-page");
});
it("其它页面:上次的会话还在就接着看,否则开新对话", () => {
expect(toggleAction({ open: false, runId: "r" }, "/console/library")).toBe("restore");
expect(toggleAction({ open: false, runId: null }, "/console/library")).toBe("open");
});
});
describe("会话页「在侧边打开」回到之前的页面", () => {
it("只记非智能体页面,带查询串", () => {
noteAgentReturnPath("/console/library", "?filter=unidentified");
noteAgentReturnPath("/console/agent");
noteAgentReturnPath("/console/agent/r1", "?tab=auto");
expect(agentReturnPath()).toBe("/console/library?filter=unidentified");
noteAgentReturnPath("/console/sites");
expect(agentReturnPath()).toBe("/console/sites");
});
});