Skip to content

The agent that grows with you

fix(desktop): name the Settings scope note by the same label as its chip

teknium161ab27e9f02e
diff --git a/apps/desktop/e2e/settings-scope-chips-bot-title.spec.ts b/apps/desktop/e2e/settings-scope-chips-bot-title.spec.ts
new file mode 100644
index 00000000000..32e11c2fea5
--- /dev/null
+++ b/apps/desktop/e2e/settings-scope-chips-bot-title.spec.ts
@@ -0,0 +1,90 @@
+import fs from 'node:fs'
+import path from 'node:path'
+
+import {
+ buildAppEnv,
+ createSandbox,
+ launchDesktop,
+ type MockBackendFixture,
+ waitForAppReady,
+ writeEnvFile,
+ writeMockProviderConfig
+} from './fixtures'
+import { startMockServer } from '../../../tests-js/scripts/mock-server'
+import { expect, test } from './test'
+
+// Settings' "Applies to" chips named every profile by its canonical slug
+// (`alpha`, `beta`) while the Bots roster called the same agents by their Bot
+// title / display name (#109686). The chip must read the presentation name the
+// rest of the app uses; the slug stays the identity underneath.
+
+let fixture: MockBackendFixture | null = null
+
+function seedProfile(hermesHome: string, mockUrl: string, name: string, profileYaml: string): void {
+ const dir = path.join(hermesHome, 'profiles', name)
+ fs.mkdirSync(dir, { recursive: true })
+ writeMockProviderConfig(dir, mockUrl)
+ writeEnvFile(dir)
+ fs.writeFileSync(path.join(dir, 'profile.yaml'), profileYaml, 'utf8')
+}
+
+test.beforeAll(async () => {
+ const mock = await startMockServer()
+ const sandbox = createSandbox('settings-chips')
+ writeMockProviderConfig(sandbox.hermesHome, mock.url)
+ writeEnvFile(sandbox.hermesHome)
+ // A Bot Mode bot: the roster shows ui_meta['hermes-bots'].title.
+ seedProfile(sandbox.hermesHome, mock.url, 'alpha', 'ui_meta:\n hermes-bots:\n title: Atlas Prime\n')
+ // A renamed profile: `hermes profile rename` writes display_name.
+ seedProfile(sandbox.hermesHome, mock.url, 'beta', 'display_name: Beacon\n')
+
+ const { app, page } = await launchDesktop(buildAppEnv(sandbox))
+
+ fixture = {
+ app,
+ page,
+ mock,
+ mockUrl: mock.url,
+ sandbox,
+ cleanup: async () => {
+ await app.close().catch(() => undefined)
+ await mock.close()
+ sandbox.cleanup()
+ }
+ }
+ await waitForAppReady(fixture, 120_000)
+})
+
+test.afterAll(async () => {
+ await fixture?.cleanup()
+ fixture = null
+})
+
+test('Settings "Applies to" chips read the Bot title / display name, not the slug', async () => {
+ test.setTimeout(300_000)
+ const page = fixture!.page
+
+ await page.evaluate(() => {
+ window.location.hash = '#/settings'
+ })
+
+ // Chips carry their label as visible text (the profile rail's avatars only
+ // carry it as aria-label), so filter by text to target the Settings strip.
+ const chip = (label: string) => page.getByRole('button', { name: label, exact: true }).filter({ hasText: label })
+ await expect(chip('Atlas Prime').first()).toBeVisible({ timeout: 60_000 })
+ await expect(chip('Beacon').first()).toBeVisible({ timeout: 15_000 })
+ // The slug is the identity, never the label.
+ await expect(chip('alpha')).toHaveCount(0)
+ await expect(chip('beta')).toHaveCount(0)
+ // The root profile keeps its slug when it has neither title nor display name (control).
+ await expect(chip('default').first()).toBeVisible()
+
+ // Selecting by presentation label still scopes by the canonical slug: the
+ // "applies to" note names the target by the same label as its chip.
+ await chip('Atlas Prime').first().click()
+ const note = page.getByRole('status').filter({ hasText: 'Atlas Prime' }).first()
+ await expect(note).toBeVisible({ timeout: 10_000 })
+ await expect(note).not.toContainText('alpha')
+
+ await page.screenshot({ path: 'test-results/settings-scope-chips-bot-title.png' })
+})
diff --git a/apps/desktop/src/app/settings/profile-scope.test.tsx b/apps/desktop/src/app/settings/profile-scope.test.tsx
index 8078568d379..556c9cfa94e 100644
--- a/apps/desktop/src/app/settings/profile-scope.test.tsx
+++ b/apps/desktop/src/app/settings/profile-scope.test.tsx
@@ -133,5 +133,8 @@ describe('SettingsProfileScope', () => {
fireEvent.click(screen.getByRole('button', { name: 'JordyV' }))
// The label changed, the identity did not: the override stores the slug.
expect($settingsScopeOverride.get()).toBe('coder')
+ // The "applies to" note names the target the way its chip does.
+ expect(document.querySelector('[role="status"]')?.textContent).toContain('JordyV')
+ expect(document.querySelector('[role="status"]')?.textContent).not.toContain('coder')
})
})
diff --git a/apps/desktop/src/app/settings/profile-scope.tsx b/apps/desktop/src/app/settings/profile-scope.tsx
index 2f656fcb496..9427302fb53 100644
--- a/apps/desktop/src/app/settings/profile-scope.tsx
+++ b/apps/desktop/src/app/settings/profile-scope.tsx
@@ -45,6 +45,11 @@ export function SettingsProfileScope({ className }: { className?: string }) {
const selected = useStore($settingsScopeProfile)
const editingNonDefault = useStore($settingsScopeEditsNonDefault)
const profiles = useStore($profiles)
+ // The note names the edit target with the same presentation label as its
+ // chip (Bot title → display_name → slug); the slug alone can name a bot the
+ // user has never seen called that.
+ const selectedLabel = profiles.find(profile => normalizeProfileKey(profile.name) === selected)
+ const selectedName = selectedLabel ? profileLabel(selectedLabel) : selected
// Refresh lazily so a profile created elsewhere shows up; the cached list
// paints immediately. Best-effort — a failure keeps the cached roster.
@@ -85,7 +90,7 @@ export function SettingsProfileScope({ className }: { className?: string }) {
data-scope-loud={editingNonDefault ? 'true' : undefined}
role="status"
>
- {scope.editsProfile(selected)}
+ {scope.editsProfile(selectedName)}
</p>
) : null}
</div>