Skip to content

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

Keep the shell's sidebar switch where the shell puts it

Fei24111942b8300dc7
diff --git a/ds-bot/client.js b/ds-bot/client.js
index 9b5e894a..fe8d39e4 100644
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@ -50,6 +50,7 @@ var ZH = {
Search: "搜索",
"New chat": "新对话",
"New…": "新建",
+ "Collapse sidebar": "收起侧边栏",
"Animation": "动画",
"Bot animation": "Bot 动画",
"Quiet": "安静",
@@ -2327,8 +2328,14 @@ button.bt-set-row:hover{background:var(--bt-hover)}
/* Shell chrome reshaped for the team view. Selectors use stable data attributes where the
shell offers them and CSS-module name suffixes elsewhere. */
-[class*="_logoRow"],[class*="_newSession"],nav[class*="_panelList"]{display:none!important}
-[class*="_footArea"]{display:flex!important;flex-direction:row-reverse;align-items:center;gap:9px;padding:8px 6px 6px!important}
+[class*="_newSession"],nav[class*="_panelList"],[class*="_logoRow"]>[class*="_brand"],[class*="_logoRow"]:not(:has([class*="_toggle"])){display:none!important}
+/* The shell's sidebar switch stays where the shell puts it whenever the sidebar is
+ collapsed: on the rail, or fixed in a Windows title bar, where it also stays while
+ 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}
+[class*="_footArea"]{flex-direction:row-reverse;align-items:center;gap:9px;padding:8px 6px 6px!important}
[class*="_footArea"]>[class*="_footerActions"]{flex:1 1 auto;min-width:0}
[class*="_footArea"]>[class*="_settingsArea"]{flex:none;width:auto!important}
[class*="_footArea"] button[aria-label="Settings"]{width:auto!important;padding:0!important;background:none!important;border-radius:50%!important;height:auto!important}
@@ -3042,6 +3049,14 @@ function PlusIcon() {
function SearchIcon() {
return (0, import_react3.createElement)("svg", { width: 16, height: 16, viewBox: "0 0 20 20", "aria-hidden": true }, (0, import_react3.createElement)("circle", { cx: 8.5, cy: 8.5, r: 5.5, stroke: "currentColor", strokeWidth: 1.6, fill: "none" }), (0, import_react3.createElement)("path", { d: "M13 13l4 4", stroke: "currentColor", strokeWidth: 1.6, strokeLinecap: "round" }));
}
+function SidebarIcon() {
+ return (0, import_react3.createElement)(
+ "svg",
+ { width: 16, height: 16, viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: 1.6, "aria-hidden": true },
+ (0, import_react3.createElement)("rect", { x: 3, y: 4, width: 14, height: 12, rx: 2.5 }),
+ (0, import_react3.createElement)("path", { d: "M8 4v12" })
+ );
+}
function PeopleIcon() {
return (0, import_react3.createElement)(
"svg",
@@ -5087,7 +5102,8 @@ function TeamSidebar(props) {
(0, import_react8.createElement)("span", { className: "bt-brand" }, (0, import_react8.createElement)(BrandMark, { size: 22 }), (0, import_react8.createElement)(BrandName)),
(0, import_react8.createElement)(UpdateButton, { useUpdate: props.useUpdate, actions }),
(0, import_react8.createElement)("button", { type: "button", className: "bt-round", "aria-label": t("Search"), title: t("Search"), onClick: () => actions.openPalette() }, (0, import_react8.createElement)(SearchIcon)),
- (0, import_react8.createElement)("button", { type: "button", className: "bt-round", "aria-label": t("New…"), title: t("New…"), onClick: () => actions.openNewChat("new") }, (0, import_react8.createElement)(PlusIcon))
+ (0, import_react8.createElement)("button", { type: "button", className: "bt-round", "aria-label": t("New…"), title: t("New…"), onClick: () => actions.openNewChat("new") }, (0, import_react8.createElement)(PlusIcon)),
+ (0, import_react8.createElement)("button", { type: "button", className: "bt-round bt-side-collapse", "aria-label": t("Collapse sidebar"), title: t("Collapse sidebar"), onClick: () => actions.toggleSidebar() }, (0, import_react8.createElement)(SidebarIcon))
) : (0, import_react8.createElement)(
import_react8.Fragment,
null,
@@ -5473,7 +5489,7 @@ var SIDEBAR_CSS = `
.bt-rail .bt-row{position:relative}
.bt-rail .bt-pin{position:absolute;top:3px;left:calc(50% + 12px)}
.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){display:flex!important;flex-direction:row!important;align-items:center;gap:6px}
+[class*="_footArea"]:has(.bt-foot-account){flex-direction:row!important;align-items:center;gap:6px}
[class*="_footArea"]:has(.bt-foot-account)>[class*="_footerActions"],[class*="_footArea"]:has(.bt-foot-account)>[class*="_footerActions"]>div{display:contents!important}
.bt-foot-account{order:-1;flex:none;display:inline-flex}
[class*="_footArea"]:has(.bt-foot-account) .bt-connect-foot{order:0;flex:1 1 auto;min-width:0;width:auto}
@@ -13765,6 +13781,9 @@ function apply(ctx) {
selectPanel: (id) => {
ctx.layout.selectPanel(id);
},
+ toggleSidebar: () => {
+ ctx.layout.toggleSidebar();
+ },
openNewChat: (mode) => {
ui2.set((state) => ({ ...state, newChat: mode, menu: null, palette: null }));
},
diff --git a/ds-bot/src/client/i18n.js b/ds-bot/src/client/i18n.js
index 83b39980..ff1493b0 100644
--- a/ds-bot/src/client/i18n.js
+++ b/ds-bot/src/client/i18n.js
@@ -13,6 +13,7 @@ const ZH = {
Search: '搜索',
'New chat': '新对话',
'New…': '新建',
+ 'Collapse sidebar': '收起侧边栏',
'Animation': '动画',
'Bot animation': 'Bot 动画',
'Quiet': '安静',
diff --git a/ds-bot/src/client/icons.js b/ds-bot/src/client/icons.js
index 6941c1ae..40771214 100644
--- a/ds-bot/src/client/icons.js
+++ b/ds-bot/src/client/icons.js
@@ -6,6 +6,10 @@ export function PlusIcon() {
export function SearchIcon() {
return h('svg', { width: 16, height: 16, viewBox: '0 0 20 20', 'aria-hidden': true }, h('circle', { cx: 8.5, cy: 8.5, r: 5.5, stroke: 'currentColor', strokeWidth: 1.6, fill: 'none' }), h('path', { d: 'M13 13l4 4', stroke: 'currentColor', strokeWidth: 1.6, strokeLinecap: 'round' }))
}
+export function SidebarIcon() {
+ return h('svg', { width: 16, height: 16, viewBox: '0 0 20 20', fill: 'none', stroke: 'currentColor', strokeWidth: 1.6, 'aria-hidden': true },
+ h('rect', { x: 3, y: 4, width: 14, height: 12, rx: 2.5 }), h('path', { d: 'M8 4v12' }))
+}
export function PeopleIcon() {
return h('svg', { width: 14, height: 14, viewBox: '0 0 20 20', fill: 'none', stroke: 'currentColor', strokeWidth: 1.5, strokeLinecap: 'round', 'aria-hidden': true },
h('circle', { cx: 7.5, cy: 7, r: 3 }), h('path', { d: 'M2 16.5c.6-2.8 2.8-4.5 5.5-4.5s4.9 1.7 5.5 4.5' }),
diff --git a/ds-bot/src/client/index.js b/ds-bot/src/client/index.js
index 203345b2..5e714515 100644
--- a/ds-bot/src/client/index.js
+++ b/ds-bot/src/client/index.js
@@ -418,6 +418,7 @@ export function apply(ctx) {
ctx.uiWorkspace.openSession(target)
},
selectPanel: (id) => { ctx.layout.selectPanel(id) },
+ toggleSidebar: () => { ctx.layout.toggleSidebar() },
openNewChat: (mode) => { ui.set(state => ({ ...state, newChat: mode, menu: null, palette: null })) },
openPalette: (query = '') => { ui.set(state => ({ ...state, palette: { query, token: Date.now() }, newChat: null, menu: null })) },
// The token keeps a late exit timer from closing a palette opened again since.
diff --git a/ds-bot/src/client/sidebar.js b/ds-bot/src/client/sidebar.js
index 254d0b89..1d673001 100644
--- a/ds-bot/src/client/sidebar.js
+++ b/ds-bot/src/client/sidebar.js
@@ -3,7 +3,7 @@ import { createPortal } from 'react-dom'
import { FishLogo } from '@deepseek-ai/dsh-client-ui-primitives'
import { isMainOf } from './sources.js'
import { currentPart, previewOf, relativeShort } from './text.js'
-import { PlusIcon, SearchIcon, GaugeIcon, PlugIcon, ClockIcon, GearIcon, PinMarkIcon, ConnectorIcon, SwitchIcon, CloudDownloadIcon } from './icons.js'
+import { PlusIcon, SearchIcon, SidebarIcon, GaugeIcon, PlugIcon, ClockIcon, GearIcon, PinMarkIcon, ConnectorIcon, SwitchIcon, CloudDownloadIcon } from './icons.js'
import { MAIN_LOOK } from './characters.js'
import { botState, BotMark, BotAvatar, RoomAvatar } from './mark.js'
import { reducedMotion } from './activity-row.js'
@@ -271,7 +271,8 @@ export function TeamSidebar(props) {
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', '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))),
@@ -606,7 +607,7 @@ export const SIDEBAR_CSS = `
.bt-rail .bt-row{position:relative}
.bt-rail .bt-pin{position:absolute;top:3px;left:calc(50% + 12px)}
.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){display:flex!important;flex-direction:row!important;align-items:center;gap:6px}
+[class*="_footArea"]:has(.bt-foot-account){flex-direction:row!important;align-items:center;gap:6px}
[class*="_footArea"]:has(.bt-foot-account)>[class*="_footerActions"],[class*="_footArea"]:has(.bt-foot-account)>[class*="_footerActions"]>div{display:contents!important}
.bt-foot-account{order:-1;flex:none;display:inline-flex}
[class*="_footArea"]:has(.bt-foot-account) .bt-connect-foot{order:0;flex:1 1 auto;min-width:0;width:auto}
diff --git a/ds-bot/src/client/styles.js b/ds-bot/src/client/styles.js
index c800f00d..46d38b66 100644
--- a/ds-bot/src/client/styles.js
+++ b/ds-bot/src/client/styles.js
@@ -506,8 +506,14 @@ button.bt-set-row:hover{background:var(--bt-hover)}
/* Shell chrome reshaped for the team view. Selectors use stable data attributes where the
shell offers them and CSS-module name suffixes elsewhere. */
-[class*="_logoRow"],[class*="_newSession"],nav[class*="_panelList"]{display:none!important}
-[class*="_footArea"]{display:flex!important;flex-direction:row-reverse;align-items:center;gap:9px;padding:8px 6px 6px!important}
+[class*="_newSession"],nav[class*="_panelList"],[class*="_logoRow"]>[class*="_brand"],[class*="_logoRow"]:not(:has([class*="_toggle"])){display:none!important}
+/* The shell's sidebar switch stays where the shell puts it whenever the sidebar is
+ collapsed: on the rail, or fixed in a Windows title bar, where it also stays while
+ 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}
+[class*="_footArea"]{flex-direction:row-reverse;align-items:center;gap:9px;padding:8px 6px 6px!important}
[class*="_footArea"]>[class*="_footerActions"]{flex:1 1 auto;min-width:0}
[class*="_footArea"]>[class*="_settingsArea"]{flex:none;width:auto!important}
[class*="_footArea"] button[aria-label="Settings"]{width:auto!important;padding:0!important;background:none!important;border-radius:50%!important;height:auto!important}
diff --git a/ds-bot/test/sidebar-switch.test.js b/ds-bot/test/sidebar-switch.test.js
new file mode 100644
index 00000000..aec1be8a
--- /dev/null
+++ b/ds-bot/test/sidebar-switch.test.js
@@ -0,0 +1,133 @@
+import { test } from 'node:test'
+import assert from 'node:assert/strict'
+import { createRequire } from 'node:module'
+import { dirname, join } from 'node:path'
+import { fileURLToPath } from 'node:url'
+import { runInNewContext } from 'node:vm'
+import { build } from 'esbuild'
+
+// jsdom comes from the harness that test/harness-resolve.mjs found, like the dsh packages.
+const PLUGIN = dirname(dirname(fileURLToPath(import.meta.url)))
+const { JSDOM } = createRequire(join(process.env.DSH_HARNESS ?? join(PLUGIN, '..', 'deepseek-harness'), 'package.json'))('jsdom')
+
+// The sidebar and its style sheets import the browser's React; bundle them with a minimal
+// stand-in, as the tool-cell tests do: components run as plain functions, effects never run.
+const { outputFiles } = await build({
+ stdin: {
+ contents: "export { SHELL_CSS } from './src/client/styles.js'\nexport { SIDEBAR_CSS, TeamSidebar } from './src/client/sidebar.js'",
+ resolveDir: PLUGIN,
+ },
+ bundle: true, format: 'cjs', platform: 'browser', write: false, logLevel: 'silent',
+ external: ['react', 'react-dom', '@deepseek-ai/dsh-client-ui-primitives'],
+})
+const react = {
+ createElement: (type, props, ...children) => ({ type, props: { ...props, children } }), Fragment: Symbol('Fragment'),
+ useEffect() {}, useLayoutEffect() {}, useState: initial => [initial, () => {}],
+ useMemo: make => make(), useRef: current => ({ current }), useId: () => 'id',
+}
+const module = { exports: {} }
+runInNewContext(outputFiles[0].text, {
+ module, exports: module.exports,
+ require: name => (name === 'react' ? react : {}),
+})
+const { SHELL_CSS, SIDEBAR_CSS, TeamSidebar } = module.exports
+
+function rulesOf(css) {
+ const text = css.replace(/\/\*[\s\S]*?\*\//g, '')
+ const rules = []
+ for (let at = 0; ;) {
+ const open = text.indexOf('{', at)
+ if (open === -1) return rules
+ let end = open + 1
+ for (let depth = 1; depth > 0; end += 1) depth += text[end] === '{' ? 1 : text[end] === '}' ? -1 : 0
+ const selector = text.slice(at, open).trim()
+ if (!selector.startsWith('@')) rules.push({ selector, body: text.slice(open + 1, end - 1).replace(/\s+/g, '') })
+ at = end
+ }
+}
+const SHELL_PARTS = /_logoRow|_brand|_toggle|_newSession|_footArea|_collapsed|_topStrip|bt-side-collapse/
+const rules = [...rulesOf(SHELL_CSS), ...rulesOf(SIDEBAR_CSS)].filter(rule => SHELL_PARTS.test(rule.selector))
+const hiding = rules.filter(rule => /display:none/.test(rule.body))
+
+// The shell sidebar's own markup (dsh-client-ui-sidebar SidebarRoot), reduced to what the
+// team view reshapes: the switch is in the logo row, except in a macOS desktop window,
+// where it sits in the strip by the window buttons.
+function shell({ platform, collapsed }) {
+ const darwin = platform === 'mac'
+ const toggle = '<button class="x_iconButton x_toggle" aria-label="Toggle sidebar"></button>'
+ const html = `<!doctype html><html${platform === 'windows' ? ' data-windows-titlebar' : ''}${darwin ? ' data-platform="darwin"' : ''}><body>
+ <div${collapsed ? ' data-sidebar-collapsed="true"' : ''}>
+ <div class="x_root${collapsed ? ' x_collapsed' : ''}">
+ ${darwin ? `<div class="x_topStrip">${toggle}</div>` : ''}
+ <div class="x_logoRow">${collapsed ? '' : '<button class="x_brand x_wide"></button>'}${darwin ? '' : toggle}</div>
+ <div class="x_newSession"></div>
+ <div class="team">${collapsed ? '' : '<div class="bt-side-top"><button class="bt-round bt-side-collapse"></button></div>'}</div>
+ <div class="x_footArea"><span class="bt-foot-account"></span></div>
+ </div>
+ </div></body></html>`
+ const { document } = new JSDOM(html).window
+ const hidden = (node) => {
+ for (let at = node; at && at.nodeType === 1; at = at.parentElement) {
+ if (hiding.some(rule => at.matches(rule.selector))) return true
+ }
+ return false
+ }
+ const switches = [...document.querySelectorAll('.x_toggle, .bt-side-collapse')].filter(node => !hidden(node))
+ return { document, hidden, switches }
+}
+
+for (const platform of ['web', 'windows', 'mac']) {
+ for (const collapsed of [false, true]) {
+ test(`${collapsed ? 'a collapsed' : 'an open'} sidebar on ${platform} shows exactly one sidebar switch`, () => {
+ const { document, hidden, switches } = shell({ platform, collapsed })
+ assert.equal(switches.length, 1, `switches shown: ${switches.map(node => node.className).join(' | ') || 'none'}`)
+ const [shown] = switches
+ // An open sidebar on the web has the team's own button; everywhere else the shell's
+ // switch stays where the shell puts it.
+ assert.equal(shown.classList.contains('bt-side-collapse'), platform === 'web' && !collapsed)
+ // What the team view replaces stays out of sight.
+ assert.equal(hidden(document.querySelector('.x_newSession')), true)
+ const brand = document.querySelector('.x_brand')
+ if (brand) assert.equal(hidden(brand), true)
+ })
+ }
+}
+
+test('an open sidebar has a button that collapses it; the rail leaves that to the shell', () => {
+ 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') },
+ })
+ const find = (node, match) => {
+ if (Array.isArray(node)) return node.map(child => find(child, match)).find(Boolean)
+ if (!node || typeof node !== 'object') return undefined
+ return match(node) ? node : find(node.props?.children, match)
+ }
+ const collapse = node => node.type === 'button' && node.props['aria-label'] === 'Collapse sidebar'
+ const button = find(TeamSidebar(props(true)), collapse)
+ assert.ok(button?.props.className.split(' ').includes('bt-side-collapse'))
+ button.props.onClick()
+ assert.deepEqual(calls, ['toggle'])
+ assert.equal(find(TeamSidebar(props(false)), collapse), undefined)
+})
+
+test('the logo row takes no room in an open sidebar under a Windows title bar', () => {
+ const { document } = shell({ platform: 'windows', collapsed: false })
+ const row = document.querySelector('.x_logoRow')
+ const flat = rules.filter(rule => row.matches(rule.selector) && /height:0!important/.test(rule.body))
+ assert.equal(flat.length, 1)
+ assert.equal(shell({ platform: 'windows', collapsed: true }).document.querySelector('.x_logoRow').matches(flat[0].selector), false)
+})
+
+// The shell hides the footer of a collapsed sidebar under a Windows title bar, whose width
+// is zero; a forced display put the account button off the screen.
+test('the team view lays out the shell footer but never decides whether it shows', () => {
+ const { document } = shell({ platform: 'windows', collapsed: true })
+ const foot = document.querySelector('.x_footArea')
+ const deciding = rules.filter(rule => foot.matches(rule.selector) && /(^|;)display:/.test(rule.body))
+ assert.deepEqual(deciding.map(rule => rule.selector), [])
+})