Skip to content

The agent that grows with you

fix(desktop): open SSH default bots on the remote root profile

Al Zilla30299efa3852
diff --git a/apps/desktop/electron/connection-config.test.ts b/apps/desktop/electron/connection-config.test.ts
index f65eb3e0e25..404997d1243 100644
--- a/apps/desktop/electron/connection-config.test.ts
+++ b/apps/desktop/electron/connection-config.test.ts
@@ -42,6 +42,7 @@ import {
remoteRequestMatchesBaseUrl,
resolveAuthMode,
resolveProfileBackendRoute,
+ resolveRemoteSshDashboardProfile,
resolveTestWsUrl,
RT_COOKIE_VARIANTS,
savedProfileSsh,
@@ -58,6 +59,17 @@ test('connectionScopeKey trims to a name or null for the global scope', () => {
assert.equal(connectionScopeKey(undefined), null)
})
+test('resolveRemoteSshDashboardProfile never sends a conn: pool key to the remote', () => {
+ // Clicking Mac Mini / Spark default used `remoteProfile || poolKey`, which
+ // spawned a dashboard for the fictional profile "conn:mac-mini::default".
+ assert.equal(resolveRemoteSshDashboardProfile('', 'conn:mac-mini::default'), '')
+ assert.equal(resolveRemoteSshDashboardProfile(undefined, 'conn:spark::default'), '')
+ assert.equal(resolveRemoteSshDashboardProfile('', 'conn:mac-mini::dixie'), 'dixie')
+ assert.equal(resolveRemoteSshDashboardProfile('', 'bob'), 'bob')
+ assert.equal(resolveRemoteSshDashboardProfile('', 'default'), '')
+ assert.equal(resolveRemoteSshDashboardProfile('writer', 'conn:mac-mini::default'), 'writer')
+})
+
test('normAuthMode coerces to token unless explicitly oauth', () => {
assert.equal(normAuthMode('oauth'), 'oauth')
assert.equal(normAuthMode('token'), 'token')
diff --git a/apps/desktop/electron/connection-config.ts b/apps/desktop/electron/connection-config.ts
index c71163c9ce3..395be771e90 100644
--- a/apps/desktop/electron/connection-config.ts
+++ b/apps/desktop/electron/connection-config.ts
@@ -214,6 +214,27 @@ function connectionScopeKey(profile) {
return String(profile ?? '').trim() || null
}
+/** Which Hermes profile the remote SSH dashboard should actually run as.
+ * Registry pool keys (`conn:mac-mini::default`) are desktop routing labels —
+ * they must never be sent to the remote as a profile name. `default` and
+ * empty mean the remote root home. */
+function resolveRemoteSshDashboardProfile(configuredRemoteProfile, poolOrProfileKey) {
+ const configured = String(configuredRemoteProfile || '').trim()
+
+ if (configured && configured !== 'default') {
+ return configured
+ }
+
+ const key = String(poolOrProfileKey || '').trim()
+ const requested = key.startsWith('conn:') ? key.split('::').pop() || '' : key
+
+ if (!requested || requested === 'default') {
+ return ''
+ }
+
+ return requested
+}
+
// Coerce a remote auth mode to one of the two supported values ('token' default).
function normAuthMode(mode) {
return mode === 'oauth' ? 'oauth' : 'token'
@@ -802,6 +823,7 @@ export {
remoteRequestMatchesBaseUrl,
resolveAuthMode,
resolveProfileBackendRoute,
+ resolveRemoteSshDashboardProfile,
resolveTestWsUrl,
RT_COOKIE_VARIANTS,
savedProfileSsh,
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index 771a370891a..e2102225d92 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -87,6 +87,7 @@ import {
remoteRequestMatchesBaseUrl,
resolveAuthMode,
resolveProfileBackendRoute,
+ resolveRemoteSshDashboardProfile,
resolveTestWsUrl,
savedProfileSsh,
tokenPreview,
@@ -8847,7 +8848,7 @@ async function bootstrapSshConnectionInner(profile, sshConfig, reuseToken, sourc
const lifecycle = platform.os === 'Windows' ? connectWindowsRemote : remoteLifecycle.connect
result = await lifecycle({
ssh,
- profile: sshConfig.remoteProfile || connectionScopeKey(profile) || '',
+ profile: resolveRemoteSshDashboardProfile(sshConfig.remoteProfile, profile),
remoteHermesPath: sshConfig.remoteHermesPath || '',
ownershipId: sshOwnershipKey(profile),
reuseToken: reuseToken || '',
diff --git a/apps/desktop/src/plugins/hermes-bots/plugin.js b/apps/desktop/src/plugins/hermes-bots/plugin.js
index c88d19f72bb..39f69cb45e1 100644
--- a/apps/desktop/src/plugins/hermes-bots/plugin.js
+++ b/apps/desktop/src/plugins/hermes-bots/plugin.js
@@ -2548,6 +2548,13 @@ async function prepareBotSource(bot, pinnedChat) {
return pinnedChat
}
+ const liveId = String(typeof host.activeConnectionId === 'function' ? host.activeConnectionId() || '' : '').trim()
+ const targetId = String(bot.connectionId || '').trim()
+
+ if (targetId && targetId !== 'local' && liveId !== targetId) {
+ throw new Error(`Still on ${liveId || 'this device'}, not ${bot.connectionLabel || targetId}`)
+ }
+
// Thin rows deliberately omit metadata from the active source. Once their
// owner is active, recover that source's canonical-chat pointer so
// same-named agents never reuse or overwrite each other's pin.
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.mjs
index 1185358eb24..de402b903d6 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
@@ -23,6 +23,7 @@ function renderBotRow(input = 'alpha') {
const ensured = []
const opened = []
const warmed = []
+ let liveConnectionId = 'local'
const atom = value => ({
get: () => value,
set: next => {
@@ -63,7 +64,11 @@ function renderBotRow(input = 'alpha') {
useState: initial => [typeof initial === 'function' ? initial() : initial, () => undefined],
host: {
state: { gateway: atom('open'), profile: atom('default') },
- ensureAgent: async (connectionId, profile) => ensured.push([connectionId, profile]),
+ ensureAgent: async (connectionId, profile) => {
+ ensured.push([connectionId, profile])
+ liveConnectionId = connectionId
+ },
+ activeConnectionId: () => liveConnectionId,
warmAgent: (connectionId, profile) => warmed.push([connectionId, profile]),
warmProfile: profile => warmed.push(profile),
request: async method =>
@@ -129,3 +134,83 @@ test('behavior: a thin source row activates its owner and uses that owner\'s cha
assert.deepEqual(ensured, [['work', 'research']])
assert.deepEqual(opened, [['research', 'owner-chat']])
})
+
+test('behavior: remote default does not open this-device chat when the source did not activate', async () => {
+ const bot = {
+ connectionId: 'mac-mini',
+ connectionLabel: 'Mac Mini',
+ name: 'default',
+ remoteSource: true,
+ sourceScoped: true
+ }
+ const prepareSource = sourceBetween('async function prepareBotSource(', 'function displayName(')
+ const botRowSource = sourceBetween('function BotRow(', '// ── model picker')
+ const ensured = []
+ const opened = []
+ const errors = []
+ const atom = value => ({
+ get: () => value,
+ set: next => {
+ value = next
+ }
+ })
+ const node = (type, props = {}) => ({ type, props })
+ const context = {
+ BotFace: 'BotFace',
+ ContextMenu: 'ContextMenu',
+ ContextMenuContent: 'ContextMenuContent',
+ ContextMenuItem: 'ContextMenuItem',
+ ContextMenuSeparator: 'ContextMenuSeparator',
+ ContextMenuTrigger: 'ContextMenuTrigger',
+ ROSTER_KEY: ['hermes-bots', 'roster'],
+ $botMeta: atom({ default: { chat: 'this-device-chat' } }),
+ $botUnread: atom({}),
+ $lastRoster: atom([]),
+ $selectedBot: atom('default'),
+ botAppearance: () => ({ shape: 'round', color: '#000', image: null }),
+ botHandle: value => value,
+ botRosterMeta: () => null,
+ cn: (...values) => values.filter(Boolean).join(' '),
+ createCanonicalChat: async () => null,
+ displayName: bot => bot.connectionLabel || bot.name,
+ duplicateBot: async () => 'copy',
+ haptic: () => undefined,
+ previewKind: () => ({ fromBot: false, sender: null }),
+ generatedSessionTitle: () => null,
+ openBotCanonicalChat: async (...args) => {
+ opened.push(args)
+ return 'this-device-chat'
+ },
+ ACTIVE_WINDOW_S: 90,
+ A2A_PREFIX_RE: /^$/,
+ useEffect: () => undefined,
+ useState: initial => [typeof initial === 'function' ? initial() : initial, () => undefined],
+ host: {
+ state: { gateway: atom('open'), profile: atom('default') },
+ ensureAgent: async (connectionId, profile) => ensured.push([connectionId, profile]),
+ activeConnectionId: () => 'local',
+ warmAgent: () => undefined,
+ warmProfile: () => undefined,
+ request: async () => ({ profiles: [{ name: 'default', ui_meta: { 'hermes-bots': { chat: 'this-device-chat' } } }] }),
+ notify: () => undefined,
+ notifyError: (_err, msg) => errors.push(msg)
+ },
+ jsx: node,
+ jsxs: node,
+ onEdit: () => undefined,
+ queryClient: { invalidateQueries: () => undefined },
+ relativeTime: () => 'now',
+ saveBotMeta: () => undefined,
+ showsHandle: () => false,
+ useValue: store => store.get()
+ }
+
+ vm.runInNewContext(`${prepareSource}\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
+
+ await row.props.onClick()
+ assert.deepEqual(ensured, [['mac-mini', 'default']])
+ assert.deepEqual(opened, [])
+ assert.match(String(errors[0] || ''), /Mac Mini/)
+})