The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(desktop): consume upstream Bot owner routing
David Dudok de Wit8523819fcf88
diff --git a/apps/desktop/src/plugins/hermes-bots/plugin.js b/apps/desktop/src/plugins/hermes-bots/plugin.jsindex 9357b94e38f..a56c91048be 100644--- a/apps/desktop/src/plugins/hermes-bots/plugin.js+++ b/apps/desktop/src/plugins/hermes-bots/plugin.js@@ -156,7 +156,7 @@ function trackInboundActivity(roster) {// Activity in the exact bot owner the user is currently looking at is// already visible — never badge the open chat or its same-named twin.- if ($selectedRosterKey.get() === key) {+ if ($selectedBot.get() === key) {continue}@@ -164,7 +164,7 @@ function trackInboundActivity(roster) {// Roster-hidden bots stay quiet: the unread flag above accumulates// silently (unhiding reveals the badge) but a hidden bot never toasts.- if (isBotHidden(bot, $botMeta.get())) {+ if (botRosterMeta(bot, $botMeta.get())?.hidden) {continue}@@ -226,9 +226,9 @@ let botsHomeClose = nulllet suppressBotsHomeReopen = falsefunction saveSelectedRosterBot(bot) {- const key = botSelectionKey(bot)+ const key = botRosterKey(bot)- $selectedBot.set(key)+ $selectedBot.set(botSelectionKey(bot))$selectedRosterKey.set(key)try {@@ -239,7 +239,7 @@ function saveSelectedRosterBot(bot) {}function clearSelectedRosterBot(bot) {- clearSelectedRosterKey(botSelectionKey(bot))+ clearSelectedRosterKey(botRosterKey(bot))}/** Drop the persisted selection when it is exactly this key — the caller has@@ -1918,12 +1918,8 @@ async function sweepBotProfileSessions() {// back to the active gateway's own profile list (local bots; remote// sources get covered by the next sweep once the roster cache exists).try {- const route = await activeBotRoute()- const res = await requestForBot(- route ? { name: route.profile, sourceScoped: true, route } : { name: 'default' },- 'profiles.list',- {}- )+ const activeBot = { name: String(host.state.profile?.get?.() || 'default').trim() || 'default' }+ const res = await requestForBot(activeBot, 'profiles.list', {})roster = Array.isArray(res?.profiles) ? res.profiles : []} catch {return@@ -4224,7 +4220,16 @@ function useRoster() {if (typeof host.agents === 'function') {try {const union = await host.agents()- return { ...mergeMultiSourceRoster(local, union, activeConnectionId, $lastRoster.get()), fetchedAt: issuedAt }+ const previous = $lastRoster.get().filter(row => !row?.ghost)+ const merged = mergeMultiSourceRoster(local, union, activeConnectionId, previous)+ const sources = Array.isArray(union?.sources) ? union.sources : []++ return {+ ...merged,+ profiles: (merged?.profiles || []).map(row => annotateBotSource(row, sources)),+ sources,+ fetchedAt: issuedAt+ }} catch {/* older build or roster failure — single-source list stands */}@@ -4300,7 +4305,6 @@ function cachedUnionRoster() {function mergeMultiSourceRoster(local, union, activeConnectionId, previous = []) {const localProfiles = Array.isArray(local?.profiles) ? local.profiles : []const agents = Array.isArray(union?.agents) ? union.agents : []- const sources = Array.isArray(union?.sources) ? union.sources : []// A live id of null/'' means the window is on the unscoped local backend// (legacy hosts reported null for mode:'local'; the SDK now reports// 'local'). Do NOT fall back to registry primary when the third argument@@ -4446,10 +4450,7 @@ function mergeMultiSourceRoster(local, union, activeConnectionId, previous = [])const name = String(row?.name || '').trim()const key = `${connectionId}::${name || 'default'}`- // Ghost owners are presentation-only placeholders. Re-adopting one as- // a cached remote row would keep it alive after the selection changes- // and let an identity without its durable handle leak into shared state.- if (row?.ghost || !row?.remoteSource || !connectionId || !name || present.has(key)) {+ if (!row?.remoteSource || !connectionId || !name || present.has(key)) {continue}@@ -4464,7 +4465,7 @@ function mergeMultiSourceRoster(local, union, activeConnectionId, previous = [])}}- return { ...local, profiles: profiles.map(row => annotateBotSource(row, sources)), sources }+ return { ...local, profiles }}/** The @handle users tag a bot with. Multi-source rosters precompute the@@ -5333,7 +5334,7 @@ async function ensureBotMetadata(bot) {* resolves a canonical-chat id. */async function openRosterBot(bot) {const generation = ++botOpenGeneration- const key = botSelectionKey(bot)+ const key = botRosterKey(bot)const meta = botRosterMeta(bot, $botMeta.get())// Keep the currently visible group as a fallback until this explicit action// has actually fronted a new owner; a failed home open must not steal the@@ -7333,7 +7334,7 @@ function botRowOwnsWorkspace(}if (botsHomeFronted || !botChatFocused) {- return selectedRosterKey === botSelectionKey(bot)+ return selectedRosterKey === botRosterKey(bot)}return isActiveRosterBot(bot, focusedOwner)@@ -12458,22 +12459,17 @@ function BotsHomeView() {children: description}): null,- unavailable || !bot.remoteSource- ? jsx('p', {- className: cn(- 'mt-4 max-w-lg text-xs leading-5',- unavailable ? 'text-amber-700 dark:text-amber-300' : 'text-(--ui-text-tertiary)'- ),- children: unavailable- ? sourceRemoved- ? `${gateway} was removed. Choose another bot from the sidebar.`- : `${gateway} is unavailable. Retry when it is back online.`- : 'Open this bot’s continuous chat. Its background work keeps running when you switch away.'- })- : jsx('p', {- className: 'mt-4 max-w-lg text-xs leading-5 text-(--ui-text-tertiary)',- children: `This bot lives on ${gateway}. Mention it from any Bot Chat to send it a message.`- }),+ jsx('p', {+ className: cn(+ 'mt-4 max-w-lg text-xs leading-5',+ unavailable ? 'text-amber-700 dark:text-amber-300' : 'text-(--ui-text-tertiary)'+ ),+ children: unavailable+ ? sourceRemoved+ ? `${gateway} was removed. Choose another bot from the sidebar.`+ : `${gateway} is unavailable. Retry when it is back online.`+ : 'Open this bot’s continuous chat. Its background work keeps running when you switch away.'+ }),unavailable && !sourceRemoved? jsx(Button, {variant: 'secondary',@@ -12482,15 +12478,13 @@ function BotsHomeView() {onClick: retrySource,children: 'Retry'})- : bot.remoteSource- ? null- : jsx(Button, {- variant: 'secondary',- size: 'sm',- className: 'mt-5',- onClick: () => void openRosterBot(bot),- children: 'Open chat'- })+ : jsx(Button, {+ variant: 'secondary',+ size: 'sm',+ className: 'mt-5',+ onClick: () => void openRosterBot(bot),+ children: 'Open chat'+ })]})})@@ -13338,22 +13332,28 @@ function BotsPane() {className: 'flex min-w-0 items-center gap-1 px-2.5 pb-1.5',children: [showRosterSearch- ? jsx(SearchField, {- 'aria-label': 'Search bots and group chats',- containerClassName: cn(- 'min-w-0 flex-1',- query ? 'opacity-100!' : 'opacity-50 focus-within:opacity-100'- ),- inputClassName:- 'w-full text-[0.75rem] placeholder:text-(--ui-text-tertiary)',- placeholder: 'Search bots and group chats…',- value: query,- onChange: setQuery- })- : jsx('span', { className: 'min-w-0 flex-1' }),+ ? jsx(+ SearchField,+ {+ 'aria-label': 'Search bots and group chats',+ containerClassName: cn(+ 'min-w-0 flex-1',+ query ? 'opacity-100!' : 'opacity-50 focus-within:opacity-100'+ ),+ inputClassName:+ 'w-full text-[0.75rem] placeholder:text-(--ui-text-tertiary)',+ placeholder: 'Search bots and group chats…',+ value: query,+ onChange: setQuery+ },+ 'roster-search'+ )+ : jsx('span', { className: 'min-w-0 flex-1' }, 'roster-search-spacer'),showRosterFilters- ? jsxs(DropdownMenu, {- children: [+ ? jsxs(+ DropdownMenu,+ {+ children: [jsx(Tip, {label: activeFilterCount ? `Filters (${activeFilterCount} active)` : 'Filter roster',children: jsx(DropdownMenuTrigger, {@@ -13466,8 +13466,10 @@ function BotsPane() {: null]})- ]- })+ ]+ },+ 'roster-filters'+ ): null]})@@ -13554,10 +13556,12 @@ function BotsPane() {row.kind === 'group' ? renderGroupRow(row) : renderBotRow(row.bot))),showHiddenSection- ? jsxs('div', {- ref: hiddenSectionRef,- className: 'mt-1 border-t border-(--ui-stroke-tertiary) pt-1',- children: [+ ? jsxs(+ 'div',+ {+ ref: hiddenSectionRef,+ className: 'mt-1 border-t border-(--ui-stroke-tertiary) pt-1',+ children: [hasRosterConstraint? jsxs('div', {className:@@ -13596,8 +13600,10 @@ function BotsPane() {children: 'No hidden bots match these filters.'}): null- ]- })+ ]+ },+ 'hidden-section'+ ): null]})diff --git a/apps/desktop/src/plugins/hermes-bots/tests/active-now-strip.test.mjs b/apps/desktop/src/plugins/hermes-bots/tests/active-now-strip.test.mjsindex 6734e3fed7e..c667250a306 100644--- a/apps/desktop/src/plugins/hermes-bots/tests/active-now-strip.test.mjs+++ b/apps/desktop/src/plugins/hermes-bots/tests/active-now-strip.test.mjs@@ -189,5 +189,5 @@ test('ActiveNowStrip renders above the roster, is a live region, and is click-acconst open = source.slice(openStart, openStart + 3200)assert.match(open, /await prepareBotSource\(bot\)/)- assert.match(open, /await openBotCanonicalChat\(bot\.name\)/)+ assert.match(open, /await openBotCanonicalChat\(bot\)/)})diff --git a/apps/desktop/src/plugins/hermes-bots/tests/bot-delete.test.mjs b/apps/desktop/src/plugins/hermes-bots/tests/bot-delete.test.mjsindex b7f699a1ef9..63c58f0d14a 100644--- a/apps/desktop/src/plugins/hermes-bots/tests/bot-delete.test.mjs+++ b/apps/desktop/src/plugins/hermes-bots/tests/bot-delete.test.mjs@@ -204,13 +204,13 @@ test('unit: older desktop without host.deleteProfile falls back to the non-intertest('integration: a deleted bot is removed from plugin-local state and the roster is refreshed', async () => {const { context, invalidations, stored } = load()context.__delete.$botMeta.set({ researcher: { title: 'Research' }, writer: { title: 'Writer' } })- context.__delete.$botUnread.set({ 'legacy::researcher': true, 'legacy::writer': true })+ context.__delete.$botUnread.set({ researcher: true, writer: true })context.__delete.$selectedBot.set('researcher')await context.__delete.deleteBot({ name: 'researcher' })assert.equal(context.__delete.$botMeta.get().researcher, undefined)- assert.equal(context.__delete.$botUnread.get()['legacy::researcher'], undefined)+ assert.equal(context.__delete.$botUnread.get().researcher, undefined)assert.equal(context.__delete.$selectedBot.get(), 'default')assert.equal(stored.at(-1).key, 'bot-meta')assert.equal(stored.at(-1).value.researcher, undefined)diff --git a/apps/desktop/src/plugins/hermes-bots/tests/bots-home.test.mjs b/apps/desktop/src/plugins/hermes-bots/tests/bots-home.test.mjsindex 411b4255fcc..d20db31067c 100644--- a/apps/desktop/src/plugins/hermes-bots/tests/bots-home.test.mjs+++ b/apps/desktop/src/plugins/hermes-bots/tests/bots-home.test.mjs@@ -127,7 +127,6 @@ globalThis.__home = {ghostRosterOwner,rosterWithSelectedOwner,reconcileRosterSelection,- saveRosterPreference,saveSelectedRosterBot,clearSelectedRosterBot,clearSelectedRosterKey,@@ -197,7 +196,7 @@ test('selection persists the source-qualified key, not the bare profile name', (assertNothingRouted(t, 'saving a selection')})-test('a remote selection never redirects the bare-name consumers at a local twin', () => {+test('a remote selection keeps the exact-owner selection distinct from a local twin', () => {const t = load()t.setPluginCtx({ storage: { set: () => undefined } })@@ -210,8 +209,8 @@ test('a remote selection never redirects the bare-name consumers at a local twinassert.equal(t.$selectedRosterKey.get(), 'mac-mini::default')assert.equal(t.$selectedBot.get(),- 'default',- 'the Cronjobs/slash-guard name tracker keeps its LOCAL owner — a remote row must not claim it'+ 'mac-mini::default',+ 'the shared selection follows the same exact owner as the roster workspace')})@@ -331,10 +330,7 @@ test('a hidden bot is not auto-selected', () => {const sources = [{ connectionId: 'local', kind: 'local', label: 'This device', reachable: true }]const roster = [{ connectionId: 'local', name: 'hidden-one' }, { connectionId: 'local', name: 'writer' }]- // Hidden is a source-qualified Desktop preference, so hide the exact row.- t.saveRosterPreference(roster[0], 'hidden', true)-- t.reconcileRosterSelection(roster, sources, {})+ t.reconcileRosterSelection(roster, sources, { 'hidden-one': { hidden: true } })assert.equal(t.$selectedRosterKey.get(),diff --git a/apps/desktop/src/plugins/hermes-bots/tests/canonical-chat-registry.test.mjs b/apps/desktop/src/plugins/hermes-bots/tests/canonical-chat-registry.test.mjsindex 331185ecf96..c2ef83ca3da 100644--- a/apps/desktop/src/plugins/hermes-bots/tests/canonical-chat-registry.test.mjs+++ b/apps/desktop/src/plugins/hermes-bots/tests/canonical-chat-registry.test.mjs@@ -48,6 +48,7 @@ function loadOpenPath({ openSession, request }) {? { bot: { name: owner }, key: owner, name: owner, route: null }: { bot: owner, key: owner?.name, name: owner?.name, route: owner?.route || null }),backendTargetProfile: (route, name) => route?.targetProfile || name,+ botWorkspaceOwnerKey: bot => `bot:${bot?.connectionId ? `${bot.connectionId}::` : ''}${bot?.name || 'default'}`,requestForBot: (_bot, method, params) => context.host.request(method, params),window: { setTimeout: callback => callback() }}diff --git a/apps/desktop/src/plugins/hermes-bots/tests/focused-bot-highlight.test.mjs b/apps/desktop/src/plugins/hermes-bots/tests/focused-bot-highlight.test.mjsindex 7b31017a8c0..8ca96f3e0e3 100644--- a/apps/desktop/src/plugins/hermes-bots/tests/focused-bot-highlight.test.mjs+++ b/apps/desktop/src/plugins/hermes-bots/tests/focused-bot-highlight.test.mjs@@ -58,17 +58,17 @@ test('BotRow keys the highlight off the focused profile, not the socket home', (const row = source.slice(rowStart, rowStart + 2000)assert.match(row, /const focusedOwner = focusedRosterOwner\(useValue\(\$focusedBotOwner\)\)/)- assert.match(row, /const isActive = !activeGroup && isActiveRosterBot\(bot, focusedOwner\)/)+ assert.match(row, /const isActive = botRowOwnsWorkspace\([\s\S]*?focusedOwner,[\s\S]*?selectedRosterKey/)})test('BotRow keeps turn-busy (work mood) a socket fact', () => {const rowStart = source.indexOf('function BotRow(')- const row = source.slice(rowStart, rowStart + 3000)+ const row = source.slice(rowStart, rowStart + 5000)// Only the gateway-home profile can actually be mid-turn: the mood must NOT// switch to the focus-keyed identity.assert.match(row, /const isGatewayHome = !bot\.remoteSource && bot\.name === activeProfile/)- assert.match(row, /const botMood = \(isGatewayHome && gatewayState === 'busy'\) \|\| activeNow \? 'work' : 'idle'/)+ assert.match(row, /const botMood = workerActive \|\| \(isGatewayHome && gatewayState === 'busy'\) \? 'work' : 'idle'/)})test('RoutinesPane scopes the Cronjobs tile to the focused chat owner', () => {diff --git a/apps/desktop/src/plugins/hermes-bots/tests/group-chat.test.mjs b/apps/desktop/src/plugins/hermes-bots/tests/group-chat.test.mjsindex f84a1a56bc2..626d2a27692 100644--- a/apps/desktop/src/plugins/hermes-bots/tests/group-chat.test.mjs+++ b/apps/desktop/src/plugins/hermes-bots/tests/group-chat.test.mjs@@ -1148,7 +1148,7 @@ test('closing an older selected group does not clear the newer selection', () =>})test('source contract: active group styling suppresses bot styling', () => {- assert.match(pluginSource, /const isActive = !activeGroup && isActiveRosterBot\(bot, focusedOwner\)/)+ assert.match(pluginSource, /function botRowOwnsWorkspace\([\s\S]*?if \(activeGroup\) \{\s*return false/)assert.match(pluginSource, /active && 'bg-\(--ui-row-active-background\)'/)assert.match(pluginSource, /active: groupChatName === row\.name/)})@@ -1261,10 +1261,10 @@ test('disband: a running room leaves an epoch-bumped empty tombstone so in-fligh'disbanded name is immediately reusable — tombstone does not hold it')})-test('source contract: workspace header offers disband behind a ConfirmDialog', () => {+test('source contract: workspace deletion stays behind a ConfirmDialog', () => {assert.match(pluginSource, /function disbandGroupChat\(/)- assert.match(pluginSource, /Disband group chat\?/)- assert.match(pluginSource, /title: `Disband the \$\{group\} group chat`/)+ assert.match(pluginSource, /title: 'Delete group chat\?'/)+ assert.match(pluginSource, /await disbandGroupChat\(deletingGroup\.name, deletingGroup\.members\)/)})test('default profile speaks as Hermes in room transcripts, not @default', () => {@@ -1328,9 +1328,10 @@ test('source contract: room messages carry the speaker avatar via the roster appassert.match(workspace, /image && !isBackfilledFacePng\(image\)/)assert.match(workspace, /jsx\(BotFace, \{\s*shape,\s*color,\s*image: photo \? image : null,\s*size: 24,\s*name: entry\.from\.name/)- // Header shows the member faces (capped) with a names tooltip.- assert.match(workspace, /members\.slice\(0, 6\)\.map\(/)- assert.match(workspace, /title: members\.map\(b => displayName\(b, botRosterMeta\(b, allMeta\)\)\)\.join\(', '\)/)+ // Header stays quiet: member avatars belong to messages, while the header+ // exposes a concise count instead of an overlapping face stack.+ assert.doesNotMatch(workspace, /members\.slice\(0, 6\)\.map\(/)+ assert.match(workspace, /children: members\.length > 0 && availableMembers < members\.length \? availabilityLabel : `\$\{members\.length\} bots`/)})test('stranded harvest: a timed-out turn whose reply landed late posts into the room and clears the marker', async () => {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.mjsindex 98efb82509a..2f228921016 100644--- a/apps/desktop/src/plugins/hermes-bots/tests/hide-bots.test.mjs+++ b/apps/desktop/src/plugins/hermes-bots/tests/hide-bots.test.mjs@@ -186,24 +186,23 @@ test('activity: a hidden bot accumulates unread silently but never toasts, even// ── source shape ─────────────────────────────────────────────────────────────-test('shape: roster list filters through isBotHidden unless the show-hidden toggle is on', () => {+test('shape: visible and hidden bots render through separate recoverable sections', () => {assert.match(pluginSource,- /const visibleRoster = showHidden \? roster : roster\.filter\(bot => !isBotHidden\(bot, allMeta\)\)/+ /const visibleRoster = roster\.filter\(bot => !isBotHidden\(bot, allMeta\)\)/)- assert.match(pluginSource, /const filteredRoster = filterBots\(visibleRoster, allMeta, query\)/)+ assert.match(pluginSource, /const matchingHiddenBots = rowKindFilter === 'groups' \? \[\] : filteredHiddenBots/)})-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: Hidden section renders only when recovery is relevant', () => {+ assert.match(pluginSource, /const showHiddenSection = hiddenBots\.length > 0/)+ assert.match(pluginSource, /onClick: \(\) => \$showHiddenBots\.set\(!hiddenExpanded\)/)})-test('shape: revealed hidden rows are dimmed and flagged with the eye-closed glyph', () => {+test('shape: revealed hidden rows are flagged and can be restored', () => {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, /children: hidden \? 'Unhide' : 'Hide'/)assert.match(botRow, /saveBotMeta\(bot, \{ hidden: !hidden \}\)/)})@@ -213,7 +212,7 @@ test('shape: hiding never filters mentions, group flows, or the meta/activity sw// which is derived from the unfiltered roster, not visibleRoster.assert.match(pluginSource, /const activeSourceRoster = roster\.filter\(bot => !bot\.remoteSource\)/)assert.match(pluginSource, /mergeServerMeta\(activeSourceRoster, data\?\.fetchedAt \|\| 0\)/)- assert.match(pluginSource, /trackInboundActivity\(activeSourceRoster\)/)+ assert.match(pluginSource, /trackInboundActivity\(roster\)/)// Mention resolution never consults the hidden flag.const mentions = pluginSource.slice(pluginSource.indexOf('function resolveRosterMentions('),diff --git a/apps/desktop/src/plugins/hermes-bots/tests/multi-source-roster.test.mjs b/apps/desktop/src/plugins/hermes-bots/tests/multi-source-roster.test.mjsindex ee0ae378a50..815e21585e4 100644--- a/apps/desktop/src/plugins/hermes-bots/tests/multi-source-roster.test.mjs+++ b/apps/desktop/src/plugins/hermes-bots/tests/multi-source-roster.test.mjs@@ -661,3 +661,12 @@ test('resolveRosterMentions: @hermes in this chat is not a handoff to yourself',assert.equal(hits.length, 1)assert.equal(hits[0].connectionId, 'mac-mini')})++test('source contract: active roster queries use the SDK ambient owner route', () => {+ assert.doesNotMatch(source, /activeBotRoute/)+ assert.equal(+ source.match(/requestForBot\(activeBot, 'profiles\.list', \{\}\)/g)?.length,+ 2,+ 'roster hydration and the session sweep must both use the upstream ambient-owner route'+ )+})diff --git a/apps/desktop/src/plugins/hermes-bots/tests/profile-prewarm.test.mjs b/apps/desktop/src/plugins/hermes-bots/tests/profile-prewarm.test.mjsindex a79bfeb3c7e..e03e48579f0 100644--- a/apps/desktop/src/plugins/hermes-bots/tests/profile-prewarm.test.mjs+++ b/apps/desktop/src/plugins/hermes-bots/tests/profile-prewarm.test.mjs@@ -24,7 +24,6 @@ function activitySessionSource() {function renderBotRow(input = 'alpha') {const bot = typeof input === 'string' ? { name: input } : inputconst name = bot.name- const prepareSource = sourceBetween('async function prepareBotSource(', 'function displayName(')const botRowSource = sourceBetween('function BotRow(', '// ── model picker')// REAL owner-route resolver — the derivation from bare connectionId rows is// exactly what these tests exercise, so a hand stub would drift.@@ -48,20 +47,28 @@ function renderBotRow(input = 'alpha') {ContextMenuItem: 'ContextMenuItem',ContextMenuSeparator: 'ContextMenuSeparator',ContextMenuTrigger: 'ContextMenuTrigger',+ Codicon: 'Codicon',+ Tip: 'Tip',ROSTER_KEY: ['hermes-bots', 'roster'],$botMeta: atom({}),$botUnread: atom({}),+ $botChatFocused: atom(false),+ $botsHomeFronted: atom(false),$focusedBotOwner: atom({ connectionId: 'local', profile: 'default' }),$focusedBotProfile: atom('default'),$groupChatWorkspace: atom(null),$lastRoster: atom([]),$selectedBot: atom('default'),+ $selectedRosterKey: atom(''),botAppearance: () => ({ shape: 'round', color: '#000', image: null }),botMetaKey: value => value.sourceScoped? `${value.route?.connectionId || value.connectionId}::${value.name}`: value.name,botGroups: () => [],botHandle: value => value,+ botRosterKey: value => `${value.connectionId || 'legacy'}::${value.name}`,+ botRowOwnsWorkspace: () => false,+ botSourceStatus: () => ({ available: true, label: 'Ready' }),botOpenGeneration: 0,botRosterMeta: (_bot, metaByName) => {const key = _bot.sourceScoped@@ -73,6 +80,7 @@ function renderBotRow(input = 'alpha') {createCanonicalChat: async () => null,displayName: bot => bot.name,duplicateBot: async () => `${name}-copy`,+ ensureBotMetadata: async () => ({ pinned: true }),haptic: () => undefined,// #49 session-aware-row helpers referenced inside BotRow.previewKind: () => ({ fromBot: false, sender: null }),@@ -80,6 +88,8 @@ function renderBotRow(input = 'alpha') {focusedRosterOwner: owner => ({ connectionId: owner.connectionId, name: owner.profile }),isActiveRosterBot: () => false,isBackfilledFacePng: () => false,+ isBotHidden: () => false,+ isBotPinned: () => false,botSelectionKey: value => value.sourceScoped ? `${value.connectionId}::${value.name}` : value.name,isDefaultBot: value => value.name === 'default',newBotChat: () => undefined,@@ -87,6 +97,11 @@ function renderBotRow(input = 'alpha') {opened.push(args)return 'stored-chat'},+ openRosterBot: async value => {+ opened.push([value])+ return true+ },+ workerActiveAt: () => false,ACTIVE_WINDOW_S: 90,A2A_PREFIX_RE: /^$/,useEffect: () => undefined,@@ -131,7 +146,7 @@ function renderBotRow(input = 'alpha') {useValue: store => store.get()}- vm.runInNewContext(`${activitySessionSource()}\n${routeSource}\n${prepareSource}\n${botRowSource}\nglobalThis.BotRow = BotRow`, context)+ vm.runInNewContext(`${activitySessionSource()}\n${routeSource}\n${botRowSource}\nglobalThis.BotRow = BotRow`, context)const tree = context.BotRow({ bot, onEdit: context.onEdit })const row = tree.type === 'button' ? tree : tree.props.children[0].props.children@@ -211,7 +226,6 @@ test('behavior: remote default never opens the same-name local chat', async () =remoteSource: true,sourceScoped: true}- const prepareSource = sourceBetween('async function prepareBotSource(', 'function displayName(')const botRowSource = sourceBetween('function BotRow(', '// ── model picker')const ensured = []const opened = []@@ -230,29 +244,40 @@ test('behavior: remote default never opens the same-name local chat', async () =ContextMenuItem: 'ContextMenuItem',ContextMenuSeparator: 'ContextMenuSeparator',ContextMenuTrigger: 'ContextMenuTrigger',+ Codicon: 'Codicon',+ Tip: 'Tip',ROSTER_KEY: ['hermes-bots', 'roster'],$botMeta: atom({ default: { chat: 'this-device-chat' } }),$botUnread: atom({}),+ $botChatFocused: atom(false),+ $botsHomeFronted: atom(false),$focusedBotOwner: atom({ connectionId: 'mac-mini', profile: 'default' }),$focusedBotProfile: atom('default'),$groupChatWorkspace: atom(null),$lastRoster: atom([]),$selectedBot: atom('default'),+ $selectedRosterKey: atom(''),botAppearance: () => ({ shape: 'round', color: '#000', image: null }),botGroups: () => [],botHandle: value => value,+ botRosterKey: value => `${value.connectionId || 'legacy'}::${value.name}`,+ botRowOwnsWorkspace: () => false,+ botSourceStatus: () => ({ available: true, label: 'Ready' }),botOpenGeneration: 0,botRosterMeta: () => null,cn: (...values) => values.filter(Boolean).join(' '),createCanonicalChat: async () => null,displayName: bot => bot.connectionLabel || bot.name,duplicateBot: async () => 'copy',+ ensureBotMetadata: async () => ({ pinned: true }),haptic: () => undefined,previewKind: () => ({ fromBot: false, sender: null }),generatedSessionTitle: () => null,focusedRosterOwner: owner => ({ connectionId: owner.connectionId, name: owner.profile }),isActiveRosterBot: () => false,isBackfilledFacePng: () => false,+ isBotHidden: () => false,+ isBotPinned: () => false,botSelectionKey: value => value.sourceScoped ? `${value.connectionId}::${value.name}` : value.name,isDefaultBot: value => value.name === 'default',newBotChat: () => undefined,@@ -260,6 +285,11 @@ test('behavior: remote default never opens the same-name local chat', async () =opened.push(args)return 'this-device-chat'},+ openRosterBot: async value => {+ opened.push([value])+ return true+ },+ workerActiveAt: () => false,ACTIVE_WINDOW_S: 90,A2A_PREFIX_RE: /^$/,useEffect: () => undefined,@@ -287,7 +317,7 @@ test('behavior: remote default never opens the same-name local chat', async () =}const routeSource = sourceBetween('function botConnectionRoute(', 'function rewriteCliProfileOperands(')- vm.runInNewContext(`${activitySessionSource()}\n${routeSource}\n${prepareSource}\n${botRowSource}\nglobalThis.BotRow = BotRow`, context)+ vm.runInNewContext(`${activitySessionSource()}\n${routeSource}\n${botRowSource}\nglobalThis.BotRow = BotRow`, context)const tree = context.BotRow({ bot, onEdit: context.onEdit })const row = tree.type === 'button' ? tree : tree.props.children[0].props.childrendiff --git a/apps/desktop/src/plugins/hermes-bots/tests/roster-preview.test.mjs b/apps/desktop/src/plugins/hermes-bots/tests/roster-preview.test.mjsindex 89cc02fdef5..989767e97a0 100644--- a/apps/desktop/src/plugins/hermes-bots/tests/roster-preview.test.mjs+++ b/apps/desktop/src/plugins/hermes-bots/tests/roster-preview.test.mjs@@ -205,7 +205,7 @@ test('render: BotRow tolerates a fresh bot with no sessions yet', () => {assert.doesNotMatch(text, /No conversations yet/)})-test('render: a remote bot keeps its identity while gateway details stay in the tooltip', () => {+test('render: a remote default uses its gateway identity without repeating it', () => {const r = renderRuntime()const tree = r.__BotRow({bot: {@@ -217,14 +217,13 @@ test('render: a remote bot keeps its identity while gateway details stay in the},onEdit: () => undefined})- const name = findNode(tree, node => node.type === 'span' && textOf(node) === 'Hermes')+ const name = findNode(tree, node => node.type === 'span' && textOf(node) === 'Studio over SSH')const button = findNode(tree, node => node.type === 'button' && node.props?.['aria-label'])assert.ok(name)assert.ok(button)- assert.match(button.props['aria-label'], /Hermes/)assert.match(button.props['aria-label'], /Studio over SSH/)- assert.doesNotMatch(textOf(button), /Studio over SSH/)+ assert.equal((textOf(button).match(/Studio over SSH/g) || []).length, 1)})test('render: BotRow previews the pinned canonical chat, not an unrelated latest session', () => {diff --git a/apps/desktop/src/sdk/index.ts b/apps/desktop/src/sdk/index.tsindex 5f196bbbc39..9495cc969c4 100644--- a/apps/desktop/src/sdk/index.ts+++ b/apps/desktop/src/sdk/index.ts@@ -142,6 +142,7 @@ const $focusedSessionOwner = computed([$focusedStoredSessionId, $sessions, $activeGatewayProfile, $connection],(focused, sessions, activeProfile, connection): PluginFocusedSessionOwner | null => {const activeConnectionId = String(connection?.connectionId || (connection?.mode === 'local' ? 'local' : '')).trim()+const fallback = {connectionId: activeConnectionId,profile: normalizeProfileKey(activeProfile)diff --git a/apps/desktop/src/sdk/profile-routing.test.ts b/apps/desktop/src/sdk/profile-routing.test.tsindex 129231aadab..e70116947f6 100644--- a/apps/desktop/src/sdk/profile-routing.test.ts+++ b/apps/desktop/src/sdk/profile-routing.test.ts@@ -125,6 +125,7 @@ const {const { $focusedRuntimeId, $focusedSessionState, $focusedStoredSessionId, $sessionStates, $sessionTiles } =await import('@/store/session-states')+const { setWorkspaceScope } = await import('@/components/pane-shell/workspace-scope')const {