Skip to content

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

Add the floating computer indicator and its tray entries

Fei241119667f4c70c0
diff --git a/app/scripts/check-packed.mjs b/app/scripts/check-packed.mjs
index 80fa44ee..757c414e 100644
--- a/app/scripts/check-packed.mjs
+++ b/app/scripts/check-packed.mjs
@@ -6,7 +6,7 @@
// The executable defaults to the one that `npm run pack` or `npm run dist` writes into dist-pack/.
import { spawn, spawnSync } from 'node:child_process'
import { connect, createServer } from 'node:net'
-import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs'
+import { cpSync, existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { basename, dirname, isAbsolute, join, relative, resolve } from 'node:path'
import { setTimeout as sleep } from 'node:timers/promises'
@@ -47,6 +47,17 @@ if (!existsSync(executable)) {
join(unpacked, 'node_modules', 'ds-bot', 'office.js'),
]
const missing = required.filter((entry) => !existsSync(join(resources, entry)))
+ // macOS carries the signed "DSH Computer Use" helper outside the asar, in a
+ // hash-named folder; find it by its name rather than the changing hash.
+ if (process.platform === 'darwin') {
+ const rootDir = join(resources, unpacked, 'node_modules', '@deepseek-ai', 'dsh-experimental-cua-macos', 'native', 'bin')
+ const dirs = existsSync(rootDir) ? readdirSync(rootDir) : []
+ const helper = dirs.flatMap(dir => {
+ const here = join(rootDir, dir)
+ return existsSync(here) ? readdirSync(here).map(hash => join(here, hash, 'DSH Computer Use.app')) : []
+ }).find(entry => existsSync(entry))
+ if (helper === undefined) missing.push(join(unpacked, 'node_modules', '@deepseek-ai', 'dsh-experimental-cua-macos', 'native', 'bin', '<arch>', '<hash>', 'DSH Computer Use.app'))
+ }
if (missing.length > 0) {
console.error(`check-packed: FAILED: missing from ${resources}:\n ${missing.join('\n ')}`)
process.exit(1)
diff --git a/app/src/computer-indicator.mjs b/app/src/computer-indicator.mjs
new file mode 100644
index 00000000..c9945834
--- /dev/null
+++ b/app/src/computer-indicator.mjs
@@ -0,0 +1,99 @@
+// The floating computer-use indicator: a small always-on-top bar at the top of the
+// screen that shows which Bots hold a computer lease and offers Stop, Stop all and
+// "Let it continue". It is `focusable: false` so it never steals the cursor, and
+// `setContentProtection(true)` keeps it out of the Bots' own screenshots.
+
+/**
+ * @param {{
+ * BrowserWindow: new (options: object) => object,
+ * screen: { getPrimaryDisplay: () => { workAreaSize: { width: number, height: number }, workArea: { x: number, y: number } } },
+ * html: (entries: object[]) => string,
+ * onAction?: (action: string, botId: string | null) => void,
+ * log?: Pick<Console, 'warn'>,
+ * }} options injected Electron surface and a renderer for the bar
+ * @returns {{ update: (entries: object[]) => void, dispose: () => void }}
+ */
+export function createComputerIndicator({ BrowserWindow, screen, html, onAction = () => {}, log = console }) {
+ let win = null
+ let entries = []
+ const open = () => {
+ if (win !== null) return
+ const area = screen.getPrimaryDisplay()
+ const width = Math.min(520, area.workAreaSize.width - 64)
+ const height = 40 + entries.length * 0
+ win = new BrowserWindow({
+ width,
+ height,
+ x: Math.round(area.workArea.x + (area.workAreaSize.width - width) / 2),
+ y: area.workArea.y + 8,
+ frame: false,
+ transparent: true,
+ alwaysOnTop: true,
+ focusable: false,
+ resizable: false,
+ movable: false,
+ skipTaskbar: true,
+ hasShadow: false,
+ show: false,
+ webPreferences: { sandbox: true },
+ })
+ // The bar must never appear inside a screenshot the provider hands a Bot.
+ try { win.setContentProtection(true) } catch (error) { log.warn(`DS Bot: the indicator could not hide from screenshots: ${error instanceof Error ? error.message : String(error)}`) }
+ try { win.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true }) } catch (error) { log.warn(`DS Bot: the indicator could not join every workspace: ${error instanceof Error ? error.message : String(error)}`) }
+ win.once('ready-to-show', () => { win?.showInactive() })
+ win.on('closed', () => { win = null })
+ // Button clicks in the bar page post a message back; the main process turns
+ // them into client actions. The page is data: only, no preload.
+ win.webContents?.on?.('console-message', (_event, _level, message) => {
+ if (typeof message !== 'string' || !message.startsWith('dsbot-computer:')) return
+ const [, action, botId] = message.split(':')
+ onAction(action, botId === '' || botId === undefined ? null : botId)
+ })
+ const page = html(entries)
+ win.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(page)}`).catch((error) => {
+ log.warn(`DS Bot: the indicator did not load: ${error instanceof Error ? error.message : String(error)}`)
+ })
+ }
+ const close = () => {
+ if (win === null) return
+ const closing = win
+ win = null
+ try { closing.close() } catch (error) { log.warn(`DS Bot: the indicator did not close: ${error instanceof Error ? error.message : String(error)}`) }
+ }
+ return {
+ /** Re-render the bar; empty entries hide the window, entries show it. */
+ update(next) {
+ entries = Array.isArray(next) ? next : []
+ if (entries.length === 0) { close(); return }
+ if (win === null) { open(); return }
+ try { win.webContents?.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(html(entries))}`) } catch (error) { log.warn(`DS Bot: the indicator did not update: ${error instanceof Error ? error.message : String(error)}`) }
+ },
+ dispose() {
+ entries = []
+ close()
+ },
+ }
+}
+
+// The bar's own page: one row per entry, buttons that post a console message the
+// main process listens for. Plain inline styles keep it self-contained.
+export function indicatorHtml(entries) {
+ const row = (entry) => `
+ <span style="display:flex;align-items:center;gap:4px;min-width:0">
+ <span style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${escapeHtml(entry.label)}</span>
+ <button data-act="stop:${escapeHtml(entry.botId ?? '')}" style="border:0;border-radius:50%;width:18px;height:18px;cursor:pointer;font-size:12px;line-height:1">×</button>
+ </span>`
+ const waiting = (entry) => `
+ <span style="display:flex;align-items:center;gap:6px">
+ <span style="white-space:nowrap">${escapeHtml(entry.label)}</span>
+ <button data-act="letgo:${escapeHtml(entry.botId ?? '')}" style="border:0;background:none;color:#2563eb;cursor:pointer;font:inherit;white-space:nowrap">Let it continue</button>
+ </span>`
+ const rows = entries.map(entry => entry.waiting ? waiting(entry) : row(entry)).join('')
+ const stopAll = entries.filter(entry => !entry.waiting).length > 1
+ ? '<button data-act="stopall:" style="border:0;background:none;color:#2563eb;cursor:pointer;font:inherit;white-space:nowrap">Stop all</button>' : ''
+ return `<!doctype html><html><body style="margin:0;display:flex;align-items:center;gap:8px;height:40px;padding:0 12px;border-radius:20px;background:rgba(28,28,30,.92);color:#fff;font:12.5px -apple-system,sans-serif;-webkit-app-region:no-drag;user-select:none" onclick="const a=event.target.dataset&&event.target.dataset.act;if(a)console.log('dsbot-computer:'+a)">${rows}${stopAll}</body></html>`
+}
+
+function escapeHtml(value) {
+ return String(value).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;')
+}
diff --git a/app/src/main.mjs b/app/src/main.mjs
index 386d45f0..bfe005ee 100644
--- a/app/src/main.mjs
+++ b/app/src/main.mjs
@@ -6,6 +6,7 @@
// what the start window and the tray need is imported up front; the rest loads once the start
// window is up (docs/plans/2026-10-26-start-window.md §11).
import { app, BrowserWindow, clipboard, ipcMain, Menu, nativeImage, nativeTheme, powerMonitor, screen, session, shell as electronShell, systemPreferences, Tray, WebContentsView } from 'electron'
+import { createComputerIndicator, indicatorHtml } from './computer-indicator.mjs'
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs'
import { readFile, rm } from 'node:fs/promises'
import { release } from 'node:os'
@@ -42,6 +43,7 @@ const IPC = {
appUpdateState: 'ds-bot:app-update-state', appUpdateCheck: 'ds-bot:app-update-check',
appUpdateInstall: 'ds-bot:app-update-install', appUpdateOpen: 'ds-bot:app-update-open',
appUpdateChanged: 'ds-bot:app-update-changed',
+ idleSeconds: 'ds-bot:idle-seconds', computer: 'ds-bot:computer', computerAction: 'ds-bot:computer-action',
}
// A cookie export larger than this is not a cookie export.
const IMPORT_FILE_MAX = 32 * 1024 * 1024
@@ -154,6 +156,8 @@ const shell = createShell({
target.focus()
},
quit: () => { app.quit() },
+ // A tray entry's Stop (or Stop all) goes back to the page, which owns the actions.
+ computer: (kind, botId) => { mainWindow?.webContents.send(IPC.computerAction, { kind, botId }) },
busy: () => copying !== undefined,
// Before the first run has chosen its places there is no window to show, and before the
// first load of the Host there is no address to load.
@@ -721,6 +725,19 @@ function handleIpc() {
// A throwaway run (DS_BOT_HOME) keeps its folders where it was told.
const fixed = Boolean(process.env.DS_BOT_HOME)
// The team view has mounted (ds-bot calls dsBotApp.ready()): the start window hands over.
+ const computerIndicator = createComputerIndicator({
+ BrowserWindow, screen, html: indicatorHtml,
+ onAction: (kind, botId) => { mainWindow?.webContents.send(IPC.computerAction, { kind, botId }) },
+ log: logs,
+ })
+ ipcMain.on(IPC.computer, (event, entries) => {
+ if (!fromWindow(event)) return
+ const list = Array.isArray(entries) ? entries.filter(entry => entry && typeof entry.label === 'string').slice(0, 12) : []
+ computerIndicator.update(list)
+ shell.setComputer(list)
+ })
+ ipcMain.handle(IPC.idleSeconds, (event) => (fromWindow(event) ? powerMonitor.getSystemIdleTime() : 0))
+ app.on('before-quit', () => { computerIndicator.dispose() })
ipcMain.on(IPC.ready, (event, report) => { if (fromWindow(event)) startWindow.ready(report) })
// It has drawn the whale the start window hands over: the windows cross-fade.
ipcMain.on(IPC.handoffReady, (event) => { if (fromWindow(event)) startWindow.teamReady() })
diff --git a/app/src/preload.cjs b/app/src/preload.cjs
index a65addda..c9ac713d 100644
--- a/app/src/preload.cjs
+++ b/app/src/preload.cjs
@@ -46,6 +46,18 @@ if (startPage !== undefined) {
browser: browserBridge(),
// The app's own updater, for the About row's state and buttons.
updates: updatesBridge(),
+ // Computer use: the OS idle time behind the foreground gate, and the floating
+ // indicator's entries; the window answers its buttons.
+ idleSeconds: () => ipcRenderer.invoke('ds-bot:idle-seconds'),
+ computer: (entries) => { ipcRenderer.send('ds-bot:computer', computerEntriesOf(entries)) },
+ onComputerAction: (run) => {
+ if (typeof run !== 'function') return
+ ipcRenderer.removeAllListeners('ds-bot:computer-action')
+ ipcRenderer.on('ds-bot:computer-action', (_event, action) => {
+ if (action === null || typeof action !== 'object' || typeof action.kind !== 'string') return
+ run({ kind: action.kind, botId: typeof action.botId === 'string' ? action.botId : null })
+ })
+ },
})
// Only plain numbers cross; the main process checks that they make a box inside the page.
const placeOf = (value) => {
@@ -58,6 +70,17 @@ if (startPage !== undefined) {
}
return place
}
+ const computerEntriesOf = (value) => {
+ if (!Array.isArray(value)) return []
+ return value.map((entry) => {
+ if (entry === null || typeof entry !== 'object' || typeof entry.label !== 'string') return undefined
+ return {
+ label: String(entry.label).slice(0, 80),
+ botId: typeof entry.botId === 'string' ? entry.botId : null,
+ waiting: entry.waiting === true,
+ }
+ }).filter(entry => entry !== undefined)
+ }
const handoffOf = (value) => {
if (value === null || typeof value !== 'object') return undefined
const from = {}
diff --git a/app/src/shell.mjs b/app/src/shell.mjs
index f522a442..a2527618 100644
--- a/app/src/shell.mjs
+++ b/app/src/shell.mjs
@@ -133,6 +133,7 @@ export function createShell(options) {
image, tooltip: text().tooltip,
open: { label: text().open, run: () => { open() } },
quit: { label: text().quit, run: () => { quit() } },
+ computer: { onAction: (kind, botId) => { options.computer?.(kind, botId) } },
log,
})
} catch (error) {
@@ -225,6 +226,8 @@ export function createShell(options) {
beginQuit,
cancelQuit,
dispose,
+ /** The same computer-use entries the floating indicator carries. */
+ setComputer: entries => { tray?.setComputer(entries) },
hasTray: () => tray !== undefined,
isQuitting: () => quitting,
isHidden: (target) => hidden.has(target),
diff --git a/app/src/tray.mjs b/app/src/tray.mjs
index 46de7b20..4872de9f 100644
--- a/app/src/tray.mjs
+++ b/app/src/tray.mjs
@@ -9,17 +9,27 @@
* tooltip: string,
* open: { label: string, run: () => void },
* quit: { label: string, run: () => void },
+ * computer?: { onAction: (kind: string, botId: string | null) => void },
* log?: Pick<Console, 'warn'>,
* }} options the mark, the tooltip and the two entries of the menu
- * @returns {{ tray: object, relabel: () => void, dispose: () => void }}
+ * @returns {{ tray: object, relabel: () => void, setComputer: (entries: object[]) => void, dispose: () => void }}
*/
-export function createTray({ Tray, Menu, platform, image, tooltip, open, quit, log = console }) {
+export function createTray({ Tray, Menu, platform, image, tooltip, open, quit, computer, log = console }) {
const tray = new Tray(image)
let disposed = false
+ let entries = []
const relabel = () => {
tray.setToolTip(tooltip)
+ const rows = entries.map(entry => ({
+ label: entry.label,
+ click: () => { computer?.onAction('stop', entry.botId ?? null) },
+ }))
+ if (entries.length > 1) rows.push({
+ label: 'Stop all', click: () => { computer?.onAction('stopall', null) },
+ })
tray.setContextMenu(Menu.buildFromTemplate([
{ label: open.label, click: () => { open.run() } },
+ ...(rows.length > 0 ? [{ type: 'separator' }, ...rows] : []),
{ type: 'separator' },
{ label: quit.label, click: () => { quit.run() } },
]))
@@ -31,6 +41,11 @@ export function createTray({ Tray, Menu, platform, image, tooltip, open, quit, l
return {
tray,
relabel,
+ /** The same entries the floating indicator shows, while any Bot is on the computer. */
+ setComputer(next) {
+ entries = Array.isArray(next) ? next.filter(entry => entry && typeof entry.label === 'string') : []
+ if (!disposed) relabel()
+ },
/** Take the icon away; the app leaves no dead icon behind. */
dispose() {
if (disposed) return
diff --git a/app/test/computer-indicator.test.mjs b/app/test/computer-indicator.test.mjs
new file mode 100644
index 00000000..8721af96
--- /dev/null
+++ b/app/test/computer-indicator.test.mjs
@@ -0,0 +1,74 @@
+import assert from 'node:assert/strict'
+import { test } from 'node:test'
+import { createComputerIndicator, indicatorHtml } from '../src/computer-indicator.mjs'
+
+function fakeElectron() {
+ const windows = []
+ class FakeWindow {
+ constructor(options) {
+ this.options = options
+ this.listeners = new Map()
+ this.webContents = { on: (name, fn) => { this.web = { ...this.web, [name]: fn } }, send: () => {}, loadURL: async () => {} }
+ this.once = (name, fn) => { this.listeners.set(name, fn) }
+ this.on = (name, fn) => { this.listeners.set(name, fn) }
+ this.actions = []
+ windows.push(this)
+ }
+ setContentProtection(on) { this.protection = on }
+ setVisibleOnAllWorkspaces(on) { this.workspaces = on }
+ showInactive() { this.shown = true }
+ close() { this.closed = true; this.listeners.get('closed')?.() }
+ loadURL(url) { this.url = url; return Promise.resolve() }
+ }
+ return {
+ windows,
+ BrowserWindow: FakeWindow,
+ screen: { getPrimaryDisplay: () => ({ workAreaSize: { width: 1440, height: 900 }, workArea: { x: 0, y: 0 } }) },
+ }
+}
+
+test('the indicator window is frameless, unfocusable, protected and centered', () => {
+ const { BrowserWindow, screen, windows } = fakeElectron()
+ const indicator = createComputerIndicator({ BrowserWindow, screen, html: indicatorHtml, log: { warn: () => {} } })
+ indicator.update([{ label: 'River · Notes', botId: 'w1' }])
+ assert.equal(windows.length, 1)
+ const [win] = windows
+ assert.equal(win.options.frame, false)
+ assert.equal(win.options.transparent, true)
+ assert.equal(win.options.alwaysOnTop, true)
+ assert.equal(win.options.focusable, false)
+ assert.equal(win.protection, true)
+ assert.equal(win.workspaces, true)
+ // top center of the primary display
+ assert.equal(win.options.x, Math.round((1440 - 520) / 2))
+ assert.equal(win.options.y, 8)
+ indicator.dispose()
+ assert.equal(win.closed, true)
+})
+
+test('empty entries hide the window; button clicks reach onAction', async () => {
+ const { BrowserWindow, screen, windows } = fakeElectron()
+ const actions = []
+ const indicator = createComputerIndicator({ BrowserWindow, screen, html: indicatorHtml, onAction: (kind, botId) => actions.push([kind, botId]), log: { warn: () => {} } })
+ indicator.update([{ label: 'River · Notes', botId: 'w1' }])
+ const [win] = windows
+ win.web['console-message'](null, 3, 'dsbot-computer:stop:w1')
+ win.web['console-message'](null, 3, 'dsbot-computer:stopall:')
+ win.web['console-message'](null, 3, 'dsbot-computer:letgo:m1')
+ win.web['console-message'](null, 3, 'console noise')
+ assert.deepEqual(actions, [['stop', 'w1'], ['stopall', null], ['letgo', 'm1']])
+ indicator.update([])
+ assert.equal(win.closed, true)
+})
+
+test('the page lists every entry with its own stop and escapes markup', () => {
+ const page = indicatorHtml([{ label: 'River · <img>', botId: 'w1' }, { label: 'Chief · Mail', botId: 'm1' }, { label: 'Writer waits', botId: 'w2', waiting: true }])
+ assert.match(page, /River · &lt;img&gt;/)
+ assert.match(page, /data-act="stop:w1"/)
+ assert.match(page, /data-act="stop:m1"/)
+ assert.match(page, /data-act="letgo:w2"/)
+ assert.match(page, /data-act="stopall:"/)
+ assert.doesNotMatch(page, /<img>/)
+ const one = indicatorHtml([{ label: 'River · Notes', botId: 'w1' }])
+ assert.doesNotMatch(one, /stopall/)
+})