A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Hide the sidebar with its switch and reach the rail by dragging its edge
Fei24110ffb322d9b7d
diff --git a/docs/design/ui-standard.md b/docs/design/ui-standard.mdindex 0eec2d8a..4570be19 100644--- a/docs/design/ui-standard.md+++ b/docs/design/ui-standard.md@@ -180,7 +180,7 @@ Bot 名字、提及用同一个颜色写字;纯黑读起来像标题,所以| 设置对话框 | 宽 `min(1100px, 100vw - 48px)`,高 `min(780px, …)`,所有页面同一尺寸(和用量页一致),切换页面时不变;左侧导航 198px || 记忆对话框 | 宽 `min(680px, 100vw - 48px)`,高 `min(760px, …)` || 右侧面板 | 详情 320px;浏览器默认 520px,可拖动,最小 360px,对话列至少保留 420px |-| 左侧栏 | 和右侧面板一样不被挤窄。窗口变窄时先收起右侧面板(放得下时自动回来),再把左侧栏收成 88px 头像窄栏(头像 44px),Windows、macOS、网页都一样;手动收起也是这条窄栏。窄时打开面板,左侧栏先收成窄栏让位,仍放不下才盖住对话。桌面应用最小窗口宽 508px(窄栏 + 420) |+| 左侧栏 | 和右侧面板一样不被挤窄。拖右边缘调宽度,264–420px;拖到 176px 以下松手,吸附成 88px 头像窄栏(头像 44px),从窄栏往外拖回到完整栏。左上角的开关(和快捷键)整列收起、再次点击恢复。窗口变窄时先收起右侧面板(放得下时自动回来),再把左侧栏收成头像窄栏;窄时打开面板,左侧栏先收成窄栏让位,仍放不下才盖住对话。Windows、macOS、网页都一样。桌面应用最小窗口宽 508px(窄栏 + 420) || 气泡 | Bot 气泡最宽 `min(var(--bt-msg-w) × 100%, 100% - 82px)`,用户气泡最宽 `var(--bt-msg-w) × 100%`;`--bt-msg-w` 是设置里的气泡宽度(50%–100%,默认 80%) || 输入框卡片 | 最宽 `min(992px, 100%)` || 主 Bot 卡片 | 宽 95px |diff --git a/ds-bot/client.js b/ds-bot/client.jsindex 77da178b..eb5cc4f4 100644--- a/ds-bot/client.js+++ b/ds-bot/client.js@@ -55,6 +55,7 @@ var ZH = {"New…": "新建","Collapse sidebar": "收起侧边栏","Expand sidebar": "展开侧边栏",+ "Resize sidebar": "调整侧边栏宽度","Animation": "动画","Bot animation": "Bot 动画","Quiet": "安静",@@ -2505,6 +2506,13 @@ body[data-bt-motion=quiet] .bt-mark[data-poke]{cursor:default}and the floating drawer keeps the opaque fill over the conversation. */.bt-leftcol{position:fixed;left:0;top:0;bottom:0;z-index:25;display:flex;--bt-lc-clear:var(--dsh-frame-top-clearance,var(--dsh-windows-titlebar-height,0px));background:var(--bt-leftcol-fill,var(--bt-sidebar));border-right:.5px solid var(--bt-line);box-sizing:border-box;padding:calc(var(--bt-lc-clear) + 6px) 12px 6px;color:var(--bt-ink);font-family:var(--bt-font)}html[data-windows-titlebar] .bt-leftcol,html[data-platform=darwin] .bt-leftcol{border-right:none}+.bt-leftcol-grip{position:absolute;right:-4px;top:0;bottom:0;width:8px;cursor:col-resize;z-index:3;touch-action:none}+.bt-leftcol-grip:hover,.bt-leftcol-grip:active{background:linear-gradient(to right,transparent 3px,var(--bt-line-2) 3px,var(--bt-line-2) 5px,transparent 5px)}+/* The shell's collapsed sidebar keeps no track in the Bot view, so a hidden+ column leaves nothing behind (the shell's right column, when open, keeps its+ own geometry). Our own collapse of it lands without the shell's slide. */+[class*="_frame"][data-sidebar-collapsed][data-rightbar-collapsed]:has(>[class*="_sidebarCol"]){grid-template-columns:0px minmax(0,1fr) 0px!important}+html[data-bt-collapsing] [class*="_frame"]:has(>[class*="_sidebarCol"]){transition:none!important}.bt-leftcol[data-left=drawer]{background:var(--bt-sidebar);box-shadow:8px 0 24px rgba(0,0,0,.14)}.bt-leftcol>.bt-side{width:100%}.bt-leftcol-foot{display:flex;align-items:center;gap:9px;padding-top:8px;flex:none}@@ -2731,7 +2739,9 @@ html[data-windows-titlebar]:not([data-fullscreen]) :is(.bt-pane,.bt-panel)::befo.bt-panel[data-leaving]{transform:translateX(100%);transition:transform .3s cubic-bezier(.2,0,0,1);pointer-events:none}.bt-panel[data-instant]{transition:none}@keyframes bt-pane-in{from{transform:translateX(100%)}}-[class*="_centerCol"]{transition:margin-right ${SPRING_SHAPE.duration}ms ${SPRING_SHAPE.easing},margin-left ${SPRING_SHAPE.duration}ms ${SPRING_SHAPE.easing}}+/* The right margin glides with the Bot panel's slide; the left one lands at once,+ as our left column appears, folds and hides without a slide of its own. */+[class*="_centerCol"]{transition:margin-right ${SPRING_SHAPE.duration}ms ${SPRING_SHAPE.easing}}.bt-panel-grip{position:absolute;left:-5px;top:0;bottom:0;width:8px;cursor:col-resize;z-index:3;touch-action:none}.bt-panel-grip:hover,.bt-panel[data-dragging] .bt-panel-grip{background:linear-gradient(to right,transparent 4px,var(--bt-line-2) 4px,var(--bt-line-2) 6px,transparent 6px)}.bt-drag-shield{position:fixed;inset:0;z-index:45;cursor:col-resize}@@ -2921,14 +2931,16 @@ button.bt-set-row:hover{background:var(--bt-hover)}the sidebar is open. Elsewhere an open sidebar uses the team's own top row. */html:not([data-windows-titlebar]) :not([class*="_collapsed"])>[class*="_logoRow"]{display:none!important}html[data-windows-titlebar] :not([class*="_collapsed"])>[class*="_logoRow"]{height:0!important;margin:0!important}-html[data-windows-titlebar] :is(.bt-side-collapse,.bt-rail-expand),html[data-platform=darwin] :is(.bt-side-collapse,.bt-rail-expand){display:none}+html[data-windows-titlebar] .bt-side-collapse{display:none}/* Under a Windows title bar our own switch replaces the shell's: the shell'stoggle expands the shell sidebar first, and pulling it back afterwards is avisible flash of the shell's column. */html[data-windows-titlebar] [class*="_logoRow"]>[class*="_toggle"]{display:none!important}-.bt-title-toggle{display:none;position:fixed;left:12px;top:calc((var(--dsh-windows-titlebar-height,0px) - 28px) / 2);width:28px;height:28px;z-index:30;-webkit-app-region:no-drag;align-items:center;justify-content:center;border:0;border-radius:6px;padding:0;background:transparent;color:var(--bt-ink);cursor:pointer;font-family:var(--bt-font)}-html[data-windows-titlebar] .bt-title-toggle{display:inline-flex}-.bt-title-toggle:hover{background:var(--bt-hover)}+html[data-windows-titlebar] .bt-title-toggle{position:fixed;left:12px;top:calc((var(--dsh-windows-titlebar-height,0px) - 28px) / 2);width:28px;height:28px;z-index:30;-webkit-app-region:no-drag;display:inline-flex;align-items:center;justify-content:center;border:0;border-radius:6px;padding:0;background:transparent;color:var(--bt-ink);cursor:pointer;font-family:var(--bt-font)}+html[data-windows-titlebar] .bt-title-toggle:hover{background:var(--bt-hover)}+/* Elsewhere the switch shows only while the column is hidden, where the column's+ own top row had it. */+html:not([data-windows-titlebar]) .bt-title-toggle{position:fixed;left:12px;top:calc(var(--dsh-frame-top-clearance,0px) + 6px);z-index:30}/* The footer ends in the Bot row: the whale's settings seat, then the account menuwhen no plugin holds that seat. Every other plugin's entry takes a whole row aboveit, in the shell's order, so none of them squeezes the Bot row. */@@ -8636,36 +8648,52 @@ var MIN_CHAT = 420;var RAIL_WIDTH = 88;var PANEL_MIN = { details: 320, browser: 360, side: 320 };var DSH_NARROW = 1024;+var SIDEBAR_MIN = 264;+var SIDEBAR_MAX = 420;var FALLBACK_SIDEBAR_WIDTH = 280;+var RAIL_SNAP = (RAIL_WIDTH + SIDEBAR_MIN) / 2;function frameLayout({ viewport, sidebarWidth, pref, drawer = false, panel = null }) {const fits = pref === "open" && viewport >= sidebarWidth + MIN_CHAT;- let left = fits ? "open" : drawer && pref === "open" ? "drawer" : "rail";- let occupied = left === "open" ? sidebarWidth : RAIL_WIDTH;+ let left = pref === "hidden" ? "hidden" : fits ? "open" : drawer && pref === "open" ? "drawer" : "rail";+ let occupied = left === "open" ? sidebarWidth : left === "hidden" ? 0 : RAIL_WIDTH;let panelState = "none";if (panel !== null) {const need = (PANEL_MIN[panel.view] ?? PANEL_MIN.details) + MIN_CHAT;if (occupied + need <= viewport) panelState = "shown";else if (panel.yielded === true) {- left = "rail";- occupied = RAIL_WIDTH;- panelState = RAIL_WIDTH + need <= viewport ? "shown" : "overlay";+ if (left !== "hidden") {+ left = "rail";+ occupied = RAIL_WIDTH;+ }+ panelState = occupied + need <= viewport ? "shown" : "overlay";} else panelState = "folded";}return { left, panel: panelState, room: Math.max(0, viewport - occupied) };}-var dshExpandedFor = (viewport, left) => viewport >= DSH_NARROW && left === "open";+function dragColumn(x, viewport) {+ if (x < RAIL_SNAP) return { left: "rail", width: RAIL_WIDTH };+ const docks = viewport >= SIDEBAR_MIN + MIN_CHAT;+ const high = docks ? Math.max(SIDEBAR_MIN, Math.min(SIDEBAR_MAX, viewport - MIN_CHAT)) : SIDEBAR_MAX;+ return { left: docks ? "open" : "drawer", width: Math.round(Math.max(SIDEBAR_MIN, Math.min(x, high))) };+}+var toggledPref = (pref, shown) => pref === "hidden" ? shown : "hidden";var RESIZE_SETTLE_MS = 500;var userSidebarToggle = ({ before, after, requested = false, sinceResize = Infinity }) => before.collapsed !== after.collapsed && !requested && sinceResize >= RESIZE_SETTLE_MS && before.viewport < DSH_NARROW === after.viewport < DSH_NARROW;-function readSidebarPref(storage = globalThis.localStorage) {+var PREFS = ["open", "rail", "hidden"];+function readSidebar(storage = globalThis.localStorage) {try {- return storage.getItem(STORAGE.sidebar) === "rail" ? "rail" : "open";+ const saved = JSON.parse(storage.getItem(STORAGE.sidebar) ?? "null");+ const pref = PREFS.includes(saved?.pref) ? saved.pref : "open";+ const shown = saved?.shown === "rail" ? "rail" : "open";+ const width = Number.isFinite(saved?.width) ? Math.max(SIDEBAR_MIN, Math.min(SIDEBAR_MAX, saved.width)) : FALLBACK_SIDEBAR_WIDTH;+ return { pref, shown, width };} catch {- return "open";+ return { pref: "open", shown: "open", width: FALLBACK_SIDEBAR_WIDTH };}}-function writeSidebarPref(pref, storage = globalThis.localStorage) {+function writeSidebar(value, storage = globalThis.localStorage) {try {- storage.setItem(STORAGE.sidebar, pref === "rail" ? "rail" : "open");+ storage.setItem(STORAGE.sidebar, JSON.stringify(value));} catch {}}@@ -8724,7 +8752,6 @@ var chatRoom = {}};function installFrameWatch(frame) {- let sidebarWidth = FALLBACK_SIDEBAR_WIDTH;let collapsedWidth = collapsedTrackWidth();let raf = 0;const watched = /* @__PURE__ */ new Set();@@ -8734,13 +8761,10 @@ function installFrameWatch(frame) {const animating = column?.closest("[data-animating]") != null;const width = animating ? null : sidebarTrackWidth();const collapsed = dshCollapsed();- if (width !== null) {- if (collapsed === true) collapsedWidth = width;- else if (collapsed === false) sidebarWidth = width;- }+ if (width !== null && collapsed === true) collapsedWidth = width;frame.set((state) => {- const next = { viewport: window.innerWidth, sidebarWidth, collapsedWidth, collapsed: collapsed === true };- return state.viewport === next.viewport && state.sidebarWidth === next.sidebarWidth && state.collapsedWidth === next.collapsedWidth && state.collapsed === next.collapsed ? state : next;+ const next = { ...state, viewport: window.innerWidth, collapsedWidth, collapsed: collapsed === true };+ return state.viewport === next.viewport && state.collapsedWidth === next.collapsedWidth && state.collapsed === next.collapsed ? state : next;});};const measure = () => {@@ -9060,17 +9084,24 @@ function useListGlide(listRef, layout, key) {tops.current = { layout, map: next };}, [layout, key]);}-function LeftColumn({ mode, width, children }) {- return (0, import_react_dom3.createPortal)((0, import_react15.createElement)("div", { className: "bt-leftcol", "data-left": mode, style: { width: `${width}px` } }, children), document.body);+function LeftColumn({ mode, width, onGrip, children }) {+ return (0, import_react_dom3.createPortal)((0, import_react15.createElement)(+ "div",+ { className: "bt-leftcol", "data-left": mode, style: { width: `${width}px` } },+ children,+ (0, import_react15.createElement)("div", { className: "bt-leftcol-grip", role: "separator", "aria-orientation": "vertical", "aria-label": t("Resize sidebar"), title: t("Resize sidebar"), onPointerDown: onGrip })+ ), document.body);}-function TitleToggle({ left, onToggle }) {- if (typeof document === "undefined" || !document.documentElement.hasAttribute("data-windows-titlebar")) return null;- const collapse = left === "open" || left === "drawer";+function TitleToggle({ hidden, onToggle }) {+ if (typeof document === "undefined") return null;+ const titlebar = document.documentElement.hasAttribute("data-windows-titlebar");+ if (!titlebar && !hidden) return null;+ const label = t(hidden ? "Expand sidebar" : "Collapse sidebar");return (0, import_react_dom3.createPortal)((0, import_react15.createElement)("button", {type: "button",- className: "bt-title-toggle",- "aria-label": t(collapse ? "Collapse sidebar" : "Expand sidebar"),- title: t(collapse ? "Collapse sidebar" : "Expand sidebar"),+ className: titlebar ? "bt-title-toggle" : "bt-round bt-title-toggle",+ "aria-label": label,+ title: label,onClick: onToggle}, (0, import_react15.createElement)(SidebarIcon)), document.body);}@@ -9090,7 +9121,8 @@ function TeamSidebar(props) {drawer: uiNow.leftDrawer === true,panel: uiNow.details ? { view: uiNow.view, yielded: uiNow.panelYield === true } : null});- const mode = wide ? "inline" : layout.left;+ const [drag, setDrag] = (0, import_react15.useState)(null);+ const mode = drag?.left ?? layout.left;const wideContent = mode !== "rail";const updated = useSessions((list) => {const stamps = {};@@ -9110,15 +9142,51 @@ function TeamSidebar(props) {const main = roster.byId[roster.mainBotId];useListGlide(listRef, wideContent, order.map((entry) => entry.item.id).join(","));useLandOnMainBot(roster, useSessions, actions);- const ourWidth = layout.left === "rail" ? RAIL_WIDTH : frameSnap.sidebarWidth;- const pushed = layout.left === "open" ? frameSnap.sidebarWidth : RAIL_WIDTH;+ const openWidth = drag?.width ?? frameSnap.sidebarWidth;+ const ourWidth = mode === "rail" ? RAIL_WIDTH : openWidth;+ const pushed = mode === "open" ? openWidth : mode === "hidden" ? 0 : RAIL_WIDTH;(0, import_react15.useLayoutEffect)(() => {if (typeof document === "undefined") return;- chatRoom.setLeft(mode === "inline" ? null : Math.max(0, pushed - (frameSnap.collapsedWidth ?? 0)));- }, [mode, pushed, frameSnap.collapsedWidth]);+ chatRoom.setLeft(Math.max(0, pushed - (frameSnap.collapsedWidth ?? 0)));+ }, [pushed, frameSnap.collapsedWidth]);(0, import_react15.useEffect)(() => () => {if (typeof document !== "undefined") chatRoom.setLeft(null);}, []);+ const startDrag = (event) => {+ if (event.button !== 0) return;+ event.preventDefault();+ const grip = event.currentTarget;+ grip.setPointerCapture?.(event.pointerId);+ chatRoom.hold(true);+ let last = null;+ let done = false;+ const onMove = (move) => {+ last = dragColumn(move.clientX, window.innerWidth);+ setDrag(last);+ };+ const ends = ["pointerup", "pointercancel", "lostpointercapture"];+ const onEnd = (end) => {+ if (done) return;+ done = true;+ if (end.type === "pointerup") last = dragColumn(end.clientX, window.innerWidth);+ grip.removeEventListener("pointermove", onMove);+ for (const name of ends) grip.removeEventListener(name, onEnd);+ setDrag(null);+ chatRoom.hold(false);+ if (last === null) return;+ actions.setPanelYield?.(false);+ if (last.left === "rail") {+ actions.setLeftDrawer?.(false);+ actions.setSidebarPref?.("rail");+ return;+ }+ actions.setSidebarWidth?.(last.width);+ actions.setSidebarPref?.("open");+ actions.setLeftDrawer?.(last.left === "drawer");+ };+ grip.addEventListener("pointermove", onMove);+ for (const name of ends) grip.addEventListener(name, onEnd);+ };const dsh = (0, import_react15.useRef)(null);const requested = (0, import_react15.useRef)(false);const requestLapse = (0, import_react15.useRef)(0);@@ -9132,39 +9200,40 @@ function TeamSidebar(props) {window.addEventListener("resize", onResize);return () => window.removeEventListener("resize", onResize);}, []);+ const quiet = (on) => {+ if (on) document.documentElement.setAttribute("data-bt-collapsing", "");+ else document.documentElement.removeAttribute("data-bt-collapsing");+ };+ (0, import_react15.useEffect)(() => () => quiet(false), []);(0, import_react15.useLayoutEffect)(() => {if (typeof document === "undefined" || typeof actions.toggleSidebar !== "function") return void 0;const collapsed = dshCollapsed() ?? !wide;const prev = dsh.current;const viewport = window.innerWidth;- dsh.current = { collapsed, viewport, left: layout.left };+ dsh.current = { collapsed, viewport };if (prev !== null && collapsed !== prev.collapsed) {if (requested.current) requested.current = false;- else if (userSidebarToggle({ before: prev, after: { collapsed, viewport }, sinceResize: performance.now() - resizedAt.current })) {- if (prev.left === "open") actions.setSidebarPref?.("rail");- else {- actions.setSidebarPref?.("open");- if (frameSnap.viewport < frameSnap.sidebarWidth + MIN_CHAT) actions.setLeftDrawer?.(true);- }- actions.setPanelYield?.(false);- return void 0;+ else if (!collapsed && userSidebarToggle({ before: prev, after: { collapsed, viewport }, sinceResize: performance.now() - resizedAt.current })) {+ toggleRef.current();}}- const wantOpen = dshExpandedFor(frameSnap.viewport, layout.left);- if (collapsed === !wantOpen) {+ if (collapsed) {requested.current = false;+ quiet(false);return void 0;}if (requested.current) return void 0;requested.current = true;+ quiet(true);actions.toggleSidebar();clearTimeout(requestLapse.current);requestLapse.current = setTimeout(() => {requested.current = false;+ quiet(false);setLapsed((value) => value + 1);}, 300);return void 0;- }, [wide, frameSnap.viewport, frameSnap.sidebarWidth, layout.left, lapsed]);+ }, [wide, frameSnap.viewport, lapsed]);(0, import_react15.useEffect)(() => {if (mode !== "drawer") return void 0;const onDown = (event) => {@@ -9202,20 +9271,9 @@ function TeamSidebar(props) {event.preventDefault();actions.openPalette(event.key);};- const expandLeft = () => {- actions.setPanelYield?.(false);- actions.setSidebarPref?.("open");- if (frameSnap.viewport < frameSnap.sidebarWidth + MIN_CHAT) actions.setLeftDrawer?.(true);- };- const onTitleToggle = () => {- if (layout.left === "open") {- actions.setLeftDrawer?.(false);- actions.setSidebarPref?.("rail");- } else if (layout.left === "drawer") actions.setLeftDrawer?.(false);- else expandLeft();- };- const toggleRef = (0, import_react15.useRef)(onTitleToggle);- toggleRef.current = onTitleToggle;+ const onToggle = () => actions.toggleLeftHidden?.();+ const toggleRef = (0, import_react15.useRef)(onToggle);+ toggleRef.current = onToggle;(0, import_react15.useEffect)(() => {const onKey = (event) => {if (event.defaultPrevented || event.isComposing || !pressesShellShortcut(event, "sidebar.left.toggle")) return;@@ -9235,19 +9293,16 @@ function TeamSidebar(props) {(0, import_react15.createElement)(UpdateButton, { useUpdate: props.useUpdate, actions }),(0, import_react15.createElement)("button", { type: "button", className: "bt-round", "aria-label": t("Search"), title: t("Search"), onClick: () => actions.openPalette() }, (0, import_react15.createElement)(SearchIcon)),(0, import_react15.createElement)("button", { type: "button", className: "bt-round", "aria-label": t("New…"), title: t("New…"), onClick: () => actions.openNewChat("new") }, (0, import_react15.createElement)(PlusIcon)),- (0, import_react15.createElement)("button", { type: "button", className: "bt-round bt-side-collapse", "aria-label": t("Collapse sidebar"), title: t("Collapse sidebar"), onClick: () => {- actions.setLeftDrawer?.(false);- actions.setSidebarPref?.("rail");- } }, (0, import_react15.createElement)(SidebarIcon))+ (0, import_react15.createElement)("button", { type: "button", className: "bt-round bt-side-collapse", "aria-label": t("Collapse sidebar"), title: t("Collapse sidebar"), onClick: onToggle }, (0, import_react15.createElement)(SidebarIcon))) : (0, import_react15.createElement)("div",{ className: "bt-rail-top" },(0, import_react15.createElement)(UpdateButton, { useUpdate: props.useUpdate, actions }),- (0, import_react15.createElement)("button", { type: "button", className: "bt-round bt-rail-expand", "aria-label": t("Expand sidebar"), title: t("Expand sidebar"), onClick: expandLeft }, (0, import_react15.createElement)(SidebarIcon)),+ (0, import_react15.createElement)("button", { type: "button", className: "bt-round bt-side-collapse", "aria-label": t("Collapse sidebar"), title: t("Collapse sidebar"), onClick: onToggle }, (0, import_react15.createElement)(SidebarIcon)),main ? (0, import_react15.createElement)(BotRow, { ...rowProps, bot: main, marked: markedUnread[main.id] === true }) : roster.ready ? null : (0, import_react15.createElement)("div", { className: "bt-hint" }, t("Setting up your Main Bot…")),(0, import_react15.createElement)("span", { className: "bt-rail-sep", "aria-hidden": true }));- const foot = mode === "inline" ? null : wideContent ? (0, import_react15.createElement)("div", { className: "bt-leftcol-foot" }, (0, import_react15.createElement)(AccountLauncher, { seat: false, actions })) : (0, import_react15.createElement)(+ const foot = wideContent ? (0, import_react15.createElement)("div", { className: "bt-leftcol-foot" }, (0, import_react15.createElement)(AccountLauncher, { seat: false, actions })) : (0, import_react15.createElement)("div",{ className: "bt-leftcol-foot bt-leftcol-foot-rail" },(0, import_react15.createElement)("button", { type: "button", className: "bt-round", "aria-label": t("New…"), title: t("New…"), onClick: () => actions.openNewChat("new") }, (0, import_react15.createElement)(PlusIcon)),@@ -9269,8 +9324,8 @@ function TeamSidebar(props) {return (0, import_react15.createElement)(import_react15.Fragment,null,- (0, import_react15.createElement)(TitleToggle, { left: layout.left, onToggle: onTitleToggle }),- mode === "inline" ? content : (0, import_react15.createElement)(LeftColumn, { mode, width: ourWidth }, content)+ (0, import_react15.createElement)(TitleToggle, { hidden: mode === "hidden", onToggle }),+ mode === "hidden" ? null : (0, import_react15.createElement)(LeftColumn, { mode, width: ourWidth, onGrip: startDrag }, content));}function UpdateButton({ useUpdate, actions }) {@@ -19466,8 +19521,9 @@ function apply(ctx) {const seenStore = sharedMap(STORAGE.seen);let seenAt = seenStore.read();const ui2 = createSource({ details: null, view: "details", renaming: false, tab: null, side: null, newChat: null, exchange: null, menu: null, voice: null, palette: null, quote: null, settings: null, memory: null, toast: null, signIn: null, renameAgent: null, unread: unreadStore.read(), reactions: reactionStore.read(), visits: {}, panelYield: false, leftDrawer: false });- const sidebarPref = createSource(readSidebarPref());- const frame = createSource({ viewport: typeof window === "undefined" ? 0 : window.innerWidth, sidebarWidth: FALLBACK_SIDEBAR_WIDTH, collapsedWidth: 0, collapsed: false });+ let sidebarSaved = readSidebar();+ const sidebarPref = createSource(sidebarSaved.pref);+ const frame = createSource({ viewport: typeof window === "undefined" ? 0 : window.innerWidth, sidebarWidth: sidebarSaved.width, collapsedWidth: 0, collapsed: false });const surface = createSource({ mode: readMode(), plain: false });let agentSessionCache = /* @__PURE__ */ new Set();try {@@ -19915,13 +19971,23 @@ function apply(ctx) {toggleSidebar: () => {ctx.layout.toggleSidebar();},- // The left column's own preference; the sidebar sync pulls the shell's- // collapsed flag after it (TeamSidebar's frame effect).+ // The left column's own preference: 'open', 'rail' or 'hidden'. The switch+ // remembers the shown one it hid; a drag sets the open column's width.setSidebarPref: (pref) => {- const next = pref === "rail" ? "rail" : "open";- writeSidebarPref(next);+ const next = pref === "rail" || pref === "hidden" ? pref : "open";+ sidebarSaved = { ...sidebarSaved, pref: next, ...next === "hidden" ? {} : { shown: next } };+ writeSidebar(sidebarSaved);sidebarPref.set(next);},+ toggleLeftHidden: () => {+ ui2.set((state) => state.leftDrawer || state.panelYield ? { ...state, leftDrawer: false, panelYield: false } : state);+ actions.setSidebarPref(toggledPref(sidebarPref.getSnapshot(), sidebarSaved.shown));+ },+ setSidebarWidth: (width) => {+ sidebarSaved = { ...sidebarSaved, width };+ writeSidebar(sidebarSaved);+ frame.set((state) => state.sidebarWidth === width ? state : { ...state, sidebarWidth: width });+ },setLeftDrawer: (on) => ui2.set((state) => state.leftDrawer === on ? state : { ...state, leftDrawer: on }),setPanelYield: (on) => ui2.set((state) => state.panelYield === on ? state : { ...state, panelYield: on }),// Agent mode hands the surface back to the shell; everything open on the Bot@@ -19937,6 +20003,7 @@ function apply(ctx) {}writeMode(mode);surface.set((state) => ({ ...state, mode }));+ if (mode === "agent" && window.innerWidth >= DSH_NARROW && frame.getSnapshot().collapsed) ctx.layout.toggleSidebar();if (mode !== "bot") return;ensureBotHome();},diff --git a/ds-bot/src/client/frame-layout.js b/ds-bot/src/client/frame-layout.jsindex 430e9aea..15659b5e 100644--- a/ds-bot/src/client/frame-layout.js+++ b/ds-bot/src/client/frame-layout.js@@ -1,33 +1,36 @@-// The Bot shell's frame geometry: the left column (open, avatar rail or drawer),-// the Bot panel and the conversation share the window. The conversation keeps at-// least MIN_CHAT px; the column folds to a rail of avatars before the chat is-// squeezed, and an open panel that no longer fits folds away or covers the chat.-// These rules are pure so tests can drive them; the DOM side lives in+// The Bot shell's frame geometry: the left column (open, avatar rail, drawer or+// hidden), the Bot panel and the conversation share the window. The conversation+// keeps at least MIN_CHAT px; the column folds to a rail of avatars before the+// chat is squeezed, and an open panel that no longer fits folds away or covers+// the chat. These rules are pure so tests can drive them; the DOM side lives in// frame-watch.js.import { STORAGE } from './storage.js'export const MIN_CHAT = 420export const RAIL_WIDTH = 88export const PANEL_MIN = { details: 320, browser: 360, side: 320 }-// The shell collapses its own sidebar below this width; our column takes over-// from there, and its toggleSidebar flips narrow-expanded state instead.+// The shell collapses its own sidebar below this width.export const DSH_NARROW = 1024-// The shell column's width when it was never measured (its own default is 280).+// The open column's width range; a drag released short of RAIL_SNAP lands on the rail.+export const SIDEBAR_MIN = 264+export const SIDEBAR_MAX = 420export const FALLBACK_SIDEBAR_WIDTH = 280+export const RAIL_SNAP = (RAIL_WIDTH + SIDEBAR_MIN) / 2/*** @param {{viewport: number, sidebarWidth: number,- * pref: 'open'|'rail', drawer?: boolean,+ * pref: 'open'|'rail'|'hidden', drawer?: boolean,* panel: null | {view: string, yielded: boolean}}} input- * @returns {{left: 'open'|'rail'|'drawer', panel: 'none'|'shown'|'folded'|'overlay', room: number}}+ * @returns {{left: 'open'|'rail'|'drawer'|'hidden', panel: 'none'|'shown'|'folded'|'overlay', room: number}}* `room` is the width the panel and the conversation share: the viewport minus- * what the left column occupies (its full width when open, else the rail's —- * a drawer floats over the rail's place, so the chat does not move under it).+ * what the left column occupies (its full width when open, nothing when hidden,+ * else the rail's — a drawer floats over the rail's place, so the chat does not+ * move under it).*/export function frameLayout({ viewport, sidebarWidth, pref, drawer = false, panel = null }) {const fits = pref === 'open' && viewport >= sidebarWidth + MIN_CHAT- let left = fits ? 'open' : drawer && pref === 'open' ? 'drawer' : 'rail'- let occupied = left === 'open' ? sidebarWidth : RAIL_WIDTH+ let left = pref === 'hidden' ? 'hidden' : fits ? 'open' : drawer && pref === 'open' ? 'drawer' : 'rail'+ let occupied = left === 'open' ? sidebarWidth : left === 'hidden' ? 0 : RAIL_WIDTHlet panelState = 'none'if (panel !== null) {const need = (PANEL_MIN[panel.view] ?? PANEL_MIN.details) + MIN_CHAT@@ -35,17 +38,28 @@ export function frameLayout({ viewport, sidebarWidth, pref, drawer = false, paneelse if (panel.yielded === true) {// A panel the user asks to see takes the column's room: it falls back to// the rail, and covers the conversation only when even that is not enough.- left = 'rail'- occupied = RAIL_WIDTH- panelState = RAIL_WIDTH + need <= viewport ? 'shown' : 'overlay'+ if (left !== 'hidden') { left = 'rail'; occupied = RAIL_WIDTH }+ panelState = occupied + need <= viewport ? 'shown' : 'overlay'} else panelState = 'folded'}return { left, panel: panelState, room: Math.max(0, viewport - occupied) }}-// The shell sidebar stays expanded only for our 'open' column at a wide-enough-// window; under DSH_NARROW it is always collapsed and our own column draws.-export const dshExpandedFor = (viewport, left) => viewport >= DSH_NARROW && left === 'open'+/**+ * Where a drag of the column's edge to `x` lands: short of RAIL_SNAP the rail;+ * past it an open column of that width, docked while the chat keeps MIN_CHAT+ * beside it, else floating as a drawer.+ * @returns {{left: 'rail'|'open'|'drawer', width: number}}+ */+export function dragColumn(x, viewport) {+ if (x < RAIL_SNAP) return { left: 'rail', width: RAIL_WIDTH }+ const docks = viewport >= SIDEBAR_MIN + MIN_CHAT+ const high = docks ? Math.max(SIDEBAR_MIN, Math.min(SIDEBAR_MAX, viewport - MIN_CHAT)) : SIDEBAR_MAX+ return { left: docks ? 'open' : 'drawer', width: Math.round(Math.max(SIDEBAR_MIN, Math.min(x, high))) }+}++// The top-left switch hides the whole column and brings back the one it hid.+export const toggledPref = (pref, shown) => (pref === 'hidden' ? shown : 'hidden')// The shell measures the window on its own frame, a beat apart from us, and// re-applies its own rule when it does: a flip this soon after a width change is@@ -58,11 +72,19 @@ export const userSidebarToggle = ({ before, after, requested = false, sinceResizbefore.collapsed !== after.collapsed && !requested && sinceResize >= RESIZE_SETTLE_MS&& (before.viewport < DSH_NARROW) === (after.viewport < DSH_NARROW)-// The user's sidebar preference survives restarts: 'open' by default, 'rail'-// after they collapse the column themselves.-export function readSidebarPref(storage = globalThis.localStorage) {- try { return storage.getItem(STORAGE.sidebar) === 'rail' ? 'rail' : 'open' } catch { return 'open' }+// The user's column survives restarts: `pref` is 'open' by default, 'rail' after+// a drag down to it, 'hidden' after the switch; `shown` is what the switch brings+// back; `width` is the open column's.+const PREFS = ['open', 'rail', 'hidden']+export function readSidebar(storage = globalThis.localStorage) {+ try {+ const saved = JSON.parse(storage.getItem(STORAGE.sidebar) ?? 'null')+ const pref = PREFS.includes(saved?.pref) ? saved.pref : 'open'+ const shown = saved?.shown === 'rail' ? 'rail' : 'open'+ const width = Number.isFinite(saved?.width) ? Math.max(SIDEBAR_MIN, Math.min(SIDEBAR_MAX, saved.width)) : FALLBACK_SIDEBAR_WIDTH+ return { pref, shown, width }+ } catch { return { pref: 'open', shown: 'open', width: FALLBACK_SIDEBAR_WIDTH } }}-export function writeSidebarPref(pref, storage = globalThis.localStorage) {- try { storage.setItem(STORAGE.sidebar, pref === 'rail' ? 'rail' : 'open') } catch { /* storage unavailable */ }+export function writeSidebar(value, storage = globalThis.localStorage) {+ try { storage.setItem(STORAGE.sidebar, JSON.stringify(value)) } catch { /* storage unavailable */ }}diff --git a/ds-bot/src/client/frame-watch.js b/ds-bot/src/client/frame-watch.jsindex 4bc47d67..b4c70c2d 100644--- a/ds-bot/src/client/frame-watch.js+++ b/ds-bot/src/client/frame-watch.js@@ -2,7 +2,6 @@// sidebar track, and the one CSS rule that writes the conversation column's// margins (our own column on the left, the Bot panel on the right).import { installStyles } from './styles.js'-import { FALLBACK_SIDEBAR_WIDTH } from './frame-layout.js'export const sidebarTrackWidth = () =>typeof document === 'undefined' ? null : document.querySelector('[class*="_sidebarCol"]')?.getBoundingClientRect().width ?? null@@ -63,11 +62,10 @@ export const chatRoom = {}// Feeds the frame source the geometry the layout rules read: viewport, the-// shell sidebar's expanded and collapsed track widths, and its collapsed flag.-// A resize or a sidebar slide does not always come with a window event, so the-// column widths come off a ResizeObserver and the flag off a MutationObserver.+// shell sidebar's collapsed track width, and its collapsed flag. A resize or a+// sidebar slide does not always come with a window event, so the track width+// comes off a ResizeObserver and the flag off a MutationObserver.export function installFrameWatch(frame) {- let sidebarWidth = FALLBACK_SIDEBAR_WIDTHlet collapsedWidth = collapsedTrackWidth()let raf = 0const watched = new Set()@@ -81,13 +79,10 @@ export function installFrameWatch(frame) {const animating = column?.closest('[data-animating]') != nullconst width = animating ? null : sidebarTrackWidth()const collapsed = dshCollapsed()- if (width !== null) {- if (collapsed === true) collapsedWidth = width- else if (collapsed === false) sidebarWidth = width- }+ if (width !== null && collapsed === true) collapsedWidth = widthframe.set((state) => {- const next = { viewport: window.innerWidth, sidebarWidth, collapsedWidth, collapsed: collapsed === true }- return state.viewport === next.viewport && state.sidebarWidth === next.sidebarWidth && state.collapsedWidth === next.collapsedWidth && state.collapsed === next.collapsed ? state : next+ const next = { ...state, viewport: window.innerWidth, collapsedWidth, collapsed: collapsed === true }+ return state.viewport === next.viewport && state.collapsedWidth === next.collapsedWidth && state.collapsed === next.collapsed ? state : next})}const measure = () => {diff --git a/ds-bot/src/client/i18n.js b/ds-bot/src/client/i18n.jsindex 32ba8c99..0c3114f2 100644--- a/ds-bot/src/client/i18n.js+++ b/ds-bot/src/client/i18n.js@@ -18,6 +18,7 @@ const ZH = {'New…': '新建','Collapse sidebar': '收起侧边栏','Expand sidebar': '展开侧边栏',+ 'Resize sidebar': '调整侧边栏宽度','Animation': '动画','Bot animation': 'Bot 动画','Quiet': '安静',diff --git a/ds-bot/src/client/index.js b/ds-bot/src/client/index.jsindex 34c59061..0cb4e6c4 100644--- a/ds-bot/src/client/index.js+++ b/ds-bot/src/client/index.js@@ -8,7 +8,7 @@ import { MENTION_ORIGIN, currentPart } from './text.js'import { SHELL_CSS, CONVERSATION_CSS, installStyles, installCompiledStyles } from './styles.js'import { lookOf } from './mark.js'import { TeamSidebar, YouAvatar, AccountLauncher, FooterAccount, BrandMark, BrandName, BotReturn, SIDEBAR_CSS, RETURN_CSS, holdShellShortcuts, openHarnessOnboarding, openHarnessSettings } from './sidebar.js'-import { frameLayout, readSidebarPref, writeSidebarPref, FALLBACK_SIDEBAR_WIDTH } from './frame-layout.js'+import { frameLayout, readSidebar, writeSidebar, toggledPref, DSH_NARROW } from './frame-layout.js'import { installFrameWatch } from './frame-watch.js'import { HeaderPill } from './header.js'import { ComposerPlus, ComposerVoice, menuIcons } from './composer.js'@@ -60,10 +60,12 @@ export function apply(ctx) {// `details` is the panel's subject (a Session id); `view` picks details or the// subject Bot's browser inside it.const ui = createSource({ details: null, view: 'details', renaming: false, tab: null, side: null, newChat: null, exchange: null, menu: null, voice: null, palette: null, quote: null, settings: null, memory: null, toast: null, signIn: null, renameAgent: null, unread: unreadStore.read(), reactions: reactionStore.read(), visits: {}, panelYield: false, leftDrawer: false })- // The left column's kept preference, and the measured frame geometry the- // layout rules in frame-layout.js read (installFrameWatch feeds it).- const sidebarPref = createSource(readSidebarPref())- const frame = createSource({ viewport: typeof window === 'undefined' ? 0 : window.innerWidth, sidebarWidth: FALLBACK_SIDEBAR_WIDTH, collapsedWidth: 0, collapsed: false })+ // The left column's kept preference, and the frame geometry the layout rules+ // in frame-layout.js read: the window and the shell's collapsed track come from+ // installFrameWatch, the open column's width is the user's own.+ let sidebarSaved = readSidebar()+ const sidebarPref = createSource(sidebarSaved.pref)+ const frame = createSource({ viewport: typeof window === 'undefined' ? 0 : window.innerWidth, sidebarWidth: sidebarSaved.width, collapsedWidth: 0, collapsed: false })// Bot mode paints the whole team surface; Agent mode withdraws every slot and// style so the shell's own interface returns. `plain` stays false until a Bot-mode// view hosts a plain session, which drops only the conversation replacements.@@ -494,13 +496,23 @@ export function apply(ctx) {},selectPanel: (id) => { ctx.layout.selectPanel(id) },toggleSidebar: () => { ctx.layout.toggleSidebar() },- // The left column's own preference; the sidebar sync pulls the shell's- // collapsed flag after it (TeamSidebar's frame effect).+ // The left column's own preference: 'open', 'rail' or 'hidden'. The switch+ // remembers the shown one it hid; a drag sets the open column's width.setSidebarPref: (pref) => {- const next = pref === 'rail' ? 'rail' : 'open'- writeSidebarPref(next)+ const next = pref === 'rail' || pref === 'hidden' ? pref : 'open'+ sidebarSaved = { ...sidebarSaved, pref: next, ...(next === 'hidden' ? {} : { shown: next }) }+ writeSidebar(sidebarSaved)sidebarPref.set(next)},+ toggleLeftHidden: () => {+ ui.set(state => (state.leftDrawer || state.panelYield ? { ...state, leftDrawer: false, panelYield: false } : state))+ actions.setSidebarPref(toggledPref(sidebarPref.getSnapshot(), sidebarSaved.shown))+ },+ setSidebarWidth: (width) => {+ sidebarSaved = { ...sidebarSaved, width }+ writeSidebar(sidebarSaved)+ frame.set(state => (state.sidebarWidth === width ? state : { ...state, sidebarWidth: width }))+ },setLeftDrawer: (on) => ui.set(state => (state.leftDrawer === on ? state : { ...state, leftDrawer: on })),setPanelYield: (on) => ui.set(state => (state.panelYield === on ? state : { ...state, panelYield: on })),// Agent mode hands the surface back to the shell; everything open on the Bot@@ -518,6 +530,9 @@ export function apply(ctx) {}writeMode(mode)surface.set(state => ({ ...state, mode }))+ // The Bot view kept the shell's sidebar collapsed under its own column; the+ // shell's own view gets it back (below DSH_NARROW the shell decides itself).+ if (mode === 'agent' && window.innerWidth >= DSH_NARROW && frame.getSnapshot().collapsed) ctx.layout.toggleSidebar()if (mode !== 'bot') returnensureBotHome()},diff --git a/ds-bot/src/client/sidebar.js b/ds-bot/src/client/sidebar.jsindex 28b77d8e..ba696ac9 100644--- a/ds-bot/src/client/sidebar.js+++ b/ds-bot/src/client/sidebar.js@@ -11,7 +11,7 @@ import { Shimmer, workPhrase } from './cells.js'import { springEasing, SPRING_SHAPE, useViewport, viewBottom } from './motion.js'import { hostText, t } from './i18n.js'import { showsDshRow } from './dsh-offer.js'-import { frameLayout, MIN_CHAT, RAIL_WIDTH, FALLBACK_SIDEBAR_WIDTH, dshExpandedFor, userSidebarToggle } from './frame-layout.js'+import { frameLayout, dragColumn, RAIL_WIDTH, FALLBACK_SIDEBAR_WIDTH, userSidebarToggle } from './frame-layout.js'import { chatRoom, dshCollapsed } from './frame-watch.js'// -------------------------------------------------------------------------@@ -253,23 +253,27 @@ function useListGlide(listRef, layout, key) {}, [layout, key])}-// While the shell's sidebar is collapsed we draw the left column ourselves on-// <body>: the open column or the avatar rail push the conversation over, the-// drawer floats above it.-function LeftColumn({ mode, width, children }) {- return createPortal(h('div', { className: 'bt-leftcol', 'data-left': mode, style: { width: `${width}px` } }, children), document.body)+// In the Bot view the left column is ours, drawn on <body> over the shell's+// collapsed sidebar: the open column or the avatar rail push the conversation+// over, the drawer floats above it. Its right edge drags the open width, and+// down to the rail.+function LeftColumn({ mode, width, onGrip, children }) {+ return createPortal(h('div', { className: 'bt-leftcol', 'data-left': mode, style: { width: `${width}px` } },+ children,+ h('div', { className: 'bt-leftcol-grip', role: 'separator', 'aria-orientation': 'vertical', 'aria-label': t('Resize sidebar'), title: t('Resize sidebar'), onPointerDown: onGrip })), document.body)}-// The shell's title-bar switch on Windows asks the shell to expand before our-// sync pulls it back, a visible flash. Under a Windows title bar our own switch-// replaces it and goes straight to the next state.-function TitleToggle({ left, onToggle }) {- if (typeof document === 'undefined' || !document.documentElement.hasAttribute('data-windows-titlebar')) return null- const collapse = left === 'open' || left === 'drawer'+// The top-left switch hides the whole column and brings it back. Under a+// Windows title bar it takes the shell's own place in the title band; elsewhere+// it shows only while the column is hidden, since the column's own top row+// carries it otherwise.+function TitleToggle({ hidden, onToggle }) {+ if (typeof document === 'undefined') return null+ const titlebar = document.documentElement.hasAttribute('data-windows-titlebar')+ if (!titlebar && !hidden) return null+ const label = t(hidden ? 'Expand sidebar' : 'Collapse sidebar')return createPortal(h('button', {- type: 'button', className: 'bt-title-toggle',- 'aria-label': t(collapse ? 'Collapse sidebar' : 'Expand sidebar'),- title: t(collapse ? 'Collapse sidebar' : 'Expand sidebar'), onClick: onToggle,+ type: 'button', className: titlebar ? 'bt-title-toggle' : 'bt-round bt-title-toggle', 'aria-label': label, title: label, onClick: onToggle,}, h(SidebarIcon)), document.body)}@@ -287,8 +291,9 @@ export function TeamSidebar(props) {pref, drawer: uiNow.leftDrawer === true,panel: uiNow.details ? { view: uiNow.view, yielded: uiNow.panelYield === true } : null,})- // 'inline' is the shell's own expanded sidebar; the rest are our portalled column.- const mode = wide ? 'inline' : layout.left+ // A drag of the column's edge shows where it would land, live.+ const [drag, setDrag] = useState(null)+ const mode = drag?.left ?? layout.leftconst wideContent = mode !== 'rail'const updated = useSessions(list => {const stamps = {}@@ -312,17 +317,50 @@ export function TeamSidebar(props) {// Our column pushes the conversation over by what it takes beyond the shell's// collapsed track; a drawer floats over the rail's place, so it pushes as much// as the rail and the chat stays put when it opens or closes.- const ourWidth = layout.left === 'rail' ? RAIL_WIDTH : frameSnap.sidebarWidth- const pushed = layout.left === 'open' ? frameSnap.sidebarWidth : RAIL_WIDTH+ const openWidth = drag?.width ?? frameSnap.sidebarWidth+ const ourWidth = mode === 'rail' ? RAIL_WIDTH : openWidth+ const pushed = mode === 'open' ? openWidth : mode === 'hidden' ? 0 : RAIL_WIDTHuseLayoutEffect(() => {if (typeof document === 'undefined') return- chatRoom.setLeft(mode === 'inline' ? null : Math.max(0, pushed - (frameSnap.collapsedWidth ?? 0)))- }, [mode, pushed, frameSnap.collapsedWidth])+ chatRoom.setLeft(Math.max(0, pushed - (frameSnap.collapsedWidth ?? 0)))+ }, [pushed, frameSnap.collapsedWidth])useEffect(() => () => { if (typeof document !== 'undefined') chatRoom.setLeft(null) }, [])- // The shell sidebar's collapsed flag follows what our column needs. A flip we- // did not ask for is the user's own switch gesture (the shell's title-bar- // button or shortcut), unless the width just crossed the auto-collapse line.+ // The edge drag: live while the pointer moves, the column's new state on release.+ const startDrag = (event) => {+ if (event.button !== 0) return+ event.preventDefault()+ const grip = event.currentTarget+ grip.setPointerCapture?.(event.pointerId)+ chatRoom.hold(true)+ let last = null+ let done = false+ const onMove = (move) => { last = dragColumn(move.clientX, window.innerWidth); setDrag(last) }+ const ends = ['pointerup', 'pointercancel', 'lostpointercapture']+ const onEnd = (end) => {+ if (done) return+ done = true+ if (end.type === 'pointerup') last = dragColumn(end.clientX, window.innerWidth)+ grip.removeEventListener('pointermove', onMove)+ for (const name of ends) grip.removeEventListener(name, onEnd)+ setDrag(null)+ chatRoom.hold(false)+ if (last === null) return+ // The drag is the latest explicit gesture: it takes back a yielded panel's room.+ actions.setPanelYield?.(false)+ if (last.left === 'rail') { actions.setLeftDrawer?.(false); actions.setSidebarPref?.('rail'); return }+ actions.setSidebarWidth?.(last.width)+ actions.setSidebarPref?.('open')+ actions.setLeftDrawer?.(last.left === 'drawer')+ }+ grip.addEventListener('pointermove', onMove)+ for (const name of ends) grip.addEventListener(name, onEnd)+ }++ // In the Bot view the shell's own sidebar stays collapsed under our column. A+ // flip we did not ask for is the user's own switch gesture (the shell's button+ // or shortcut where it still reaches), unless the width just crossed the+ // shell's auto-collapse line, which re-applies the shell's own rule.const dsh = useRef(null)const requested = useRef(false)// The request mark always lapses on its own: a re-render before the shell's@@ -340,35 +378,34 @@ export function TeamSidebar(props) {window.addEventListener('resize', onResize)return () => window.removeEventListener('resize', onResize)}, [])+ const quiet = (on) => {+ // Our own collapse of the shell's sidebar lands at once: its slide would drag+ // the conversation across under our column.+ if (on) document.documentElement.setAttribute('data-bt-collapsing', '')+ else document.documentElement.removeAttribute('data-bt-collapsing')+ }+ useEffect(() => () => quiet(false), [])useLayoutEffect(() => {if (typeof document === 'undefined' || typeof actions.toggleSidebar !== 'function') return undefinedconst collapsed = dshCollapsed() ?? !wideconst prev = dsh.currentconst viewport = window.innerWidth- dsh.current = { collapsed, viewport, left: layout.left }+ dsh.current = { collapsed, viewport }if (prev !== null && collapsed !== prev.collapsed) {if (requested.current) requested.current = false- else if (userSidebarToggle({ before: prev, after: { collapsed, viewport }, sinceResize: performance.now() - resizedAt.current })) {- // The last explicit gesture wins: fold to the rail, or open the column —- // as a drawer when it no longer fits docked.- if (prev.left === 'open') actions.setSidebarPref?.('rail')- else {- actions.setSidebarPref?.('open')- if (frameSnap.viewport < frameSnap.sidebarWidth + MIN_CHAT) actions.setLeftDrawer?.(true)- }- actions.setPanelYield?.(false)- return undefined+ else if (!collapsed && userSidebarToggle({ before: prev, after: { collapsed, viewport }, sinceResize: performance.now() - resizedAt.current })) {+ toggleRef.current()}}- const wantOpen = dshExpandedFor(frameSnap.viewport, layout.left)- if (collapsed === !wantOpen) { requested.current = false; return undefined }+ if (collapsed) { requested.current = false; quiet(false); return undefined }if (requested.current) return undefinedrequested.current = true+ quiet(true)actions.toggleSidebar()clearTimeout(requestLapse.current)- requestLapse.current = setTimeout(() => { requested.current = false; setLapsed(value => value + 1) }, 300)+ requestLapse.current = setTimeout(() => { requested.current = false; quiet(false); setLapsed(value => value + 1) }, 300)return undefined- }, [wide, frameSnap.viewport, frameSnap.sidebarWidth, layout.left, lapsed])+ }, [wide, frameSnap.viewport, lapsed])// The drawer closes on a row pick, on Escape and on a press outside it.useEffect(() => {@@ -407,23 +444,14 @@ export function TeamSidebar(props) {event.preventDefault()actions.openPalette(event.key)}- // Opening the column is the latest explicit gesture: it takes back the room a- // yielded panel had, and opens as a drawer when it cannot dock.- const expandLeft = () => {- actions.setPanelYield?.(false)- actions.setSidebarPref?.('open')- if (frameSnap.viewport < frameSnap.sidebarWidth + MIN_CHAT) actions.setLeftDrawer?.(true)- }- const onTitleToggle = () => {- if (layout.left === 'open') { actions.setLeftDrawer?.(false); actions.setSidebarPref?.('rail') }- else if (layout.left === 'drawer') actions.setLeftDrawer?.(false)- else expandLeft()- }+ // The switch (top-left button, the shortcut) hides the whole column or brings+ // back the one it hid.+ const onToggle = () => actions.toggleLeftHidden?.()// The shell's sidebar shortcut is caught on its way down, before the shell's// own listener on window sees it: left to the shell, it would expand the shell's// sidebar first and our sync would pull it back, a visible flash.- const toggleRef = useRef(onTitleToggle)- toggleRef.current = onTitleToggle+ const toggleRef = useRef(onToggle)+ toggleRef.current = onToggleuseEffect(() => {const onKey = (event) => {if (event.defaultPrevented || event.isComposing || !pressesShellShortcut(event, 'sidebar.left.toggle')) return@@ -442,15 +470,15 @@ export function TeamSidebar(props) {h(UpdateButton, { useUpdate: props.useUpdate, actions }),h('button', { type: 'button', className: 'bt-round', 'aria-label': t('Search'), title: t('Search'), onClick: () => actions.openPalette() }, h(SearchIcon)),h('button', { type: 'button', className: 'bt-round', 'aria-label': t('New…'), title: t('New…'), onClick: () => actions.openNewChat('new') }, h(PlusIcon)),- h('button', { type: 'button', className: 'bt-round bt-side-collapse', 'aria-label': t('Collapse sidebar'), title: t('Collapse sidebar'), onClick: () => { actions.setLeftDrawer?.(false); actions.setSidebarPref?.('rail') } }, h(SidebarIcon)))+ h('button', { type: 'button', className: 'bt-round bt-side-collapse', 'aria-label': t('Collapse sidebar'), title: t('Collapse sidebar'), onClick: onToggle }, h(SidebarIcon))): h('div', { className: 'bt-rail-top' },h(UpdateButton, { useUpdate: props.useUpdate, actions }),- h('button', { type: 'button', className: 'bt-round bt-rail-expand', 'aria-label': t('Expand sidebar'), title: t('Expand sidebar'), onClick: expandLeft }, h(SidebarIcon)),+ h('button', { type: 'button', className: 'bt-round bt-side-collapse', 'aria-label': t('Collapse sidebar'), title: t('Collapse sidebar'), onClick: onToggle }, h(SidebarIcon)),main ? h(BotRow, { ...rowProps, bot: main, marked: markedUnread[main.id] === true }) : roster.ready ? null : h('div', { className: 'bt-hint' }, t('Setting up your Main Bot…')),h('span', { className: 'bt-rail-sep', 'aria-hidden': true }))// The foot stands in for the shell's hidden footer: the account avatar, and on// the rail the new-chat button above it.- const foot = mode === 'inline' ? null : wideContent+ const foot = wideContent? h('div', { className: 'bt-leftcol-foot' }, h(AccountLauncher, { seat: false, actions })): h('div', { className: 'bt-leftcol-foot bt-leftcol-foot-rail' },h('button', { type: 'button', className: 'bt-round', 'aria-label': t('New…'), title: t('New…'), onClick: () => actions.openNewChat('new') }, h(PlusIcon)),@@ -467,8 +495,8 @@ export function TeamSidebar(props) {: h(AgentRow, { key: entry.item.id, ...rowProps, agent: entry.item, marked: markedUnread[entry.item.id] === true })))),foot)return h(Fragment, null,- h(TitleToggle, { left: layout.left, onToggle: onTitleToggle }),- mode === 'inline' ? content : h(LeftColumn, { mode, width: ourWidth }, content))+ h(TitleToggle, { hidden: mode === 'hidden', onToggle }),+ mode === 'hidden' ? null : h(LeftColumn, { mode, width: ourWidth, onGrip: startDrag }, content))}// The update button at the sidebar's top right: a cloud while a newer DS Bot —diff --git a/ds-bot/src/client/styles.js b/ds-bot/src/client/styles.jsindex ff4fd8ad..eac6ea54 100644--- a/ds-bot/src/client/styles.js+++ b/ds-bot/src/client/styles.js@@ -152,6 +152,13 @@ body[data-bt-motion=quiet] .bt-mark[data-poke]{cursor:default}and the floating drawer keeps the opaque fill over the conversation. */.bt-leftcol{position:fixed;left:0;top:0;bottom:0;z-index:25;display:flex;--bt-lc-clear:var(--dsh-frame-top-clearance,var(--dsh-windows-titlebar-height,0px));background:var(--bt-leftcol-fill,var(--bt-sidebar));border-right:.5px solid var(--bt-line);box-sizing:border-box;padding:calc(var(--bt-lc-clear) + 6px) 12px 6px;color:var(--bt-ink);font-family:var(--bt-font)}html[data-windows-titlebar] .bt-leftcol,html[data-platform=darwin] .bt-leftcol{border-right:none}+.bt-leftcol-grip{position:absolute;right:-4px;top:0;bottom:0;width:8px;cursor:col-resize;z-index:3;touch-action:none}+.bt-leftcol-grip:hover,.bt-leftcol-grip:active{background:linear-gradient(to right,transparent 3px,var(--bt-line-2) 3px,var(--bt-line-2) 5px,transparent 5px)}+/* The shell's collapsed sidebar keeps no track in the Bot view, so a hidden+ column leaves nothing behind (the shell's right column, when open, keeps its+ own geometry). Our own collapse of it lands without the shell's slide. */+[class*="_frame"][data-sidebar-collapsed][data-rightbar-collapsed]:has(>[class*="_sidebarCol"]){grid-template-columns:0px minmax(0,1fr) 0px!important}+html[data-bt-collapsing] [class*="_frame"]:has(>[class*="_sidebarCol"]){transition:none!important}.bt-leftcol[data-left=drawer]{background:var(--bt-sidebar);box-shadow:8px 0 24px rgba(0,0,0,.14)}.bt-leftcol>.bt-side{width:100%}.bt-leftcol-foot{display:flex;align-items:center;gap:9px;padding-top:8px;flex:none}@@ -378,7 +385,9 @@ html[data-windows-titlebar]:not([data-fullscreen]) :is(.bt-pane,.bt-panel)::befo.bt-panel[data-leaving]{transform:translateX(100%);transition:transform .3s cubic-bezier(.2,0,0,1);pointer-events:none}.bt-panel[data-instant]{transition:none}@keyframes bt-pane-in{from{transform:translateX(100%)}}-[class*="_centerCol"]{transition:margin-right ${SPRING_SHAPE.duration}ms ${SPRING_SHAPE.easing},margin-left ${SPRING_SHAPE.duration}ms ${SPRING_SHAPE.easing}}+/* The right margin glides with the Bot panel's slide; the left one lands at once,+ as our left column appears, folds and hides without a slide of its own. */+[class*="_centerCol"]{transition:margin-right ${SPRING_SHAPE.duration}ms ${SPRING_SHAPE.easing}}.bt-panel-grip{position:absolute;left:-5px;top:0;bottom:0;width:8px;cursor:col-resize;z-index:3;touch-action:none}.bt-panel-grip:hover,.bt-panel[data-dragging] .bt-panel-grip{background:linear-gradient(to right,transparent 4px,var(--bt-line-2) 4px,var(--bt-line-2) 6px,transparent 6px)}.bt-drag-shield{position:fixed;inset:0;z-index:45;cursor:col-resize}@@ -568,14 +577,16 @@ button.bt-set-row:hover{background:var(--bt-hover)}the sidebar is open. Elsewhere an open sidebar uses the team's own top row. */html:not([data-windows-titlebar]) :not([class*="_collapsed"])>[class*="_logoRow"]{display:none!important}html[data-windows-titlebar] :not([class*="_collapsed"])>[class*="_logoRow"]{height:0!important;margin:0!important}-html[data-windows-titlebar] :is(.bt-side-collapse,.bt-rail-expand),html[data-platform=darwin] :is(.bt-side-collapse,.bt-rail-expand){display:none}+html[data-windows-titlebar] .bt-side-collapse{display:none}/* Under a Windows title bar our own switch replaces the shell's: the shell'stoggle expands the shell sidebar first, and pulling it back afterwards is avisible flash of the shell's column. */html[data-windows-titlebar] [class*="_logoRow"]>[class*="_toggle"]{display:none!important}-.bt-title-toggle{display:none;position:fixed;left:12px;top:calc((var(--dsh-windows-titlebar-height,0px) - 28px) / 2);width:28px;height:28px;z-index:30;-webkit-app-region:no-drag;align-items:center;justify-content:center;border:0;border-radius:6px;padding:0;background:transparent;color:var(--bt-ink);cursor:pointer;font-family:var(--bt-font)}-html[data-windows-titlebar] .bt-title-toggle{display:inline-flex}-.bt-title-toggle:hover{background:var(--bt-hover)}+html[data-windows-titlebar] .bt-title-toggle{position:fixed;left:12px;top:calc((var(--dsh-windows-titlebar-height,0px) - 28px) / 2);width:28px;height:28px;z-index:30;-webkit-app-region:no-drag;display:inline-flex;align-items:center;justify-content:center;border:0;border-radius:6px;padding:0;background:transparent;color:var(--bt-ink);cursor:pointer;font-family:var(--bt-font)}+html[data-windows-titlebar] .bt-title-toggle:hover{background:var(--bt-hover)}+/* Elsewhere the switch shows only while the column is hidden, where the column's+ own top row had it. */+html:not([data-windows-titlebar]) .bt-title-toggle{position:fixed;left:12px;top:calc(var(--dsh-frame-top-clearance,0px) + 6px);z-index:30}/* The footer ends in the Bot row: the whale's settings seat, then the account menuwhen no plugin holds that seat. Every other plugin's entry takes a whole row aboveit, in the shell's order, so none of them squeezes the Bot row. */diff --git a/ds-bot/test/frame-layout.test.js b/ds-bot/test/frame-layout.test.jsindex 1d77fc28..e330a2ae 100644--- a/ds-bot/test/frame-layout.test.js+++ b/ds-bot/test/frame-layout.test.js@@ -1,8 +1,8 @@import assert from 'node:assert/strict'import { test } from 'node:test'import {- RAIL_WIDTH, DSH_NARROW,- frameLayout, dshExpandedFor, userSidebarToggle,+ RAIL_WIDTH, RAIL_SNAP, SIDEBAR_MIN, SIDEBAR_MAX, MIN_CHAT, FALLBACK_SIDEBAR_WIDTH,+ frameLayout, dragColumn, toggledPref, userSidebarToggle, readSidebar, writeSidebar,} from '../src/client/frame-layout.js'import { createSource } from '../src/client/sources.js'import { teamActions } from '../src/client/team-actions.js'@@ -73,13 +73,51 @@ test('an unknown panel view folds by the details minimum', () => {assert.equal(at(1000, 280, { panel: { view: 'mystery', yielded: false } }).panel, 'folded')})-// The shell's own sidebar is expanded only for our open column above DSH_NARROW.-test('the shell sidebar stays expanded only for the open column on a wide window', () => {- assert.equal(dshExpandedFor(DSH_NARROW, 'open'), true)- assert.equal(dshExpandedFor(1400, 'open'), true)- assert.equal(dshExpandedFor(DSH_NARROW - 1, 'open'), false)- assert.equal(dshExpandedFor(1400, 'rail'), false)- assert.equal(dshExpandedFor(1400, 'drawer'), false)+// The switch hides the whole column: nothing is left beside the chat.+test('a hidden column takes no room, and a panel shows or covers beside nothing', () => {+ const layout = at(1000, 280, { pref: 'hidden', panel: details() })+ assert.deepEqual({ left: layout.left, panel: layout.panel, room: layout.room }, { left: 'hidden', panel: 'shown', room: 1000 })+ assert.equal(at(600, 280, { pref: 'hidden', panel: details() }).panel, 'folded')+ assert.deepEqual(at(600, 280, { pref: 'hidden', panel: details(true) }), { left: 'hidden', panel: 'overlay', room: 600 })+})++test('the switch hides the column and brings back the one it hid', () => {+ assert.equal(toggledPref('open', 'open'), 'hidden')+ assert.equal(toggledPref('rail', 'rail'), 'hidden')+ assert.equal(toggledPref('hidden', 'rail'), 'rail')+ assert.equal(toggledPref('hidden', 'open'), 'open')+})++// The edge drag: a width in the open range, docked while the chat keeps its+// room; short of the snap point the rail.+test('a drag short of the snap point lands on the rail', () => {+ assert.deepEqual(dragColumn(RAIL_SNAP - 1, 1400), { left: 'rail', width: RAIL_WIDTH })+ assert.deepEqual(dragColumn(30, 1400), { left: 'rail', width: RAIL_WIDTH })+})++test('a drag past the snap point opens a column within its width range', () => {+ assert.deepEqual(dragColumn(RAIL_SNAP, 1400), { left: 'open', width: SIDEBAR_MIN })+ assert.deepEqual(dragColumn(333.4, 1400), { left: 'open', width: 333 })+ assert.deepEqual(dragColumn(900, 1400), { left: 'open', width: SIDEBAR_MAX })+ // The chat keeps MIN_CHAT beside a docked column.+ assert.deepEqual(dragColumn(400, 800), { left: 'open', width: 800 - MIN_CHAT })+})++test('a drag past the snap point on a window too narrow to dock floats a drawer', () => {+ assert.deepEqual(dragColumn(300, 600), { left: 'drawer', width: 300 })+ assert.deepEqual(dragColumn(500, 600), { left: 'drawer', width: SIDEBAR_MAX })+})++test('the saved column reads back, and anything unknown falls back to the open default', () => {+ const store = new Map()+ const storage = { getItem: key => store.get(key) ?? null, setItem: (key, value) => store.set(key, value) }+ assert.deepEqual(readSidebar(storage), { pref: 'open', shown: 'open', width: FALLBACK_SIDEBAR_WIDTH })+ writeSidebar({ pref: 'hidden', shown: 'rail', width: 350 }, storage)+ assert.deepEqual(readSidebar(storage), { pref: 'hidden', shown: 'rail', width: 350 })+ writeSidebar({ pref: 'odd', shown: 'odd', width: 9999 }, storage)+ assert.deepEqual(readSidebar(storage), { pref: 'open', shown: 'open', width: SIDEBAR_MAX })+ store.set('ds-bot:sidebar', 'rail')+ assert.deepEqual(readSidebar(storage), { pref: 'open', shown: 'open', width: FALLBACK_SIDEBAR_WIDTH })})// A flip of the shell's collapsed flag is the user's switch gesture only when wediff --git a/ds-bot/test/sidebar-switch.test.js b/ds-bot/test/sidebar-switch.test.jsindex 1443a195..ce116463 100644--- a/ds-bot/test/sidebar-switch.test.js+++ b/ds-bot/test/sidebar-switch.test.js@@ -255,33 +255,53 @@ function shell({ platform, collapsed }) {return { document, hidden, switches }}-for (const platform of ['web', 'windows', 'mac']) {- for (const collapsed of [false, true]) {- test(`${collapsed ? 'a collapsed' : 'an open'} sidebar on ${platform} shows exactly one sidebar switch`, () => {- const { document, hidden, switches } = shell({ platform, collapsed })- assert.equal(switches.length, 1, `switches shown: ${switches.map(node => node.className).join(' | ') || 'none'}`)- const [shown] = switches- // An open sidebar on the web has the team's own button; under a Windows- // title bar our own switch replaces the shell's (which would flash the- // shell's column before we pull it back); elsewhere the shell's stays.- assert.equal(shown.classList.contains('bt-side-collapse'), platform === 'web' && !collapsed)- assert.equal(shown.classList.contains('bt-title-toggle'), platform === 'windows')- // What the team view replaces stays out of sight.+// The switch is always ours. Under a Windows title bar it is the title-band+// button and the shell's own is hidden (left to the shell, it would expand the+// shell's sidebar before we pull it back, a flash); elsewhere it is the column's+// top-row button, or the floating one while the column is hidden.+for (const collapsed of [false, true]) {+ test(`${collapsed ? 'a collapsed' : 'an open'} shell sidebar under a Windows title bar shows only our switch`, () => {+ const { switches } = shell({ platform: 'windows', collapsed })+ assert.deepEqual(switches.map(node => node.className), ['bt-title-toggle'])+ })+}++test('off a Windows title bar the column\'s top row and the floating switch are never hidden by style', () => {+ for (const platform of ['web', 'mac']) {+ const { document, hidden } = shell({ platform, collapsed: false })+ assert.equal(hidden(document.querySelector('.bt-side-collapse')), false, platform)+ assert.equal(hidden(document.querySelector('.bt-title-toggle')), false, platform)+ }+})++test('what the team view replaces in the shell sidebar stays out of sight', () => {+ for (const platform of ['web', 'windows', 'mac']) {+ for (const collapsed of [false, true]) {+ const { document, hidden } = shell({ platform, collapsed })assert.equal(hidden(document.querySelector('.x_newSession')), true)const brand = document.querySelector('.x_brand')if (brand) assert.equal(hidden(brand), true)- })+ }}-}+})-test('an open sidebar has a button that folds it to the rail; the rail offers the way back', () => {+// The shell's collapsed sidebar keeps no track in the Bot view, so a hidden+// column leaves nothing behind; the shell's right column keeps its own geometry.+test('the shell\'s collapsed sidebar keeps no track while its right column is closed', () => {+ const frame = [...rulesOf(SHELL_CSS), ...rulesOf(SIDEBAR_CSS)].find(rule => rule.selector.includes('[data-sidebar-collapsed][data-rightbar-collapsed]'))+ assert.match(frame?.body ?? '', /grid-template-columns:0px/)+})++test('the column\'s top row hides it, on the rail too, and its edge is a drag grip', () => {+ viewport.innerWidth = 1280const calls = []const roster = { bots: [], rooms: [], agents: [], byId: {}, ready: true }- const props = wide => ({- wide,+ const props = pref => ({+ wide: false,useRoster: pick => pick(roster), useUi: pick => pick({ unread: {} }), useRegistry: pick => pick({}),useSessions: pick => pick({ ids: [], byId: {} }), useUpdate: () => ({}),- actions: { setSidebarPref: pref => calls.push(pref), setLeftDrawer: on => calls.push(['drawer', on]), toggleSidebar: () => calls.push('toggle') },+ useSidebarPref: pick => pick(pref),+ actions: { toggleLeftHidden: () => calls.push('toggle'), toggleSidebar: () => {} },})const find = (node, match) => {if (Array.isArray(node)) return node.map(child => find(child, match)).find(Boolean)@@ -289,16 +309,21 @@ test('an open sidebar has a button that folds it to the rail; the rail offers threturn match(node) ? node : find(node.props?.children, match)}const collapse = node => node.type === 'button' && node.props['aria-label'] === 'Collapse sidebar'- const button = find(TeamSidebar(props(true)), collapse)- assert.ok(button?.props.className.split(' ').includes('bt-side-collapse'))- button.props.onClick()- assert.deepEqual(calls, [['drawer', false], 'rail'])- // The collapsed column is our own rail with an expand button (hidden where the- // shell's title-bar switch shows).- const rail = TeamSidebar(props(false))- assert.equal(find(rail, collapse), undefined)- const expand = find(rail, node => node.type === 'button' && node.props['aria-label'] === 'Expand sidebar')- assert.ok(expand?.props.className.split(' ').includes('bt-rail-expand'))+ for (const pref of ['open', 'rail']) {+ const tree = TeamSidebar(props(pref))+ const button = find(tree, collapse)+ assert.ok(button?.props.className.split(' ').includes('bt-side-collapse'), pref)+ button.props.onClick()+ const column = find(tree, node => node.type?.name === 'LeftColumn')+ assert.equal(column.props.mode, pref)+ assert.equal(typeof column.props.onGrip, 'function')+ }+ assert.deepEqual(calls, ['toggle', 'toggle'])+ // Hidden, there is no column at all; the floating switch brings it back.+ const hidden = TeamSidebar(props('hidden'))+ assert.equal(find(hidden, node => node.type?.name === 'LeftColumn'), undefined)+ const toggle = find(hidden, node => node.type?.name === 'TitleToggle')+ assert.equal(toggle.props.hidden, true)})test('the logo row takes no room in an open sidebar under a Windows title bar', () => {