fix(bot-mode): group rooms name renamed bots — 'Lucy is thinking…', never a stale 'Hermes'

groupSpeakerLabel resolved friendly identity for exactly one case: the
literal profile name 'default' → 'Hermes'. A renamed default (core
display_name via 'hermes profile rename', e.g. Lucy) or a Bot Mode title
never reached the room's working line, activity feed, or transcript
speaker prefix — the community report was Lucy's group turns still
reading 'hermes thinking'.

The label now walks the same rungs as displayName(): Bot Mode title
first, then the ACTIVE gateway roster row's display_name (remote/thin
rows are skipped so another connection's default can't lend its name),
then the existing default→Hermes fallback.

Validation: group-chat.test.mjs 87/87, full hermes-bots suite 474/474.
This commit is contained in:
Teknium
2026-08-23 04:55:20 -07:00
parent 2c244f0751
commit f530cd2b54
2 changed files with 74 additions and 5 deletions
+36 -4
View File
@@ -5975,11 +5975,43 @@ function rotateGroupSpeakers(members, round) {
return [...members.slice(shift), ...members.slice(0, shift)]
}
/** Transcript form of a room speaker's profile name. The primary profile is
* literally named "default" — render it as Hermes (matching displayName and
* the @hermes handle) so the main agent never loses its name in rooms. */
/** Transcript form of a room speaker's profile name. Friendly identity wins:
* a Bot Mode title or a core profile display_name (e.g. default renamed to
* "Lucy") labels the speaker everywhere this helper feeds — the "X is
* thinking…" working line, the activity feed, and transcript lines — so a
* renamed bot never shows up as its raw profile id or a stale "Hermes"
* (community report, Aug 21 2026: renamed default still read "Hermes is
* thinking…" in group rooms). The untitled primary profile is literally
* named "default" — render it as Hermes (matching displayName and the
* @hermes handle) so the main agent never loses its name in rooms. */
function groupSpeakerLabel(name) {
return (name || '').trim().toLowerCase() === 'default' ? 'Hermes' : name
const trimmed = (name || '').trim()
if (!trimmed) {
return trimmed
}
// Bot Mode title (edit dialog) — same first rung as displayName().
const title = String($botMeta.get()?.[trimmed]?.title || '').trim()
if (title) {
return title
}
// Core profile display_name (`hermes profile rename …` / dashboard) from
// the ACTIVE gateway's roster row. Source-scoped remote speakers carry
// their device suffix separately and keep their raw name here.
const roster = $lastRoster.get()
const row = Array.isArray(roster)
? roster.find(bot => bot?.name === trimmed && !bot?.remoteSource && !bot?.sourceScoped)
: null
const renamed = typeof row?.display_name === 'string' ? row.display_name.trim() : ''
if (renamed) {
return renamed
}
return trimmed.toLowerCase() === 'default' ? 'Hermes' : trimmed
}
/** Room-log line as a member sees it: `Name (user): …` / `Name: …` /
@@ -196,7 +196,7 @@ function load(turnScript, { busyUntilResumeCall, clarifyUntilResumeCall, approva
.replace(/^import .* from 'react\/jsx-runtime'\r?\n/m, '')
.replace('export default {', 'globalThis.plugin = {')
.concat(
'\nglobalThis.__gc = { sendToGroupChat, runGroupChatRounds, harvestStrandedGroupReply, resolveGroupResponders, parseGroupChatMentions, rotateGroupSpeakers, isGroupPassText, formatGroupChatLine, buildGroupChatTurnPrompt, trimGroupChatLog, groupChatSyncSnapshot, groupChatGatewayJsonSize, mergeGroupChatSyncSnapshots, mergeRemoteGroupChatSnapshotIntoRooms, scheduleGroupChatServerSync, disbandGroupChat, renameGroupChat, updateGroupChat, durableGroupChatRooms, persistGroupChatRooms, ensureGroupChatSession, uniqueGroupChatName, liveGroupChatNames, openGroupChat, closeGroupChatMainTab, shouldRenderGroupChatInPane, syncGroupClarify, clearGroupClarify, answerGroupClarify, $groupClarify, $groupChats, $groupNeedsYou, $groupChatWorkspace, $groupMainTabsRev, $botMeta, GROUP_CHAT_MAX_ROUNDS, GROUP_CHAT_MAX_MESSAGES };\n'
'\nglobalThis.__gc = { sendToGroupChat, runGroupChatRounds, harvestStrandedGroupReply, resolveGroupResponders, parseGroupChatMentions, rotateGroupSpeakers, isGroupPassText, formatGroupChatLine, groupSpeakerLabel, buildGroupChatTurnPrompt, trimGroupChatLog, groupChatSyncSnapshot, groupChatGatewayJsonSize, mergeGroupChatSyncSnapshots, mergeRemoteGroupChatSnapshotIntoRooms, scheduleGroupChatServerSync, disbandGroupChat, renameGroupChat, updateGroupChat, durableGroupChatRooms, persistGroupChatRooms, ensureGroupChatSession, uniqueGroupChatName, liveGroupChatNames, openGroupChat, closeGroupChatMainTab, shouldRenderGroupChatInPane, syncGroupClarify, clearGroupClarify, answerGroupClarify, $groupClarify, $groupChats, $groupNeedsYou, $groupChatWorkspace, $groupMainTabsRev, $botMeta, $lastRoster, GROUP_CHAT_MAX_ROUNDS, GROUP_CHAT_MAX_MESSAGES };\n'
)
vm.runInNewContext(source, context, { filename: 'plugin.js' })
const storageWrites = new Map()
@@ -1280,6 +1280,43 @@ test('default profile speaks as Hermes in room transcripts, not @default', () =>
assert.equal(plain, 'builder: yo')
})
test('speaker labels honor friendly identity: Bot Mode title, then display_name, never a stale Hermes', () => {
const gc = load(() => '(pass)')
// A renamed default (core display_name via `hermes profile rename`) must
// read as its new name — the community report was "Lucy" still showing
// "Hermes is thinking…" in group rooms.
gc.$lastRoster.set([{ name: 'default', display_name: 'Lucy' }])
assert.equal(gc.groupSpeakerLabel('default'), 'Lucy')
assert.equal(
gc.formatGroupChatLine({ from: { kind: 'member', name: 'default' }, text: 'hi' }, 'builder'),
'Lucy: hi'
)
// A Bot Mode title outranks display_name (same precedence as displayName).
gc.$botMeta.set({ default: { title: 'Moxie' } })
assert.equal(gc.groupSpeakerLabel('default'), 'Moxie')
// Secondary profiles get their title too — the thinking line names the
// renamed bot, not the raw profile slug.
gc.$botMeta.set({ research: { title: 'Radar' } })
gc.$lastRoster.set([])
assert.equal(gc.groupSpeakerLabel('research'), 'Radar')
// Untitled rows keep today's behavior: default → Hermes, others verbatim.
gc.$botMeta.set({})
assert.equal(gc.groupSpeakerLabel('default'), 'Hermes')
assert.equal(gc.groupSpeakerLabel('builder'), 'builder')
})
test('speaker labels never borrow a remote row\u2019s display_name for a local speaker', () => {
const gc = load(() => '(pass)')
// Only a remote/thin row named default exists — its display_name belongs
// to that connection, not to the active gateway's default.
gc.$lastRoster.set([{ name: 'default', display_name: 'HomelabBot', remoteSource: true }])
assert.equal(gc.groupSpeakerLabel('default'), 'Hermes')
})
test('turn prompt addresses the default profile as @hermes', () => {
const gc = load(() => '(pass)')
const prompt = gc.buildGroupChatTurnPrompt({