Skip to content

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

Restyle the computer indicator as a glass pill with avatars

feiz59cbee7c74e9
diff --git a/app/src/computer-indicator.mjs b/app/src/computer-indicator.mjs
index 3b961ed6..b30e07f0 100644
--- a/app/src/computer-indicator.mjs
+++ b/app/src/computer-indicator.mjs
@@ -25,14 +25,24 @@ export function createComputerIndicator({ BrowserWindow, screen, html, ipcMain,
})
let entries = []
let labels = {}
+ // Fit the transparent window to the pill: only the pill is painted, so the
+ // window shrinks to its width and stays centered on the primary work area.
+ const fit = async () => {
+ try {
+ const width = await win?.webContents?.executeJavaScript("document.querySelector('.bar')?.offsetWidth ?? 0")
+ if (win === null || typeof width !== 'number' || width <= 0) return
+ const area = screen.getPrimaryDisplay()
+ const full = Math.ceil(width) + 24
+ win.setBounds({ width: full, height: 48, x: Math.round(area.workArea.x + (area.workAreaSize.width - full) / 2), y: area.workArea.y + 8 })
+ } catch {}
+ }
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,
+ height: 48,
x: Math.round(area.workArea.x + (area.workAreaSize.width - width) / 2),
y: area.workArea.y + 8,
frame: false,
@@ -52,7 +62,7 @@ export function createComputerIndicator({ BrowserWindow, screen, html, ipcMain,
win.once('ready-to-show', () => { win?.showInactive() })
win.on('closed', () => { win = null })
const page = html(entries, labels)
- win.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(page)}`).catch((error) => {
+ win.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(page)}`).then(fit).catch((error) => {
log.warn(`DS Bot: the indicator did not load: ${error instanceof Error ? error.message : String(error)}`)
})
}
@@ -65,11 +75,11 @@ export function createComputerIndicator({ BrowserWindow, screen, html, ipcMain,
return {
/** Re-render the bar; empty entries hide the window, entries show it. */
update(next) {
- entries = Array.isArray(next?.rows) ? next.rows : []
+ entries = (Array.isArray(next?.rows) ? next.rows : []).map(sanitizeEntry)
labels = next?.labels ?? {}
if (entries.length === 0) { close(); return }
if (win === null) { open(); return }
- try { win.webContents?.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(html(entries, labels))}`) } catch (error) { log.warn(`DS Bot: the indicator did not update: ${error instanceof Error ? error.message : String(error)}`) }
+ try { win.webContents?.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(html(entries, labels))}`).then(fit) } catch (error) { log.warn(`DS Bot: the indicator did not update: ${error instanceof Error ? error.message : String(error)}`) }
},
dispose() {
entries = []
@@ -78,23 +88,53 @@ export function createComputerIndicator({ BrowserWindow, screen, html, ipcMain,
}
}
-// 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.
+// The bar's own page: the same glass pill the in-app indicator wears, themed by
+// the system appearance. Only the pill is painted; the window is transparent.
export function indicatorHtml(entries, labels = {}) {
+ const avatar = (entry) => entry.avatar !== undefined
+ ? `<img class="ava" src="${escapeHtml(entry.avatar)}" alt="">`
+ : `<span class="ava dot" style="background:${escapeHtml(entry.color ?? '#888')}">${escapeHtml(String(entry.name ?? entry.label ?? 'B').slice(0, 1))}</span>`
+ const stopBtn = entry => `<button class="stop" data-act="stop:${escapeHtml(entry.botId ?? '')}" aria-label="${escapeHtml(labels.stop ?? 'Stop')}" title="${escapeHtml(labels.stop ?? 'Stop')}"><span class="sq"></span></button>`
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;background:none;color:#2563eb;cursor:pointer;font:inherit;white-space:nowrap">${escapeHtml(labels.stop ?? 'Stop')}</button>
- </span>`
+ <span class="entry">${avatar(entry)}<span class="text"><b>${escapeHtml(entry.name ?? entry.label)}</b>${entry.app !== undefined ? `<i>${escapeHtml(entry.app)}</i>` : ''}</span>${stopBtn(entry)}</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">${escapeHtml(labels.letGo ?? 'Let it continue')}</button>
- </span>`
- const rows = entries.map(entry => entry.waiting ? waiting(entry) : row(entry)).join('')
+ <span class="entry">${avatar(entry)}<span class="text"><b>${escapeHtml(entry.label)}</b></span><button class="go" data-act="letgo:${escapeHtml(entry.botId ?? '')}">${escapeHtml(labels.letGo ?? 'Let it continue')}</button></span>`
+ const rows = entries.map((entry, index) => `${index > 0 ? '<span class="sep"></span>' : ''}${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">${escapeHtml(labels.stopAll ?? '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&&window.computerIndicator){const i=a.indexOf(':');computerIndicator.act(a.slice(0,i),a.slice(i+1)||null)}">${rows}${stopAll}</body></html>`
+ ? `<button class="all" data-act="stopall:">${escapeHtml(labels.stopAll ?? 'Stop all')}</button>` : ''
+ return `<!doctype html><html><head><meta charset="utf-8"><style>
+:root{color-scheme:light dark}
+body{margin:0;background:transparent;font:12.5px -apple-system,sans-serif;-webkit-app-region:no-drag;user-select:none}
+.bar{display:inline-flex;align-items:center;gap:8px;height:36px;padding:0 12px;margin:4px 12px;border-radius:999px;backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);font-size:12.5px}
+@media (prefers-color-scheme:light){.bar{background:rgba(255,255,255,.72);border:1px solid rgba(0,0,0,.08);box-shadow:inset 0 1px 0 rgba(255,255,255,.6),0 6px 24px rgba(0,0,0,.14);color:#1c1c1e}.bar i,.go{color:#555}}
+@media (prefers-color-scheme:dark){.bar{background:rgba(30,30,32,.78);border:1px solid rgba(255,255,255,.12);box-shadow:inset 0 1px 0 rgba(255,255,255,.14),0 6px 24px rgba(0,0,0,.4);color:#f2f2f7}.bar i{color:#aaa}.go{color:#0a84ff}}
+.live{flex:none;width:7px;height:7px;border-radius:50%;background:#ff453a;box-shadow:0 0 0 3px rgba(255,69,58,.24)}
+.sep{flex:none;width:1px;height:14px;background:currentColor;opacity:.2}
+.entry{display:flex;align-items:center;gap:6px;min-width:0}
+.ava{flex:none;width:16px;height:16px;border-radius:50%;object-fit:cover}
+.ava.dot{display:inline-flex;align-items:center;justify-content:center;color:#fff;font-size:9px;font-weight:600}
+.text{display:flex;align-items:baseline;gap:5px;min-width:0;overflow:hidden}
+.text b{font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
+.text i{font-style:normal;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:110px;opacity:.75}
+.stop{flex:none;width:22px;height:22px;border:0;border-radius:50%;background:rgba(128,128,128,.2);color:inherit;cursor:pointer;display:inline-flex;align-items:center;justify-content:center}
+.sq{width:8px;height:8px;border-radius:2px;background:currentColor}
+.stop:hover{background:#ff453a;color:#fff}
+.go,.all{flex:none;border-radius:999px;padding:3px 10px;font:inherit;font-size:12px;cursor:pointer;white-space:nowrap;border:1px solid transparent}
+.go{background:rgba(10,132,255,.16);border-color:rgba(10,132,255,.32);color:#0a84ff}
+.all{background:rgba(255,69,58,.12);border-color:rgba(255,69,58,.3);color:#ff453a}
+</style></head><body onclick="const a=event.target.closest('[data-act]')?.dataset?.act;if(a&&window.computerIndicator){const i=a.indexOf(':');computerIndicator.act(a.slice(0,i),a.slice(i+1)||null)}"><div class="bar"><span class="live"></span>${rows}${stopAll}</div></body></html>`
+}
+
+// What the client may put on a row: ids and text, a hex color, an optional
+// bounded data-URL avatar. Anything else is dropped before it reaches the page.
+export function sanitizeEntry(entry) {
+ if (entry === null || typeof entry !== 'object') return { label: '' }
+ const clean = {}
+ for (const key of ['botId', 'label', 'name', 'app']) if (entry[key] !== undefined) clean[key] = String(entry[key])
+ if (entry.waiting === true) clean.waiting = true
+ if (typeof entry.color === 'string' && /^#[0-9a-fA-F]{3,8}$/.test(entry.color)) clean.color = entry.color
+ if (typeof entry.avatar === 'string' && /^data:image\/(png|jpeg|webp|svg\+xml);base64,[a-zA-Z0-9+/=]+$/.test(entry.avatar) && entry.avatar.length <= 12000) clean.avatar = entry.avatar
+ return clean
}
function escapeHtml(value) {
diff --git a/app/test/computer-indicator.test.mjs b/app/test/computer-indicator.test.mjs
index 92ea3b27..c1fba6e5 100644
--- a/app/test/computer-indicator.test.mjs
+++ b/app/test/computer-indicator.test.mjs
@@ -1,6 +1,6 @@
import assert from 'node:assert/strict'
import { test } from 'node:test'
-import { createComputerIndicator, indicatorHtml } from '../src/computer-indicator.mjs'
+import { createComputerIndicator, indicatorHtml, sanitizeEntry } from '../src/computer-indicator.mjs'
function fakeElectron() {
const windows = []
@@ -8,13 +8,14 @@ function fakeElectron() {
constructor(options) {
this.options = options
this.listeners = new Map()
- this.webContents = { on: (name, fn) => { this.web = { ...this.web, [name]: fn } }, send: () => {}, loadURL: async () => {} }
+ this.webContents = { on: (name, fn) => { this.web = { ...this.web, [name]: fn } }, send: () => {}, loadURL: async () => {}, executeJavaScript: async () => 120 }
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 }
+ setBounds(bounds) { this.bounds = bounds }
setVisibleOnAllWorkspaces(on) { this.workspaces = on }
showInactive() { this.shown = true }
close() { this.closed = true; this.listeners.get('closed')?.() }
@@ -71,14 +72,17 @@ test('the page lists every entry, escapes markup and uses the passed labels', ()
assert.match(page, /data-act="stop:m1"/)
assert.match(page, /data-act="letgo:w2"/)
assert.match(page, /data-act="stopall:"/)
- assert.match(page, />Stop</)
+ assert.match(page, /aria-label="Stop"/)
+ assert.match(page, /class="sq"/)
assert.match(page, />Stop all</)
assert.match(page, />Let it continue</)
assert.doesNotMatch(page, /<img>/)
const one = indicatorHtml([{ label: 'River · Notes', botId: 'w1' }], labels)
assert.doesNotMatch(one, /stopall/)
const zh = indicatorHtml([{ label: 'River · Notes', botId: 'w1' }], { stop: '停止' })
- assert.match(zh, />停止</)
+ assert.match(zh, /aria-label="停止"/)
+ assert.match(page, /prefers-color-scheme/)
+ assert.match(page, /class="bar"/)
})
test('button actions go over the dedicated channel and only from the indicator', () => {
@@ -127,3 +131,30 @@ test('a reopen keeps exactly one action listener, so one click acts once', () =>
assert.deepEqual(calls, ['stop'])
indicator.dispose()
})
+
+test('rows are sanitized: hex color and bounded data-url avatar only', () => {
+ const clean = sanitizeEntry({ botId: 'w1', label: 'River', name: 'River', app: 'Notes', color: '#3b82f6', avatar: 'data:image/png;base64,aGk=', extra: 'x' })
+ assert.equal(clean.color, '#3b82f6')
+ assert.equal(clean.avatar, 'data:image/png;base64,aGk=')
+ assert.equal(clean.extra, undefined)
+ assert.equal(sanitizeEntry({ label: 'a', color: 'red' }).color, undefined)
+ assert.equal(sanitizeEntry({ label: 'a', color: 'url(evil)' }).color, undefined)
+ assert.equal(sanitizeEntry({ label: 'a', avatar: 'data:text/html;base64,aGk=' }).avatar, undefined)
+ assert.equal(sanitizeEntry({ label: 'a', avatar: 'data:image/png;base64,' + 'A'.repeat(13000) }).avatar, undefined)
+ assert.equal(sanitizeEntry(null).label, '')
+ const page = indicatorHtml([{ name: 'River', app: 'Notes', color: '#3b82f6', botId: 'w1' }], {})
+ assert.match(page, /background:#3b82f6/)
+ assert.match(page, /<b>River<\/b>/)
+ assert.match(page, /<i>Notes<\/i>/)
+})
+
+test('the window resizes to the measured pill width after load', async () => {
+ const { windows, BrowserWindow } = fakeElectron()
+ const indicator = createComputerIndicator({ BrowserWindow, screen: { getPrimaryDisplay: () => ({ workAreaSize: { width: 1440, height: 900 }, workArea: { x: 0, y: 0 } }) }, html: () => '<html></html>', log: { warn: () => {} } })
+ indicator.update({ rows: [{ label: 'River · Notes', botId: 'w1' }], labels: {} })
+ await new Promise(resolve => setImmediate(resolve))
+ const win = windows[0]
+ assert.equal(win.bounds.width, 144)
+ assert.equal(win.bounds.height, 48)
+ assert.equal(win.bounds.x, Math.round((1440 - 144) / 2))
+})
diff --git a/ds-bot/client.js b/ds-bot/client.js
index c65f3ec2..b0473cc2 100644
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@ -5531,23 +5531,40 @@ function ComputerIndicator({ useComputer, useRoster, actions }) {
const leases = live.leases ?? [];
const waiting = Object.entries(live.bots ?? {}).filter(([, entry]) => entry.waitingFor === "user-idle");
if (leases.length === 0 && waiting.length === 0) return null;
- const nameOf = (id) => roster.byId[id]?.name ?? t("a Bot");
+ const botOf = (id) => roster.byId[id];
+ const nameOf = (id) => botOf(id)?.name ?? t("a Bot");
+ const avatarOf = (id) => {
+ const look = lookOf(botOf(id));
+ if (typeof look.image === "string" && look.image.startsWith("data:image/")) return (0, import_react10.createElement)("img", { className: "bt-cbar-ava", src: look.image, alt: "" });
+ return (0, import_react10.createElement)("span", { className: "bt-cbar-ava bt-cbar-ava-dot", style: { background: look.color } }, String(nameOf(id)).slice(0, 1));
+ };
+ const entries2 = [
+ ...leases.map((entry) => ({ key: `l:${entry.botId}`, botId: entry.botId, waiting: false, app: entry.kind === "foreground" ? t("Foreground") : entry.appName })),
+ ...waiting.map(([botId]) => ({ key: `w:${botId}`, botId, waiting: true, app: t("waits for the computer") }))
+ ];
return (0, import_react10.createElement)(
"div",
{ className: "bt-cbar", role: "status" },
- (0, import_react10.createElement)(MonitorIcon),
- leases.map((entry, index) => (0, import_react10.createElement)(
- "span",
- { key: index, className: "bt-cbar-entry" },
- (0, import_react10.createElement)("span", { className: "bt-cbar-name" }, entry.kind === "foreground" ? t("{name} · foreground", { name: nameOf(entry.botId) }) : `${nameOf(entry.botId)} · ${entry.appName}`),
- (0, import_react10.createElement)("button", { type: "button", className: "bt-cbar-stop", onClick: () => void actions.computerStop(entry.botId) }, t("Stop"))
- )),
- waiting.map(([botId]) => (0, import_react10.createElement)(
- "span",
- { key: botId, className: "bt-cbar-entry bt-cbar-wait" },
- (0, import_react10.createElement)("span", { className: "bt-cbar-name" }, t("{name} waits for the computer", { name: nameOf(botId) })),
- (0, import_react10.createElement)("button", { type: "button", className: "bt-cbar-go", onClick: () => void actions.computerAllowForeground(botId) }, t("Let it continue"))
- )),
+ (0, import_react10.createElement)("span", { className: "bt-cbar-live", title: t("Computer use") }),
+ ...entries2.flatMap((entry, index) => [
+ index > 0 ? (0, import_react10.createElement)("span", { key: `s${index}`, className: "bt-cbar-sep" }) : null,
+ (0, import_react10.createElement)(
+ "span",
+ { key: entry.key, className: entry.waiting ? "bt-cbar-entry bt-cbar-wait" : "bt-cbar-entry" },
+ avatarOf(entry.botId),
+ (0, import_react10.createElement)(
+ "span",
+ { className: "bt-cbar-text" },
+ (0, import_react10.createElement)("b", { className: "bt-cbar-name" }, entry.waiting ? t("{name} waits for the computer", { name: nameOf(entry.botId) }) : nameOf(entry.botId)),
+ entry.waiting ? null : (0, import_react10.createElement)("i", { className: "bt-cbar-app" }, entry.app)
+ ),
+ entry.waiting ? (0, import_react10.createElement)("button", { type: "button", className: "bt-cbar-go", onClick: () => void actions.computerAllowForeground(entry.botId) }, t("Let it continue")) : (0, import_react10.createElement)(
+ "button",
+ { type: "button", className: "bt-cbar-stop", "aria-label": t("Stop"), title: t("Stop"), onClick: () => void actions.computerStop(entry.botId) },
+ (0, import_react10.createElement)("span", { className: "bt-cbar-stopsq" })
+ )
+ )
+ ]),
leases.length > 1 ? (0, import_react10.createElement)("button", { type: "button", className: "bt-cbar-all", onClick: () => void actions.computerStop(null, true) }, t("Stop all")) : null
);
}
@@ -5566,18 +5583,26 @@ var COMPUTER_CSS = `
.bt-cview-step{display:flex;align-items:center;gap:6px;font-size:12.5px;color:var(--bt-ink-2)}
.bt-cview-step[data-ok=no]{color:var(--bt-danger)}
.bt-cview-step-err{font-size:11px}
-.bt-cbar{position:absolute;top:8px;left:50%;transform:translateX(-50%);z-index:60;display:flex;align-items:center;gap:8px;max-width:min(520px,calc(100vw - 32px));padding:6px 10px;border-radius:999px;background:var(--bt-main);border:1px solid var(--bt-line);box-shadow:0 4px 16px rgba(0,0,0,.14);font-size:12.5px}
-.bt-cbar svg{width:14px;height:14px;flex:none;color:var(--bt-ink-2)}
-.bt-cbar-entry{display:flex;align-items:center;gap:4px;min-width:0}
-.bt-cbar-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
-.bt-cbar-stop{flex:none;width:18px;height:18px;border:0;border-radius:50%;background:var(--bt-hover);color:var(--bt-ink-2);cursor:pointer;line-height:1;font-size:12px}
+.bt-cbar{position:absolute;top:8px;left:50%;transform:translateX(-50%);z-index:60;display:flex;align-items:center;gap:8px;max-width:min(620px,calc(100vw - 32px));padding:6px 12px;border-radius:999px;background:var(--bt-glass-bg,rgba(255,255,255,.72));border:1px solid var(--bt-glass-border,var(--bt-line));box-shadow:inset 0 1px 0 var(--bt-glass-rim,rgba(255,255,255,.5)),0 6px 24px var(--bt-glass-shadow,rgba(0,0,0,.14));backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);font-size:12.5px}
+.bt-cbar-live{flex:none;width:7px;height:7px;border-radius:50%;background:var(--bt-danger);box-shadow:0 0 0 3px color-mix(in srgb,var(--bt-danger) 24%,transparent)}
+.bt-cbar-sep{flex:none;width:1px;height:14px;background:var(--bt-line);opacity:.7}
+.bt-cbar-entry{display:flex;align-items:center;gap:6px;min-width:0}
+.bt-cbar-ava{flex:none;width:16px;height:16px;border-radius:50%;object-fit:cover}
+.bt-cbar-ava-dot{display:inline-flex;align-items:center;justify-content:center;color:#fff;font-size:9px;font-weight:600;line-height:1}
+.bt-cbar-text{display:flex;align-items:baseline;gap:5px;min-width:0;overflow:hidden}
+.bt-cbar-name{font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
+.bt-cbar-app{font-style:normal;color:var(--bt-ink-2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:120px}
+.bt-cbar-stop{flex:none;width:22px;height:22px;border:0;border-radius:50%;background:var(--bt-hover);color:var(--bt-ink-2);cursor:pointer;display:inline-flex;align-items:center;justify-content:center}
+.bt-cbar-stopsq{width:8px;height:8px;border-radius:2px;background:currentColor}
.bt-cbar-stop:hover{background:var(--bt-danger);color:var(--bt-mark-ink)}
+.bt-cbar-go,.bt-cbar-all{flex:none;border-radius:999px;padding:3px 10px;font:inherit;font-size:12px;cursor:pointer;white-space:nowrap;border:1px solid transparent}
+.bt-cbar-go{background:color-mix(in srgb,var(--bt-accent) 14%,transparent);color:var(--bt-accent);border-color:color-mix(in srgb,var(--bt-accent) 30%,transparent)}
+.bt-cbar-all{background:color-mix(in srgb,var(--bt-danger) 12%,transparent);color:var(--bt-danger);border-color:color-mix(in srgb,var(--bt-danger) 28%,transparent)}
.bt-cstep{display:flex;align-items:center;gap:10px;padding:3px 0;color:var(--bt-ink-2);font-size:12.5px}
.bt-cstep-shot{flex:none;border:1px solid var(--bt-line);border-radius:8px;padding:0;background:none;cursor:zoom-in;overflow:hidden;max-height:40px}
.bt-cstep-shot img{display:block;max-height:40px;max-width:72px;object-fit:cover}
.bt-cstep-shot-open{max-height:none;cursor:zoom-out}
.bt-cstep-shot-open img{max-height:280px;max-width:480px}
-.bt-cbar-go,.bt-cbar-all{border:0;background:none;color:var(--bt-accent);font:inherit;cursor:pointer;white-space:nowrap}
`;
// node_modules/deep-view/src/react/ui.js
@@ -25297,12 +25322,17 @@ function apply(ctx) {
const sync = () => {
const live2 = computer.getSnapshot();
const name = (id) => nameOf(id);
+ const look = (id) => lookOf(roster.getSnapshot().byId[id]);
const rows2 = (live2.leases ?? []).map((entry) => ({
botId: entry.botId,
- label: entry.kind === "foreground" ? `${name(entry.botId)} · ${t("Foreground")}` : `${name(entry.botId)} · ${entry.appName}`
+ name: name(entry.botId),
+ app: entry.kind === "foreground" ? t("Foreground") : entry.appName,
+ label: entry.kind === "foreground" ? `${name(entry.botId)} · ${t("Foreground")}` : `${name(entry.botId)} · ${entry.appName}`,
+ color: look(entry.botId).color,
+ avatar: look(entry.botId).image
}));
for (const [botId, entry] of Object.entries(live2.bots ?? {})) {
- if (entry.waitingFor === "user-idle") rows2.push({ botId, waiting: true, label: t("{name} waits for the computer", { name: name(botId) }) });
+ if (entry.waitingFor === "user-idle") rows2.push({ botId, waiting: true, name: name(botId), app: t("waits for the computer"), label: t("{name} waits for the computer", { name: name(botId) }), color: look(botId).color, avatar: look(botId).image });
}
appComputer.computer({
rows: rows2,
diff --git a/ds-bot/src/client/computer.js b/ds-bot/src/client/computer.js
index 97191d5c..73319a90 100644
--- a/ds-bot/src/client/computer.js
+++ b/ds-bot/src/client/computer.js
@@ -3,6 +3,7 @@ import { CheckIcon, MonitorIcon } from './icons.js'
import { useDockHold } from './card-hold.js'
import { heldCardKey } from './sources.js'
import { CellEmpty } from './cell-empty.js'
+import { lookOf } from './characters.js'
import { t } from './i18n.js'
import { toolArgs } from './text.js'
@@ -292,15 +293,31 @@ export function ComputerIndicator({ useComputer, useRoster, actions }) {
const leases = live.leases ?? []
const waiting = Object.entries(live.bots ?? {}).filter(([, entry]) => entry.waitingFor === 'user-idle')
if (leases.length === 0 && waiting.length === 0) return null
- const nameOf = id => roster.byId[id]?.name ?? t('a Bot')
+ const botOf = id => roster.byId[id]
+ const nameOf = id => botOf(id)?.name ?? t('a Bot')
+ const avatarOf = (id) => {
+ const look = lookOf(botOf(id))
+ if (typeof look.image === 'string' && look.image.startsWith('data:image/')) return h('img', { className: 'bt-cbar-ava', src: look.image, alt: '' })
+ return h('span', { className: 'bt-cbar-ava bt-cbar-ava-dot', style: { background: look.color } }, String(nameOf(id)).slice(0, 1))
+ }
+ const entries = [
+ ...leases.map(entry => ({ key: `l:${entry.botId}`, botId: entry.botId, waiting: false, app: entry.kind === 'foreground' ? t('Foreground') : entry.appName })),
+ ...waiting.map(([botId]) => ({ key: `w:${botId}`, botId, waiting: true, app: t('waits for the computer') })),
+ ]
return h('div', { className: 'bt-cbar', role: 'status' },
- h(MonitorIcon),
- leases.map((entry, index) => h('span', { key: index, className: 'bt-cbar-entry' },
- h('span', { className: 'bt-cbar-name' }, entry.kind === 'foreground' ? t('{name} · foreground', { name: nameOf(entry.botId) }) : `${nameOf(entry.botId)} · ${entry.appName}`),
- h('button', { type: 'button', className: 'bt-cbar-stop', onClick: () => void actions.computerStop(entry.botId) }, t('Stop')))),
- waiting.map(([botId]) => h('span', { key: botId, className: 'bt-cbar-entry bt-cbar-wait' },
- h('span', { className: 'bt-cbar-name' }, t('{name} waits for the computer', { name: nameOf(botId) })),
- h('button', { type: 'button', className: 'bt-cbar-go', onClick: () => void actions.computerAllowForeground(botId) }, t('Let it continue')))),
+ h('span', { className: 'bt-cbar-live', title: t('Computer use') }),
+ ...entries.flatMap((entry, index) => [
+ index > 0 ? h('span', { key: `s${index}`, className: 'bt-cbar-sep' }) : null,
+ h('span', { key: entry.key, className: entry.waiting ? 'bt-cbar-entry bt-cbar-wait' : 'bt-cbar-entry' },
+ avatarOf(entry.botId),
+ h('span', { className: 'bt-cbar-text' },
+ h('b', { className: 'bt-cbar-name' }, entry.waiting ? t('{name} waits for the computer', { name: nameOf(entry.botId) }) : nameOf(entry.botId)),
+ entry.waiting ? null : h('i', { className: 'bt-cbar-app' }, entry.app)),
+ entry.waiting
+ ? h('button', { type: 'button', className: 'bt-cbar-go', onClick: () => void actions.computerAllowForeground(entry.botId) }, t('Let it continue'))
+ : h('button', { type: 'button', className: 'bt-cbar-stop', 'aria-label': t('Stop'), title: t('Stop'), onClick: () => void actions.computerStop(entry.botId) },
+ h('span', { className: 'bt-cbar-stopsq' }))),
+ ]),
leases.length > 1 ? h('button', { type: 'button', className: 'bt-cbar-all', onClick: () => void actions.computerStop(null, true) }, t('Stop all')) : null)
}
@@ -319,16 +336,24 @@ export const COMPUTER_CSS = `
.bt-cview-step{display:flex;align-items:center;gap:6px;font-size:12.5px;color:var(--bt-ink-2)}
.bt-cview-step[data-ok=no]{color:var(--bt-danger)}
.bt-cview-step-err{font-size:11px}
-.bt-cbar{position:absolute;top:8px;left:50%;transform:translateX(-50%);z-index:60;display:flex;align-items:center;gap:8px;max-width:min(520px,calc(100vw - 32px));padding:6px 10px;border-radius:999px;background:var(--bt-main);border:1px solid var(--bt-line);box-shadow:0 4px 16px rgba(0,0,0,.14);font-size:12.5px}
-.bt-cbar svg{width:14px;height:14px;flex:none;color:var(--bt-ink-2)}
-.bt-cbar-entry{display:flex;align-items:center;gap:4px;min-width:0}
-.bt-cbar-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
-.bt-cbar-stop{flex:none;width:18px;height:18px;border:0;border-radius:50%;background:var(--bt-hover);color:var(--bt-ink-2);cursor:pointer;line-height:1;font-size:12px}
+.bt-cbar{position:absolute;top:8px;left:50%;transform:translateX(-50%);z-index:60;display:flex;align-items:center;gap:8px;max-width:min(620px,calc(100vw - 32px));padding:6px 12px;border-radius:999px;background:var(--bt-glass-bg,rgba(255,255,255,.72));border:1px solid var(--bt-glass-border,var(--bt-line));box-shadow:inset 0 1px 0 var(--bt-glass-rim,rgba(255,255,255,.5)),0 6px 24px var(--bt-glass-shadow,rgba(0,0,0,.14));backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);font-size:12.5px}
+.bt-cbar-live{flex:none;width:7px;height:7px;border-radius:50%;background:var(--bt-danger);box-shadow:0 0 0 3px color-mix(in srgb,var(--bt-danger) 24%,transparent)}
+.bt-cbar-sep{flex:none;width:1px;height:14px;background:var(--bt-line);opacity:.7}
+.bt-cbar-entry{display:flex;align-items:center;gap:6px;min-width:0}
+.bt-cbar-ava{flex:none;width:16px;height:16px;border-radius:50%;object-fit:cover}
+.bt-cbar-ava-dot{display:inline-flex;align-items:center;justify-content:center;color:#fff;font-size:9px;font-weight:600;line-height:1}
+.bt-cbar-text{display:flex;align-items:baseline;gap:5px;min-width:0;overflow:hidden}
+.bt-cbar-name{font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
+.bt-cbar-app{font-style:normal;color:var(--bt-ink-2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:120px}
+.bt-cbar-stop{flex:none;width:22px;height:22px;border:0;border-radius:50%;background:var(--bt-hover);color:var(--bt-ink-2);cursor:pointer;display:inline-flex;align-items:center;justify-content:center}
+.bt-cbar-stopsq{width:8px;height:8px;border-radius:2px;background:currentColor}
.bt-cbar-stop:hover{background:var(--bt-danger);color:var(--bt-mark-ink)}
+.bt-cbar-go,.bt-cbar-all{flex:none;border-radius:999px;padding:3px 10px;font:inherit;font-size:12px;cursor:pointer;white-space:nowrap;border:1px solid transparent}
+.bt-cbar-go{background:color-mix(in srgb,var(--bt-accent) 14%,transparent);color:var(--bt-accent);border-color:color-mix(in srgb,var(--bt-accent) 30%,transparent)}
+.bt-cbar-all{background:color-mix(in srgb,var(--bt-danger) 12%,transparent);color:var(--bt-danger);border-color:color-mix(in srgb,var(--bt-danger) 28%,transparent)}
.bt-cstep{display:flex;align-items:center;gap:10px;padding:3px 0;color:var(--bt-ink-2);font-size:12.5px}
.bt-cstep-shot{flex:none;border:1px solid var(--bt-line);border-radius:8px;padding:0;background:none;cursor:zoom-in;overflow:hidden;max-height:40px}
.bt-cstep-shot img{display:block;max-height:40px;max-width:72px;object-fit:cover}
.bt-cstep-shot-open{max-height:none;cursor:zoom-out}
.bt-cstep-shot-open img{max-height:280px;max-width:480px}
-.bt-cbar-go,.bt-cbar-all{border:0;background:none;color:var(--bt-accent);font:inherit;cursor:pointer;white-space:nowrap}
`
diff --git a/ds-bot/src/client/index.js b/ds-bot/src/client/index.js
index 24df7d0d..0972cd87 100644
--- a/ds-bot/src/client/index.js
+++ b/ds-bot/src/client/index.js
@@ -748,12 +748,17 @@ export function apply(ctx) {
const sync = () => {
const live = computer.getSnapshot()
const name = id => nameOf(id)
+ const look = id => lookOf(roster.getSnapshot().byId[id])
const rows = (live.leases ?? []).map(entry => ({
botId: entry.botId,
+ name: name(entry.botId),
+ app: entry.kind === 'foreground' ? t('Foreground') : entry.appName,
label: entry.kind === 'foreground' ? `${name(entry.botId)} · ${t('Foreground')}` : `${name(entry.botId)} · ${entry.appName}`,
+ color: look(entry.botId).color,
+ avatar: look(entry.botId).image,
}))
for (const [botId, entry] of Object.entries(live.bots ?? {})) {
- if (entry.waitingFor === 'user-idle') rows.push({ botId, waiting: true, label: t('{name} waits for the computer', { name: name(botId) }) })
+ if (entry.waitingFor === 'user-idle') rows.push({ botId, waiting: true, name: name(botId), app: t('waits for the computer'), label: t('{name} waits for the computer', { name: name(botId) }), color: look(botId).color, avatar: look(botId).image })
}
appComputer.computer({
rows,