A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Fold the panel first, then the sidebar to a rail, on narrow windows
Fei24110c6c4c15e34d
diff --git a/app/src/main.mjs b/app/src/main.mjsindex 4b7a6088..dbbb5adb 100644--- a/app/src/main.mjs+++ b/app/src/main.mjs@@ -499,7 +499,9 @@ function createWindow() {const dark = nativeTheme.shouldUseDarkColorsconst win32 = process.platform === 'win32'mainWindow = new BrowserWindow({- width: 1320, height: 860, minWidth: 720, minHeight: 480,+ // The window never squeezes the chat: RAIL_WIDTH + MIN_CHAT from ds-bot's+ // src/client/frame-layout.js is the avatar rail plus the smallest chat column.+ width: 1320, height: 860, minWidth: 508, minHeight: 480,title: 'DeepSeek Bot', show: false, icon: iconFile,backgroundColor: mica ? '#00000000' : dark ? '#1b1b1c' : '#ffffff',// Frameless as in DSH Desktop: the caption buttons overlay the page's band. They keep thediff --git a/docs/design/ui-standard.md b/docs/design/ui-standard.mdindex 1ef0603d..15c73e9c 100644--- a/docs/design/ui-standard.md+++ b/docs/design/ui-standard.md@@ -180,6 +180,7 @@ Bot 名字、提及用同一个颜色写字;纯黑读起来像标题,所以| 设置对话框 | 宽 `min(1100px, 100vw - 48px)`,高 `min(780px, …)`,所有页面同一尺寸(和用量页一致),切换页面时不变;左侧导航 198px || 记忆对话框 | 宽 `min(680px, 100vw - 48px)`,高 `min(760px, …)` || 右侧面板 | 详情 320px;浏览器默认 520px,可拖动,最小 360px,对话列至少保留 420px |+| 左侧栏 | 收起后是自己的 88px 头像窄栏(Windows、macOS、网页都一样)。窗口变窄时先收右侧面板,仍放不下才盖住对话;窄时打开面板,左侧栏先收成窄栏让位 || 气泡 | 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 c2312a5f..94609ea8 100644--- a/ds-bot/client.js+++ b/ds-bot/client.js@@ -1503,7 +1503,7 @@ function countCards(state, sessionId, callIds, delta) {}// src/client/team-actions.js-function teamActions({ call: call2, after, partFor, roster, ui: ui2, live, cards, heldCards, turnClock }) {+function teamActions({ call: call2, after, partFor, roster, ui: ui2, live, cards, heldCards, turnClock, panelFolded }) {const memoryOf = (id) => roster.getSnapshot().roomsById[id] ? { roomId: id } : { botId: id };const openSideChat = (sessionId, chatId) => {ui2.set((state) => ({ ...state, details: sessionId, view: "side", side: chatId ?? null, renaming: false, tab: null }));@@ -1531,6 +1531,7 @@ function teamActions({ call: call2, after, partFor, roster, ui: ui2, live, cardstoggleDetails: (id, force) => {ui2.set((state) => {const details = force || state.details !== id || state.view !== "details" ? id : null;+ if (details === null && panelFolded?.() === true) return { ...state, renaming: false, tab: null, details: id, view: "details", panelYield: true };return { ...state, renaming: false, tab: null, details, view: "details" };});},@@ -2459,8 +2460,24 @@ body[data-bt-motion=quiet] .bt-mark[data-poke]{cursor:default}.bt-row-preview{font-size:13px;line-height:18px;color:var(--bt-ink-2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.bt-unread{width:8px;height:8px;border-radius:50%;background:var(--bt-accent);flex:none;margin-right:2px;animation:bt-fade .13s cubic-bezier(.22,1,.36,1)}.bt-unread-wait{background:var(--bt-star)}-.bt-rail{align-items:center;padding:0 0 8px}-.bt-rail .bt-row{justify-content:center;padding:6px 0;min-height:44px}+/* Our own left column, portalled over the shell's collapsed sidebar: it starts+ below the window's title strip and stays under the shell's title-bar switch+ (z 30) and the popovers (z 60). */+.bt-leftcol{position:fixed;left:0;top:var(--dsh-frame-top-clearance,0px);bottom:0;z-index:25;display:flex;background:var(--bt-sidebar);border-right:.5px solid var(--bt-line);box-sizing:border-box;padding:6px 12px;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[data-left=drawer]{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}+.bt-rail{align-items:center;padding:0}+.bt-rail .bt-row{justify-content:center;width:56px;height:56px;min-height:56px;padding:0;border-radius:16px}+.bt-rail-top{display:flex;flex-direction:column;align-items:center;gap:6px;padding-bottom:8px}+.bt-rail-sep{width:24px;height:1px;flex:none;background:var(--bt-line)}+.bt-rail .bt-agent-ava{width:44px;height:44px}+.bt-rail .bt-list{align-items:center;gap:4px}+.bt-leftcol[data-left=rail]{padding:8px 16px}+.bt-leftcol-foot-rail{flex-direction:column;gap:6px}+.bt-dot{position:absolute;top:4px;right:8px;width:8px;height:8px;border-radius:50%;background:var(--bt-accent);box-shadow:0 0 0 1.5px var(--bt-sidebar)}+.bt-dot-wait{background:var(--bt-star)}.bt-side-foot{display:flex;padding-top:8px}.bt-connect{flex:1;height:36px;border-radius:999px;border:1px solid var(--bt-line);background:var(--bt-main);color:var(--bt-ink);font-family:inherit;font-size:14px;line-height:20px;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:8px;transition:background-color .12s ease}.bt-connect:hover{background:var(--bt-hover)}@@ -2675,7 +2692,7 @@ 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}}+[class*="_centerCol"]{transition:margin-right ${SPRING_SHAPE.duration}ms ${SPRING_SHAPE.easing},margin-left ${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}@@ -2865,7 +2882,7 @@ 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] .bt-side-collapse,html[data-platform=darwin] .bt-side-collapse{display:none}+html[data-windows-titlebar] :is(.bt-side-collapse,.bt-rail-expand),html[data-platform=darwin] :is(.bt-side-collapse,.bt-rail-expand){display:none}/* The footer ends in the Bot row: the whale's settings seat, then Connect plugins. Everyother plugin's entry takes a whole row above it, in the shell's order, so none of themsqueezes the Bot row. */@@ -8245,6 +8262,210 @@ function showsDshRow(dsh, app) {return dsh.kind === "app" && APP_OFFER.has(app?.phase) && sameVersion(app.version, dsh.verified);}+// src/client/storage.js+var STORAGE = {+ unread: "ds-bot:unread",+ reactions: "ds-bot:reactions",+ seen: "ds-bot:seen",+ prefs: "ds-bot:prefs",+ surface: "ds-bot:surface",+ agentSessions: "ds-bot:agent-sessions",+ browserWidth: "ds-bot:browser-width",+ sidebar: "ds-bot:sidebar",+ browsers: "ds-bot.browser.v2"+};+var LEGACY_PREFIXES = ["dsh-bot:", "dsh-bot-team:"];+var LEGACY_BROWSER_KEYS = ["ds-bot.browser.v1", "dsh-bot.browser.v1"];+var LEGACY_THEMES = { grok: "mono" };+function legacyKeys(key) {+ if (key === STORAGE.browsers) return LEGACY_BROWSER_KEYS;+ const name = key.slice(key.indexOf(":") + 1);+ return LEGACY_PREFIXES.map((prefix) => `${prefix}${name}`);+}+var migrateBrowsers = (storage) => {+ if (storage.getItem(STORAGE.browsers) !== null) {+ for (const key of LEGACY_BROWSER_KEYS) storage.removeItem(key);+ return;+ }+ for (const key of LEGACY_BROWSER_KEYS) {+ try {+ const value = storage.getItem(key);+ if (value === null) continue;+ const previous = JSON.parse(value) ?? {};+ const tabs = Object.fromEntries(Object.entries(previous).filter(([, page]) => page && typeof page === "object").map(([botId, page]) => {+ const tab = { id: `v1-${botId}`, url: page.url ?? "", title: page.title ?? "" };+ return [botId, { tabs: [tab], active: tab.id }];+ }));+ storage.setItem(STORAGE.browsers, JSON.stringify(tabs));+ for (const earlier of LEGACY_BROWSER_KEYS) storage.removeItem(earlier);+ return;+ } catch {+ }+ }+};+function migrateStorage(storage = globalThis.localStorage) {+ for (const key of Object.values(STORAGE)) {+ if (key === STORAGE.browsers) continue;+ for (const legacy of legacyKeys(key)) {+ try {+ const value = storage.getItem(legacy);+ if (value !== null && storage.getItem(key) === null) storage.setItem(key, value);+ storage.removeItem(legacy);+ } catch {+ }+ }+ }+ try {+ migrateBrowsers(storage);+ } catch {+ }+ try {+ const prefs = JSON.parse(storage.getItem(STORAGE.prefs) ?? "null");+ if (prefs && Object.hasOwn(LEGACY_THEMES, prefs.theme ?? "")) {+ storage.setItem(STORAGE.prefs, JSON.stringify({ ...prefs, theme: LEGACY_THEMES[prefs.theme] }));+ }+ } catch {+ }+}++// src/client/frame-layout.js+var MIN_CHAT = 420;+var RAIL_WIDTH = 88;+var PANEL_MIN = { details: 320, browser: 360, side: 320 };+var DSH_NARROW = 1024;+var FALLBACK_SIDEBAR_WIDTH = 280;+function frameLayout({ viewport, sidebarWidth, collapsedWidth = 0, 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 : left === "rail" ? RAIL_WIDTH : collapsedWidth;+ 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";+ } else panelState = "folded";+ }+ return { left, panel: panelState, room: Math.max(0, viewport - occupied) };+}+var dshExpandedFor = (viewport, left) => viewport >= DSH_NARROW && left === "open";+var userSidebarToggle = ({ before, after, requested = false }) => before.collapsed !== after.collapsed && !requested && before.viewport < DSH_NARROW === after.viewport < DSH_NARROW;+function readSidebarPref(storage = globalThis.localStorage) {+ try {+ return storage.getItem(STORAGE.sidebar) === "rail" ? "rail" : "open";+ } catch {+ return "open";+ }+}+function writeSidebarPref(pref, storage = globalThis.localStorage) {+ try {+ storage.setItem(STORAGE.sidebar, pref === "rail" ? "rail" : "open");+ } catch {+ }+}++// src/client/frame-watch.js+var sidebarTrackWidth = () => typeof document === "undefined" ? null : document.querySelector('[class*="_sidebarCol"]')?.getBoundingClientRect().width ?? null;+var dshCollapsed = () => {+ if (typeof document === "undefined") return null;+ const column = document.querySelector('[class*="_sidebarCol"]');+ return column ? column.parentElement?.hasAttribute("data-sidebar-collapsed") ?? false : null;+};+var collapsedTrackWidth = () => document.documentElement.hasAttribute("data-windows-titlebar") || document.documentElement.dataset.platform === "darwin" ? 0 : 56;+var room = { rule: null, selector: "" };+var roomRule = () => {+ const live = room.rule?.parentStyleSheet?.ownerNode?.isConnected;+ if (live && room.selector) return room.rule;+ const column = document.querySelector('[class*="_centerCol"]');+ const selector = column ? [...column.classList].filter((name) => name.includes("_centerCol")).map((name) => `.${CSS.escape(name)}`).join(",") : "";+ if (live && !selector) return room.rule;+ const declarations2 = room.rule?.style.cssText ?? "";+ room.rule?.parentStyleSheet?.ownerNode?.remove();+ const style = installStyles(`${selector || '[class*="_centerCol"]'}{${declarations2}}`, "chat-room");+ room.rule = style.sheet.cssRules[0];+ room.selector = selector;+ return room.rule;+};+var margin = (side, width, style) => {+ if (width === null) style.removeProperty(`margin-${side}`);+ else style.setProperty(`margin-${side}`, `${width}px`, "important");+};+var roomHold = 0;+var chatRoom = {+ /** The margin the Bot panel takes on the right, in px, or null for the shell's own. */+ setRight(width) {+ margin("right", width, roomRule().style);+ },+ /** The margin our own left column takes while the shell sidebar is collapsed. */+ setLeft(width) {+ margin("left", width, roomRule().style);+ },+ /** While on, a margin change lands at once instead of gliding. */+ hold(on) {+ cancelAnimationFrame(roomHold);+ if (on) {+ roomRule().style.setProperty("transition", "none", "important");+ return;+ }+ roomHold = requestAnimationFrame(() => {+ roomHold = requestAnimationFrame(() => roomRule().style.removeProperty("transition"));+ });+ },+ /** The columns themselves, for a drag's per-frame writes. */+ columns() {+ roomRule();+ return room.selector ? [...document.querySelectorAll(room.selector)] : [];+ }+};+function installFrameWatch(frame) {+ let sidebarWidth = FALLBACK_SIDEBAR_WIDTH;+ let collapsedWidth = collapsedTrackWidth();+ let raf = 0;+ const watched = /* @__PURE__ */ new Set();+ const observer = typeof ResizeObserver === "function" ? new ResizeObserver(() => schedule()) : null;+ const read = () => {+ const width = sidebarTrackWidth();+ const collapsed = dshCollapsed();+ if (width !== null) {+ if (collapsed === true) collapsedWidth = width;+ else if (collapsed === false) sidebarWidth = 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 measure = () => {+ for (const selector of ['[class*="_sidebarCol"]', '[class*="_centerCol"]']) {+ for (const column of document.querySelectorAll(selector)) {+ if (!watched.has(column)) {+ watched.add(column);+ observer?.observe(column);+ }+ }+ }+ read();+ };+ const schedule = () => {+ if (raf === 0) raf = requestAnimationFrame(() => {+ raf = 0;+ measure();+ });+ };+ measure();+ const mutations = new MutationObserver(schedule);+ mutations.observe(document.documentElement, { subtree: true, childList: true, attributes: true, attributeFilter: ["data-sidebar-collapsed"] });+ window.addEventListener("resize", schedule);+ return () => {+ cancelAnimationFrame(raf);+ mutations.disconnect();+ observer?.disconnect();+ window.removeEventListener("resize", schedule);+ };+}+// src/client/sidebar.jsvar import_react14 = require("react");var import_react_dom3 = require("react-dom");@@ -8321,7 +8542,7 @@ function BotRow({ bot, roster, actions, useSessions, useSessionStatus, useSessioonClick: () => actions.openSession(id),onContextMenu},- (0, import_react14.createElement)(BotAvatar, { bot, size: 36, state, main }),+ (0, import_react14.createElement)(BotAvatar, { bot, size: wide ? 36 : 44, state, main }),pinned && !wide ? (0, import_react14.createElement)(PinMark) : null,wide ? (0, import_react14.createElement)("span",@@ -8329,7 +8550,7 @@ function BotRow({ bot, roster, actions, useSessions, useSessionStatus, useSessio(0, import_react14.createElement)("span", { className: "bt-row-name" }, (0, import_react14.createElement)("span", { className: "bt-row-title" }, bot.name), pinned ? (0, import_react14.createElement)(PinMark) : null),runningLine ? (0, import_react14.createElement)("span", { className: "bt-row-preview" }, runningLine) : awayLine ? (0, import_react14.createElement)("span", { className: "bt-row-preview" }, awayLine) : waitsFor ? (0, import_react14.createElement)("span", { className: "bt-row-preview" }, waitsFor) : preview ? (0, import_react14.createElement)("span", { className: "bt-row-preview" }, preview) : null) : null,- wide && unread && !active ? (0, import_react14.createElement)("span", { className: "bt-unread", "aria-hidden": true }) : null+ wide && unread && !active ? (0, import_react14.createElement)("span", { className: "bt-unread", "aria-hidden": true }) : !wide && !active && (alert || unread) ? (0, import_react14.createElement)("span", { className: `bt-dot${alert ? " bt-dot-wait" : ""}`, "aria-hidden": true }) : null);}function RoomRow({ room: room2, roster, actions, useSessions, useSessionStatus, useSessionRetainInfo, useWork, wide, marked }) {@@ -8360,7 +8581,7 @@ function RoomRow({ room: room2, roster, actions, useSessions, useSessionStatus,actions.openMenu({ kind: "room", id, x: event.clientX, y: event.clientY });}},- (0, import_react14.createElement)(RoomAvatar, { room: room2, roster, size: 36 }),+ (0, import_react14.createElement)(RoomAvatar, { room: room2, roster, size: wide ? 36 : 44 }),pinned && !wide ? (0, import_react14.createElement)(PinMark) : null,wide ? (0, import_react14.createElement)("span",@@ -8368,7 +8589,7 @@ function RoomRow({ room: room2, roster, actions, useSessions, useSessionStatus,(0, import_react14.createElement)("span", { className: "bt-row-name" }, (0, import_react14.createElement)("span", { className: "bt-row-title" }, room2.name), pinned ? (0, import_react14.createElement)(PinMark) : null),workingLine ? (0, import_react14.createElement)("span", { className: "bt-row-preview" }, workingLine) : preview ? (0, import_react14.createElement)("span", { className: "bt-row-preview" }, preview) : null) : null,- wide && approval && !active ? (0, import_react14.createElement)("span", { className: "bt-unread bt-unread-wait", "aria-hidden": true }) : wide && unread && !active ? (0, import_react14.createElement)("span", { className: "bt-unread", "aria-hidden": true }) : null+ wide && approval && !active ? (0, import_react14.createElement)("span", { className: "bt-unread bt-unread-wait", "aria-hidden": true }) : wide && unread && !active ? (0, import_react14.createElement)("span", { className: "bt-unread", "aria-hidden": true }) : !wide && !active && (approval || unread) ? (0, import_react14.createElement)("span", { className: `bt-dot${approval ? " bt-dot-wait" : ""}`, "aria-hidden": true }) : null);}function AgentSessionRow({ session, agent, actions, renaming, index }) {@@ -8478,14 +8699,14 @@ function AgentRow({ agent, actions, useSessions, useSessionStatus, useUi, wide,actions.openMenu({ kind: "agent", id: agent.id, x: event.clientX, y: event.clientY });}},- (0, import_react14.createElement)("span", { className: `bt-agent-ava${running ? " bt-run" : ""}` }, (0, import_react14.createElement)(import_dsh_client_ui_primitives.FishLogo, { size: 22 })),+ (0, import_react14.createElement)("span", { className: `bt-agent-ava${running ? " bt-run" : ""}` }, (0, import_react14.createElement)(import_dsh_client_ui_primitives.FishLogo, { size: wide ? 22 : 24 })),wide ? (0, import_react14.createElement)("span",{ className: "bt-row-body" },(0, import_react14.createElement)("span", { className: "bt-row-name" }, "DSH Agent"),preview ? (0, import_react14.createElement)("span", { className: "bt-row-preview" }, preview) : null) : null,- wide && unread && !active ? (0, import_react14.createElement)("span", { className: "bt-unread", "aria-hidden": true }) : null+ wide && unread && !active ? (0, import_react14.createElement)("span", { className: "bt-unread", "aria-hidden": true }) : !wide && unread && !active ? (0, import_react14.createElement)("span", { className: "bt-dot", "aria-hidden": true }) : null),(0, import_react14.createElement)("div",@@ -8533,16 +8754,28 @@ 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_react14.createElement)("div", { className: "bt-leftcol", "data-left": mode, style: { width: `${width}px` } }, children), document.body);+}function TeamSidebar(props) {- const { wide, expandSidebar, useRoster, useUi, useSessions, actions } = props;+ const { wide, useRoster, useUi, useSessions, actions } = props;const listRef = (0, import_react14.useRef)(null);- const closing = (0, import_react14.useRef)(false);- (0, import_react14.useLayoutEffect)(() => {- closing.current = false;- });const roster = useRoster((value) => value);const markedUnread = useUi((value) => value.unread);+ const uiNow = useUi((value) => value);props.useRegistry((value) => value);+ const frameSnap = props.useFrame ? props.useFrame((value) => value) : { viewport: typeof window === "undefined" ? 0 : window.innerWidth, sidebarWidth: FALLBACK_SIDEBAR_WIDTH, collapsedWidth: 0 };+ const pref = props.useSidebarPref ? props.useSidebarPref((value) => value) : "open";+ const layout = frameLayout({+ viewport: frameSnap.viewport,+ sidebarWidth: frameSnap.sidebarWidth,+ collapsedWidth: frameSnap.collapsedWidth ?? 0,+ pref,+ drawer: uiNow.leftDrawer === true,+ panel: uiNow.details ? { view: uiNow.view, yielded: uiNow.panelYield === true } : null+ });+ const mode = wide ? "inline" : layout.left;+ const wideContent = mode !== "rail";const updated = useSessions((list) => {const stamps = {};for (const id of list.ids) stamps[id] = list.byId[id]?.updatedAt ?? 0;@@ -8559,15 +8792,69 @@ function TeamSidebar(props) {return entries2.sort((a, b) => Number(Boolean(b.item.pinned)) - Number(Boolean(a.item.pinned)) || b.at - a.at);}, [roster, updated]);const main = roster.byId[roster.mainBotId];- useListGlide(listRef, wide, order.map((entry) => entry.item.id).join(","));+ useListGlide(listRef, wideContent, order.map((entry) => entry.item.id).join(","));useLandOnMainBot(roster, useSessions, actions);+ const ourWidth = layout.left === "rail" ? RAIL_WIDTH : frameSnap.sidebarWidth;+ (0, import_react14.useLayoutEffect)(() => {+ if (typeof document === "undefined") return;+ chatRoom.setLeft(mode === "inline" || mode === "drawer" ? null : Math.max(0, ourWidth - (frameSnap.collapsedWidth ?? 0)));+ }, [mode, ourWidth, frameSnap.collapsedWidth]);+ (0, import_react14.useEffect)(() => () => {+ if (typeof document !== "undefined") chatRoom.setLeft(null);+ }, []);+ const dsh = (0, import_react14.useRef)(null);+ const requested = (0, import_react14.useRef)(false);+ (0, import_react14.useLayoutEffect)(() => {+ if (typeof document === "undefined" || typeof actions.toggleSidebar !== "function") return void 0;+ const collapsed = dshCollapsed() ?? !wide;+ const prev = dsh.current;+ dsh.current = { collapsed, viewport: frameSnap.viewport, left: layout.left };+ if (prev !== null && collapsed !== prev.collapsed) {+ if (requested.current) requested.current = false;+ else if (userSidebarToggle({ before: prev, after: { collapsed, viewport: frameSnap.viewport } })) {+ 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;+ }+ }+ const wantOpen = dshExpandedFor(frameSnap.viewport, layout.left);+ if (collapsed === !wantOpen) {+ requested.current = false;+ return void 0;+ }+ if (requested.current) return void 0;+ requested.current = true;+ actions.toggleSidebar();+ const timer = setTimeout(() => {+ requested.current = false;+ }, 300);+ return () => clearTimeout(timer);+ }, [wide, frameSnap.viewport, frameSnap.sidebarWidth, layout.left]);+ (0, import_react14.useEffect)(() => {+ if (mode !== "drawer") return void 0;+ const onDown = (event) => {+ if (event.target instanceof Element && event.target.closest(".bt-leftcol")) return;+ actions.setLeftDrawer?.(false);+ };+ const onKey = (event) => {+ if (event.key !== "Escape") return;+ event.stopPropagation();+ actions.setLeftDrawer?.(false);+ };+ window.addEventListener("mousedown", onDown);+ window.addEventListener("keydown", onKey, true);+ return () => {+ window.removeEventListener("mousedown", onDown);+ window.removeEventListener("keydown", onKey, true);+ };+ }, [mode]);const navigate = (open, id) => {const result = open(id);- if (wide && window.innerWidth < 1024 && !closing.current) {- closing.current = true;- expandSidebar?.();- actions.toggleSidebar();- }+ if (uiNow.leftDrawer === true) actions.setLeftDrawer?.(false);return result;};const rowActions = {@@ -8577,38 +8864,58 @@ function TeamSidebar(props) {openAgentSession: (id) => navigate(actions.openAgentSession, id),newAgentSession: (id) => navigate(actions.newAgentSession, id)};- const rowProps = { roster, actions: rowActions, useSessions, useUi, useSessionStatus: props.useSessionStatus, useSessionRetainInfo: props.useSessionRetainInfo, useActivity: props.useActivity, useWork: props.useWork, wide };+ const rowProps = { roster, actions: rowActions, useSessions, useUi, useSessionStatus: props.useSessionStatus, useSessionRetainInfo: props.useSessionRetainInfo, useActivity: props.useActivity, useWork: props.useWork, wide: wideContent };const typeToSearch = (event) => {if (event.defaultPrevented || event.key.length !== 1 || event.key === " " || event.metaKey || event.ctrlKey || event.altKey || event.nativeEvent.isComposing) return;if (event.target instanceof Element && event.target.closest("input,textarea,[contenteditable]")) return;event.preventDefault();actions.openPalette(event.key);};- return (0, import_react14.createElement)(+ const expandLeft = () => {+ actions.setSidebarPref?.("open");+ if (frameSnap.viewport < frameSnap.sidebarWidth + MIN_CHAT) actions.setLeftDrawer?.(true);+ };+ const top = wideContent ? (0, import_react14.createElement)("div",- { className: wide ? "bt-side" : "bt-side bt-rail", onKeyDown: typeToSearch },- wide ? (0, import_react14.createElement)(- "div",- { className: "bt-side-top" },- (0, import_react14.createElement)("span", { className: "bt-brand" }, (0, import_react14.createElement)(BrandMark, { size: 22 }), (0, import_react14.createElement)(BrandName)),- (0, import_react14.createElement)(UpdateButton, { useUpdate: props.useUpdate, actions }),- (0, import_react14.createElement)("button", { type: "button", className: "bt-round", "aria-label": t("Search"), title: t("Search"), onClick: () => actions.openPalette() }, (0, import_react14.createElement)(SearchIcon)),- (0, import_react14.createElement)("button", { type: "button", className: "bt-round", "aria-label": t("New…"), title: t("New…"), onClick: () => actions.openNewChat("new") }, (0, import_react14.createElement)(PlusIcon)),- (0, import_react14.createElement)("button", { type: "button", className: "bt-round bt-side-collapse", "aria-label": t("Collapse sidebar"), title: t("Collapse sidebar"), onClick: () => actions.toggleSidebar() }, (0, import_react14.createElement)(SidebarIcon))- ) : (0, import_react14.createElement)(- import_react14.Fragment,- null,- (0, import_react14.createElement)(UpdateButton, { useUpdate: props.useUpdate, actions }),- (0, import_react14.createElement)("button", { type: "button", className: "bt-round", "aria-label": t("New…"), title: t("New…"), onClick: () => actions.openNewChat("new") }, (0, import_react14.createElement)(PlusIcon))- ),- wide && roster.readOnly ? (0, import_react14.createElement)("div", { className: "bt-hint bt-read-only", role: "status" }, hostText(roster.readOnly)) : null,+ { className: "bt-side-top" },+ (0, import_react14.createElement)("span", { className: "bt-brand" }, (0, import_react14.createElement)(BrandMark, { size: 22 }), (0, import_react14.createElement)(BrandName)),+ (0, import_react14.createElement)(UpdateButton, { useUpdate: props.useUpdate, actions }),+ (0, import_react14.createElement)("button", { type: "button", className: "bt-round", "aria-label": t("Search"), title: t("Search"), onClick: () => actions.openPalette() }, (0, import_react14.createElement)(SearchIcon)),+ (0, import_react14.createElement)("button", { type: "button", className: "bt-round", "aria-label": t("New…"), title: t("New…"), onClick: () => actions.openNewChat("new") }, (0, import_react14.createElement)(PlusIcon)),+ (0, import_react14.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_react14.createElement)(SidebarIcon))+ ) : (0, import_react14.createElement)(+ "div",+ { className: "bt-rail-top" },+ (0, import_react14.createElement)(UpdateButton, { useUpdate: props.useUpdate, actions }),+ (0, import_react14.createElement)("button", { type: "button", className: "bt-round bt-rail-expand", "aria-label": t("Expand sidebar"), title: t("Expand sidebar"), onClick: expandLeft }, (0, import_react14.createElement)(SidebarIcon)),+ main ? (0, import_react14.createElement)(BotRow, { ...rowProps, bot: main, marked: markedUnread[main.id] === true }) : roster.ready ? null : (0, import_react14.createElement)("div", { className: "bt-hint" }, t("Setting up your Main Bot…")),+ (0, import_react14.createElement)("span", { className: "bt-rail-sep", "aria-hidden": true })+ );+ const foot = mode === "inline" ? null : wideContent ? (0, import_react14.createElement)("div", { className: "bt-leftcol-foot" }, (0, import_react14.createElement)(AccountLauncher, { seat: false, actions }), (0, import_react14.createElement)(ConnectPlugins, { wide: true, actions })) : (0, import_react14.createElement)(+ "div",+ { className: "bt-leftcol-foot bt-leftcol-foot-rail" },+ (0, import_react14.createElement)("button", { type: "button", className: "bt-round", "aria-label": t("New…"), title: t("New…"), onClick: () => actions.openNewChat("new") }, (0, import_react14.createElement)(PlusIcon)),+ (0, import_react14.createElement)("button", { type: "button", className: "bt-round", "aria-label": t("Connect plugins"), title: t("Connect plugins"), onClick: () => actions.selectPanel("plugins") }, (0, import_react14.createElement)(PlugIcon)),+ (0, import_react14.createElement)(AccountLauncher, { seat: false, actions })+ );+ const content = (0, import_react14.createElement)(+ "div",+ { className: wideContent ? "bt-side" : "bt-side bt-rail", onKeyDown: typeToSearch },+ top,+ wideContent && roster.readOnly ? (0, import_react14.createElement)("div", { className: "bt-hint bt-read-only", role: "status" }, hostText(roster.readOnly)) : null,(0, import_react14.createElement)("div",{ ref: listRef, className: "bt-list", role: "region", "aria-label": t("Bot list") },- main ? (0, import_react14.createElement)(BotRow, { ...rowProps, bot: main, marked: markedUnread[main.id] === true }) : roster.ready ? null : (0, import_react14.createElement)("div", { className: "bt-hint" }, t("Setting up your Main Bot…")),+ wideContent ? main ? (0, import_react14.createElement)(BotRow, { ...rowProps, bot: main, marked: markedUnread[main.id] === true }) : roster.ready ? null : (0, import_react14.createElement)("div", { className: "bt-hint" }, t("Setting up your Main Bot…")) : null,order.map((entry) => entry.kind === "bot" ? (0, import_react14.createElement)(BotRow, { key: entry.item.id, ...rowProps, bot: entry.item, marked: markedUnread[entry.item.id] === true }) : entry.kind === "room" ? (0, import_react14.createElement)(RoomRow, { key: entry.item.id, ...rowProps, room: entry.item, marked: markedUnread[entry.item.id] === true }) : (0, import_react14.createElement)(AgentRow, { key: entry.item.id, ...rowProps, agent: entry.item, marked: markedUnread[entry.item.id] === true }))- )+ ),+ foot);+ if (mode === "inline") return content;+ return (0, import_react14.createElement)(LeftColumn, { mode, width: ourWidth }, content);}function UpdateButton({ useUpdate, actions }) {const update = useUpdate((value) => value);@@ -9022,7 +9329,7 @@ var SIDEBAR_CSS = `.bt-brand .bt-mark{flex:none}.bt-pin{flex:none;display:inline-flex;color:var(--bt-ink-3)}.bt-rail .bt-row{position:relative}-.bt-rail .bt-pin{position:absolute;top:3px;left:calc(50% + 12px)}+.bt-rail .bt-pin{position:absolute;top:1px;left:calc(50% + 14px)}.bt-side .bt-read-only{margin:4px 8px 6px;padding:8px 10px;border-radius:10px;background:var(--bt-hover);font-size:12px;line-height:1.45;text-align:left}[class*="_footArea"]:has(.bt-foot-account){grid-template-columns:auto minmax(0,1fr) auto;column-gap:6px}[class*="_footArea"]>[class*="_footerActions"]>div>.bt-foot-account{grid-column:1;order:1;display:inline-flex}@@ -10015,71 +10322,6 @@ function turnDetector({ loud = 0.12, quiet = 0.06, quietMs = 1200 } = {}) {};}-// src/client/storage.js-var STORAGE = {- unread: "ds-bot:unread",- reactions: "ds-bot:reactions",- seen: "ds-bot:seen",- prefs: "ds-bot:prefs",- surface: "ds-bot:surface",- agentSessions: "ds-bot:agent-sessions",- browserWidth: "ds-bot:browser-width",- browsers: "ds-bot.browser.v2"-};-var LEGACY_PREFIXES = ["dsh-bot:", "dsh-bot-team:"];-var LEGACY_BROWSER_KEYS = ["ds-bot.browser.v1", "dsh-bot.browser.v1"];-var LEGACY_THEMES = { grok: "mono" };-function legacyKeys(key) {- if (key === STORAGE.browsers) return LEGACY_BROWSER_KEYS;- const name = key.slice(key.indexOf(":") + 1);- return LEGACY_PREFIXES.map((prefix) => `${prefix}${name}`);-}-var migrateBrowsers = (storage) => {- if (storage.getItem(STORAGE.browsers) !== null) {- for (const key of LEGACY_BROWSER_KEYS) storage.removeItem(key);- return;- }- for (const key of LEGACY_BROWSER_KEYS) {- try {- const value = storage.getItem(key);- if (value === null) continue;- const previous = JSON.parse(value) ?? {};- const tabs = Object.fromEntries(Object.entries(previous).filter(([, page]) => page && typeof page === "object").map(([botId, page]) => {- const tab = { id: `v1-${botId}`, url: page.url ?? "", title: page.title ?? "" };- return [botId, { tabs: [tab], active: tab.id }];- }));- storage.setItem(STORAGE.browsers, JSON.stringify(tabs));- for (const earlier of LEGACY_BROWSER_KEYS) storage.removeItem(earlier);- return;- } catch {- }- }-};-function migrateStorage(storage = globalThis.localStorage) {- for (const key of Object.values(STORAGE)) {- if (key === STORAGE.browsers) continue;- for (const legacy of legacyKeys(key)) {- try {- const value = storage.getItem(legacy);- if (value !== null && storage.getItem(key) === null) storage.setItem(key, value);- storage.removeItem(legacy);- } catch {- }- }- }- try {- migrateBrowsers(storage);- } catch {- }- try {- const prefs = JSON.parse(storage.getItem(STORAGE.prefs) ?? "null");- if (prefs && Object.hasOwn(LEGACY_THEMES, prefs.theme ?? "")) {- storage.setItem(STORAGE.prefs, JSON.stringify({ ...prefs, theme: LEGACY_THEMES[prefs.theme] }));- }- } catch {- }-}-// src/client/surface.jsfunction groupsFor({ mode, plain = false }) {return { shell: mode === "bot", conversation: mode === "bot" && !plain };@@ -16396,9 +16638,6 @@ var DEFAULT_WIDTH = 520;var DETAILS_WIDTH = 320;var DETAILS_MAX = 520;var MIN_WIDTH = 360;-var MIN_CHAT = 420;-var PANEL_MIN = { details: DETAILS_WIDTH, browser: MIN_WIDTH, side: DETAILS_WIDTH };-var overlayAt = (view, viewport) => viewport < MIN_CHAT + PANEL_MIN[view];var READ_FLASH_MS = 2400;var EMPTY_PAGE = { url: "", title: "", favicon: null, loading: false, canGoBack: false, canGoForward: false, error: null, excerpt: "" };var EMPTY_TABS2 = { ids: [], active: null };@@ -16435,47 +16674,8 @@ var savedWidth = () => {return null;}};-var widthRange = (view, viewport) => view === "browser" ? [MIN_WIDTH, viewport - MIN_CHAT] : [DETAILS_WIDTH, Math.min(DETAILS_MAX, viewport - MIN_CHAT)];+var widthRange = (view, room2) => view === "browser" ? [MIN_WIDTH, room2 - MIN_CHAT] : [DETAILS_WIDTH, Math.min(DETAILS_MAX, room2 - MIN_CHAT)];var fitWidth = (width, [low, high]) => Math.round(Math.max(low, Math.min(width, high)));-var room = { rule: null, selector: "" };-var roomRule = () => {- const live = room.rule?.parentStyleSheet?.ownerNode?.isConnected;- if (live && room.selector) return room.rule;- const column = document.querySelector('[class*="_centerCol"]');- const selector = column ? [...column.classList].filter((name) => name.includes("_centerCol")).map((name) => `.${CSS.escape(name)}`).join(",") : "";- if (live && !selector) return room.rule;- const declarations2 = room.rule?.style.cssText ?? "";- room.rule?.parentStyleSheet?.ownerNode?.remove();- const style = installStyles(`${selector || '[class*="_centerCol"]'}{${declarations2}}`, "chat-room");- room.rule = style.sheet.cssRules[0];- room.selector = selector;- return room.rule;-};-var roomHold = 0;-var chatRoom = {- /** The column's right margin in px, or null for the shell's own. */- set(width) {- const { style } = roomRule();- if (width === null) style.removeProperty("margin-right");- else style.setProperty("margin-right", `${width}px`, "important");- },- /** While on, a margin change lands at once instead of gliding. */- hold(on) {- cancelAnimationFrame(roomHold);- if (on) {- roomRule().style.setProperty("transition", "none", "important");- return;- }- roomHold = requestAnimationFrame(() => {- roomHold = requestAnimationFrame(() => roomRule().style.removeProperty("transition"));- });- },- /** The columns themselves, for a drag's per-frame writes. */- columns() {- roomRule();- return room.selector ? [...document.querySelectorAll(room.selector)] : [];- }-};var shortAddress = (url) => String(url ?? "").replace(/^https?:\/\//i, "").replace(/^www\./i, "").replace(/\/$/, "");var reducedMotion2 = () => typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;var tabLabel = (page) => page.title || shortAddress(page.url) || t("New tab");@@ -17078,7 +17278,7 @@ function ImportCard({ flow, page, busy, onApply, onCancel, onCloseAndImport, onD)));}-function BotPanel({ pane, leaving, roster, actions, useSessions, useSessionStatus, useActivity, useWork, useBrowserTabs, useBrowserPages, useBrowserHolds }) {+function BotPanel({ pane, leaving, room: room2, overlay, roster, actions, useSessions, useSessionStatus, useActivity, useWork, useBrowserTabs, useBrowserPages, useBrowserHolds }) {const bot = roster.byId[pane.id];const canBrowse = Boolean(bot && roster.browser === true && actions.browserShow);const sideChats = bot ? sideChatsOf(roster, bot.id) : [];@@ -17093,13 +17293,11 @@ function BotPanel({ pane, leaving, roster, actions, useSessions, useSessionStatuconst [landed, setLanded] = (0, import_react42.useState)(false);const [settling, setSettling] = (0, import_react42.useState)(false);const [width, setWidth] = (0, import_react42.useState)(savedWidth);- const [viewport, setViewport] = (0, import_react42.useState)(() => window.innerWidth);const [dragging, setDragging] = (0, import_react42.useState)(false);const [resizing, setResizing] = (0, import_react42.useState)(false);const instant = dragging || resizing;const [reading, setReading] = (0, import_react42.useState)(false);- const overlay = overlayAt(view, viewport);- const panelWidth = fitWidth(width ?? (view === "browser" ? DEFAULT_WIDTH : DETAILS_WIDTH), widthRange(view, viewport));+ const panelWidth = fitWidth(width ?? (view === "browser" ? DEFAULT_WIDTH : DETAILS_WIDTH), widthRange(view, room2));(0, import_react42.useLayoutEffect)(() => {if (view === "browser" && width === null) setWidth(DEFAULT_WIDTH);}, [view, width]);@@ -17116,27 +17314,23 @@ function BotPanel({ pane, leaving, roster, actions, useSessions, useSessionStatuconst switched = settling && shownView.current !== view;shownView.current = view;if (switched) chatRoom.hold(true);- chatRoom.set(leaving || overlay ? null : panelWidth);+ chatRoom.setRight(leaving || overlay ? null : panelWidth);if (switched) chatRoom.hold(false);}, [view, panelWidth, leaving, overlay]);(0, import_react42.useEffect)(() => () => {- chatRoom.set(null);+ chatRoom.setRight(null);chatRoom.hold(false);}, []);+ const mounted = (0, import_react42.useRef)(false);(0, import_react42.useEffect)(() => {- let timer;- const onResize = () => {- setResizing(true);- setViewport(window.innerWidth);- clearTimeout(timer);- timer = setTimeout(() => setResizing(false), 160);- };- window.addEventListener("resize", onResize);- return () => {- clearTimeout(timer);- window.removeEventListener("resize", onResize);- };- }, []);+ if (!mounted.current) {+ mounted.current = true;+ return void 0;+ }+ setResizing(true);+ const timer = setTimeout(() => setResizing(false), 160);+ return () => clearTimeout(timer);+ }, [room2]);(0, import_react42.useEffect)(() => {if (!settling) return void 0;const timer = setTimeout(() => setSettling(false), SPRING_SHAPE.duration + 40);@@ -17249,7 +17443,7 @@ function BotPanel({ pane, leaving, roster, actions, useSessions, useSessionStatuconst panel = root.current;const grip = event.currentTarget;grip.setPointerCapture?.(event.pointerId);- const range = widthRange(view, window.innerWidth);+ const range = widthRange(view, room2);const from = { x: event.clientX, width: panelWidth };let next = panelWidth;setDragging(true);@@ -17260,7 +17454,7 @@ function BotPanel({ pane, leaving, roster, actions, useSessions, useSessionStatuconst onMove = (move) => {next = fitWidth(from.width + from.x - move.clientX, range);panel.style.width = `${next}px`;- if (columns2.length === 0) chatRoom.set(next);+ if (columns2.length === 0) chatRoom.setRight(next);for (const column of columns2) column.style.setProperty("margin-right", `${next}px`, "important");};const ends = ["pointerup", "pointercancel", "lostpointercapture"];@@ -17268,7 +17462,7 @@ function BotPanel({ pane, leaving, roster, actions, useSessions, useSessionStatuif (end.type === "pointerup") onMove(end);grip.removeEventListener("pointermove", onMove);for (const name of ends) grip.removeEventListener(name, onEnd);- chatRoom.set(next);+ chatRoom.setRight(next);for (const column of columns2) {column.style.removeProperty("margin-right");column.style.removeProperty("transition");@@ -17458,10 +17652,12 @@ var import_react43 = require("react");var import_react_dom9 = require("react-dom");var DIALOG_EXIT_MS = 160;var MENU_EXIT_MS3 = 120;-function Overlays({ useRoster, useUi, useSessions, useSessionStatus, useActivity, useWork, useRegistry, useBrowserPages, useBrowserTabs, useBrowserHolds, useUpdate, actions }) {+function Overlays({ useRoster, useUi, useSessions, useSessionStatus, useActivity, useWork, useRegistry, useBrowserPages, useBrowserTabs, useBrowserHolds, useUpdate, useFrame, useSidebarPref, actions }) {const roster = useRoster((value) => value);const ui2 = useUi((value) => value);useRegistry((value) => value);+ const frameSnap = useFrame ? useFrame((value) => value) : { viewport: window.innerWidth, sidebarWidth: FALLBACK_SIDEBAR_WIDTH, collapsedWidth: 0 };+ const pref = useSidebarPref ? useSidebarPref((value) => value) : "open";const current = useSessions((list) => Object.values(list.byId).find((session) => (session?.retainedBy?.mainView ?? 0) > 0)?.id ?? null);const previous = (0, import_react43.useRef)(current);(0, import_react43.useEffect)(() => {@@ -17470,16 +17666,25 @@ function Overlays({ useRoster, useUi, useSessions, useSessionStatus, useActivityif (current) actions.followPanel?.(current);}, [current]);const open = ui2.details ? { id: ui2.details, view: ui2.view ?? "details", renaming: ui2.renaming, tab: ui2.tab, side: ui2.side } : null;- const [kept, setKept] = (0, import_react43.useState)(open);+ const layout = frameLayout({+ viewport: frameSnap.viewport,+ sidebarWidth: frameSnap.sidebarWidth,+ collapsedWidth: frameSnap.collapsedWidth ?? 0,+ pref,+ drawer: ui2.leftDrawer === true,+ panel: open ? { view: open.view, yielded: ui2.panelYield === true } : null+ });+ const shown = open !== null && layout.panel !== "folded" ? open : null;+ const [kept, setKept] = (0, import_react43.useState)(shown);(0, import_react43.useEffect)(() => {- if (open) {- setKept(open);+ if (shown) {+ setKept(shown);return void 0;}const timer = setTimeout(() => setKept(null), PANEL_LINGER_MS);return () => clearTimeout(timer);- }, [ui2.details, ui2.view, ui2.renaming, ui2.tab]);- const pane = open ?? kept;+ }, [ui2.details, ui2.view, ui2.renaming, ui2.tab, shown === null]);+ const pane = shown ?? kept;const [settings, settingsLeaving] = useLinger(ui2.settings, DIALOG_EXIT_MS);const memoryOwner = (id) => {const bot = roster.byId[id];@@ -17493,7 +17698,7 @@ function Overlays({ useRoster, useUi, useSessions, useSessionStatus, useActivityreturn (0, import_react43.createElement)(import_react43.Fragment,null,- pane ? (0, import_react_dom9.createPortal)((0, import_react43.createElement)(BotPanel, { pane, leaving: open === null, roster, actions, useSessions, useSessionStatus, useActivity, useWork, useBrowserTabs, useBrowserPages, useBrowserHolds }), document.body) : null,+ pane ? (0, import_react_dom9.createPortal)((0, import_react43.createElement)(BotPanel, { pane, leaving: shown === null, room: layout.room, overlay: layout.panel === "overlay", roster, actions, useSessions, useSessionStatus, useActivity, useWork, useBrowserTabs, useBrowserPages, useBrowserHolds }), document.body) : null,ui2.newChat ? (0, import_react_dom9.createPortal)((0, import_react43.createElement)(NewChat, { key: ui2.newChat, mode: ui2.newChat, roster, actions }), document.body) : null,ui2.palette ? (0, import_react_dom9.createPortal)((0, import_react43.createElement)(CommandPalette, { key: ui2.palette.token, start: ui2.palette.query, token: ui2.palette.token, roster, actions, useSessions }), document.body) : null,ui2.exchange ? (0, import_react_dom9.createPortal)((0, import_react43.createElement)(ExchangeDialog, { pair: ui2.exchange, roster, actions }), document.body) : null,@@ -18730,7 +18935,9 @@ function apply(ctx) {const reactionStore = sharedMap(STORAGE.reactions);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: {} });+ 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 });const surface = createSource({ mode: readMode(), plain: false });let agentSessionCache = /* @__PURE__ */ new Set();try {@@ -19070,8 +19277,14 @@ function apply(ctx) {expected2 = target;ctx.uiWorkspace.openSession(target);}, current: mainView });+ const panelFolded = () => {+ const state = ui2.getSnapshot();+ if (state.details === null) return false;+ const f = frame.getSnapshot();+ return frameLayout({ viewport: f.viewport, sidebarWidth: f.sidebarWidth, collapsedWidth: f.collapsedWidth, pref: sidebarPref.getSnapshot(), drawer: state.leftDrawer, panel: { view: state.view, yielded: false } }).panel === "folded";+ };const actions = {- ...teamActions({ call, after, partFor, roster, ui: ui2, live, cards, heldCards, turnClock }),+ ...teamActions({ call, after, partFor, roster, ui: ui2, live, cards, heldCards, turnClock, panelFolded }),// The full-pane overlays sit above the conversation, so opening one must dismiss them// or the click appears to do nothing.isAgentSession: (id) => isAgentSessionId(id),@@ -19153,6 +19366,15 @@ 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).+ setSidebarPref: (pref) => {+ const next = pref === "rail" ? "rail" : "open";+ writeSidebarPref(next);+ sidebarPref.set(next);+ },+ 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// surface closes first so nothing stale reopens on the way back.setSurface: (mode) => {@@ -19307,7 +19529,7 @@ function apply(ctx) {const browserPages = browsers?.pages ?? createSource({});const browserTabs = browsers?.tabs ?? createSource({});const browserHolds = browsers?.holds ?? createSource({});- const face = () => ({ actions, hooks: { roster, ui: ui2, activity, work, memoryNews, registry, turnClock, live, cards, heldCards, browserPages, browserTabs, browserHolds, surface, update } });+ const face = () => ({ actions, hooks: { roster, ui: ui2, activity, work, memoryNews, registry, turnClock, live, cards, heldCards, browserPages, browserTabs, browserHolds, surface, update, frame, sidebarPref } });ctx.effect(() => noticeApprovals({work,roster,@@ -19451,6 +19673,25 @@ function apply(ctx) {if (controller === void 0 || span === void 0) return;controller.toggleSource(CHATS_SOURCE, { trigger: "@", query: "", quoted: false, position: "inline", span });};+ const installFrameSync = () => {+ let last = { details: ui2.getSnapshot().details, view: ui2.getSnapshot().view };+ const sync = () => {+ const s = ui2.getSnapshot();+ const f = frame.getSnapshot();+ const opened = s.details !== null && (s.details !== last.details || s.view !== last.view);+ last = { details: s.details, view: s.view };+ const layout = frameLayout({ viewport: f.viewport, sidebarWidth: f.sidebarWidth, collapsedWidth: f.collapsedWidth, pref: sidebarPref.getSnapshot(), drawer: s.leftDrawer === true, panel: s.details === null ? null : { view: s.view, yielded: false } });+ if (s.details === null) {+ if (s.panelYield) actions.setPanelYield(false);+ } else if (!s.panelYield && opened && layout.panel === "folded") actions.setPanelYield(true);+ else if (s.panelYield && layout.panel === "shown") actions.setPanelYield(false);+ if (s.leftDrawer === true && layout.left !== "drawer") actions.setLeftDrawer(false);+ };+ const offs = [ui2.subscribe(sync), frame.subscribe(sync), sidebarPref.subscribe(sync)];+ return () => {+ for (const off of offs) off();+ };+ };const installShell = () => [() => installCompiledStyles(SHELL_CSS, "shell"),() => installCompiledStyles(SIDEBAR_CSS, "sidebar"),@@ -19466,6 +19707,8 @@ function apply(ctx) {() => installCompiledStyles(SIDE_CSS, "side"),// Strip and panel styles also serve the side-chat tabs, which need no bridge.() => installCompiledStyles(BROWSER_CSS, "browser"),+ () => installFrameWatch(frame),+ () => installFrameSync(),() => installTheme(),() => shadow("sidebar.workspaces", { priority: BOT_PRIORITY, inject: face }, TeamSidebar),() => shadow("sidebar.brand.mark", { priority: BOT_PRIORITY }, BrandMark),diff --git a/ds-bot/src/client/browser-pane.js b/ds-bot/src/client/browser-pane.jsindex a273d4dd..23ef1007 100644--- a/ds-bot/src/client/browser-pane.js+++ b/ds-bot/src/client/browser-pane.js@@ -8,7 +8,8 @@ import { createElement as h, useEffect, useLayoutEffect, useRef, useState } fromimport { createPortal } from 'react-dom'import { BotMark } from './mark.js'import { STORAGE } from './storage.js'-import { installStyles } from './styles.js'+import { MIN_CHAT } from './frame-layout.js'+import { chatRoom } from './frame-watch.js'import { SPRING_SHAPE, springEasing } from './motion.js'import { DetailsDrawer } from './details-drawer.js'import { SideChatView } from './side-chat.js'@@ -26,12 +27,6 @@ const DEFAULT_WIDTH = 520const DETAILS_WIDTH = 320const DETAILS_MAX = 520const MIN_WIDTH = 360-// The conversation keeps at least this much room beside the panel.-const MIN_CHAT = 420-const PANEL_MIN = { details: DETAILS_WIDTH, browser: MIN_WIDTH, side: DETAILS_WIDTH }-// Below this viewport width the panel cannot leave the conversation its room:-// it covers the conversation instead of pushing it aside.-const overlayAt = (view, viewport) => viewport < MIN_CHAT + PANEL_MIN[view]// How long the Bot's mark shows that it read the page.const READ_FLASH_MS = 2400const EMPTY_PAGE = { url: '', title: '', favicon: null, loading: false, canGoBack: false, canGoForward: false, error: null, excerpt: '' }@@ -72,50 +67,13 @@ const savedWidth = () => {return Number.isFinite(value) && value >= DETAILS_WIDTH ? value : null} catch { return null }}-const widthRange = (view, viewport) => (view === 'browser'- ? [MIN_WIDTH, viewport - MIN_CHAT]- : [DETAILS_WIDTH, Math.min(DETAILS_MAX, viewport - MIN_CHAT)])+// `room` is what the panel and the conversation share: the viewport minus the+// left column's footprint (frame-layout.js). The panel never takes the last+// MIN_CHAT px of it; below that it covers the conversation instead.+const widthRange = (view, room) => (view === 'browser'+ ? [MIN_WIDTH, room - MIN_CHAT]+ : [DETAILS_WIDTH, Math.min(DETAILS_MAX, room - MIN_CHAT)])const fitWidth = (width, [low, high]) => Math.round(Math.max(low, Math.min(width, high)))--// The conversation column's right margin lives in one rule of our own, matched on the-// column's exact class. A custom property on <body> would restyle the whole page, tens-// of milliseconds a write. A changed rule still restyles the column's subtree, so a drag-// writes the column's own inline style each frame and the rule once, on release.-const room = { rule: null, selector: '' }-const roomRule = () => {- const live = room.rule?.parentStyleSheet?.ownerNode?.isConnected- if (live && room.selector) return room.rule- const column = document.querySelector('[class*="_centerCol"]')- const selector = column ? [...column.classList].filter(name => name.includes('_centerCol')).map(name => `.${CSS.escape(name)}`).join(',') : ''- if (live && !selector) return room.rule- const declarations = room.rule?.style.cssText ?? ''- room.rule?.parentStyleSheet?.ownerNode?.remove()- const style = installStyles(`${selector || '[class*="_centerCol"]'}{${declarations}}`, 'chat-room')- room.rule = style.sheet.cssRules[0]- room.selector = selector- return room.rule-}-let roomHold = 0-const chatRoom = {- /** The column's right margin in px, or null for the shell's own. */- set(width) {- const { style } = roomRule()- if (width === null) style.removeProperty('margin-right')- else style.setProperty('margin-right', `${width}px`, 'important')- },- /** While on, a margin change lands at once instead of gliding. */- hold(on) {- cancelAnimationFrame(roomHold)- if (on) { roomRule().style.setProperty('transition', 'none', 'important'); return }- // Two frames, so the last held write is on screen before the glide comes back.- roomHold = requestAnimationFrame(() => { roomHold = requestAnimationFrame(() => roomRule().style.removeProperty('transition')) })- },- /** The columns themselves, for a drag's per-frame writes. */- columns() {- roomRule()- return room.selector ? [...document.querySelectorAll(room.selector)] : []- },-}// The address as the bar shows it while not editing: no scheme, no trailing slash.const shortAddress = url => String(url ?? '').replace(/^https?:\/\//i, '').replace(/^www\./i, '').replace(/\/$/, '')const reducedMotion = () => typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches@@ -563,7 +521,7 @@ function ImportCard({ flow, page, busy, onApply, onCancel, onCloseAndImport, onD* Session id the panel follows and `side` the open chat's id. Without the* Desktop bridge the browser view never shows; side chats need no bridge.*/-export function BotPanel({ pane, leaving, roster, actions, useSessions, useSessionStatus, useActivity, useWork, useBrowserTabs, useBrowserPages, useBrowserHolds }) {+export function BotPanel({ pane, leaving, room, overlay, roster, actions, useSessions, useSessionStatus, useActivity, useWork, useBrowserTabs, useBrowserPages, useBrowserHolds }) {const bot = roster.byId[pane.id]const canBrowse = Boolean(bot && roster.browser === true && actions.browserShow)const sideChats = bot ? sideChatsOf(roster, bot.id) : []@@ -578,15 +536,13 @@ export function BotPanel({ pane, leaving, roster, actions, useSessions, useSessiconst [landed, setLanded] = useState(false)const [settling, setSettling] = useState(false)const [width, setWidth] = useState(savedWidth)- const [viewport, setViewport] = useState(() => window.innerWidth)// While dragging or while the window resizes, width changes land at once.const [dragging, setDragging] = useState(false)const [resizing, setResizing] = useState(false)const instant = dragging || resizingconst [reading, setReading] = useState(false)- const overlay = overlayAt(view, viewport)- const panelWidth = fitWidth(width ?? (view === 'browser' ? DEFAULT_WIDTH : DETAILS_WIDTH), widthRange(view, viewport))+ const panelWidth = fitWidth(width ?? (view === 'browser' ? DEFAULT_WIDTH : DETAILS_WIDTH), widthRange(view, room))// Once the browser has shown, the Bot page keeps its width (up to DETAILS_MAX).useLayoutEffect(() => { if (view === 'browser' && width === null) setWidth(DEFAULT_WIDTH) }, [view, width])useLayoutEffect(() => { chatRoom.hold(instant) }, [instant])@@ -606,21 +562,18 @@ export function BotPanel({ pane, leaving, roster, actions, useSessions, useSessiconst switched = settling && shownView.current !== viewshownView.current = viewif (switched) chatRoom.hold(true)- chatRoom.set(leaving || overlay ? null : panelWidth)+ chatRoom.setRight(leaving || overlay ? null : panelWidth)if (switched) chatRoom.hold(false)}, [view, panelWidth, leaving, overlay])- useEffect(() => () => { chatRoom.set(null); chatRoom.hold(false) }, [])+ useEffect(() => () => { chatRoom.setRight(null); chatRoom.hold(false) }, [])+ // A `room` change (window resize, the left column moving) lands at once.+ const mounted = useRef(false)useEffect(() => {- let timer- const onResize = () => {- setResizing(true)- setViewport(window.innerWidth)- clearTimeout(timer)- timer = setTimeout(() => setResizing(false), 160)- }- window.addEventListener('resize', onResize)- return () => { clearTimeout(timer); window.removeEventListener('resize', onResize) }- }, [])+ if (!mounted.current) { mounted.current = true; return undefined }+ setResizing(true)+ const timer = setTimeout(() => setResizing(false), 160)+ return () => clearTimeout(timer)+ }, [room])useEffect(() => {if (!settling) return undefinedconst timer = setTimeout(() => setSettling(false), SPRING_SHAPE.duration + 40)@@ -728,7 +681,7 @@ export function BotPanel({ pane, leaving, roster, actions, useSessions, useSessiconst panel = root.currentconst grip = event.currentTargetgrip.setPointerCapture?.(event.pointerId)- const range = widthRange(view, window.innerWidth)+ const range = widthRange(view, room)const from = { x: event.clientX, width: panelWidth }let next = panelWidthsetDragging(true)@@ -739,7 +692,7 @@ export function BotPanel({ pane, leaving, roster, actions, useSessions, useSessiconst onMove = (move) => {next = fitWidth(from.width + from.x - move.clientX, range)panel.style.width = `${next}px`- if (columns.length === 0) chatRoom.set(next)+ if (columns.length === 0) chatRoom.setRight(next)for (const column of columns) column.style.setProperty('margin-right', `${next}px`, 'important')}const ends = ['pointerup', 'pointercancel', 'lostpointercapture']@@ -748,7 +701,7 @@ export function BotPanel({ pane, leaving, roster, actions, useSessions, useSessigrip.removeEventListener('pointermove', onMove)for (const name of ends) grip.removeEventListener(name, onEnd)// Hand the width back to the rule and the panel's variable in the same frame.- chatRoom.set(next)+ chatRoom.setRight(next)for (const column of columns) { column.style.removeProperty('margin-right'); column.style.removeProperty('transition') }panel.style.setProperty('--bt-panel-w', `${next}px`)panel.style.removeProperty('width')diff --git a/ds-bot/src/client/frame-layout.js b/ds-bot/src/client/frame-layout.jsnew file mode 100644index 00000000..e1c59d70--- /dev/null+++ b/ds-bot/src/client/frame-layout.js@@ -0,0 +1,63 @@+// 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+// frame-watch.js.+import { STORAGE } from './storage.js'++export const MIN_CHAT = 420+export const RAIL_WIDTH = 88+export 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.+export const DSH_NARROW = 1024+// The shell column's width when it was never measured (its own default is 280).+export const FALLBACK_SIDEBAR_WIDTH = 280++/**+ * @param {{viewport: number, sidebarWidth: number, collapsedWidth?: number,+ * pref: 'open'|'rail', drawer?: boolean,+ * panel: null | {view: string, yielded: boolean}}} input+ * @returns {{left: 'open'|'rail'|'drawer', 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, the rail's, or only+ * the shell's collapsed track under a floating drawer).+ */+export function frameLayout({ viewport, sidebarWidth, collapsedWidth = 0, 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 : left === 'rail' ? RAIL_WIDTH : collapsedWidth+ 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) {+ // 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'+ } 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'++// A flip of the shell's collapsed flag counts as the user's own switch gesture+// only when we did not request it and the width stayed on one side of the+// auto-collapse line (a crossing is the shell's own rule firing).+export const userSidebarToggle = ({ before, after, requested = false }) =>+ before.collapsed !== after.collapsed && !requested && (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' }+}+export function writeSidebarPref(pref, storage = globalThis.localStorage) {+ try { storage.setItem(STORAGE.sidebar, pref === 'rail' ? 'rail' : 'open') } catch { /* storage unavailable */ }+}diff --git a/ds-bot/src/client/frame-watch.js b/ds-bot/src/client/frame-watch.jsnew file mode 100644index 00000000..d6d33fd0--- /dev/null+++ b/ds-bot/src/client/frame-watch.js@@ -0,0 +1,108 @@+// The DOM side of the frame layout in frame-layout.js: measuring the shell's+// 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++// The shell frame marks itself [data-sidebar-collapsed]; null when no frame is found.+export const dshCollapsed = () => {+ if (typeof document === 'undefined') return null+ const column = document.querySelector('[class*="_sidebarCol"]')+ return column ? (column.parentElement?.hasAttribute('data-sidebar-collapsed') ?? false) : null+}++// The track the collapsed shell sidebar keeps: nothing under a frameless window+// (Windows title bar, macOS desktop), its icon rail elsewhere.+export const collapsedTrackWidth = () =>+ document.documentElement.hasAttribute('data-windows-titlebar') || document.documentElement.dataset.platform === 'darwin' ? 0 : 56++// The conversation column's margins live in one rule of our own, matched on the+// column's exact class. A custom property on <body> would restyle the whole page,+// tens of milliseconds a write. A changed rule still restyles the column's+// subtree, so a drag writes the column's own inline style each frame and the+// rule once, on release.+const room = { rule: null, selector: '' }+const roomRule = () => {+ const live = room.rule?.parentStyleSheet?.ownerNode?.isConnected+ if (live && room.selector) return room.rule+ const column = document.querySelector('[class*="_centerCol"]')+ const selector = column ? [...column.classList].filter(name => name.includes('_centerCol')).map(name => `.${CSS.escape(name)}`).join(',') : ''+ if (live && !selector) return room.rule+ const declarations = room.rule?.style.cssText ?? ''+ room.rule?.parentStyleSheet?.ownerNode?.remove()+ const style = installStyles(`${selector || '[class*="_centerCol"]'}{${declarations}}`, 'chat-room')+ room.rule = style.sheet.cssRules[0]+ room.selector = selector+ return room.rule+}+const margin = (side, width, style) => {+ if (width === null) style.removeProperty(`margin-${side}`)+ else style.setProperty(`margin-${side}`, `${width}px`, 'important')+}+let roomHold = 0+export const chatRoom = {+ /** The margin the Bot panel takes on the right, in px, or null for the shell's own. */+ setRight(width) { margin('right', width, roomRule().style) },+ /** The margin our own left column takes while the shell sidebar is collapsed. */+ setLeft(width) { margin('left', width, roomRule().style) },+ /** While on, a margin change lands at once instead of gliding. */+ hold(on) {+ cancelAnimationFrame(roomHold)+ if (on) { roomRule().style.setProperty('transition', 'none', 'important'); return }+ // Two frames, so the last held write is on screen before the glide comes back.+ roomHold = requestAnimationFrame(() => { roomHold = requestAnimationFrame(() => roomRule().style.removeProperty('transition')) })+ },+ /** The columns themselves, for a drag's per-frame writes. */+ columns() {+ roomRule()+ return room.selector ? [...document.querySelectorAll(room.selector)] : []+ },+}++// 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.+export function installFrameWatch(frame) {+ let sidebarWidth = FALLBACK_SIDEBAR_WIDTH+ let collapsedWidth = collapsedTrackWidth()+ let raf = 0+ const watched = new Set()+ const observer = typeof ResizeObserver === 'function' ? new ResizeObserver(() => schedule()) : null+ const read = () => {+ const width = sidebarTrackWidth()+ const collapsed = dshCollapsed()+ if (width !== null) {+ if (collapsed === true) collapsedWidth = width+ else if (collapsed === false) sidebarWidth = 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 measure = () => {+ for (const selector of ['[class*="_sidebarCol"]', '[class*="_centerCol"]']) {+ for (const column of document.querySelectorAll(selector)) {+ if (!watched.has(column)) { watched.add(column); observer?.observe(column) }+ }+ }+ read()+ }+ const schedule = () => {+ if (raf === 0) raf = requestAnimationFrame(() => { raf = 0; measure() })+ }+ measure()+ const mutations = new MutationObserver(schedule)+ mutations.observe(document.documentElement, { subtree: true, childList: true, attributes: true, attributeFilter: ['data-sidebar-collapsed'] })+ window.addEventListener('resize', schedule)+ return () => {+ cancelAnimationFrame(raf)+ mutations.disconnect()+ observer?.disconnect()+ window.removeEventListener('resize', schedule)+ }+}diff --git a/ds-bot/src/client/index.js b/ds-bot/src/client/index.jsindex 6b8b5589..9faca828 100644--- a/ds-bot/src/client/index.js+++ b/ds-bot/src/client/index.js@@ -8,6 +8,8 @@ import { MENTION_ORIGIN, currentPart } from './text.js'import { SHELL_CSS, CONVERSATION_CSS, installStyles, installCompiledStyles } from './styles.js'import { lookOf } from './mark.js'import { TeamSidebar, ConnectPlugins, 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 { installFrameWatch } from './frame-watch.js'import { HeaderPill } from './header.js'import { ComposerPlus, ComposerVoice, menuIcons } from './composer.js'import { CHATS_SOURCE, atSources } from './at-menu.js'@@ -55,7 +57,11 @@ export function apply(ctx) {let seenAt = seenStore.read()// `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: {} })+ 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 })// 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.@@ -375,8 +381,16 @@ export function apply(ctx) {}const mainView = () => Object.values(ctx.sessions.list.getSnapshot().byId ?? {}).find(session => (session?.retainedBy?.mainView ?? 0) > 0)?.idconst show = listedOpener({ list: ctx.sessions.list, refresh: () => Promise.resolve(ctx.sessions.refresh?.()).catch(quietly('refresh sessions')), open: (target) => { expected = target; ctx.uiWorkspace.openSession(target) }, current: mainView })+ // Whether the open Bot panel is folded away for lack of room: its opener then+ // means "show it" (the column yields), not "close it".+ const panelFolded = () => {+ const state = ui.getSnapshot()+ if (state.details === null) return false+ const f = frame.getSnapshot()+ return frameLayout({ viewport: f.viewport, sidebarWidth: f.sidebarWidth, collapsedWidth: f.collapsedWidth, pref: sidebarPref.getSnapshot(), drawer: state.leftDrawer, panel: { view: state.view, yielded: false } }).panel === 'folded'+ }const actions = {- ...teamActions({ call, after, partFor, roster, ui, live, cards, heldCards, turnClock }),+ ...teamActions({ call, after, partFor, roster, ui, live, cards, heldCards, turnClock, panelFolded }),// The full-pane overlays sit above the conversation, so opening one must dismiss them// or the click appears to do nothing.isAgentSession: id => isAgentSessionId(id),@@ -455,6 +469,15 @@ 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).+ setSidebarPref: (pref) => {+ const next = pref === 'rail' ? 'rail' : 'open'+ writeSidebarPref(next)+ sidebarPref.set(next)+ },+ 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// surface closes first so nothing stale reopens on the way back.setSurface: (mode) => {@@ -616,7 +639,7 @@ export function apply(ctx) {const browserPages = browsers?.pages ?? createSource({})const browserTabs = browsers?.tabs ?? createSource({})const browserHolds = browsers?.holds ?? createSource({})- const face = () => ({ actions, hooks: { roster, ui, activity, work, memoryNews, registry, turnClock, live, cards, heldCards, browserPages, browserTabs, browserHolds, surface, update } })+ const face = () => ({ actions, hooks: { roster, ui, activity, work, memoryNews, registry, turnClock, live, cards, heldCards, browserPages, browserTabs, browserHolds, surface, update, frame, sidebarPref } })ctx.effect(() => noticeApprovals({work,roster,@@ -771,6 +794,28 @@ export function apply(ctx) {controller.toggleSource(CHATS_SOURCE, { trigger: '@', query: '', quoted: false, position: 'inline', span })}+ // The panel's yield flag and the drawer's flag follow the frame: opening (or+ // re-aiming) a panel that does not fit yields the column to the rail; a panel+ // that fits again, or is closed, and a drawer that no longer applies drop+ // their flags.+ const installFrameSync = () => {+ let last = { details: ui.getSnapshot().details, view: ui.getSnapshot().view }+ const sync = () => {+ const s = ui.getSnapshot()+ const f = frame.getSnapshot()+ const opened = s.details !== null && (s.details !== last.details || s.view !== last.view)+ last = { details: s.details, view: s.view }+ const layout = frameLayout({ viewport: f.viewport, sidebarWidth: f.sidebarWidth, collapsedWidth: f.collapsedWidth, pref: sidebarPref.getSnapshot(), drawer: s.leftDrawer === true, panel: s.details === null ? null : { view: s.view, yielded: false } })+ if (s.details === null) {+ if (s.panelYield) actions.setPanelYield(false)+ } else if (!s.panelYield && opened && layout.panel === 'folded') actions.setPanelYield(true)+ else if (s.panelYield && layout.panel === 'shown') actions.setPanelYield(false)+ if (s.leftDrawer === true && layout.left !== 'drawer') actions.setLeftDrawer(false)+ }+ const offs = [ui.subscribe(sync), frame.subscribe(sync), sidebarPref.subscribe(sync)]+ return () => { for (const off of offs) off() }+ }+// The shell group paints the team surface around the session; the conversation// group re-skins the session itself. Each step returns a disposer from slots.inject,// so a surface change withdraws the whole group and the outlets re-render.@@ -789,6 +834,8 @@ export function apply(ctx) {() => installCompiledStyles(SIDE_CSS, 'side'),// Strip and panel styles also serve the side-chat tabs, which need no bridge.() => installCompiledStyles(BROWSER_CSS, 'browser'),+ () => installFrameWatch(frame),+ () => installFrameSync(),() => installTheme(),() => shadow('sidebar.workspaces', { priority: BOT_PRIORITY, inject: face }, TeamSidebar),() => shadow('sidebar.brand.mark', { priority: BOT_PRIORITY }, BrandMark),diff --git a/ds-bot/src/client/overlays.js b/ds-bot/src/client/overlays.jsindex 67d7450b..d8350696 100644--- a/ds-bot/src/client/overlays.js+++ b/ds-bot/src/client/overlays.js@@ -7,6 +7,7 @@ import { VoiceMode } from './voice.js'import { SettingsDialog } from './settings.js'import { ContextMenu } from './context-menu.js'import { PANEL_LINGER_MS, BotPanel } from './browser-pane.js'+import { frameLayout, FALLBACK_SIDEBAR_WIDTH } from './frame-layout.js'import { MemoryDialog } from './memory-panel.js'import { useLinger } from './motion.js'@@ -14,10 +15,12 @@ import { useLinger } from './motion.js'const DIALOG_EXIT_MS = 160const MENU_EXIT_MS = 120-export function Overlays({ useRoster, useUi, useSessions, useSessionStatus, useActivity, useWork, useRegistry, useBrowserPages, useBrowserTabs, useBrowserHolds, useUpdate, actions }) {+export function Overlays({ useRoster, useUi, useSessions, useSessionStatus, useActivity, useWork, useRegistry, useBrowserPages, useBrowserTabs, useBrowserHolds, useUpdate, useFrame, useSidebarPref, actions }) {const roster = useRoster(value => value)const ui = useUi(value => value)useRegistry(value => value)+ const frameSnap = useFrame ? useFrame(value => value) : { viewport: window.innerWidth, sidebarWidth: FALLBACK_SIDEBAR_WIDTH, collapsedWidth: 0 }+ const pref = useSidebarPref ? useSidebarPref(value => value) : 'open'const current = useSessions(list => Object.values(list.byId).find(session => (session?.retainedBy?.mainView ?? 0) > 0)?.id ?? null)// An open panel follows the conversation in the main view. Only a change of the// main view moves it, so opening details for another id (Rename) is not undone.@@ -28,13 +31,22 @@ export function Overlays({ useRoster, useUi, useSessions, useSessionStatus, useAif (current) actions.followPanel?.(current)}, [current])const open = ui.details ? { id: ui.details, view: ui.view ?? 'details', renaming: ui.renaming, tab: ui.tab, side: ui.side } : null- const [kept, setKept] = useState(open)+ // A panel that no longer fits folds away: its state stays open, it just is not+ // mounted — the usual exit plays and the webview goes with it — until the room+ // returns and it shows again on its own.+ const layout = frameLayout({+ viewport: frameSnap.viewport, sidebarWidth: frameSnap.sidebarWidth, collapsedWidth: frameSnap.collapsedWidth ?? 0,+ pref, drawer: ui.leftDrawer === true,+ panel: open ? { view: open.view, yielded: ui.panelYield === true } : null,+ })+ const shown = open !== null && layout.panel !== 'folded' ? open : null+ const [kept, setKept] = useState(shown)useEffect(() => {- if (open) { setKept(open); return undefined }+ if (shown) { setKept(shown); return undefined }const timer = setTimeout(() => setKept(null), PANEL_LINGER_MS)return () => clearTimeout(timer)- }, [ui.details, ui.view, ui.renaming, ui.tab])- const pane = open ?? kept+ }, [ui.details, ui.view, ui.renaming, ui.tab, shown === null])+ const pane = shown ?? keptconst [settings, settingsLeaving] = useLinger(ui.settings, DIALOG_EXIT_MS)// The memory dialog shows a Bot's memory or a group chat's.const memoryOwner = (id) => {@@ -47,7 +59,7 @@ export function Overlays({ useRoster, useUi, useSessions, useSessionStatus, useAconst owner = memory ? memoryOwner(memory) : nullconst [menu, menuLeaving] = useLinger(ui.menu, MENU_EXIT_MS)return h(Fragment, null,- pane ? createPortal(h(BotPanel, { pane, leaving: open === null, roster, actions, useSessions, useSessionStatus, useActivity, useWork, useBrowserTabs, useBrowserPages, useBrowserHolds }), document.body) : null,+ pane ? createPortal(h(BotPanel, { pane, leaving: shown === null, room: layout.room, overlay: layout.panel === 'overlay', roster, actions, useSessions, useSessionStatus, useActivity, useWork, useBrowserTabs, useBrowserPages, useBrowserHolds }), document.body) : null,ui.newChat ? createPortal(h(NewChat, { key: ui.newChat, mode: ui.newChat, roster, actions }), document.body) : null,ui.palette ? createPortal(h(CommandPalette, { key: ui.palette.token, start: ui.palette.query, token: ui.palette.token, roster, actions, useSessions }), document.body) : null,ui.exchange ? createPortal(h(ExchangeDialog, { pair: ui.exchange, roster, actions }), document.body) : null,diff --git a/ds-bot/src/client/sidebar.js b/ds-bot/src/client/sidebar.jsindex e1fda0e1..620bde74 100644--- a/ds-bot/src/client/sidebar.js+++ b/ds-bot/src/client/sidebar.js@@ -11,6 +11,8 @@ 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 { chatRoom, dshCollapsed } from './frame-watch.js'// -------------------------------------------------------------------------// Sidebar@@ -85,7 +87,7 @@ function BotRow({ bot, roster, actions, useSessions, useSessionStatus, useSessiotype: 'button', className: 'bt-row', 'aria-label': label, 'aria-current': active ? 'page' : undefined,'data-bot-id': id, title: wide ? undefined : bot.name, onClick: () => actions.openSession(id), onContextMenu,},- h(BotAvatar, { bot, size: 36, state, main }),+ h(BotAvatar, { bot, size: wide ? 36 : 44, state, main }),pinned && !wide ? h(PinMark) : null,wide ? h('span', { className: 'bt-row-body' },h('span', { className: 'bt-row-name' }, h('span', { className: 'bt-row-title' }, bot.name), pinned ? h(PinMark) : null),@@ -93,7 +95,8 @@ function BotRow({ bot, roster, actions, useSessions, useSessionStatus, useSessio: awayLine ? h('span', { className: 'bt-row-preview' }, awayLine): waitsFor ? h('span', { className: 'bt-row-preview' }, waitsFor): preview ? h('span', { className: 'bt-row-preview' }, preview) : null) : null,- wide && unread && !active ? h('span', { className: 'bt-unread', 'aria-hidden': true }) : null)+ wide && unread && !active ? h('span', { className: 'bt-unread', 'aria-hidden': true })+ : !wide && !active && (alert || unread) ? h('span', { className: `bt-dot${alert ? ' bt-dot-wait' : ''}`, 'aria-hidden': true }) : null)}function RoomRow({ room, roster, actions, useSessions, useSessionStatus, useSessionRetainInfo, useWork, wide, marked }) {@@ -115,13 +118,14 @@ function RoomRow({ room, roster, actions, useSessions, useSessionStatus, useSess'data-room-id': id, onClick: () => actions.openSession(id),onContextMenu: (event) => { event.preventDefault(); actions.openMenu({ kind: 'room', id, x: event.clientX, y: event.clientY }) },},- h(RoomAvatar, { room, roster, size: 36 }),+ h(RoomAvatar, { room, roster, size: wide ? 36 : 44 }),pinned && !wide ? h(PinMark) : null,wide ? h('span', { className: 'bt-row-body' },h('span', { className: 'bt-row-name' }, h('span', { className: 'bt-row-title' }, room.name), pinned ? h(PinMark) : null),workingLine ? h('span', { className: 'bt-row-preview' }, workingLine) : preview ? h('span', { className: 'bt-row-preview' }, preview) : null) : null,wide && approval && !active ? h('span', { className: 'bt-unread bt-unread-wait', 'aria-hidden': true })- : wide && unread && !active ? h('span', { className: 'bt-unread', 'aria-hidden': true }) : null)+ : wide && unread && !active ? h('span', { className: 'bt-unread', 'aria-hidden': true })+ : !wide && !active && (approval || unread) ? h('span', { className: `bt-dot${approval ? ' bt-dot-wait' : ''}`, 'aria-hidden': true }) : null)}// One expanded DSH Agent Session row: title, relative stamp, rename field, and a@@ -209,11 +213,12 @@ function AgentRow({ agent, actions, useSessions, useSessionStatus, useUi, wide,'data-agent-id': agent.id, title: wide ? undefined : 'DSH Agent', onClick: () => actions.openAgent(agent.id),onContextMenu: (event) => { event.preventDefault(); actions.openMenu({ kind: 'agent', id: agent.id, x: event.clientX, y: event.clientY }) },},- h('span', { className: `bt-agent-ava${running ? ' bt-run' : ''}` }, h(FishLogo, { size: 22 })),+ h('span', { className: `bt-agent-ava${running ? ' bt-run' : ''}` }, h(FishLogo, { size: wide ? 22 : 24 })),wide ? h('span', { className: 'bt-row-body' },h('span', { className: 'bt-row-name' }, 'DSH Agent'),preview ? h('span', { className: 'bt-row-preview' }, preview) : null) : null,- wide && unread && !active ? h('span', { className: 'bt-unread', 'aria-hidden': true }) : null),+ wide && unread && !active ? h('span', { className: 'bt-unread', 'aria-hidden': true })+ : !wide && unread && !active ? h('span', { className: 'bt-dot', 'aria-hidden': true }) : null),h('div', { className: 'bt-agent-sub', 'data-open': open || undefined },h('div', { className: 'bt-agent-sub-in' },h('button', { type: 'button', className: 'bt-agent-sub-row bt-agent-new', style: { '--i': 0 }, onClick: () => { void actions.newAgentSession(agent.id).catch(error => actions.reportError(error, 'agent-session')) } },@@ -248,14 +253,30 @@ 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)+}+export function TeamSidebar(props) {- const { wide, expandSidebar, useRoster, useUi, useSessions, actions } = props+ const { wide, useRoster, useUi, useSessions, actions } = propsconst listRef = useRef(null)- const closing = useRef(false)- useLayoutEffect(() => { closing.current = false })const roster = useRoster(value => value)const markedUnread = useUi(value => value.unread)+ const uiNow = useUi(value => value)props.useRegistry(value => value)+ const frameSnap = props.useFrame ? props.useFrame(value => value) : { viewport: typeof window === 'undefined' ? 0 : window.innerWidth, sidebarWidth: FALLBACK_SIDEBAR_WIDTH, collapsedWidth: 0 }+ const pref = props.useSidebarPref ? props.useSidebarPref(value => value) : 'open'+ const layout = frameLayout({+ viewport: frameSnap.viewport, sidebarWidth: frameSnap.sidebarWidth, collapsedWidth: frameSnap.collapsedWidth ?? 0,+ 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+ const wideContent = mode !== 'rail'const updated = useSessions(list => {const stamps = {}for (const id of list.ids) stamps[id] = list.byId[id]?.updatedAt ?? 0@@ -272,18 +293,71 @@ export function TeamSidebar(props) {return entries.sort((a, b) => Number(Boolean(b.item.pinned)) - Number(Boolean(a.item.pinned)) || b.at - a.at)}, [roster, updated])const main = roster.byId[roster.mainBotId]- useListGlide(listRef, wide, order.map(entry => entry.item.id).join(','))+ useListGlide(listRef, wideContent, order.map(entry => entry.item.id).join(','))useLandOnMainBot(roster, useSessions, actions)- // The shell keeps wide content during its collapse fade. Normalize through its- // public expansion action before toggling; coalesce synchronous activations- // until React commits the result.++ // Our column pushes the conversation over by what it takes beyond the shell's+ // collapsed track; a floating drawer does not push.+ const ourWidth = layout.left === 'rail' ? RAIL_WIDTH : frameSnap.sidebarWidth+ useLayoutEffect(() => {+ if (typeof document === 'undefined') return+ chatRoom.setLeft(mode === 'inline' || mode === 'drawer' ? null : Math.max(0, ourWidth - (frameSnap.collapsedWidth ?? 0)))+ }, [mode, ourWidth, 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.+ const dsh = useRef(null)+ const requested = useRef(false)+ useLayoutEffect(() => {+ if (typeof document === 'undefined' || typeof actions.toggleSidebar !== 'function') return undefined+ const collapsed = dshCollapsed() ?? !wide+ const prev = dsh.current+ dsh.current = { collapsed, viewport: frameSnap.viewport, left: layout.left }+ if (prev !== null && collapsed !== prev.collapsed) {+ if (requested.current) requested.current = false+ else if (userSidebarToggle({ before: prev, after: { collapsed, viewport: frameSnap.viewport } })) {+ // 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+ }+ }+ const wantOpen = dshExpandedFor(frameSnap.viewport, layout.left)+ if (collapsed === !wantOpen) { requested.current = false; return undefined }+ if (requested.current) return undefined+ requested.current = true+ actions.toggleSidebar()+ const timer = setTimeout(() => { requested.current = false }, 300)+ return () => clearTimeout(timer)+ }, [wide, frameSnap.viewport, frameSnap.sidebarWidth, layout.left])++ // The drawer closes on a row pick, on Escape and on a press outside it.+ useEffect(() => {+ if (mode !== 'drawer') return undefined+ const onDown = (event) => {+ if (event.target instanceof Element && event.target.closest('.bt-leftcol')) return+ actions.setLeftDrawer?.(false)+ }+ const onKey = (event) => {+ if (event.key !== 'Escape') return+ event.stopPropagation()+ actions.setLeftDrawer?.(false)+ }+ window.addEventListener('mousedown', onDown)+ window.addEventListener('keydown', onKey, true)+ return () => { window.removeEventListener('mousedown', onDown); window.removeEventListener('keydown', onKey, true) }+ }, [mode])+const navigate = (open, id) => {const result = open(id)- if (wide && window.innerWidth < 1024 && !closing.current) {- closing.current = true- expandSidebar?.()- actions.toggleSidebar()- }+ if (uiNow.leftDrawer === true) actions.setLeftDrawer?.(false)return result}const rowActions = {@@ -293,7 +367,7 @@ export function TeamSidebar(props) {openAgentSession: id => navigate(actions.openAgentSession, id),newAgentSession: id => navigate(actions.newAgentSession, id),}- const rowProps = { roster, actions: rowActions, useSessions, useUi, useSessionStatus: props.useSessionStatus, useSessionRetainInfo: props.useSessionRetainInfo, useActivity: props.useActivity, useWork: props.useWork, wide }+ const rowProps = { roster, actions: rowActions, useSessions, useUi, useSessionStatus: props.useSessionStatus, useSessionRetainInfo: props.useSessionRetainInfo, useActivity: props.useActivity, useWork: props.useWork, wide: wideContent }// Typing while the sidebar has focus starts a search.const typeToSearch = (event) => {if (event.defaultPrevented || event.key.length !== 1 || event.key === ' ' || event.metaKey || event.ctrlKey || event.altKey || event.nativeEvent.isComposing) return@@ -301,24 +375,43 @@ export function TeamSidebar(props) {event.preventDefault()actions.openPalette(event.key)}- return h('div', { className: wide ? 'bt-side' : 'bt-side bt-rail', onKeyDown: typeToSearch },- wide ? h('div', { className: 'bt-side-top' },- h('span', { className: 'bt-brand' }, h(BrandMark, { size: 22 }), h(BrandName)),- 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.toggleSidebar() }, h(SidebarIcon)))- : h(Fragment, null,- h(UpdateButton, { useUpdate: props.useUpdate, actions }),- h('button', { type: 'button', className: 'bt-round', 'aria-label': t('New…'), title: t('New…'), onClick: () => actions.openNewChat('new') }, h(PlusIcon))),- wide && roster.readOnly ? h('div', { className: 'bt-hint bt-read-only', role: 'status' }, hostText(roster.readOnly)) : null,+ const expandLeft = () => {+ actions.setSidebarPref?.('open')+ if (frameSnap.viewport < frameSnap.sidebarWidth + MIN_CHAT) actions.setLeftDrawer?.(true)+ }+ const top = wideContent+ ? h('div', { className: 'bt-side-top' },+ h('span', { className: 'bt-brand' }, h(BrandMark, { size: 22 }), h(BrandName)),+ 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('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)),+ 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, then+ // Connect plugins as its row, and on the rail the new-chat and plug buttons.+ const foot = mode === 'inline' ? null : wideContent+ ? h('div', { className: 'bt-leftcol-foot' }, h(AccountLauncher, { seat: false, actions }), h(ConnectPlugins, { wide: true, 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)),+ h('button', { type: 'button', className: 'bt-round', 'aria-label': t('Connect plugins'), title: t('Connect plugins'), onClick: () => actions.selectPanel('plugins') }, h(PlugIcon)),+ h(AccountLauncher, { seat: false, actions }))+ const content = h('div', { className: wideContent ? 'bt-side' : 'bt-side bt-rail', onKeyDown: typeToSearch },+ top,+ wideContent && roster.readOnly ? h('div', { className: 'bt-hint bt-read-only', role: 'status' }, hostText(roster.readOnly)) : null,h('div', { ref: listRef, className: 'bt-list', role: 'region', 'aria-label': t('Bot list') },- 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…')),+ wideContent ? (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…'))) : null,order.map(entry => (entry.kind === 'bot'? h(BotRow, { key: entry.item.id, ...rowProps, bot: entry.item, marked: markedUnread[entry.item.id] === true }): entry.kind === 'room'? h(RoomRow, { key: entry.item.id, ...rowProps, room: entry.item, marked: markedUnread[entry.item.id] === true })- : h(AgentRow, { key: entry.item.id, ...rowProps, agent: entry.item, marked: markedUnread[entry.item.id] === true })))))+ : h(AgentRow, { key: entry.item.id, ...rowProps, agent: entry.item, marked: markedUnread[entry.item.id] === true })))),+ foot)+ if (mode === 'inline') return content+ return h(LeftColumn, { mode, width: ourWidth }, content)}// The update button at the sidebar's top right: a cloud while a newer DS Bot —@@ -686,7 +779,7 @@ export const SIDEBAR_CSS = `.bt-brand .bt-mark{flex:none}.bt-pin{flex:none;display:inline-flex;color:var(--bt-ink-3)}.bt-rail .bt-row{position:relative}-.bt-rail .bt-pin{position:absolute;top:3px;left:calc(50% + 12px)}+.bt-rail .bt-pin{position:absolute;top:1px;left:calc(50% + 14px)}.bt-side .bt-read-only{margin:4px 8px 6px;padding:8px 10px;border-radius:10px;background:var(--bt-hover);font-size:12px;line-height:1.45;text-align:left}[class*="_footArea"]:has(.bt-foot-account){grid-template-columns:auto minmax(0,1fr) auto;column-gap:6px}[class*="_footArea"]>[class*="_footerActions"]>div>.bt-foot-account{grid-column:1;order:1;display:inline-flex}diff --git a/ds-bot/src/client/storage.js b/ds-bot/src/client/storage.jsindex f74ffcb3..5614f9d4 100644--- a/ds-bot/src/client/storage.js+++ b/ds-bot/src/client/storage.js@@ -9,6 +9,7 @@ export const STORAGE = {surface: 'ds-bot:surface',agentSessions: 'ds-bot:agent-sessions',browserWidth: 'ds-bot:browser-width',+ sidebar: 'ds-bot:sidebar',browsers: 'ds-bot.browser.v2',}diff --git a/ds-bot/src/client/styles.js b/ds-bot/src/client/styles.jsindex f70b5dac..27a3b323 100644--- a/ds-bot/src/client/styles.js+++ b/ds-bot/src/client/styles.js@@ -144,8 +144,24 @@ body[data-bt-motion=quiet] .bt-mark[data-poke]{cursor:default}.bt-row-preview{font-size:13px;line-height:18px;color:var(--bt-ink-2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.bt-unread{width:8px;height:8px;border-radius:50%;background:var(--bt-accent);flex:none;margin-right:2px;animation:bt-fade .13s cubic-bezier(.22,1,.36,1)}.bt-unread-wait{background:var(--bt-star)}-.bt-rail{align-items:center;padding:0 0 8px}-.bt-rail .bt-row{justify-content:center;padding:6px 0;min-height:44px}+/* Our own left column, portalled over the shell's collapsed sidebar: it starts+ below the window's title strip and stays under the shell's title-bar switch+ (z 30) and the popovers (z 60). */+.bt-leftcol{position:fixed;left:0;top:var(--dsh-frame-top-clearance,0px);bottom:0;z-index:25;display:flex;background:var(--bt-sidebar);border-right:.5px solid var(--bt-line);box-sizing:border-box;padding:6px 12px;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[data-left=drawer]{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}+.bt-rail{align-items:center;padding:0}+.bt-rail .bt-row{justify-content:center;width:56px;height:56px;min-height:56px;padding:0;border-radius:16px}+.bt-rail-top{display:flex;flex-direction:column;align-items:center;gap:6px;padding-bottom:8px}+.bt-rail-sep{width:24px;height:1px;flex:none;background:var(--bt-line)}+.bt-rail .bt-agent-ava{width:44px;height:44px}+.bt-rail .bt-list{align-items:center;gap:4px}+.bt-leftcol[data-left=rail]{padding:8px 16px}+.bt-leftcol-foot-rail{flex-direction:column;gap:6px}+.bt-dot{position:absolute;top:4px;right:8px;width:8px;height:8px;border-radius:50%;background:var(--bt-accent);box-shadow:0 0 0 1.5px var(--bt-sidebar)}+.bt-dot-wait{background:var(--bt-star)}.bt-side-foot{display:flex;padding-top:8px}.bt-connect{flex:1;height:36px;border-radius:999px;border:1px solid var(--bt-line);background:var(--bt-main);color:var(--bt-ink);font-family:inherit;font-size:14px;line-height:20px;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:8px;transition:background-color .12s ease}.bt-connect:hover{background:var(--bt-hover)}@@ -360,7 +376,7 @@ 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}}+[class*="_centerCol"]{transition:margin-right ${SPRING_SHAPE.duration}ms ${SPRING_SHAPE.easing},margin-left ${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}@@ -550,7 +566,7 @@ 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] .bt-side-collapse,html[data-platform=darwin] .bt-side-collapse{display:none}+html[data-windows-titlebar] :is(.bt-side-collapse,.bt-rail-expand),html[data-platform=darwin] :is(.bt-side-collapse,.bt-rail-expand){display:none}/* The footer ends in the Bot row: the whale's settings seat, then Connect plugins. Everyother plugin's entry takes a whole row above it, in the shell's order, so none of themsqueezes the Bot row. */diff --git a/ds-bot/src/client/team-actions.js b/ds-bot/src/client/team-actions.jsindex d8ada868..10277071 100644--- a/ds-bot/src/client/team-actions.js+++ b/ds-bot/src/client/team-actions.js@@ -5,7 +5,7 @@ import { noteClientError } from './diagnostics.js'// source), requests to the host, and the notes the transcript keeps. The shell around the// views adds navigation and its own panels. `after` reads the team again once a request// is done; `partFor` maps a Bot id, or any part of its chat, to its current part.-export function teamActions({ call, after, partFor, roster, ui, live, cards, heldCards, turnClock }) {+export function teamActions({ call, after, partFor, roster, ui, live, cards, heldCards, turnClock, panelFolded }) {// A memory is a Bot's or a group chat's; both are opened by id.const memoryOf = id => (roster.getSnapshot().roomsById[id] ? { roomId: id } : { botId: id })// The panel on a side chat's view, on the chat the strip tab or menu named.@@ -23,6 +23,9 @@ export function teamActions({ call, after, partFor, roster, ui, live, cards, heltoggleDetails: (id, force) => {ui.set((state) => {const details = force || state.details !== id || state.view !== 'details' ? id : null+ // A folded panel is open but not shown: its opener then means "show it"+ // (the column yields it room), not "close it".+ if (details === null && panelFolded?.() === true) return { ...state, renaming: false, tab: null, details: id, view: 'details', panelYield: true }return { ...state, renaming: false, tab: null, details, view: 'details' }})},diff --git a/ds-bot/test/frame-layout.test.js b/ds-bot/test/frame-layout.test.jsnew file mode 100644index 00000000..313fe29b--- /dev/null+++ b/ds-bot/test/frame-layout.test.js@@ -0,0 +1,99 @@+import assert from 'node:assert/strict'+import { test } from 'node:test'+import {+ RAIL_WIDTH, DSH_NARROW,+ frameLayout, dshExpandedFor, userSidebarToggle,+} from '../src/client/frame-layout.js'++// The window, the shell sidebar's track width and what is open decide which left+// column shows and how the Bot panel sits; the chat keeps MIN_CHAT.+const at = (viewport, sidebarWidth, { pref = 'open', drawer = false, panel = null, collapsedWidth = 0 } = {}) =>+ frameLayout({ viewport, sidebarWidth, pref, drawer, panel, collapsedWidth })+const details = (yielded = false) => ({ view: 'details', yielded })+const browser = (yielded = false) => ({ view: 'browser', yielded })++test('a wide window keeps the open column and a shown panel', () => {+ const layout = at(1400, 280, { panel: details() })+ assert.deepEqual({ left: layout.left, panel: layout.panel }, { left: 'open', panel: 'shown' })+ assert.equal(layout.room, 1400 - 280)+})++test('the panel folds when column, panel and chat together do not fit', () => {+ // 280 + 320 + 420 = 1020 > 1000.+ const layout = at(1000, 280, { panel: details() })+ assert.deepEqual({ left: layout.left, panel: layout.panel }, { left: 'open', panel: 'folded' })+})++test('a yielded panel gets its room back from the rail', () => {+ // 88 + 320 + 420 = 828 <= 1000.+ const layout = at(1000, 280, { panel: details(true) })+ assert.deepEqual({ left: layout.left, panel: layout.panel }, { left: 'rail', panel: 'shown' })+ assert.equal(layout.room, 1000 - RAIL_WIDTH)+})++test('a yielded browser panel shows beside the rail, and only covers the chat below its minimum', () => {+ // 88 + 360 + 420 = 868.+ assert.equal(at(1000, 280, { panel: browser(true) }).panel, 'shown')+ const layout = at(760, 280, { panel: browser(true) })+ assert.deepEqual({ left: layout.left, panel: layout.panel }, { left: 'rail', panel: 'overlay' })+})++test('without a panel the column stays open while the chat fits, then folds to the rail', () => {+ // 280 + 420 = 700 <= 800, > 690.+ assert.equal(at(800, 280).left, 'open')+ assert.equal(at(800, 280).room, 800 - 280)+ assert.equal(at(690, 280).left, 'rail')+ assert.equal(at(690, 280).room, 690 - RAIL_WIDTH)+ assert.equal(at(690, 280, { drawer: true }).left, 'drawer')+ // A drawer floats over the chat: the room loses only the shell's collapsed track.+ assert.equal(at(690, 280, { drawer: true, collapsedWidth: 56 }).room, 690 - 56)+})++test('a rail preference keeps the rail beside a shown panel', () => {+ const layout = at(1400, 280, { pref: 'rail', panel: details() })+ assert.deepEqual({ left: layout.left, panel: layout.panel }, { left: 'rail', panel: 'shown' })+ assert.equal(layout.room, 1400 - RAIL_WIDTH)+})++test('a sidebar widened in Agent mode still folds the panel first', () => {+ // 420 + 320 + 420 = 1160 > 1100.+ const layout = at(1100, 420, { panel: details() })+ assert.deepEqual({ left: layout.left, panel: layout.panel }, { left: 'open', panel: 'folded' })+})++test('a folded panel in a drawer window keeps the drawer until the panel yields it', () => {+ const layout = at(690, 280, { drawer: true, panel: details() })+ assert.deepEqual({ left: layout.left, panel: layout.panel }, { left: 'drawer', panel: 'folded' })+ assert.equal(at(690, 280, { drawer: true, panel: details(true) }).left, 'rail')+})++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)+})++// A flip of the shell's collapsed flag is the user's switch gesture only when we+// did not request it and the window stayed on one side of the auto-collapse line.+test('a sidebar flip we requested is not a user toggle', () => {+ const before = { collapsed: false, viewport: 1400 }+ assert.equal(userSidebarToggle({ before, after: { collapsed: true, viewport: 1400 }, requested: true }), false)+})++test('a flip across the auto-collapse line is the shell rule, not a gesture', () => {+ const before = { collapsed: false, viewport: 1100 }+ assert.equal(userSidebarToggle({ before, after: { collapsed: true, viewport: 1000 } }), false)+})++test('an unrequested flip on one side of the line is the user', () => {+ const before = { collapsed: false, viewport: 1400 }+ assert.equal(userSidebarToggle({ before, after: { collapsed: true, viewport: 1300 } }), true)+ assert.equal(userSidebarToggle({ before: { collapsed: true, viewport: 800 }, after: { collapsed: false, viewport: 700 } }), true)+})diff --git a/ds-bot/test/sidebar-switch.test.js b/ds-bot/test/sidebar-switch.test.jsindex af4a499e..f787586c 100644--- a/ds-bot/test/sidebar-switch.test.js+++ b/ds-bot/test/sidebar-switch.test.js@@ -38,16 +38,16 @@ runInNewContext(outputFiles[0].text, {})const { SHELL_CSS, SIDEBAR_CSS, TeamSidebar } = module.exports-function navigationSidebar(wide, { shell = true } = {}) {+function navigationSidebar(wide, { leftDrawer = false } = {}) {const calls = []const refs = []- let collapsed = !wideconst bot = { id: 'writer', name: 'Writer', createdAt: 1 }const room = { id: 'room', name: 'Team', members: [], createdAt: 2 }const agent = { id: 'agent', sessions: ['session'], createdAt: 3 }const roster = { bots: [bot], rooms: [room], agents: [agent], byId: { writer: bot }, ready: true }const actions = Object.fromEntries(['openSession', 'openAgent', 'openAgentSession', 'newAgentSession'].map(name => [name, id => { calls.push([name, id]); return id }]))- actions.toggleSidebar = () => { collapsed = !collapsed; calls.push(['toggleSidebar']) }+ actions.toggleSidebar = () => { calls.push(['toggleSidebar']) }+ actions.setLeftDrawer = (on) => { calls.push(['setLeftDrawer', on]) }const rows = []const walk = (node) => {if (Array.isArray(node)) { node.forEach(walk); return }@@ -55,18 +55,14 @@ function navigationSidebar(wide, { shell = true } = {}) {if (['BotRow', 'RoomRow', 'AgentRow'].includes(node.type?.name)) rows.push(node)walk(node.props?.children)}- const render = (nextWide = shell ? wide : !collapsed) => {+ const render = (nextWide = wide) => {wide = nextWide- // The public owner action closes over the shell's committed collapsed state;- // wide may still be true during the shell's 150ms content fade-out.- const committedCollapsed = collapsedrenderRefs = refsrefIndex = 0layoutEffects = []const tree = TeamSidebar({wide, actions,- ...(shell ? { expandSidebar: () => { if (committedCollapsed) actions.toggleSidebar() } } : {}),- useRoster: pick => pick(roster), useUi: pick => pick({ unread: {} }), useRegistry: pick => pick({}),+ useRoster: pick => pick(roster), useUi: pick => pick({ unread: {}, leftDrawer }), useRegistry: pick => pick({}),useSessions: pick => pick({ ids: [], byId: {} }), useUpdate: () => ({}),})renderRefs = undefined@@ -77,12 +73,12 @@ function navigationSidebar(wide, { shell = true } = {}) {walk(tree)}render()- return { calls, rows, actions, render, get collapsed() { return collapsed } }+ return { calls, rows, actions, render }}for (const width of [390, 1023, 1024, 1280]) {for (const wide of [false, true]) {- test(`sidebar navigation at ${width}px with ${wide ? 'expanded content' : 'a collapsed rail'} only closes an open mobile sidebar`, () => {+ test(`sidebar navigation at ${width}px with ${wide ? 'expanded content' : 'our own column'} just navigates`, () => {viewport.innerWidth = widthconst initial = navigationSidebar(wide)assert.equal(initial.rows.length, 3)@@ -91,77 +87,25 @@ for (const width of [390, 1023, 1024, 1280]) {for (const name of names) {const { rows, calls } = navigationSidebar(wide)assert.equal(rows[index].props.actions[name]('selected'), 'selected')- assert.deepEqual(calls, wide && width < 1024 ? [[name, 'selected'], ['toggleSidebar']] : [[name, 'selected']])+ assert.deepEqual(calls, [[name, 'selected']])}}})}}-test('repeated sidebar navigation before another commit closes only once', () => {+test('a row picked from the floating drawer closes it', () => {viewport.innerWidth = 390- const side = navigationSidebar(true)- side.rows[0].props.actions.openAgent('first')- side.rows[1].props.actions.openSession('second')- assert.equal(side.collapsed, true)- assert.deepEqual(side.calls, [['openAgent', 'first'], ['toggleSidebar'], ['openSession', 'second']])+ const side = navigationSidebar(false, { leftDrawer: true })+ side.rows[0].props.actions.openSession('picked')+ assert.deepEqual(side.calls, [['openSession', 'picked'], ['setLeftDrawer', false]])})-test('the standalone UI can navigate without a shell expansion action', () => {+test('a row picked outside the drawer leaves it alone', () => {viewport.innerWidth = 390- // app/ui passes its actual wide state directly, without the DSH owner action.- const side = navigationSidebar(true, { shell: false })- side.rows[1].props.actions.openSession('first')- side.rows[2].props.actions.openSession('second')- assert.equal(side.collapsed, true)- assert.deepEqual(side.calls, [['openSession', 'first'], ['toggleSidebar'], ['openSession', 'second']])- side.render()- side.calls.length = 0- side.rows[1].props.actions.openSession('from-rail')- assert.deepEqual(side.calls, [['openSession', 'from-rail']])- side.actions.toggleSidebar()- side.render()- side.rows[2].props.actions.openSession('after-expansion')- assert.equal(side.collapsed, true)-})--test('navigation during the shell fade-out keeps the already collapsed sidebar closed', () => {- viewport.innerWidth = 390- const side = navigationSidebar(true)- side.rows[0].props.actions.openAgentSession('first')- assert.equal(side.collapsed, true)- side.render(true)- side.calls.length = 0- side.rows[1].props.actions.openSession('during-fade')- assert.equal(side.collapsed, true, 'wide remains true until the content fade settles')- assert.equal(side.calls.filter(([name]) => name === 'openSession').length, 1)-})--test('a sidebar reopened before wide becomes false still closes on the next navigation', () => {- viewport.innerWidth = 390- const side = navigationSidebar(true)- side.rows[0].props.actions.openAgent('first')- side.render(true)- side.actions.toggleSidebar()- side.render(true)- assert.equal(side.collapsed, false)- side.rows[1].props.actions.openSession('after-reopen')- assert.equal(side.collapsed, true)-})--test('the navigation guard resets across a full collapse and expansion cycle', () => {- viewport.innerWidth = 390- const side = navigationSidebar(true)- side.rows[0].props.actions.newAgentSession('first')- side.render(false)- side.calls.length = 0- side.rows[1].props.actions.openSession('from-rail')- assert.equal(side.collapsed, true)- assert.deepEqual(side.calls, [['openSession', 'from-rail']])- side.actions.toggleSidebar()- side.render(true)- side.rows[1].props.actions.openSession('after-expansion')- assert.equal(side.collapsed, true)+ const side = navigationSidebar(false)+ side.rows[0].props.actions.openSession('picked')+ assert.deepEqual(side.calls, [['openSession', 'picked']])})// A Bot working in its own chat previews what it is doing, the way a group row does@@ -325,14 +269,14 @@ for (const platform of ['web', 'windows', 'mac']) {}}-test('an open sidebar has a button that collapses it; the rail leaves that to the shell', () => {+test('an open sidebar has a button that folds it to the rail; the rail offers the way back', () => {const calls = []const roster = { bots: [], rooms: [], agents: [], byId: {}, ready: true }const props = wide => ({wide,useRoster: pick => pick(roster), useUi: pick => pick({ unread: {} }), useRegistry: pick => pick({}),useSessions: pick => pick({ ids: [], byId: {} }), useUpdate: () => ({}),- actions: { toggleSidebar: () => calls.push('toggle') },+ actions: { setSidebarPref: pref => calls.push(pref), setLeftDrawer: on => calls.push(['drawer', on]), toggleSidebar: () => calls.push('toggle') },})const find = (node, match) => {if (Array.isArray(node)) return node.map(child => find(child, match)).find(Boolean)@@ -343,8 +287,13 @@ test('an open sidebar has a button that collapses it; the rail leaves that to thconst button = find(TeamSidebar(props(true)), collapse)assert.ok(button?.props.className.split(' ').includes('bt-side-collapse'))button.props.onClick()- assert.deepEqual(calls, ['toggle'])- assert.equal(find(TeamSidebar(props(false)), collapse), undefined)+ 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'))})test('the logo row takes no room in an open sidebar under a Windows title bar', () => {diff --git a/ds-bot/test/styles.test.js b/ds-bot/test/styles.test.jsindex d714f3fd..dfd6f82c 100644--- a/ds-bot/test/styles.test.js+++ b/ds-bot/test/styles.test.js@@ -161,7 +161,7 @@ test('mounting and unmounting compiled styles twice leaves no extra nodes', asyn})test('the chat-room rule is installed through installStyles, so it is owned too', () => {- const pane = readFileSync(new URL('../src/client/browser-pane.js', import.meta.url), 'utf8')+ const pane = readFileSync(new URL('../src/client/frame-watch.js', import.meta.url), 'utf8')assert.match(pane, /installStyles\(.*'chat-room'/)assert.equal(pane.includes("dataset.dshBot = 'chat-room'"), false)})