The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): fold accented Latin, keep NFC tokens and cut CJK profile ids on a token boundary
teknium11b722403b971
diff --git a/apps/desktop/src/plugins/hermes-bots/group-chat-view.tsx b/apps/desktop/src/plugins/hermes-bots/group-chat-view.tsxindex d550afb05fa..26f1762cf5a 100644--- a/apps/desktop/src/plugins/hermes-bots/group-chat-view.tsx+++ b/apps/desktop/src/plugins/hermes-bots/group-chat-view.tsx@@ -95,7 +95,7 @@ import type { GroupComposerDraft, GroupDraftSetter } from './group-panes'import { sendToGroupChat, stopGroupThread } from './group-rounds'import { clearGroupClarify, renameGroupClarify } from './group-turns'import { botsText, useBots } from './i18n'-import { displayName, slugify } from './labels'+import { displayName, slugifyProfileName } from './labels'import { botRosterMeta, setBotsWorkspaceOwner } from './routing'import { bumpBotOpenGeneration, getPluginCtx, ID } from './shared'import type { Attachment, BotMeta, GroupChat, GroupMember, GroupMessage, RosterRow } from './types'@@ -1270,7 +1270,7 @@ function GroupChatMainView({ group }: GroupChatMainViewProps) {const $visible = useMemo(() =>typeof host.paneVisibility === 'function'- ? host.paneVisibility(`plugin-workspace:${ID}:group:${slugify(group)}`)+ ? host.paneVisibility(`plugin-workspace:${ID}:group:${slugifyProfileName(group)}`): atom(true),[group])@@ -1306,7 +1306,7 @@ export function openGroupChat(group: string): void {if (typeof host.openWorkspace === 'function') {try {- const close = host.openWorkspace(`${ID}:group:${slugify(group)}`, {+ const close = host.openWorkspace(`${ID}:group:${slugifyProfileName(group)}`, {title: group,minWidth: '24rem',render: () => <GroupChatMainView group={group} />,diff --git a/apps/desktop/src/plugins/hermes-bots/labels.profile-name.test.ts b/apps/desktop/src/plugins/hermes-bots/labels.profile-name.test.tsindex 84c316d0ae3..1b12a75b943 100644--- a/apps/desktop/src/plugins/hermes-bots/labels.profile-name.test.ts+++ b/apps/desktop/src/plugins/hermes-bots/labels.profile-name.test.ts@@ -16,4 +16,21 @@ describe('profile-name identity', () => {// Symbols carry no letters or digits: still no id, Create stays disabled.expect(botProfileIdentity('🤖', '')).toEqual({ slug: '', title: '🤖' })})++ it('folds accented Latin to its base letters and keeps the accented name as the title', () => {+ // NFKD alone tokenised the detached accent: 'Résumé' → 're-sume'.+ expect(slugifyProfileName('Café Résumé')).toBe('cafe-resume')+ expect(botProfileIdentity('Café', '')).toEqual({ slug: 'cafe', title: 'Café' })+ })++ it('keeps one token per NFC code point and never splits a token at the 64-char cap', () => {+ // Hangul must not decompose to jamo (3 syllables → 6 tokens) nor ガ collapse onto カ.+ expect(slugifyProfileName('한글')).toBe('ud55c-uae00')+ expect(slugifyProfileName('ガ')).not.toBe(slugifyProfileName('カ'))++ const long = slugifyProfileName('小助手'.repeat(7))+ expect(long).toBe('u5c0f-u52a9-u624b-u5c0f-u52a9-u624b-u5c0f-u52a9-u624b-u5c0f')+ // Every id still satisfies hermes_cli.profiles._PROFILE_ID_RE.+ expect(long).toMatch(/^[a-z0-9][a-z0-9_-]{0,63}$/)+ })})diff --git a/apps/desktop/src/plugins/hermes-bots/labels.ts b/apps/desktop/src/plugins/hermes-bots/labels.tsindex 1bc212ac996..587a98390ca 100644--- a/apps/desktop/src/plugins/hermes-bots/labels.ts+++ b/apps/desktop/src/plugins/hermes-bots/labels.ts@@ -63,27 +63,42 @@ export function displayName(bot: Partial<RosterRow>, meta?: BotMeta | null): strreturn raw.replace(/\b\w/g, ch => ch.toUpperCase())}-export function slugify(value: string) {+export function slugify(value: string, max = 64) {return value.toLowerCase().replace(/[^a-z0-9_-]+/g, '-').replace(/^-+|-+$/g, '')- .slice(0, 64)+ .slice(0, max)}/** The profile id the backend accepts (`hermes_cli.profiles._PROFILE_ID_RE`* is ASCII-only), derived from whatever the user typed as the bot's name.- * Letters and digits outside ASCII become a deterministic `u<hex>` token- * per code point — `小助手` → `u5c0f-u52a9-u624b`, `test机器人` →- * `test-u673a-u5668-u4eba` — so a CJK name no longer slugs to '' and leaves- * Create disabled (#96153). Plain ASCII names slug exactly as before. */+ * Accented Latin folds to its base letters (`Résumé` → `resume`); every other+ * letter or digit becomes a deterministic `u<hex>` token per NFC code point —+ * `小助手` → `u5c0f-u52a9-u624b`, `한글` → `ud55c-uae00` — so a CJK name no+ * longer slugs to '' and leaves Create disabled (#96153). 7-bit ASCII names+ * slug exactly as before; a name past the 64-char cap is cut at the last+ * token boundary so no `u<hex>` token is split into a different code point. */export function slugifyProfileName(value: string) {- return slugify(- value- .normalize('NFKD')- .replace(/[\p{L}\p{N}]/gu, ch => (/[a-zA-Z0-9]/.test(ch) ? ch : `-u${ch.codePointAt(0)!.toString(16)}-`))- .replace(/-+/g, '-')- )+ const folded = value+ .normalize('NFC')+ .replace(/[\p{L}\p{N}]/gu, ch => {+ const base = ch.normalize('NFKD').replace(/\p{M}+/gu, '')++ return /^[a-zA-Z0-9]+$/.test(base) ? base : `-u${ch.codePointAt(0)!.toString(16)}-`+ })+ .replace(/-+/g, '-')++ const slug = slugify(folded, Infinity)++ if (slug.length <= 64) {+ return slug+ }++ const cut = slug.slice(0, 64)+ const boundary = slug[64] === '-' ? 64 : cut.lastIndexOf('-')++ return (boundary > 0 ? cut.slice(0, boundary) : cut).replace(/-+$/, '')}/** Split the dialog's Name field into the backend id and the display title.