Skip to content

A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.

Keep the chat still and the shell's sidebar hidden through every switch

Fei2411dda1a001cc6b
diff --git a/ds-bot/client.js b/ds-bot/client.js
index ab9cf4a3..c31fe0e1 100644
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@ -1512,9 +1512,9 @@ function countCards(state, sessionId, callIds, delta) {
// src/client/team-actions.js
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 yieldTo = (view) => panelFolded?.(view) === true;
+ const yieldTo = (state, view) => state.panelYield === true || panelFolded?.(view) === true;
const openSideChat = (sessionId, chatId) => {
- ui2.set((state) => ({ ...state, details: sessionId, view: "side", side: chatId ?? null, renaming: false, tab: null, panelYield: yieldTo("side") }));
+ ui2.set((state) => ({ ...state, details: sessionId, view: "side", side: chatId ?? null, renaming: false, tab: null, panelYield: yieldTo(state, "side") }));
};
return {
openNewChat: (mode) => {
@@ -1539,7 +1539,7 @@ function teamActions({ call: call2, after, partFor, roster, ui: ui2, live, cards
toggleDetails: (id, force) => {
ui2.set((state) => {
const details = force || state.details !== id || state.view !== "details" ? id : null;
- if (details === null && yieldTo("details")) return { ...state, renaming: false, tab: null, details: id, view: "details", panelYield: true };
+ if (details === null && panelFolded?.("details") === true) return { ...state, renaming: false, tab: null, details: id, view: "details", panelYield: true };
return { ...state, renaming: false, tab: null, details, view: "details" };
});
},
@@ -1555,11 +1555,11 @@ function teamActions({ call: call2, after, partFor, roster, ui: ui2, live, cards
});
},
showDetails: (id, tab = null) => {
- ui2.set((state) => ({ ...state, details: id, view: "details", renaming: false, tab, panelYield: yieldTo("details") }));
+ ui2.set((state) => ({ ...state, details: id, view: "details", renaming: false, tab, panelYield: yieldTo(state, "details") }));
},
// Opening the conversation would move focus to its composer and blur the name field.
renameBot: (id) => {
- ui2.set((state) => ({ ...state, details: id, view: "details", renaming: true, tab: null, panelYield: yieldTo("details") }));
+ ui2.set((state) => ({ ...state, details: id, view: "details", renaming: true, tab: null, panelYield: yieldTo(state, "details") }));
},
// `id` opens one Bot (page 'bots') or one group chat (page 'groups').
openSettings: (page = "general", id = null) => {
@@ -1579,7 +1579,7 @@ function teamActions({ call: call2, after, partFor, roster, ui: ui2, live, cards
},
setPanelView: (view) => {
if (view !== "details" && view !== "browser" && view !== "side") return;
- ui2.set((state) => state.details && state.view !== view ? { ...state, view, panelYield: yieldTo(view) } : state);
+ ui2.set((state) => state.details && state.view !== view ? { ...state, view, panelYield: yieldTo(state, view) } : state);
},
// A side chat on the panel's own view, opened from the strip, the `···`
// menus or `/side`. Closing the panel keeps the chats; only a tab's × deletes.
@@ -2473,9 +2473,9 @@ body[data-bt-motion=quiet] .bt-mark[data-poke]{cursor:default}
Mica the app styles DSH's sidebar the same way, via --bt-leftcol-fill there);
it stays under the shell's title-bar switch (z 30) and the popovers (z 60),
and the floating drawer keeps the opaque fill over the conversation. */
-.bt-leftcol{position:fixed;left:0;top:0;bottom:0;z-index:25;display:flex;--bt-lc-clear:var(--dsh-frame-top-clearance,var(--dsh-windows-titlebar-height,0px));background:var(--bt-leftcol-fill,var(--dsw-specific-sidebar-fill));border-right:.5px solid var(--bt-line);box-sizing:border-box;padding:calc(var(--bt-lc-clear) + 6px) 12px 6px;color:var(--bt-ink);font-family:var(--bt-font)}
+.bt-leftcol{position:fixed;left:0;top:0;bottom:0;z-index:25;display:flex;--bt-lc-clear:var(--dsh-frame-top-clearance,var(--dsh-windows-titlebar-height,0px));background:var(--bt-leftcol-fill,var(--bt-sidebar));border-right:.5px solid var(--bt-line);box-sizing:border-box;padding:calc(var(--bt-lc-clear) + 6px) 12px 6px;color:var(--bt-ink);font-family:var(--bt-font)}
html[data-windows-titlebar] .bt-leftcol,html[data-platform=darwin] .bt-leftcol{border-right:none}
-.bt-leftcol[data-left=drawer]{background:var(--dsw-specific-sidebar-fill);box-shadow:8px 0 24px rgba(0,0,0,.14)}
+.bt-leftcol[data-left=drawer]{background:var(--bt-sidebar);box-shadow:8px 0 24px rgba(0,0,0,.14)}
.bt-leftcol>.bt-side{width:100%}
.bt-leftcol-foot{display:flex;align-items:center;gap:9px;padding-top:8px;flex:none}
.bt-rail{align-items:center;padding:0}
@@ -2483,8 +2483,10 @@ html[data-windows-titlebar] .bt-leftcol,html[data-platform=darwin] .bt-leftcol{b
.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:calc(var(--bt-lc-clear) + 8px) 16px 8px}
+.bt-rail .bt-list{align-self:stretch;align-items:center;gap:4px}
+/* The rail's list spans the whole column: the badges and dots that sit on a row's
+ edge need room beside the 56px rows, or the list scrolls sideways. */
+.bt-leftcol[data-left=rail]{padding:calc(var(--bt-lc-clear) + 8px) 0 8px}
.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)}
@@ -8500,10 +8502,10 @@ 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 }) {
+function frameLayout({ viewport, sidebarWidth, pref, drawer = false, panel = null }) {
const fits = pref === "open" && viewport >= sidebarWidth + MIN_CHAT;
let left = fits ? "open" : drawer && pref === "open" ? "drawer" : "rail";
- let occupied = left === "open" ? sidebarWidth : left === "rail" ? RAIL_WIDTH : collapsedWidth;
+ let occupied = left === "open" ? sidebarWidth : RAIL_WIDTH;
let panelState = "none";
if (panel !== null) {
const need = (PANEL_MIN[panel.view] ?? PANEL_MIN.details) + MIN_CHAT;
@@ -8517,7 +8519,8 @@ function frameLayout({ viewport, sidebarWidth, collapsedWidth = 0, pref, drawer
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;
+var RESIZE_SETTLE_MS = 500;
+var userSidebarToggle = ({ before, after, requested = false, sinceResize = Infinity }) => before.collapsed !== after.collapsed && !requested && sinceResize >= RESIZE_SETTLE_MS && before.viewport < DSH_NARROW === after.viewport < DSH_NARROW;
function readSidebarPref(storage = globalThis.localStorage) {
try {
return storage.getItem(STORAGE.sidebar) === "rail" ? "rail" : "open";
@@ -8948,7 +8951,6 @@ function TeamSidebar(props) {
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
@@ -8974,23 +8976,35 @@ function TeamSidebar(props) {
useListGlide(listRef, wideContent, order.map((entry) => entry.item.id).join(","));
useLandOnMainBot(roster, useSessions, actions);
const ourWidth = layout.left === "rail" ? RAIL_WIDTH : frameSnap.sidebarWidth;
+ const pushed = layout.left === "open" ? frameSnap.sidebarWidth : RAIL_WIDTH;
(0, import_react15.useLayoutEffect)(() => {
if (typeof document === "undefined") return;
- chatRoom.setLeft(mode === "inline" || mode === "drawer" ? null : Math.max(0, ourWidth - (frameSnap.collapsedWidth ?? 0)));
- }, [mode, ourWidth, frameSnap.collapsedWidth]);
+ chatRoom.setLeft(mode === "inline" ? null : Math.max(0, pushed - (frameSnap.collapsedWidth ?? 0)));
+ }, [mode, pushed, frameSnap.collapsedWidth]);
(0, import_react15.useEffect)(() => () => {
if (typeof document !== "undefined") chatRoom.setLeft(null);
}, []);
const dsh = (0, import_react15.useRef)(null);
const requested = (0, import_react15.useRef)(false);
+ const requestLapse = (0, import_react15.useRef)(0);
+ (0, import_react15.useEffect)(() => () => clearTimeout(requestLapse.current), []);
+ const resizedAt = (0, import_react15.useRef)(0);
+ (0, import_react15.useEffect)(() => {
+ const onResize = () => {
+ resizedAt.current = performance.now();
+ };
+ window.addEventListener("resize", onResize);
+ return () => window.removeEventListener("resize", onResize);
+ }, []);
(0, import_react15.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 };
+ const viewport = window.innerWidth;
+ dsh.current = { collapsed, 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 } })) {
+ else if (userSidebarToggle({ before: prev, after: { collapsed, viewport }, sinceResize: performance.now() - resizedAt.current })) {
if (prev.left === "open") actions.setSidebarPref?.("rail");
else {
actions.setSidebarPref?.("open");
@@ -9008,10 +9022,11 @@ function TeamSidebar(props) {
if (requested.current) return void 0;
requested.current = true;
actions.toggleSidebar();
- const timer = setTimeout(() => {
+ clearTimeout(requestLapse.current);
+ requestLapse.current = setTimeout(() => {
requested.current = false;
}, 300);
- return () => clearTimeout(timer);
+ return void 0;
}, [wide, frameSnap.viewport, frameSnap.sidebarWidth, layout.left]);
(0, import_react15.useEffect)(() => {
if (mode !== "drawer") return void 0;
@@ -9051,6 +9066,7 @@ function TeamSidebar(props) {
actions.openPalette(event.key);
};
const expandLeft = () => {
+ actions.setPanelYield?.(false);
actions.setSidebarPref?.("open");
if (frameSnap.viewport < frameSnap.sidebarWidth + MIN_CHAT) actions.setLeftDrawer?.(true);
};
@@ -9061,6 +9077,20 @@ function TeamSidebar(props) {
} else if (layout.left === "drawer") actions.setLeftDrawer?.(false);
else expandLeft();
};
+ const toggleRef = (0, import_react15.useRef)(onTitleToggle);
+ toggleRef.current = onTitleToggle;
+ (0, import_react15.useEffect)(() => {
+ const onKey = (event) => {
+ if (event.defaultPrevented || event.isComposing || !pressesShellShortcut(event, "sidebar.left.toggle")) return;
+ if (event.target instanceof Element && event.target.closest(".xterm")) return;
+ if (document.querySelector('[aria-modal="true"]')) return;
+ event.preventDefault();
+ event.stopPropagation();
+ toggleRef.current();
+ };
+ document.addEventListener("keydown", onKey, true);
+ return () => document.removeEventListener("keydown", onKey, true);
+ }, []);
const top = wideContent ? (0, import_react15.createElement)(
"div",
{ className: "bt-side-top" },
@@ -9294,6 +9324,12 @@ function pressSettingsShortcut() {
metaKey: held.has("meta")
}));
}
+function pressesShellShortcut(event, id) {
+ const binding = shellShortcuts?.catalog.getSnapshot().find((row) => row.id === id)?.binding;
+ if (!binding) return false;
+ const held = new Set(binding.modifiers);
+ return event.code === binding.code && event.ctrlKey === held.has("control") && event.altKey === held.has("alt") && event.shiftKey === held.has("shift") && event.metaKey === held.has("meta");
+}
var NO_SUBSCRIBE = () => () => {
};
var NO_SNAPSHOT = () => null;
@@ -17859,7 +17895,6 @@ function Overlays({ useRoster, useUi, useSessions, useSessionStatus, useActivity
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
@@ -19471,8 +19506,9 @@ function apply(ctx) {
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: view ?? state.view, yielded: false } }).panel === "folded";
+ return frameLayout({ viewport: f.viewport, sidebarWidth: f.sidebarWidth, pref: sidebarPref.getSnapshot(), drawer: state.leftDrawer, panel: { view: view ?? state.view, yielded: state.panelYield === true } }).panel === "folded";
};
+ const yieldBrowser = (state) => state.panelYield === true || panelFolded("browser");
const actions = {
...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
@@ -19623,7 +19659,7 @@ function apply(ctx) {
if (!bot) return;
browsers.ensureTabs(bot.id);
if (browsers.tabs.getSnapshot()[bot.id]?.active == null) browsers.openTab(bot.id);
- ui2.set((state) => ({ ...state, details: id, view: "browser", renaming: false, tab: null, panelYield: panelFolded("browser") }));
+ ui2.set((state) => ({ ...state, details: id, view: "browser", renaming: false, tab: null, panelYield: yieldBrowser(state) }));
},
// '+' on the strip or the drawer's new-tab card: a blank tab in the browser view.
browserNewTab: (id) => {
@@ -19631,7 +19667,7 @@ function apply(ctx) {
if (!bot) return null;
browsers.ensureTabs(bot.id);
const tabId = browsers.openTab(bot.id);
- ui2.set((state) => ({ ...state, details: id, view: "browser", renaming: false, tab: null, panelYield: panelFolded("browser") }));
+ ui2.set((state) => ({ ...state, details: id, view: "browser", renaming: false, tab: null, panelYield: yieldBrowser(state) }));
return tabId;
},
// A drawer card: its tab active, the panel on the browser view.
@@ -19639,7 +19675,7 @@ function apply(ctx) {
const bot = roster.getSnapshot().byId[id];
if (!bot) return;
browsers.activate(bot.id, tabId);
- ui2.set((state) => ({ ...state, details: id, view: "browser", panelYield: panelFolded("browser") }));
+ ui2.set((state) => ({ ...state, details: id, view: "browser", panelYield: yieldBrowser(state) }));
},
browserEnsure: (botId) => browsers.ensureTabs(botId),
browserCloseTab: (botId, tabId) => browsers.closeTab(botId, tabId),
@@ -19871,7 +19907,7 @@ function apply(ctx) {
const f = frame.getSnapshot();
const opened = s.details !== null && lastDetails === null;
lastDetails = s.details;
- 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 } });
+ const layout = frameLayout({ viewport: f.viewport, sidebarWidth: f.sidebarWidth, 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);
diff --git a/ds-bot/src/client/frame-layout.js b/ds-bot/src/client/frame-layout.js
index e1c59d70..430e9aea 100644
--- a/ds-bot/src/client/frame-layout.js
+++ b/ds-bot/src/client/frame-layout.js
@@ -16,18 +16,18 @@ export const DSH_NARROW = 1024
export const FALLBACK_SIDEBAR_WIDTH = 280
/**
- * @param {{viewport: number, sidebarWidth: number, collapsedWidth?: number,
+ * @param {{viewport: number, sidebarWidth: 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).
+ * what the left column occupies (its full width when open, else the rail's —
+ * a drawer floats over the rail's place, so the chat does not move under it).
*/
-export function frameLayout({ viewport, sidebarWidth, collapsedWidth = 0, pref, drawer = false, panel = null }) {
+export function frameLayout({ viewport, sidebarWidth, pref, drawer = false, panel = null }) {
const fits = pref === 'open' && viewport >= sidebarWidth + MIN_CHAT
let left = fits ? 'open' : drawer && pref === 'open' ? 'drawer' : 'rail'
- let occupied = left === 'open' ? sidebarWidth : left === 'rail' ? RAIL_WIDTH : collapsedWidth
+ let occupied = left === 'open' ? sidebarWidth : RAIL_WIDTH
let panelState = 'none'
if (panel !== null) {
const need = (PANEL_MIN[panel.view] ?? PANEL_MIN.details) + MIN_CHAT
@@ -47,11 +47,16 @@ export function frameLayout({ viewport, sidebarWidth, collapsedWidth = 0, pref,
// window; under DSH_NARROW it is always collapsed and our own column draws.
export const dshExpandedFor = (viewport, left) => viewport >= DSH_NARROW && left === 'open'
+// The shell measures the window on its own frame, a beat apart from us, and
+// re-applies its own rule when it does: a flip this soon after a width change is
+// the shell settling, not a gesture.
+export const RESIZE_SETTLE_MS = 500
// 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)
+// only when we did not request it, the width has settled, and it 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, sinceResize = Infinity }) =>
+ before.collapsed !== after.collapsed && !requested && sinceResize >= RESIZE_SETTLE_MS
+ && (before.viewport < DSH_NARROW) === (after.viewport < DSH_NARROW)
// The user's sidebar preference survives restarts: 'open' by default, 'rail'
// after they collapse the column themselves.
diff --git a/ds-bot/src/client/index.js b/ds-bot/src/client/index.js
index c10167b3..fa29efa2 100644
--- a/ds-bot/src/client/index.js
+++ b/ds-bot/src/client/index.js
@@ -383,13 +383,15 @@ export function apply(ctx) {
const mainView = () => Object.values(ctx.sessions.list.getSnapshot().byId ?? {}).find(session => (session?.retainedBy?.mainView ?? 0) > 0)?.id
const 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".
+ // means "show it" (the column yields), not "close it". A panel shown because
+ // the column already yielded is not folded, so its opener closes it.
const panelFolded = (view) => {
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: view ?? state.view, yielded: false } }).panel === 'folded'
+ return frameLayout({ viewport: f.viewport, sidebarWidth: f.sidebarWidth, pref: sidebarPref.getSnapshot(), drawer: state.leftDrawer, panel: { view: view ?? state.view, yielded: state.panelYield === true } }).panel === 'folded'
}
+ const yieldBrowser = state => state.panelYield === true || panelFolded('browser')
const actions = {
...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
@@ -541,7 +543,7 @@ export function apply(ctx) {
if (!bot) return
browsers.ensureTabs(bot.id)
if (browsers.tabs.getSnapshot()[bot.id]?.active == null) browsers.openTab(bot.id)
- ui.set(state => ({ ...state, details: id, view: 'browser', renaming: false, tab: null, panelYield: panelFolded('browser') }))
+ ui.set(state => ({ ...state, details: id, view: 'browser', renaming: false, tab: null, panelYield: yieldBrowser(state) }))
},
// '+' on the strip or the drawer's new-tab card: a blank tab in the browser view.
browserNewTab: (id) => {
@@ -549,7 +551,7 @@ export function apply(ctx) {
if (!bot) return null
browsers.ensureTabs(bot.id)
const tabId = browsers.openTab(bot.id)
- ui.set(state => ({ ...state, details: id, view: 'browser', renaming: false, tab: null, panelYield: panelFolded('browser') }))
+ ui.set(state => ({ ...state, details: id, view: 'browser', renaming: false, tab: null, panelYield: yieldBrowser(state) }))
return tabId
},
// A drawer card: its tab active, the panel on the browser view.
@@ -557,7 +559,7 @@ export function apply(ctx) {
const bot = roster.getSnapshot().byId[id]
if (!bot) return
browsers.activate(bot.id, tabId)
- ui.set(state => ({ ...state, details: id, view: 'browser', panelYield: panelFolded('browser') }))
+ ui.set(state => ({ ...state, details: id, view: 'browser', panelYield: yieldBrowser(state) }))
},
browserEnsure: botId => browsers.ensureTabs(botId),
browserCloseTab: (botId, tabId) => browsers.closeTab(botId, tabId),
@@ -810,7 +812,7 @@ export function apply(ctx) {
// team-actions carry the yield themselves.
const opened = s.details !== null && lastDetails === null
lastDetails = s.details
- 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 } })
+ const layout = frameLayout({ viewport: f.viewport, sidebarWidth: f.sidebarWidth, 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)
diff --git a/ds-bot/src/client/overlays.js b/ds-bot/src/client/overlays.js
index d8350696..31368113 100644
--- a/ds-bot/src/client/overlays.js
+++ b/ds-bot/src/client/overlays.js
@@ -35,7 +35,7 @@ export function Overlays({ useRoster, useUi, useSessions, useSessionStatus, useA
// 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,
+ viewport: frameSnap.viewport, sidebarWidth: frameSnap.sidebarWidth,
pref, drawer: ui.leftDrawer === true,
panel: open ? { view: open.view, yielded: ui.panelYield === true } : null,
})
diff --git a/ds-bot/src/client/sidebar.js b/ds-bot/src/client/sidebar.js
index 6d08e9cc..2238acc2 100644
--- a/ds-bot/src/client/sidebar.js
+++ b/ds-bot/src/client/sidebar.js
@@ -283,7 +283,7 @@ export function TeamSidebar(props) {
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,
+ viewport: frameSnap.viewport, sidebarWidth: frameSnap.sidebarWidth,
pref, drawer: uiNow.leftDrawer === true,
panel: uiNow.details ? { view: uiNow.view, yielded: uiNow.panelYield === true } : null,
})
@@ -310,12 +310,14 @@ export function TeamSidebar(props) {
useLandOnMainBot(roster, useSessions, actions)
// Our column pushes the conversation over by what it takes beyond the shell's
- // collapsed track; a floating drawer does not push.
+ // collapsed track; a drawer floats over the rail's place, so it pushes as much
+ // as the rail and the chat stays put when it opens or closes.
const ourWidth = layout.left === 'rail' ? RAIL_WIDTH : frameSnap.sidebarWidth
+ const pushed = layout.left === 'open' ? frameSnap.sidebarWidth : RAIL_WIDTH
useLayoutEffect(() => {
if (typeof document === 'undefined') return
- chatRoom.setLeft(mode === 'inline' || mode === 'drawer' ? null : Math.max(0, ourWidth - (frameSnap.collapsedWidth ?? 0)))
- }, [mode, ourWidth, frameSnap.collapsedWidth])
+ chatRoom.setLeft(mode === 'inline' ? null : Math.max(0, pushed - (frameSnap.collapsedWidth ?? 0)))
+ }, [mode, pushed, frameSnap.collapsedWidth])
useEffect(() => () => { if (typeof document !== 'undefined') chatRoom.setLeft(null) }, [])
// The shell sidebar's collapsed flag follows what our column needs. A flip we
@@ -323,14 +325,27 @@ export function TeamSidebar(props) {
// button or shortcut), unless the width just crossed the auto-collapse line.
const dsh = useRef(null)
const requested = useRef(false)
+ // The request mark always lapses on its own: a re-render before the shell's
+ // flip must not leave it set, or the user's next switch would read as ours.
+ const requestLapse = useRef(0)
+ useEffect(() => () => clearTimeout(requestLapse.current), [])
+ // The window's own resize event lands before the shell's next-frame measure,
+ // so it dates a width change even while our frame source still holds the old one.
+ const resizedAt = useRef(0)
+ useEffect(() => {
+ const onResize = () => { resizedAt.current = performance.now() }
+ window.addEventListener('resize', onResize)
+ return () => window.removeEventListener('resize', onResize)
+ }, [])
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 }
+ const viewport = window.innerWidth
+ dsh.current = { collapsed, 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 } })) {
+ else if (userSidebarToggle({ before: prev, after: { collapsed, viewport }, sinceResize: performance.now() - resizedAt.current })) {
// The last explicit gesture wins: fold to the rail, or open the column —
// as a drawer when it no longer fits docked.
if (prev.left === 'open') actions.setSidebarPref?.('rail')
@@ -347,8 +362,9 @@ export function TeamSidebar(props) {
if (requested.current) return undefined
requested.current = true
actions.toggleSidebar()
- const timer = setTimeout(() => { requested.current = false }, 300)
- return () => clearTimeout(timer)
+ clearTimeout(requestLapse.current)
+ requestLapse.current = setTimeout(() => { requested.current = false }, 300)
+ return undefined
}, [wide, frameSnap.viewport, frameSnap.sidebarWidth, layout.left])
// The drawer closes on a row pick, on Escape and on a press outside it.
@@ -388,7 +404,10 @@ export function TeamSidebar(props) {
event.preventDefault()
actions.openPalette(event.key)
}
+ // Opening the column is the latest explicit gesture: it takes back the room a
+ // yielded panel had, and opens as a drawer when it cannot dock.
const expandLeft = () => {
+ actions.setPanelYield?.(false)
actions.setSidebarPref?.('open')
if (frameSnap.viewport < frameSnap.sidebarWidth + MIN_CHAT) actions.setLeftDrawer?.(true)
}
@@ -397,6 +416,23 @@ export function TeamSidebar(props) {
else if (layout.left === 'drawer') actions.setLeftDrawer?.(false)
else expandLeft()
}
+ // The shell's sidebar shortcut is caught on its way down, before the shell's
+ // own listener on window sees it: left to the shell, it would expand the shell's
+ // sidebar first and our sync would pull it back, a visible flash.
+ const toggleRef = useRef(onTitleToggle)
+ toggleRef.current = onTitleToggle
+ useEffect(() => {
+ const onKey = (event) => {
+ if (event.defaultPrevented || event.isComposing || !pressesShellShortcut(event, 'sidebar.left.toggle')) return
+ if (event.target instanceof Element && event.target.closest('.xterm')) return
+ if (document.querySelector('[aria-modal="true"]')) return
+ event.preventDefault()
+ event.stopPropagation()
+ toggleRef.current()
+ }
+ document.addEventListener('keydown', onKey, true)
+ return () => document.removeEventListener('keydown', onKey, true)
+ }, [])
const top = wideContent
? h('div', { className: 'bt-side-top' },
h('span', { className: 'bt-brand' }, h(BrandMark, { size: 22 }), h(BrandName)),
@@ -598,6 +634,15 @@ function pressSettingsShortcut() {
}))
}
+// Whether a key press is the shell's current binding for one of its shortcuts.
+function pressesShellShortcut(event, id) {
+ const binding = shellShortcuts?.catalog.getSnapshot().find(row => row.id === id)?.binding
+ if (!binding) return false
+ const held = new Set(binding.modifiers)
+ return event.code === binding.code && event.ctrlKey === held.has('control') && event.altKey === held.has('alt')
+ && event.shiftKey === held.has('shift') && event.metaKey === held.has('meta')
+}
+
const NO_SUBSCRIBE = () => () => {}
const NO_SNAPSHOT = () => null
diff --git a/ds-bot/src/client/styles.js b/ds-bot/src/client/styles.js
index 6880591b..f35848b3 100644
--- a/ds-bot/src/client/styles.js
+++ b/ds-bot/src/client/styles.js
@@ -149,9 +149,9 @@ body[data-bt-motion=quiet] .bt-mark[data-poke]{cursor:default}
Mica the app styles DSH's sidebar the same way, via --bt-leftcol-fill there);
it stays under the shell's title-bar switch (z 30) and the popovers (z 60),
and the floating drawer keeps the opaque fill over the conversation. */
-.bt-leftcol{position:fixed;left:0;top:0;bottom:0;z-index:25;display:flex;--bt-lc-clear:var(--dsh-frame-top-clearance,var(--dsh-windows-titlebar-height,0px));background:var(--bt-leftcol-fill,var(--dsw-specific-sidebar-fill));border-right:.5px solid var(--bt-line);box-sizing:border-box;padding:calc(var(--bt-lc-clear) + 6px) 12px 6px;color:var(--bt-ink);font-family:var(--bt-font)}
+.bt-leftcol{position:fixed;left:0;top:0;bottom:0;z-index:25;display:flex;--bt-lc-clear:var(--dsh-frame-top-clearance,var(--dsh-windows-titlebar-height,0px));background:var(--bt-leftcol-fill,var(--bt-sidebar));border-right:.5px solid var(--bt-line);box-sizing:border-box;padding:calc(var(--bt-lc-clear) + 6px) 12px 6px;color:var(--bt-ink);font-family:var(--bt-font)}
html[data-windows-titlebar] .bt-leftcol,html[data-platform=darwin] .bt-leftcol{border-right:none}
-.bt-leftcol[data-left=drawer]{background:var(--dsw-specific-sidebar-fill);box-shadow:8px 0 24px rgba(0,0,0,.14)}
+.bt-leftcol[data-left=drawer]{background:var(--bt-sidebar);box-shadow:8px 0 24px rgba(0,0,0,.14)}
.bt-leftcol>.bt-side{width:100%}
.bt-leftcol-foot{display:flex;align-items:center;gap:9px;padding-top:8px;flex:none}
.bt-rail{align-items:center;padding:0}
@@ -159,8 +159,10 @@ html[data-windows-titlebar] .bt-leftcol,html[data-platform=darwin] .bt-leftcol{b
.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:calc(var(--bt-lc-clear) + 8px) 16px 8px}
+.bt-rail .bt-list{align-self:stretch;align-items:center;gap:4px}
+/* The rail's list spans the whole column: the badges and dots that sit on a row's
+ edge need room beside the 56px rows, or the list scrolls sideways. */
+.bt-leftcol[data-left=rail]{padding:calc(var(--bt-lc-clear) + 8px) 0 8px}
.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)}
diff --git a/ds-bot/src/client/team-actions.js b/ds-bot/src/client/team-actions.js
index 8fc17628..324dd949 100644
--- a/ds-bot/src/client/team-actions.js
+++ b/ds-bot/src/client/team-actions.js
@@ -10,11 +10,12 @@ export function teamActions({ call, after, partFor, roster, ui, live, cards, hel
const memoryOf = id => (roster.getSnapshot().roomsById[id] ? { roomId: id } : { botId: id })
// An action that shows the panel lands the yield with it: when a folded
// panel's explicit opener fires, the column gives way in the same set.
- // `view` is the next view, since its minimum decides what fits.
- const yieldTo = view => panelFolded?.(view) === true
+ // `view` is the next view, since its minimum decides what fits; a yield already
+ // given stays.
+ const yieldTo = (state, view) => state.panelYield === true || panelFolded?.(view) === true
// The panel on a side chat's view, on the chat the strip tab or menu named.
const openSideChat = (sessionId, chatId) => {
- ui.set(state => ({ ...state, details: sessionId, view: 'side', side: chatId ?? null, renaming: false, tab: null, panelYield: yieldTo('side') }))
+ ui.set(state => ({ ...state, details: sessionId, view: 'side', side: chatId ?? null, renaming: false, tab: null, panelYield: yieldTo(state, 'side') }))
}
return {
openNewChat: (mode) => { ui.set(state => ({ ...state, newChat: mode, menu: null, palette: null })) },
@@ -29,7 +30,7 @@ export function teamActions({ call, after, partFor, roster, ui, live, cards, hel
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 && yieldTo('details')) return { ...state, renaming: false, tab: null, details: id, view: 'details', panelYield: true }
+ if (details === null && panelFolded?.('details') === true) return { ...state, renaming: false, tab: null, details: id, view: 'details', panelYield: true }
return { ...state, renaming: false, tab: null, details, view: 'details' }
})
},
@@ -46,9 +47,9 @@ export function teamActions({ call, after, partFor, roster, ui, live, cards, hel
return { ...state, details: id, view, renaming: false, tab: null }
})
},
- showDetails: (id, tab = null) => { ui.set(state => ({ ...state, details: id, view: 'details', renaming: false, tab, panelYield: yieldTo('details') })) },
+ showDetails: (id, tab = null) => { ui.set(state => ({ ...state, details: id, view: 'details', renaming: false, tab, panelYield: yieldTo(state, 'details') })) },
// Opening the conversation would move focus to its composer and blur the name field.
- renameBot: (id) => { ui.set(state => ({ ...state, details: id, view: 'details', renaming: true, tab: null, panelYield: yieldTo('details') })) },
+ renameBot: (id) => { ui.set(state => ({ ...state, details: id, view: 'details', renaming: true, tab: null, panelYield: yieldTo(state, 'details') })) },
// `id` opens one Bot (page 'bots') or one group chat (page 'groups').
openSettings: (page = 'general', id = null) => { ui.set(state => ({ ...state, settings: { page, id }, menu: null, palette: null, newChat: null })) },
closeSettings: () => { ui.set(state => (state.settings ? { ...state, settings: null } : state)) },
@@ -57,7 +58,7 @@ export function teamActions({ call, after, partFor, roster, ui, live, cards, hel
openConnectors: () => { ui.set(state => ({ ...state, settings: { page: 'connectors', id: null }, menu: null, palette: null, newChat: null })) },
setPanelView: (view) => {
if (view !== 'details' && view !== 'browser' && view !== 'side') return
- ui.set(state => (state.details && state.view !== view ? { ...state, view, panelYield: yieldTo(view) } : state))
+ ui.set(state => (state.details && state.view !== view ? { ...state, view, panelYield: yieldTo(state, view) } : state))
},
// A side chat on the panel's own view, opened from the strip, the `···`
// menus or `/side`. Closing the panel keeps the chats; only a tab's × deletes.
diff --git a/ds-bot/test/frame-layout.test.js b/ds-bot/test/frame-layout.test.js
index 7aeff6a0..1d77fc28 100644
--- a/ds-bot/test/frame-layout.test.js
+++ b/ds-bot/test/frame-layout.test.js
@@ -9,8 +9,8 @@ import { teamActions } from '../src/client/team-actions.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 at = (viewport, sidebarWidth, { pref = 'open', drawer = false, panel = null } = {}) =>
+ frameLayout({ viewport, sidebarWidth, pref, drawer, panel })
const details = (yielded = false) => ({ view: 'details', yielded })
const browser = (yielded = false) => ({ view: 'browser', yielded })
@@ -47,8 +47,8 @@ test('without a panel the column stays open while the chat fits, then folds to t
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)
+ // A drawer floats over the rail's place: the chat keeps the room it had beside the rail.
+ assert.equal(at(690, 280, { drawer: true }).room, 690 - RAIL_WIDTH)
})
test('a rail preference keeps the rail beside a shown panel', () => {
@@ -94,6 +94,12 @@ test('a flip across the auto-collapse line is the shell rule, not a gesture', ()
assert.equal(userSidebarToggle({ before, after: { collapsed: true, viewport: 1000 } }), false)
})
+test('a flip right after a width change is the shell settling, not a gesture', () => {
+ const before = { collapsed: true, viewport: 1386 }
+ assert.equal(userSidebarToggle({ before, after: { collapsed: false, viewport: 1386 }, sinceResize: 120 }), false)
+ assert.equal(userSidebarToggle({ before, after: { collapsed: false, viewport: 1386 }, sinceResize: 800 }), true)
+})
+
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)
@@ -102,8 +108,8 @@ test('an unrequested flip on one side of the line is the user', () => {
// A folded panel is open but not shown. The panel following the chat to another
// subject is not the user asking to see it; the openers are.
-const bench = (folded) => {
- const ui = createSource({ details: 'chief', view: 'details', renaming: false, tab: null, side: null, panelYield: false, leftDrawer: false })
+const bench = (folded, panelYield = false) => {
+ const ui = createSource({ details: 'chief', view: 'details', renaming: false, tab: null, side: null, panelYield, leftDrawer: false })
const roster = createSource({ byId: { chief: { id: 'chief' }, writer: { id: 'writer' } }, roomsById: {}, sideChats: {} })
const actions = teamActions({
call: () => Promise.resolve(null), after: promise => promise, partFor: id => id,
@@ -133,3 +139,19 @@ test('openers on a panel that fits do not yield', () => {
actions.showDetails('writer')
assert.equal(ui.getSnapshot().panelYield, false)
})
+
+// A panel shown because the column yielded is not folded: its opener closes it,
+// and the other openers keep the yield it already has.
+test('the opener closes a panel the column yielded to', () => {
+ const { ui, actions } = bench(false, true)
+ actions.toggleDetails('chief')
+ assert.equal(ui.getSnapshot().details, null)
+})
+
+test('openers keep a yield already given', () => {
+ const { ui, actions } = bench(false, true)
+ actions.showDetails('writer')
+ assert.equal(ui.getSnapshot().panelYield, true)
+ actions.setPanelView('side')
+ assert.equal(ui.getSnapshot().panelYield, true)
+})