fix(desktop): stop phantom local default on remote-gateway desktops; keep the main agent named Hermes
Follow-up to #88523/#88542 from a community report (main agent listed twice, both rows unnamed @default handles). Two distinct bugs, both specific to remote-gateway-primary desktops: 1. Phantom "This device" default (electron): the roster enumeration dialed ensureRegistryBackend for the registry's local entry unconditionally. On a remote-primary desktop that forces resolveRegistryLocalRoute into the forced-local branch — SPAWNING a local backend the user never asked for. That backend enumerates a `default` profile, so a second default agent appears AND the duplicate-handle rule forces -device suffixes onto the real one. New shouldDeferLocalEnumeration() treats the forced-local route as connect-on-demand (same courtesy as undialed SSH sources): the local entry only enumerates when it is the delegate route (local-primary desktops, byte-identical behavior) or a forced-local child is already pooled (the user opened one). 2. Main agent renamed to a connection label (plugin): displayName keyed the "show the connection label for a default row" rule off sourceScoped — which annotation also sets on ACTIVE-source rows. A remote-gateway user's main agent rendered as an IP-derived label (or bare handle) instead of "Hermes"/their title. Key it off remoteSource: only THIN rows from another source trade the friendly name for their source label. Tests: shouldDeferLocalEnumeration route matrix (delegate always enumerates; forced-local defers until a conn:local:: child exists; bare-key remote descriptor doesn't count), displayName regression (active default stays Hermes/title; thin remote default still shows its source label).
This commit is contained in:
@@ -28,6 +28,7 @@ import {
|
||||
removeConnection,
|
||||
resolveRegistryLocalRoute,
|
||||
setPrimaryConnection,
|
||||
shouldDeferLocalEnumeration,
|
||||
uniqueLabel,
|
||||
updateEligibility,
|
||||
upsertConnection
|
||||
@@ -159,6 +160,28 @@ test('registry local route: a per-profile remote override also forces local', ()
|
||||
assert.deepEqual(route, { delegate: false, poolKey: 'conn:local::research' })
|
||||
})
|
||||
|
||||
// --- shouldDeferLocalEnumeration (roster's connect-on-demand for 'local') ---
|
||||
|
||||
test('local enumeration: delegate route (local-primary desktop) always enumerates', () => {
|
||||
const route = resolveRegistryLocalRoute('default', {})
|
||||
|
||||
assert.equal(shouldDeferLocalEnumeration(route, []), false)
|
||||
assert.equal(shouldDeferLocalEnumeration(route, ['conn:local::default']), false)
|
||||
})
|
||||
|
||||
test('local enumeration: forced-local route defers until a local child exists (remote-primary desktop)', () => {
|
||||
// Remote-gateway-only desktops: enumerating "This device" here would SPAWN
|
||||
// a local backend the user never asked for — a phantom `default` agent
|
||||
// that duplicates their real one and forces -device handles onto it.
|
||||
const route = resolveRegistryLocalRoute('default', { globalRemote: true })
|
||||
|
||||
assert.equal(shouldDeferLocalEnumeration(route, []), true)
|
||||
// The v1 remote descriptor cached at the BARE profile key is not a local child.
|
||||
assert.equal(shouldDeferLocalEnumeration(route, ['default', 'research']), true)
|
||||
// Once the user has genuinely opened a forced-local child, it enumerates.
|
||||
assert.equal(shouldDeferLocalEnumeration(route, ['conn:local::default']), false)
|
||||
})
|
||||
|
||||
// --- buildAgentRoster (union roster + @name-device rule) ---
|
||||
|
||||
test('roster: unique profiles keep bare handles; duplicates get @name-device', () => {
|
||||
|
||||
@@ -211,6 +211,28 @@ export function resolveRegistryLocalRoute(
|
||||
return { delegate: true, poolKey: profileKey }
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the roster enumeration should SKIP the registry's local entry as
|
||||
* connect-on-demand. True when the local source is the forced-local route
|
||||
* (primary resolves remote — enumerating would spawn a local backend the
|
||||
* user never asked for, minting a phantom `default` agent and forcing
|
||||
* -device handles onto the real one) AND no forced-local child is already
|
||||
* pooled. Pure — main.ts feeds it the live route + pool keys.
|
||||
*/
|
||||
export function shouldDeferLocalEnumeration(
|
||||
route: RegistryLocalRoute,
|
||||
poolKeys: Iterable<string>,
|
||||
connectionId: string = LOCAL_CONNECTION_ID
|
||||
): boolean {
|
||||
if (route.delegate) {
|
||||
return false
|
||||
}
|
||||
|
||||
const prefix = backendScopePrefix(connectionId)
|
||||
|
||||
return ![...poolKeys].some(key => String(key).startsWith(prefix))
|
||||
}
|
||||
|
||||
// ── Union agent roster ──────────────────────────────────────────────────────
|
||||
|
||||
export interface ConnectionAgents {
|
||||
|
||||
@@ -103,6 +103,7 @@ import {
|
||||
removeConnection,
|
||||
resolveRegistryLocalRoute,
|
||||
setPrimaryConnection,
|
||||
shouldDeferLocalEnumeration,
|
||||
updateEligibility,
|
||||
upsertConnection
|
||||
} from './connection-registry'
|
||||
@@ -12490,6 +12491,25 @@ async function enumerateRegistryAgentSources(registry = readDesktopConnectionsRe
|
||||
return { connection, profiles: null, error: 'connect-on-demand' }
|
||||
}
|
||||
|
||||
// Same connect-on-demand courtesy for the forced-local path: when the
|
||||
// primary route is remote, enumerating "This device" would SPAWN a
|
||||
// local backend this user has never asked for — a phantom `default`
|
||||
// agent that also forces -device handle disambiguation onto the real
|
||||
// one (remote-gateway-only desktops showed their main agent twice,
|
||||
// Aug 17 2026). Enumerate the local source only when it is the
|
||||
// delegate route (local-primary desktops, unchanged behavior) or a
|
||||
// forced-local child is ALREADY pooled (the user opened one).
|
||||
if (connection.kind === 'local') {
|
||||
const localRoute = resolveRegistryLocalRoute('default', {
|
||||
globalRemote: globalRemoteActive(),
|
||||
profileRemoteOverride: Boolean(profileHasRemoteOverride(primaryProfileKey()))
|
||||
})
|
||||
|
||||
if (shouldDeferLocalEnumeration(localRoute, backendPool.keys(), connection.id)) {
|
||||
return { connection, profiles: null, error: 'connect-on-demand' }
|
||||
}
|
||||
}
|
||||
|
||||
const descriptor: any = await ensureRegistryBackend(connection.id, null)
|
||||
const body: any = await getJsonForBackend(descriptor, '/api/profiles', { timeoutMs: 8_000 })
|
||||
|
||||
|
||||
@@ -2482,7 +2482,12 @@ async function prepareBotSource(bot, pinnedChat) {
|
||||
}
|
||||
|
||||
function displayName(bot, meta) {
|
||||
if (bot?.sourceScoped && (bot.name || '').trim().toLowerCase() === 'default' && bot.connectionLabel) {
|
||||
// Only THIN rows from another source trade the friendly name for their
|
||||
// connection label — the active gateway's own default must keep reading
|
||||
// "Hermes". Annotated active rows carry sourceScoped too, and keying this
|
||||
// off sourceScoped renamed the user's main agent to an IP-derived label
|
||||
// (community report, Aug 17 2026).
|
||||
if (bot?.remoteSource && (bot.name || '').trim().toLowerCase() === 'default' && bot.connectionLabel) {
|
||||
return bot.connectionLabel
|
||||
}
|
||||
|
||||
|
||||
@@ -240,8 +240,15 @@ test('default rows use source identity without borrowing another source title',
|
||||
|
||||
assert.equal(metaFor(remote, metadata), null)
|
||||
assert.equal(name(remote, metaFor(remote, metadata)), 'Personal')
|
||||
assert.equal(name(active, metadata.default), 'Personal')
|
||||
assert.equal(key(remote), 'personal::default')
|
||||
|
||||
// The ACTIVE gateway's own default is the user's main agent — annotation
|
||||
// (sourceScoped + connection fields) must NOT rename it to a connection
|
||||
// label. Titled: the title wins. Untitled: it stays "Hermes". Regression:
|
||||
// remote-gateway desktops showed the main agent as an IP-derived label
|
||||
// with no shortname (Aug 17 2026 report).
|
||||
assert.equal(name(active, metadata.default), 'Active workspace')
|
||||
assert.equal(name(active, undefined), 'Hermes')
|
||||
})
|
||||
|
||||
test('botHandle: precomputed multi-source handle wins; default stays hermes', () => {
|
||||
|
||||
Reference in New Issue
Block a user