Skip to content

The agent that grows with you

fix(desktop): allow CJK bot names

105232631108debd715f36
diff --git a/apps/desktop/src/plugins/hermes-bots/create-agent-lazy-profile.test.tsx b/apps/desktop/src/plugins/hermes-bots/create-agent-lazy-profile.test.tsx
index ee1dbfe5412..25a6d746a2f 100644
--- a/apps/desktop/src/plugins/hermes-bots/create-agent-lazy-profile.test.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/create-agent-lazy-profile.test.tsx
@@ -162,6 +162,30 @@ afterEach(() => {
})
describe('materializing the draft profile', () => {
+ it.each([
+ ['小助手', 'u5c0f-u52a9-u624b'],
+ ['test机器人', 'test-u673a-u5668-u4eba']
+ ])('creates %s with an ASCII profile id and retains the display name', async (enteredName, profileName) => {
+ await renderDialog(true)
+
+ fireEvent.change(screen.getByPlaceholderText('inbox-triage'), {
+ target: { value: enteredName }
+ })
+
+ const create = screen.getByRole('button', { name: 'Create Bot' })
+
+ expect((create as HTMLButtonElement).disabled).toBe(false)
+ fireEvent.click(create)
+
+ await waitFor(() => expect(createCalls()).toHaveLength(1))
+ expect(createCalls()[0][1]).toMatchObject({
+ description: enteredName,
+ name: profileName
+ })
+ expect(mocks.saveBotMeta).toHaveBeenCalledWith(profileName, expect.objectContaining({ title: enteredName }))
+ await waitFor(() => expect(mocks.createCanonicalChat).toHaveBeenCalledWith(profileName, { kickoff: true }))
+ })
+
it('creates it once when the Capabilities tab opens, pinned to the new slug', async () => {
await renderDialog(true)
diff --git a/apps/desktop/src/plugins/hermes-bots/create-dialog.tsx b/apps/desktop/src/plugins/hermes-bots/create-dialog.tsx
index 062d0d628f0..707f0e1e30e 100644
--- a/apps/desktop/src/plugins/hermes-bots/create-dialog.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/create-dialog.tsx
@@ -56,7 +56,7 @@ import {
liveGroupChatNames
} from './group-membership'
import { useBots } from './i18n'
-import { displayName, slugify } from './labels'
+import { botProfileIdentity, displayName } from './labels'
import { McpSetupButton } from './mcp-setup'
import { ModelPicker } from './model-picker'
import type {
@@ -209,7 +209,7 @@ export function CreateAgentDialog({ open, onClose, roster }: CreateAgentDialogPr
const [capFilter, setCapFilter] = useState('')
const [busy, setBusy] = useState(false)
const [error, setError] = useState<null | string>(null)
- const slug = slugify(name)
+ const { slug, title: botTitle } = botProfileIdentity(name, title)
const valid = slug.length > 0 && NAME_RE.test(slug)
// Once the draft profile is materialized (Capabilities tab / MCP setup) it
@@ -378,7 +378,7 @@ export function CreateAgentDialog({ open, onClose, roster }: CreateAgentDialogPr
return null
}
- const descriptionText = [title, description].filter(Boolean).join(' — ')
+ const descriptionText = [botTitle, description].filter(Boolean).join(' — ')
await requestForTarget('profiles.create', {
name: slug,
description: descriptionText,
@@ -394,7 +394,7 @@ export function CreateAgentDialog({ open, onClose, roster }: CreateAgentDialogPr
mirror_credentials: mirrorCredentials,
soul: composeSoul({
name: slug,
- title,
+ title: botTitle,
description,
roster,
customSoul: soul
@@ -449,7 +449,7 @@ export function CreateAgentDialog({ open, onClose, roster }: CreateAgentDialogPr
color,
image,
imageKind: image ? 'photo' : 'shape',
- title: title.trim(),
+ title: botTitle,
created: Date.now()
}
@@ -477,7 +477,7 @@ export function CreateAgentDialog({ open, onClose, roster }: CreateAgentDialogPr
color: color ?? undefined,
image,
imageKind: image ? 'photo' : 'shape',
- title: title.trim(),
+ title: botTitle,
created: Date.now()
})
}
@@ -515,11 +515,11 @@ export function CreateAgentDialog({ open, onClose, roster }: CreateAgentDialogPr
message: remoteTarget
? `Bot "${displayName({
name: slug,
- title
+ title: botTitle
})}" created on ${targetLabel}`
: `Bot "${displayName({
name: slug,
- title
+ title: botTitle
})}" created`
})
const wasRemote = remoteTarget
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.ts
new file mode 100644
index 00000000000..84c316d0ae3
--- /dev/null
+++ b/apps/desktop/src/plugins/hermes-bots/labels.profile-name.test.ts
@@ -0,0 +1,19 @@
+import { describe, expect, it } from 'vitest'
+
+import { botProfileIdentity, slugifyProfileName } from './labels'
+
+describe('profile-name identity', () => {
+ it('derives a stable ASCII profile id from a CJK name and keeps the name as the title', () => {
+ expect(slugifyProfileName('小助手')).toBe('u5c0f-u52a9-u624b')
+ expect(slugifyProfileName('test机器人')).toBe('test-u673a-u5668-u4eba')
+ // The encoded form is its own fixed point, and ASCII input slugs as before.
+ expect(slugifyProfileName('u5c0f-u52a9-u624b')).toBe('u5c0f-u52a9-u624b')
+ expect(slugifyProfileName('Inbox Triage')).toBe('inbox-triage')
+
+ expect(botProfileIdentity('小助手', '')).toEqual({ slug: 'u5c0f-u52a9-u624b', title: '小助手' })
+ expect(botProfileIdentity('小助手', 'Helper')).toEqual({ slug: 'u5c0f-u52a9-u624b', title: 'Helper' })
+ expect(botProfileIdentity('Test', '')).toEqual({ slug: 'test', title: '' })
+ // Symbols carry no letters or digits: still no id, Create stays disabled.
+ expect(botProfileIdentity('🤖', '')).toEqual({ slug: '', title: '🤖' })
+ })
+})
diff --git a/apps/desktop/src/plugins/hermes-bots/labels.ts b/apps/desktop/src/plugins/hermes-bots/labels.ts
index 39de2166e5a..1bc212ac996 100644
--- a/apps/desktop/src/plugins/hermes-bots/labels.ts
+++ b/apps/desktop/src/plugins/hermes-bots/labels.ts
@@ -71,6 +71,33 @@ export function slugify(value: string) {
.slice(0, 64)
}
+/** 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. */
+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, '-')
+ )
+}
+
+/** Split the dialog's Name field into the backend id and the display title.
+ * A non-ASCII name cannot be the profile id, so the entered string survives
+ * as the title when the user left Title empty. */
+export function botProfileIdentity(name: string, title: string) {
+ const enteredName = name.trim()
+
+ return {
+ slug: slugifyProfileName(enteredName),
+ title: title.trim() || (/[^\u0020-\u007e]/.test(enteredName) ? enteredName : '')
+ }
+}
+
/** Flatten markdown syntax out of a one-line roster preview so rows read
* like Discord's — no raw **bold**, `code`, > quotes, or [link](url)
* characters in the preview line. */