A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Give the Bot header a toggle for DSH's right sidebar
Fei24111f8e42f4fd7a
diff --git a/ds-bot/client.js b/ds-bot/client.jsindex 9b5e894a..7ffab945 100644--- a/ds-bot/client.js+++ b/ds-bot/client.js@@ -635,6 +635,8 @@ var ZH = {"Updating memory": "正在更新记忆","Checking memory": "正在查看记忆","Memory updated": "记忆已更新",+ "Show or hide the right sidebar": "显示或隐藏右侧栏",+ "Right sidebar": "右侧栏","Team memory updated": "团队记忆已更新","Updated {name}'s memory": "已更新 {name} 的记忆","Memory updated. Open {name}'s memory": "记忆已更新,打开 {name} 的记忆",@@ -1977,6 +1979,8 @@ body[data-bt-motion=quiet] .bt-mark[data-poke]{cursor:default}.bt-head{position:relative;display:flex;justify-content:center;align-items:center;height:40px;flex:none;pointer-events:none}.bt-pill{pointer-events:auto;display:inline-flex;align-items:center;gap:8px;height:40px;padding:7.5px 13.5px 7.5px 7.5px;border-radius:999px;background:var(--bt-main);border:.5px solid var(--bt-line-2);box-shadow:0 2px 8px -1px rgba(0,0,0,.06),0 1px 2px rgba(0,0,0,.04);color:var(--bt-ink);font-family:inherit;font-size:14px;line-height:20px;cursor:pointer;max-width:70%;box-sizing:border-box;transition:background-color .12s ease,transform ${SPRING_TAP.duration}ms ${SPRING_TAP.easing}}.bt-pill:hover{background:color-mix(in srgb,var(--bt-main),#777 9%)}+.bt-head-side{position:absolute;right:12px;top:4px;width:32px;height:32px;border-radius:8px;pointer-events:auto;transition:background-color .12s ease}+.bt-head-side:hover{background:color-mix(in srgb,var(--bt-main),#777 12%);color:var(--bt-ink)}.bt-pill:active{transform:scale(.965)}.bt-pill-name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:500}.bt-pill-mem{flex:none;display:inline-flex;width:0;margin-left:-8px;overflow:hidden;transition:${spring(SPRING_SHAPE, "width", "margin-left")}}@@ -3134,6 +3138,7 @@ var TrashIcon = lineIcon(["M3.5 5.5h13", "M8 5.5V4a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1var DuplicateIcon = lineIcon(["M7 7h8.5v9.5H7z", "M4.5 13V3.5H13", "M11.25 9.5v4.5M9 11.75h4.5"]);var SlidersIcon = lineIcon(["M4 6.5h5M12.5 6.5H16M4 13.5h4M11.5 13.5H16", "M10.5 4.5v4M9.5 11.5v4"]);var MemoryIcon = lineIcon(["M5.5 3.5h8A1.5 1.5 0 0 1 15 5v10a1.5 1.5 0 0 1-1.5 1.5h-8z", "M5.5 3.5v13", "M8.5 7.5h3.5M8.5 10.5h2.5", "M12 3.5v4l1-.8 1 .8"]);+var SidePanelIcon = lineIcon(["M4.5 4h11A1.5 1.5 0 0 1 17 5.5v9a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 3 14.5v-9A1.5 1.5 0 0 1 4.5 4z", "M12.5 4v12"]);var FolderIcon = lineIcon(["M3 6A1.5 1.5 0 0 1 4.5 4.5h3.2l1.8 2h6A1.5 1.5 0 0 1 17 8v6.5a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 3 14.5z"]);var ChatsIcon = lineIcon(["M3.5 5.5A1.5 1.5 0 0 1 5 4h7a1.5 1.5 0 0 1 1.5 1.5V10A1.5 1.5 0 0 1 12 11.5H8L5 14v-2.5A1.5 1.5 0 0 1 3.5 10z", "M13.5 7.5H15A1.5 1.5 0 0 1 16.5 9v4.5A1.5 1.5 0 0 1 15 15v2l-2.5-2h-3A1.5 1.5 0 0 1 8 13.5V13"]);var SETTINGS_ICONS = { general: GearIcon, bots: PeopleIcon, groups: ChatsIcon, usage: GaugeIcon };@@ -5621,7 +5626,9 @@ function HeaderPill({ sessionId, useRoster, useSessions, useSessionStatus, useSe),(0, import_react9.createElement)("span", { className: "bt-sr", role: "status" }, memoryNotice ? t("Memory updated") : ""),(0, import_react9.createElement)(NewMessagePills, { key: sessionId, sessionId, useSessions, useUi, useTurnClock }),- (0, import_react9.createElement)(ActivityIndicator, { key: `activity:${sessionId}`, sessionId, useRoster, useSessionStatus, useSession, useLive, actions })+ (0, import_react9.createElement)(ActivityIndicator, { key: `activity:${sessionId}`, sessionId, useRoster, useSessionStatus, useSession, useLive, actions }),+ // DSH's way into its right sidebar sits in the session header this pill replaces.+ actions.hasRightSidebar?.() ? (0, import_react9.createElement)("button", { type: "button", className: "bt-icon-btn bt-head-side", "data-bt-right-sidebar": "", "aria-label": t("Show or hide the right sidebar"), title: t("Right sidebar"), onClick: () => actions.toggleRightSidebar() }, (0, import_react9.createElement)(SidePanelIcon)) : null);}function useTranscriptView() {@@ -13941,6 +13948,15 @@ function apply(ctx) {diagnostics: (payload) => call("diagnostics", payload),diagnosticsLog: () => call("diagnostics-log"),diagnosticsClear: () => call("diagnostics-clear"),+ // DSH's right sidebar (files, terminals), which a plugin may load after this one.+ hasRightSidebar: () => ctx.get("sidebarRight") !== void 0,+ toggleRightSidebar: () => {+ try {+ ctx.get("sidebarRight")?.toggleExpanded();+ } catch (error) {+ actions.reportError(error, "right-sidebar");+ }+ },// A failed action away from any form (a menu, the palette) shows as a toast.reportError: (error, where = "action") => {noteClientError(where, error);diff --git a/ds-bot/src/client/header.js b/ds-bot/src/client/header.jsindex 7544124c..cf8bccb5 100644--- a/ds-bot/src/client/header.js+++ b/ds-bot/src/client/header.js@@ -1,7 +1,7 @@import { createElement as h, Fragment, useEffect, useLayoutEffect, useRef, useState } from 'react'import { createPortal } from 'react-dom'import { currentPart, latestMemoryChange } from './text.js'-import { ArrowUpIcon, CloseIcon, ArrowDownIcon, MemoryIcon } from './icons.js'+import { ArrowUpIcon, CloseIcon, ArrowDownIcon, MemoryIcon, SidePanelIcon } from './icons.js'import { botState, BotAvatar, RoomAvatar } from './mark.js'import { ActivityIndicator } from './activity-row.js'import { clockLabel, openingTurn, unseenSince } from './cells.js'@@ -102,7 +102,11 @@ export function HeaderPill({ sessionId, useRoster, useSessions, useSessionStatush('span', { className: 'bt-pill-go', 'aria-hidden': true }, h(GoArrow))),h('span', { className: 'bt-sr', role: 'status' }, memoryNotice ? t('Memory updated') : ''),h(NewMessagePills, { key: sessionId, sessionId, useSessions, useUi, useTurnClock }),- h(ActivityIndicator, { key: `activity:${sessionId}`, sessionId, useRoster, useSessionStatus, useSession, useLive, actions }))+ h(ActivityIndicator, { key: `activity:${sessionId}`, sessionId, useRoster, useSessionStatus, useSession, useLive, actions }),+ // DSH's way into its right sidebar sits in the session header this pill replaces.+ actions.hasRightSidebar?.()+ ? h('button', { type: 'button', className: 'bt-icon-btn bt-head-side', 'data-bt-right-sidebar': '', 'aria-label': t('Show or hide the right sidebar'), title: t('Right sidebar'), onClick: () => actions.toggleRightSidebar() }, h(SidePanelIcon))+ : null)}// New-message pills. "N new messages ↓" takes Back to bottom's place whendiff --git a/ds-bot/src/client/i18n.js b/ds-bot/src/client/i18n.jsindex 83b39980..5ef27a16 100644--- a/ds-bot/src/client/i18n.js+++ b/ds-bot/src/client/i18n.js@@ -582,6 +582,8 @@ const ZH = {'Updating memory': '正在更新记忆','Checking memory': '正在查看记忆','Memory updated': '记忆已更新',+ 'Show or hide the right sidebar': '显示或隐藏右侧栏',+ 'Right sidebar': '右侧栏','Team memory updated': '团队记忆已更新',"Updated {name}'s memory": '已更新 {name} 的记忆',"Memory updated. Open {name}'s memory": '记忆已更新,打开 {name} 的记忆',diff --git a/ds-bot/src/client/icons.js b/ds-bot/src/client/icons.jsindex 6941c1ae..fb7eec7b 100644--- a/ds-bot/src/client/icons.js+++ b/ds-bot/src/client/icons.js@@ -84,6 +84,7 @@ export const DuplicateIcon = lineIcon(['M7 7h8.5v9.5H7z', 'M4.5 13V3.5H13', 'M11export const SlidersIcon = lineIcon(['M4 6.5h5M12.5 6.5H16M4 13.5h4M11.5 13.5H16', 'M10.5 4.5v4M9.5 11.5v4'])// A notebook with a ribbon: what a Bot remembers.export const MemoryIcon = lineIcon(['M5.5 3.5h8A1.5 1.5 0 0 1 15 5v10a1.5 1.5 0 0 1-1.5 1.5h-8z', 'M5.5 3.5v13', 'M8.5 7.5h3.5M8.5 10.5h2.5', 'M12 3.5v4l1-.8 1 .8'])+export const SidePanelIcon = lineIcon(['M4.5 4h11A1.5 1.5 0 0 1 17 5.5v9a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 3 14.5v-9A1.5 1.5 0 0 1 4.5 4z', 'M12.5 4v12'])export const FolderIcon = lineIcon(['M3 6A1.5 1.5 0 0 1 4.5 4.5h3.2l1.8 2h6A1.5 1.5 0 0 1 17 8v6.5a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 3 14.5z'])// Defined here, after the icons: SettingsDialog only reads them at render time.// Two speech bubbles, the back one peeking out: a group chat.diff --git a/ds-bot/src/client/index.js b/ds-bot/src/client/index.jsindex 203345b2..cf203c12 100644--- a/ds-bot/src/client/index.js+++ b/ds-bot/src/client/index.js@@ -561,6 +561,15 @@ export function apply(ctx) {diagnostics: payload => call('diagnostics', payload),diagnosticsLog: () => call('diagnostics-log'),diagnosticsClear: () => call('diagnostics-clear'),+ // DSH's right sidebar (files, terminals), which a plugin may load after this one.+ hasRightSidebar: () => ctx.get('sidebarRight') !== undefined,+ toggleRightSidebar: () => {+ try {+ ctx.get('sidebarRight')?.toggleExpanded()+ } catch (error) {+ actions.reportError(error, 'right-sidebar')+ }+ },// A failed action away from any form (a menu, the palette) shows as a toast.reportError: (error, where = 'action') => {noteClientError(where, error)diff --git a/ds-bot/src/client/styles.js b/ds-bot/src/client/styles.jsindex c800f00d..94611b86 100644--- a/ds-bot/src/client/styles.js+++ b/ds-bot/src/client/styles.js@@ -156,6 +156,8 @@ body[data-bt-motion=quiet] .bt-mark[data-poke]{cursor:default}.bt-head{position:relative;display:flex;justify-content:center;align-items:center;height:40px;flex:none;pointer-events:none}.bt-pill{pointer-events:auto;display:inline-flex;align-items:center;gap:8px;height:40px;padding:7.5px 13.5px 7.5px 7.5px;border-radius:999px;background:var(--bt-main);border:.5px solid var(--bt-line-2);box-shadow:0 2px 8px -1px rgba(0,0,0,.06),0 1px 2px rgba(0,0,0,.04);color:var(--bt-ink);font-family:inherit;font-size:14px;line-height:20px;cursor:pointer;max-width:70%;box-sizing:border-box;transition:background-color .12s ease,transform ${SPRING_TAP.duration}ms ${SPRING_TAP.easing}}.bt-pill:hover{background:color-mix(in srgb,var(--bt-main),#777 9%)}+.bt-head-side{position:absolute;right:12px;top:4px;width:32px;height:32px;border-radius:8px;pointer-events:auto;transition:background-color .12s ease}+.bt-head-side:hover{background:color-mix(in srgb,var(--bt-main),#777 12%);color:var(--bt-ink)}.bt-pill:active{transform:scale(.965)}.bt-pill-name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:500}.bt-pill-mem{flex:none;display:inline-flex;width:0;margin-left:-8px;overflow:hidden;transition:${spring(SPRING_SHAPE, 'width', 'margin-left')}}diff --git a/ds-bot/test/header.test.js b/ds-bot/test/header.test.jsnew file mode 100644index 00000000..b9f129cd--- /dev/null+++ b/ds-bot/test/header.test.js@@ -0,0 +1,65 @@+import assert from 'node:assert/strict'+import { test } from 'node:test'+import { fileURLToPath } from 'node:url'+import { runInNewContext } from 'node:vm'+import { build } from 'esbuild'++const bundle = await build({+ entryPoints: [fileURLToPath(new URL('../src/client/header.js', import.meta.url))],+ bundle: true, format: 'cjs', platform: 'node', write: false,+ external: ['react', 'react-dom', '@deepseek-ai/dsh-client-ui-primitives'],+})+const module = { exports: {} }+runInNewContext(bundle.outputFiles[0].text, {+ module, exports: module.exports, URL, URLSearchParams, setTimeout, clearTimeout,+ require: (name) => {+ const platform = {+ react: { createElement: (type, props, ...children) => ({ type, props: props ?? {}, children: children.flat(Infinity) }), useState: initial => [initial, () => {}], useEffect: () => {}, useRef: current => ({ current }), useLayoutEffect: () => {}, useMemo: make => make(), useCallback: fn => fn, Fragment: 'fragment' },+ 'react-dom': { createPortal: node => node },+ '@deepseek-ai/dsh-client-ui-primitives': { MarkdownText: () => null },+ }+ if (!(name in platform)) throw new Error(`no platform module ${name}`)+ return platform[name]+ },+})+const { HeaderPill } = module.exports++const roster = { byId: { a: { id: 'a', name: 'Chief', sessionId: 'a' } }, roomsById: {}, bots: [], exchangeTurns: {}, questions: {} }+const hook = value => select => select(value)+const header = actions => HeaderPill({+ sessionId: 'a',+ useRoster: hook(roster),+ useSessions: hook({ byId: {} }),+ useSessionStatus: hook(new Map()),+ useSession: hook({}),+ useActivity: hook({}),+ useMemoryNews: hook({}),+ useTurnClock: hook({}),+ useUi: hook({}),+ useLive: hook({}),+ actions,+})+const sideButton = (node) => {+ if (node === null || typeof node !== 'object') return null+ if (node.props?.['data-bt-right-sidebar'] !== undefined) return node+ for (const child of node.children ?? []) {+ const found = sideButton(child)+ if (found) return found+ }+ return null+}++// 公开#172: the Bot header replaces DSH's session header, and with it the corner seat+// where DSH puts the button that opens its right sidebar; only the shortcut was left.+test('the Bot header has the right sidebar toggle that DSH keeps in the header it replaces', () => {+ let toggled = 0+ const button = sideButton(header({ hasRightSidebar: () => true, toggleRightSidebar: () => { toggled += 1 } }))+ assert.ok(button)+ assert.equal(button.props['aria-label'], 'Show or hide the right sidebar')+ button.props.onClick()+ assert.equal(toggled, 1)+})++test('without DSH\'s right sidebar the Bot header shows no toggle', () => {+ assert.equal(sideButton(header({ hasRightSidebar: () => false, toggleRightSidebar: () => {} })), null)+})