A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Close the narrow sidebar after selecting a conversation
Chimney974be081a14d
diff --git a/ds-bot/client.js b/ds-bot/client.jsindex 70a0f3d1..12654a9d 100644--- a/ds-bot/client.js+++ b/ds-bot/client.js@@ -5559,7 +5559,19 @@ function TeamSidebar(props) {const main = roster.byId[roster.mainBotId];useListGlide(listRef, wide, order.map((entry) => entry.item.id).join(","));useLandOnMainBot(roster, useSessions, actions);- const rowProps = { roster, actions, useSessions, useUi, useSessionStatus: props.useSessionStatus, useSessionRetainInfo: props.useSessionRetainInfo, useActivity: props.useActivity, useWork: props.useWork, wide };+ const navigate = (open, id) => {+ const result = open(id);+ if (wide && window.innerWidth < 1024) actions.toggleSidebar();+ return result;+ };+ const rowActions = {+ ...actions,+ openSession: (id) => navigate(actions.openSession, id),+ openAgent: (id) => navigate(actions.openAgent, id),+ 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 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;diff --git a/ds-bot/src/client/sidebar.js b/ds-bot/src/client/sidebar.jsindex adfb2d36..e222f8cf 100644--- a/ds-bot/src/client/sidebar.js+++ b/ds-bot/src/client/sidebar.js@@ -267,7 +267,21 @@ export function TeamSidebar(props) {const main = roster.byId[roster.mainBotId]useListGlide(listRef, wide, order.map(entry => entry.item.id).join(','))useLandOnMainBot(roster, useSessions, actions)- const rowProps = { roster, actions, useSessions, useUi, useSessionStatus: props.useSessionStatus, useSessionRetainInfo: props.useSessionRetainInfo, useActivity: props.useActivity, useWork: props.useWork, wide }+ // The shell gives this slot its live fold state. Only a navigation from its+ // expanded, narrow sidebar dismisses it; other ways to open a chat never toggle it.+ const navigate = (open, id) => {+ const result = open(id)+ if (wide && window.innerWidth < 1024) actions.toggleSidebar()+ return result+ }+ const rowActions = {+ ...actions,+ openSession: id => navigate(actions.openSession, id),+ openAgent: id => navigate(actions.openAgent, id),+ 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 }// 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) returndiff --git a/ds-bot/test/sidebar-switch.test.js b/ds-bot/test/sidebar-switch.test.jsindex 29b5234c..a89754ba 100644--- a/ds-bot/test/sidebar-switch.test.js+++ b/ds-bot/test/sidebar-switch.test.js@@ -26,12 +26,64 @@ const react = {useMemo: make => make(), useRef: current => ({ current }), useId: () => 'id',}const module = { exports: {} }+const viewport = { innerWidth: 1280 }runInNewContext(outputFiles[0].text, {module, exports: module.exports,require: name => (name === 'react' ? react : {}),+ window: viewport,})const { SHELL_CSS, SIDEBAR_CSS, TeamSidebar } = module.exports+function navigationSidebar(wide) {+ const calls = []+ const 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 = () => calls.push(['toggleSidebar'])+ const tree = TeamSidebar({+ wide, actions,+ useRoster: pick => pick(roster), useUi: pick => pick({ unread: {} }), useRegistry: pick => pick({}),+ useSessions: pick => pick({ ids: [], byId: {} }), useUpdate: () => ({}),+ })+ const rows = []+ const walk = (node) => {+ if (Array.isArray(node)) { node.forEach(walk); return }+ if (!node || typeof node !== 'object') return+ if (['BotRow', 'RoomRow', 'AgentRow'].includes(node.type?.name)) rows.push(node)+ walk(node.props?.children)+ }+ walk(tree)+ return { calls, rows, actions }+}++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`, () => {+ viewport.innerWidth = width+ const { rows, calls } = navigationSidebar(wide)+ assert.equal(rows.length, 3)+ for (const row of rows) {+ const names = row.type.name === 'AgentRow' ? ['openAgent', 'openAgentSession', 'newAgentSession'] : ['openSession']+ for (const name of names) {+ calls.length = 0+ assert.equal(row.props.actions[name]('selected'), 'selected')+ assert.deepEqual(calls, wide && width < 1024 ? [[name, 'selected'], ['toggleSidebar']] : [[name, 'selected']])+ }+ }+ })+ }+}++test('preparing sidebar navigation leaves actions elsewhere unchanged', () => {+ viewport.innerWidth = 390+ const { actions, calls } = navigationSidebar(true)+ assert.deepEqual(calls, [])+ actions.openSession('from-another-surface')+ assert.deepEqual(calls, [['openSession', 'from-another-surface']])+})+function rulesOf(css) {const text = css.replace(/\/\*[\s\S]*?\*\//g, '')const rules = []