Skip to content

The agent that grows with you

feat(bot-mode): hide bots from the roster via right-click — header eye toggle reveals and unhides them

Teknium133381508fb1
diff --git a/apps/desktop/src/plugins/hermes-bots/plugin.js b/apps/desktop/src/plugins/hermes-bots/plugin.js
index b68d2adf404..68a01f7c96a 100644
--- a/apps/desktop/src/plugins/hermes-bots/plugin.js
+++ b/apps/desktop/src/plugins/hermes-bots/plugin.js
@@ -132,6 +132,12 @@ function trackInboundActivity(roster) {
$botUnread.set({ ...$botUnread.get(), [bot.name]: true })
+ // Roster-hidden bots stay quiet: the unread flag above accumulates
+ // silently (unhiding reveals the badge) but a hidden bot never toasts.
+ if ($botMeta.get()[bot.name]?.hidden) {
+ continue
+ }
+
// Toasts are opt-in: the unread badge is always set above, but the
// per-message notification fires only when the user enabled it.
if ($activityToasts.get()) {
@@ -269,6 +275,51 @@ async function saveBotMeta(name, patch) {
return { serverPersisted: serverOutcome === 'persisted', serverOutcome }
}
+// ── hidden bots (right-click → Hide Bot) ────────────────────────────────────
+// Hiding is a ROSTER-DISPLAY concern only: a hidden bot keeps working —
+// @mentions still resolve, group-chat membership is untouched, its name
+// still counts as taken, and an open chat stays open. The flag lives in bot
+// meta (`hidden: true`), so it rides the same local-storage + server
+// ui_meta pipeline as pins/titles and follows the profile across machines.
+// Unhide writes `hidden: false` (never null): a null key survives the local
+// `{ ...prev, ...patch }` merge while the server DELETES None keys, and
+// that asymmetry lets mergeServerMeta resurrect a stale truthy copy. A
+// literal false round-trips identically through both stores.
+
+/** Session-only view toggle: reveal hidden bots (dimmed) in the roster. */
+const $showHiddenBots = atom(false)
+
+/** Hidden flag for a roster row. Thin remote-source rows never read local
+ * meta (botRosterMeta returns null for them), so hide is by NAME on the
+ * active source; remote rows of the same name stay visible. */
+function isBotHidden(bot, metaByName) {
+ return Boolean(botRosterMeta(bot, metaByName)?.hidden)
+}
+
+/** Hiding the selected bot re-homes the selection (the Routines pane
+ * follows it): first visible bot wins, then 'default' — unless default is
+ * itself hidden with nothing else visible, in which case the selection
+ * stays put rather than pointing somewhere even less real. */
+function fallbackSelectionAfterHide(name) {
+ if ($selectedBot.get() !== name) {
+ return
+ }
+
+ const meta = $botMeta.get()
+ const visible = $lastRoster
+ .get()
+ .filter(bot => !bot.remoteSource && bot.name !== name && !meta[bot.name]?.hidden)
+
+ if (visible.length) {
+ $selectedBot.set(visible[0].name)
+ return
+ }
+
+ if (name !== 'default' && !meta.default?.hidden) {
+ $selectedBot.set('default')
+ }
+}
+
/** One-time reconciliation: Bot Mode sessions are always hidden, but rooms
* and Bot Chats created before this policy (or while the old pref was off)
* left visible rows behind. On every plugin load, sweep every session id we
@@ -4026,7 +4077,10 @@ function BotRow({ bot, onDelete, onEdit, onGroup }) {
className: cn(
'flex w-full min-w-0 max-w-full items-center gap-2.5 overflow-hidden rounded-md px-2 py-2 text-left transition-colors',
'hover:bg-(--chrome-action-hover)',
- isActive && 'bg-(--chrome-action-hover)'
+ isActive && 'bg-(--chrome-action-hover)',
+ // Hidden bots only render while the header eye toggle is on — dimmed,
+ // so the temporary reveal reads as a different state from the roster.
+ meta?.hidden && 'opacity-60'
),
children: [
jsx('div', {
@@ -4049,6 +4103,13 @@ function BotRow({ bot, onDelete, onEdit, onGroup }) {
children: '📌'
})
: null,
+ meta?.hidden
+ ? jsx(Codicon, {
+ name: 'eye-closed',
+ className: 'shrink-0 text-[0.6875rem] text-(--ui-text-quaternary)',
+ title: 'Hidden from the roster'
+ })
+ : null,
jsx('span', {
className: 'truncate text-[0.8125rem] font-medium',
children: displayName(bot, meta)
@@ -4137,6 +4198,26 @@ function BotRow({ bot, onDelete, onEdit, onGroup }) {
},
children: meta?.pinned ? 'Unpin' : 'Pin to top'
}),
+ jsx(ContextMenuItem, {
+ onSelect: () => {
+ const hidden = Boolean($botMeta.get()[bot.name]?.hidden)
+ // `hidden: false` (not null) so unhide round-trips through the
+ // server ui_meta merge the same way the local merge sees it.
+ saveBotMeta(bot.name, { hidden: !hidden })
+
+ if (!hidden) {
+ fallbackSelectionAfterHide(bot.name)
+ }
+
+ host.notify({
+ kind: 'info',
+ message: hidden
+ ? `${displayName(bot, meta)} is back in the roster`
+ : `${displayName(bot, meta)} hidden — use the eye button in the Bots header to see hidden bots`
+ })
+ },
+ children: meta?.hidden ? 'Unhide Bot' : 'Hide Bot'
+ }),
jsx(ContextMenuSeparator, {}),
jsx(ContextMenuItem, {
onSelect: () => openBotSessionsWorkspace(bot),
@@ -7738,7 +7819,16 @@ function BotsPane() {
return activityOf(b) - activityOf(a)
})
const activeSourceRoster = roster.filter(bot => !bot.remoteSource)
- const filteredRoster = filterBots(roster, allMeta, query)
+ // Hidden bots (right-click → Hide Bot) drop out of the roster list unless
+ // the header eye toggle reveals them. Display-only: every other consumer
+ // (mentions, group chats, name-collision checks, merge/avatar/activity
+ // sweeps) keeps the FULL roster.
+ const showHidden = useValue($showHiddenBots)
+ const unreadByName = useValue($botUnread)
+ const hiddenBots = roster.filter(bot => isBotHidden(bot, allMeta))
+ const hiddenUnread = hiddenBots.some(bot => !bot.remoteSource && unreadByName[bot.name])
+ const visibleRoster = showHidden ? roster : roster.filter(bot => !isBotHidden(bot, allMeta))
+ const filteredRoster = filterBots(visibleRoster, allMeta, query)
// Group chats are first-class roster rows (Discord-style): one standalone
// row per room, competing in the SAME recency ordering as bot rows — a
// group's activity is its newest room-log line. Pinned bots still lead;
@@ -7812,6 +7902,35 @@ function BotsPane() {
children: jsx(Codicon, { name: activityToasts ? 'bell' : 'bell-slash' })
})
}),
+ // Eye toggle appears only once something is hidden — zero
+ // hidden bots means zero extra chrome. It stays visible while
+ // hidden rows are revealed, so Unhide is always reachable.
+ hiddenBots.length
+ ? jsx(Tip, {
+ label: showHidden
+ ? 'Hide hidden bots again'
+ : `Show ${hiddenBots.length} hidden bot${hiddenBots.length === 1 ? '' : 's'}`,
+ children: jsxs('button', {
+ type: 'button',
+ 'aria-label': showHidden ? 'Hide hidden bots' : 'Show hidden bots',
+ className: cn(
+ 'relative flex size-6 items-center justify-center rounded-md transition-colors hover:bg-(--chrome-action-hover) hover:text-foreground',
+ showHidden ? 'text-foreground' : 'text-(--ui-text-tertiary)'
+ ),
+ onClick: () => $showHiddenBots.set(!showHidden),
+ children: [
+ jsx(Codicon, { name: showHidden ? 'eye' : 'eye-closed' }),
+ hiddenUnread && !showHidden
+ ? jsx('span', {
+ className:
+ 'absolute right-0.5 top-0.5 size-1.5 rounded-full bg-(--ui-accent,#4f9cf9)',
+ 'aria-label': 'a hidden bot has unread activity'
+ })
+ : null
+ ]
+ })
+ })
+ : null,
jsxs(DropdownMenu, {
children: [
jsx(Tip, {
@@ -7848,7 +7967,7 @@ function BotsPane() {
]
}),
jsx(ActiveNowStrip, {
- roster,
+ roster: visibleRoster,
activeProfile,
gatewayState,
metaByName: allMeta,
@@ -7955,7 +8074,9 @@ function BotsPane() {
className:
'flex flex-1 items-center justify-center px-4 text-center text-xs text-(--ui-text-tertiary)',
role: 'status',
- children: `No bots match “${query.trim()}”`
+ children: query.trim()
+ ? `No bots match “${query.trim()}”`
+ : 'All bots are hidden — use the eye button above to show them.'
})
: jsx(ScrollArea, {
className: 'hermes-bots-roster min-h-0 flex-1',
diff --git a/apps/desktop/src/plugins/hermes-bots/tests/hide-bots.test.mjs b/apps/desktop/src/plugins/hermes-bots/tests/hide-bots.test.mjs
new file mode 100644
index 00000000000..9a1bb6e0d9c
--- /dev/null
+++ b/apps/desktop/src/plugins/hermes-bots/tests/hide-bots.test.mjs
@@ -0,0 +1,223 @@
+import assert from 'node:assert/strict'
+import { readFileSync } from 'node:fs'
+import test from 'node:test'
+import vm from 'node:vm'
+
+// Per-bot Hide/Unhide: right-click → Hide Bot persists `hidden: true` in bot
+// meta (local ctx.storage + server ui_meta via saveBotMeta), hidden bots drop
+// out of the roster list, and a header eye toggle — rendered only while at
+// least one bot is hidden — reveals them dimmed for right-click → Unhide.
+// Hiding is a roster-DISPLAY concern only: mentions, group chats, and the
+// name-collision check keep the full roster.
+
+const pluginSource = readFileSync(new URL('../plugin.js', import.meta.url), 'utf8')
+
+function load({ toastsOn = false } = {}) {
+ const values = new Map()
+ const atom = initial => {
+ const slot = { get: () => values.get(slot), set: value => values.set(slot, value) }
+ values.set(slot, initial)
+ return slot
+ }
+ const notifications = []
+ const requests = []
+ const context = {
+ atom,
+ PALETTE_AREA: 'palette',
+ COMPOSER_AREAS: { middleware: 'middleware' },
+ document: { getElementById: () => null, createElement: () => ({}), head: { appendChild: () => undefined } },
+ host: {
+ state: {
+ profile: { get: () => 'default', listen: () => undefined },
+ gateway: { get: () => 'open', listen: () => undefined }
+ },
+ request: (method, params) => {
+ requests.push({ method, params })
+ return Promise.resolve({ applied: { ui_meta: true } })
+ },
+ notify: params => notifications.push(params)
+ },
+ sdk: new Proxy({}, { get: () => undefined })
+ }
+ const source = pluginSource
+ .replace(/^import\s+\*\s+as\s+sdk\s+from '@hermes\/plugin-sdk'\r?\n/m, '')
+ .replace(/^import\s+\{[\s\S]*?\}\s+from '@hermes\/plugin-sdk'\r?\n/m, '')
+ .replace(/^const \{ McpTab, ToolsetConfigPanel \} = sdk\r?\n/m, '')
+ .replace(/^import .* from 'react'\r?\n/m, '')
+ .replace(/^import .* from 'react\/jsx-runtime'\r?\n/m, '')
+ .replace('export default {', 'globalThis.plugin = {')
+ .concat(`
+globalThis.__hide = {
+ isBotHidden,
+ fallbackSelectionAfterHide,
+ mergeServerMeta,
+ saveBotMeta,
+ trackInboundActivity,
+ $botMeta,
+ $botUnread,
+ $selectedBot,
+ $lastRoster,
+ $showHiddenBots,
+ $activityToasts,
+ setPluginCtx: value => { pluginCtx = value }
+};
+`)
+ vm.runInNewContext(source, context, { filename: 'plugin.js' })
+ if (toastsOn) {
+ context.__hide.$activityToasts.set(true)
+ }
+ return { ...context.__hide, notifications, requests }
+}
+
+test('hide: saveBotMeta persists hidden:true locally and ships it in server ui_meta', async () => {
+ const t = load()
+ const writes = []
+ t.setPluginCtx({ storage: { set: (key, value) => writes.push({ key, value }) } })
+
+ await t.saveBotMeta('default', { hidden: true })
+
+ assert.equal(t.$botMeta.get().default.hidden, true)
+ assert.equal(writes.at(-1).key, 'bot-meta')
+ assert.equal(writes.at(-1).value.default.hidden, true)
+ const configure = t.requests.find(r => r.method === 'profiles.configure')
+ assert.equal(configure.params.ui_meta['hermes-bots'].hidden, true)
+})
+
+test('roster: hidden bots are filtered out; remote-source rows of the same name stay visible', () => {
+ const t = load()
+ t.$botMeta.set({ ghost: { hidden: true } })
+ const roster = [
+ { name: 'default' },
+ { name: 'ghost' },
+ { name: 'ghost', remoteSource: true, connectionId: 'mini' }
+ ]
+ const meta = t.$botMeta.get()
+ const visible = roster.filter(bot => !t.isBotHidden(bot, meta))
+
+ assert.equal(JSON.stringify(visible.map(b => `${b.remoteSource ? 'r:' : ''}${b.name}`)), JSON.stringify(['default', 'r:ghost']))
+})
+
+test('unhide: hidden:false clears locally AND survives a mergeServerMeta round-trip', async () => {
+ const t = load()
+ const writes = []
+ t.setPluginCtx({ storage: { set: (key, value) => writes.push({ key, value }) } })
+ t.$botMeta.set({ ghost: { hidden: true, title: 'Ghost' } })
+
+ await t.saveBotMeta('ghost', { hidden: false })
+ assert.equal(t.$botMeta.get().ghost.hidden, false, 'local merge must clear the flag')
+ const configure = t.requests.find(r => r.method === 'profiles.configure')
+ assert.equal(configure.params.ui_meta['hermes-bots'].hidden, false, 'server copy carries the literal false')
+
+ // Machine B: its stale local copy still says hidden:true; the server
+ // overlay (which merges OVER local) must win with the false.
+ t.$botMeta.set({ ghost: { hidden: true, title: 'Ghost' } })
+ t.mergeServerMeta([{ name: 'ghost', ui_meta: { 'hermes-bots': { hidden: false, title: 'Ghost' } } }])
+ assert.equal(t.$botMeta.get().ghost.hidden, false, 'server false must beat stale local true')
+})
+
+test('cross-machine: a hide done elsewhere lands via mergeServerMeta and persists to storage', () => {
+ const t = load()
+ const writes = []
+ t.setPluginCtx({ storage: { set: (key, value) => writes.push({ key, value }) } })
+ t.$botMeta.set({ ghost: { title: 'Ghost' } })
+
+ t.mergeServerMeta([{ name: 'ghost', ui_meta: { 'hermes-bots': { hidden: true, title: 'Ghost' } } }])
+
+ assert.equal(t.$botMeta.get().ghost.hidden, true)
+ assert.equal(writes.at(-1).value.ghost.hidden, true)
+})
+
+test('selection: hiding the selected bot falls back to the first visible bot', () => {
+ const t = load()
+ t.$selectedBot.set('ghost')
+ t.$botMeta.set({ ghost: { hidden: true } })
+ t.$lastRoster.set([{ name: 'ghost' }, { name: 'scribe' }, { name: 'default' }])
+
+ t.fallbackSelectionAfterHide('ghost')
+
+ assert.equal(t.$selectedBot.get(), 'scribe')
+})
+
+test('selection: falls back to default when nothing else is visible', () => {
+ const t = load()
+ t.$selectedBot.set('ghost')
+ t.$botMeta.set({ ghost: { hidden: true } })
+ t.$lastRoster.set([{ name: 'ghost' }])
+
+ t.fallbackSelectionAfterHide('ghost')
+
+ assert.equal(t.$selectedBot.get(), 'default')
+})
+
+test('selection: hiding default with nothing else visible keeps the selection (Routines must not chase a ghost)', () => {
+ const t = load()
+ t.$selectedBot.set('default')
+ t.$botMeta.set({ default: { hidden: true } })
+ t.$lastRoster.set([{ name: 'default' }])
+
+ t.fallbackSelectionAfterHide('default')
+
+ assert.equal(t.$selectedBot.get(), 'default')
+})
+
+test('selection: hiding an unselected bot never moves the selection', () => {
+ const t = load()
+ t.$selectedBot.set('scribe')
+ t.$botMeta.set({ ghost: { hidden: true } })
+ t.$lastRoster.set([{ name: 'ghost' }, { name: 'scribe' }])
+
+ t.fallbackSelectionAfterHide('ghost')
+
+ assert.equal(t.$selectedBot.get(), 'scribe')
+})
+
+test('activity: a hidden bot accumulates unread silently but never toasts, even with toasts on', () => {
+ const t = load({ toastsOn: true })
+ t.$botMeta.set({ ghost: { hidden: true } })
+ t.$selectedBot.set('default')
+
+ const rosterAt = ts => [{ name: 'ghost', last_session: { last_active: ts, preview: 'Message from writer: hi' } }]
+ t.trackInboundActivity(rosterAt(100)) // seeding poll
+ t.trackInboundActivity(rosterAt(200)) // activity past the watermark
+
+ assert.equal(t.$botUnread.get().ghost, true, 'unread must accumulate while hidden')
+ assert.equal(t.notifications.length, 0, 'hidden bots never toast')
+})
+
+// ── source shape ─────────────────────────────────────────────────────────────
+
+test('shape: roster list filters through isBotHidden unless the show-hidden toggle is on', () => {
+ assert.match(
+ pluginSource,
+ /const visibleRoster = showHidden \? roster : roster\.filter\(bot => !isBotHidden\(bot, allMeta\)\)/
+ )
+ assert.match(pluginSource, /const filteredRoster = filterBots\(visibleRoster, allMeta, query\)/)
+})
+
+test('shape: header eye toggle renders only when at least one bot is hidden', () => {
+ assert.match(pluginSource, /hiddenBots\.length\s*\n?\s*\? jsx\(Tip, \{/)
+ assert.match(pluginSource, /onClick: \(\) => \$showHiddenBots\.set\(!showHidden\)/)
+})
+
+test('shape: revealed hidden rows are dimmed and flagged with the eye-closed glyph', () => {
+ const botRow = pluginSource.slice(pluginSource.indexOf('function BotRow('), pluginSource.indexOf('// ── model picker'))
+ assert.match(botRow, /meta\?\.hidden && 'opacity-60'/)
+ assert.match(botRow, /name: 'eye-closed'/)
+ assert.match(botRow, /children: meta\?\.hidden \? 'Unhide Bot' : 'Hide Bot'/)
+ assert.match(botRow, /saveBotMeta\(bot\.name, \{ hidden: !hidden \}\)/)
+})
+
+test('shape: hiding never filters mentions, group flows, or the meta/activity sweeps', () => {
+ // The full-roster consumers keep the FULL roster: mergeServerMeta,
+ // avatar pulls, and activity tracking all run on activeSourceRoster —
+ // which is derived from the unfiltered roster, not visibleRoster.
+ assert.match(pluginSource, /const activeSourceRoster = roster\.filter\(bot => !bot\.remoteSource\)/)
+ assert.match(pluginSource, /mergeServerMeta\(activeSourceRoster\)/)
+ assert.match(pluginSource, /trackInboundActivity\(activeSourceRoster\)/)
+ // Mention resolution never consults the hidden flag.
+ const mentions = pluginSource.slice(
+ pluginSource.indexOf('function resolveRosterMentions('),
+ pluginSource.indexOf('const REMOTE_DM_TIMEOUT_MS')
+ )
+ assert.doesNotMatch(mentions, /hidden/i)
+})