Skip to content

The agent that grows with you

fix(desktop): localize the session-named prompt title; trim to two invariants

teknium11879088d3fad
diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.ts
index 9a9161fc79b..84273e59bb6 100644
--- a/apps/desktop/src/i18n/ar.ts
+++ b/apps/desktop/src/i18n/ar.ts
@@ -264,9 +264,11 @@ export const ar = defineLocale({
},
native: {
approvalTitle: 'مطلوب موافقة',
+ approvalTitleNamed: session => `مطلوب موافقة — ${session}`,
approveAction: 'موافقة',
rejectAction: 'رفض',
inputTitle: 'مطلوب إدخال',
+ inputTitleNamed: session => `مطلوب إدخال — ${session}`,
inputBody: 'ينتظر Hermes ردّك.',
turnDoneTitle: 'أنهى Hermes',
turnDoneBody: '',
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index 4939f4fafc9..fcd287befc0 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -325,9 +325,11 @@ export const en: Translations = {
},
native: {
approvalTitle: 'Approval needed',
+ approvalTitleNamed: session => `Approval needed — ${session}`,
approveAction: 'Approve',
rejectAction: 'Reject',
inputTitle: 'Input needed',
+ inputTitleNamed: session => `Input needed — ${session}`,
inputBody: 'Hermes is waiting for your response.',
turnDoneTitle: 'Hermes finished',
turnDoneBody: '',
diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.ts
index a2eec2699df..2d6f25a159d 100644
--- a/apps/desktop/src/i18n/ja.ts
+++ b/apps/desktop/src/i18n/ja.ts
@@ -262,9 +262,11 @@ export const ja = defineLocale({
},
native: {
approvalTitle: '承認が必要です',
+ approvalTitleNamed: session => `承認が必要です — ${session}`,
approveAction: '承認',
rejectAction: '拒否',
inputTitle: '入力が必要です',
+ inputTitleNamed: session => `入力が必要です — ${session}`,
inputBody: 'Hermes が応答を待っています。',
turnDoneTitle: 'Hermes が完了しました',
turnDoneBody: '',
diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.ts
index a9525d71b88..66104c48cbf 100644
--- a/apps/desktop/src/i18n/ru.ts
+++ b/apps/desktop/src/i18n/ru.ts
@@ -272,9 +272,11 @@ export const ru = defineLocale({
},
native: {
approvalTitle: 'Требуется одобрение',
+ approvalTitleNamed: session => `Требуется одобрение — ${session}`,
approveAction: 'Одобрить',
rejectAction: 'Отклонить',
inputTitle: 'Требуется ввод',
+ inputTitleNamed: session => `Требуется ввод — ${session}`,
inputBody: 'Hermes ожидает ваш ответ.',
turnDoneTitle: 'Hermes завершил',
turnDoneBody: '',
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index dbd9ce08ee8..7429e74e960 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -371,9 +371,11 @@ export interface Translations {
// bodies (the agent's reply, a command, an error) are passed through raw.
native: {
approvalTitle: string
+ approvalTitleNamed: (session: string) => string
approveAction: string
rejectAction: string
inputTitle: string
+ inputTitleNamed: (session: string) => string
inputBody: string
turnDoneTitle: string
turnDoneBody: string
diff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.ts
index 6e45174100a..421362188a9 100644
--- a/apps/desktop/src/i18n/zh-hant.ts
+++ b/apps/desktop/src/i18n/zh-hant.ts
@@ -255,9 +255,11 @@ export const zhHant = defineLocale({
},
native: {
approvalTitle: '需要核准',
+ approvalTitleNamed: session => `需要核准 — ${session}`,
approveAction: '核准',
rejectAction: '拒絕',
inputTitle: '需要輸入',
+ inputTitleNamed: session => `需要輸入 — ${session}`,
inputBody: 'Hermes 正在等待你的回應。',
turnDoneTitle: 'Hermes 已完成',
turnDoneBody: '',
diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.ts
index e5cc0fd8e43..dd0818fa4d6 100644
--- a/apps/desktop/src/i18n/zh.ts
+++ b/apps/desktop/src/i18n/zh.ts
@@ -289,9 +289,11 @@ export const zh = defineLocale({
},
native: {
approvalTitle: '需要批准',
+ approvalTitleNamed: session => `需要批准 — ${session}`,
approveAction: '批准',
rejectAction: '拒绝',
inputTitle: '需要输入',
+ inputTitleNamed: session => `需要输入 — ${session}`,
inputBody: 'Hermes 正在等待你的回应。',
turnDoneTitle: 'Hermes 已完成',
turnDoneBody: '',
diff --git a/apps/desktop/src/store/native-notifications.test.ts b/apps/desktop/src/store/native-notifications.test.ts
index b2e6577c1db..11d14921bc3 100644
--- a/apps/desktop/src/store/native-notifications.test.ts
+++ b/apps/desktop/src/store/native-notifications.test.ts
@@ -170,39 +170,18 @@ describe('dispatchNativeNotification preferences', () => {
})
describe('dispatchNativeNotification session context', () => {
- it('names the session in a blocking-prompt title so parked approvals stay tellable apart', () => {
- setSessions([{ id: 'review-chat', title: 'Fix the flaky test' } as SessionInfo])
-
- try {
- dispatchNativeNotification({ kind: 'approval', sessionId: 'review-chat', title: 'Approval needed' })
- expect(notify).toHaveBeenCalledWith(expect.objectContaining({ title: 'Approval needed — Fix the flaky test' }))
- } finally {
- setSessions([])
- }
- })
-
- it('carries the same label on the sibling input.request toast', () => {
+ it('names the session on blocking-prompt titles only, falling back to the id tail without a row', () => {
setSessions([{ id: 'named-chat', title: 'Migrate the schema' } as SessionInfo])
try {
dispatchNativeNotification({ kind: 'input', sessionId: 'named-chat', title: 'Input needed' })
expect(notify).toHaveBeenCalledWith(expect.objectContaining({ title: 'Input needed — Migrate the schema' }))
- } finally {
- setSessions([])
- }
- })
- it('falls back to a short id tail while the session has no row yet', () => {
- dispatchNativeNotification({ kind: 'approval', sessionId: 'abcdef123456', title: 'Approval needed' })
- expect(notify).toHaveBeenCalledWith(expect.objectContaining({ title: 'Approval needed — #123456' }))
- })
-
- it('leaves a completion title alone (only blocking prompts need the session)', () => {
- setSessions([{ id: 'done-chat', title: 'Fix the flaky test' } as SessionInfo])
- setActiveSessionId('done-chat')
+ dispatchNativeNotification({ kind: 'approval', sessionId: 'abcdef123456', title: 'Approval needed' })
+ expect(notify).toHaveBeenCalledWith(expect.objectContaining({ title: 'Approval needed — #123456' }))
- try {
- dispatchNativeNotification({ kind: 'turnDone', sessionId: 'done-chat', title: 'Hermes finished' })
+ setActiveSessionId('named-chat')
+ dispatchNativeNotification({ kind: 'turnDone', sessionId: 'named-chat', title: 'Hermes finished' })
expect(notify).toHaveBeenCalledWith(expect.objectContaining({ title: 'Hermes finished' }))
} finally {
setSessions([])
diff --git a/apps/desktop/src/store/native-notifications.ts b/apps/desktop/src/store/native-notifications.ts
index cc70fa13f0b..b5fd075e16b 100644
--- a/apps/desktop/src/store/native-notifications.ts
+++ b/apps/desktop/src/store/native-notifications.ts
@@ -1,5 +1,6 @@
import { atom } from 'nanostores'
+import { translateNow } from '@/i18n'
import { type HermesOpenTarget, resolveHermesOpenPath } from '@/lib/hermes-open-target'
import { persistString, storedString } from '@/lib/storage'
@@ -159,20 +160,23 @@ function shouldFire(kind: NativeNotificationKind, sessionId?: null | string, glo
* tail still tells three parked approvals apart. */
const shortSessionId = (id: string) => `#${id.slice(-6)}`
-/** Name the session in a blocking-prompt title: "Approval needed — Fix the flaky
- * test". Without it every parallel parked approval raises an identical OS toast
- * and the user cannot tell which chat is waiting (the runtime id the caller
- * already passes is the whole hint needed). */
-function withSessionLabel(title: string, runtimeSessionId: string): string {
+/** Blocking prompts name their session in the title ("Approval needed — Fix the
+ * flaky test") so parallel parked approvals stay tellable apart; the caller's
+ * `title` stays the bare fallback for a prompt with no session. */
+const NAMED_TITLE_KEYS: Partial<Record<NativeNotificationKind, string>> = {
+ approval: 'notifications.native.approvalTitleNamed',
+ input: 'notifications.native.inputTitleNamed'
+}
+
+/** Sidebar naming order (title → preview → short id) via the locale's
+ * named-title template; the runtime id the caller already passes is the whole
+ * hint needed. */
+function withSessionLabel(namedKey: string, runtimeSessionId: string): string {
const storedId = storedSessionIdForRuntimeId(runtimeSessionId) ?? runtimeSessionId
const row = ownerLookupSessionRows().find(session => sessionMatchesStoredId(session, storedId))
- const name = row?.title?.trim() || row?.preview?.trim()
-
- if (!name) {
- return `${title} — ${shortSessionId(storedId)}`
- }
+ const name = row?.title?.trim() || row?.preview?.trim() || shortSessionId(storedId)
- return `${title} — ${name.length > 80 ? `${name.slice(0, 80).trimEnd()}…` : name}`
+ return translateNow(namedKey, name.length > 80 ? `${name.slice(0, 80).trimEnd()}…` : name)
}
export interface NativeNotificationAction {
@@ -234,8 +238,8 @@ export function dispatchNativeNotification(input: NativeNotificationInput): bool
return false
}
- const title =
- ATTENTION_KINDS.has(input.kind) && input.sessionId ? withSessionLabel(input.title, input.sessionId) : input.title
+ const namedKey = input.sessionId ? NAMED_TITLE_KEYS[input.kind] : undefined
+ const title = namedKey && input.sessionId ? withSessionLabel(namedKey, input.sessionId) : input.title
void window.hermesDesktop?.notify({
actions: input.actions,