Skip to content

The agent that grows with you

fix(desktop): keep completion notification body off the session title

keepConcentration6086a87cc9b7
diff --git a/apps/desktop/src/app/session/hooks/use-message-stream/index.ts b/apps/desktop/src/app/session/hooks/use-message-stream/index.ts
index 90707a010e2..fce0fabcbb5 100644
--- a/apps/desktop/src/app/session/hooks/use-message-stream/index.ts
+++ b/apps/desktop/src/app/session/hooks/use-message-stream/index.ts
@@ -28,6 +28,7 @@ import {
stripGeneratedImageEchoes
} from '@/lib/generated-images'
import { isTodoToolName, nextTodosFromToolEvent, parseTodoRevision } from '@/lib/todos'
+import { turnDoneNotificationBody } from '@/lib/turn-done-notification-body'
import type { ScopedServerRequest } from '@/store/gateway'
import { dispatchNativeNotification } from '@/store/native-notifications'
import { isDiskFullErrorMessage, notifyError } from '@/store/notifications'
@@ -1116,7 +1117,7 @@ export function useMessageStream({
}
dispatchNativeNotification({
- body: text.slice(0, 140) || translateNow('notifications.native.turnDoneBody'),
+ body: turnDoneNotificationBody(text, translateNow('notifications.native.turnDoneBody')),
kind: 'turnDone',
sessionId,
title: translateNow('notifications.native.turnDoneTitle')
diff --git a/apps/desktop/src/i18n/ar_diagnostics.ts b/apps/desktop/src/i18n/ar_diagnostics.ts
index f537374190f..4694eaf93bf 100644
--- a/apps/desktop/src/i18n/ar_diagnostics.ts
+++ b/apps/desktop/src/i18n/ar_diagnostics.ts
@@ -95,7 +95,7 @@ export const arDiagnostics = {
inputTitleNamed: session => `مطلوب إدخال — ${session}`,
inputBody: 'ينتظر Hermes ردّك.',
turnDoneTitle: 'أنهى Hermes',
- turnDoneBody: '',
+ turnDoneBody: 'اكتملت الرسالة.',
turnErrorTitle: 'فشلت الجولة',
backgroundDoneTitle: 'انتهت المهمة في الخلفية',
backgroundFailedTitle: 'فشلت المهمة في الخلفية'
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index 0e1b10608c2..bed9a6c3e6d 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -602,7 +602,7 @@ export const en: Translations = {
inputTitleNamed: session => `Input needed — ${session}`,
inputBody: 'Hermes is waiting for your response.',
turnDoneTitle: 'Hermes finished',
- turnDoneBody: '',
+ turnDoneBody: 'Message complete.',
turnErrorTitle: 'Turn failed',
backgroundDoneTitle: 'Background task finished',
backgroundFailedTitle: 'Background task failed',
diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.ts
index 2c2c1c49f6b..2008ff86fc2 100644
--- a/apps/desktop/src/i18n/ja.ts
+++ b/apps/desktop/src/i18n/ja.ts
@@ -285,7 +285,7 @@ export const ja = defineLocale({
inputTitleNamed: session => `入力が必要です — ${session}`,
inputBody: 'Hermes が応答を待っています。',
turnDoneTitle: 'Hermes が完了しました',
- turnDoneBody: '',
+ turnDoneBody: 'メッセージが完了しました。',
turnErrorTitle: 'ターンが失敗しました',
backgroundDoneTitle: 'バックグラウンドタスクが完了しました',
backgroundFailedTitle: 'バックグラウンドタスクが失敗しました',
diff --git a/apps/desktop/src/i18n/zh-hant_diagnostics.ts b/apps/desktop/src/i18n/zh-hant_diagnostics.ts
index 298b8f83a6b..ac186d836e1 100644
--- a/apps/desktop/src/i18n/zh-hant_diagnostics.ts
+++ b/apps/desktop/src/i18n/zh-hant_diagnostics.ts
@@ -75,7 +75,7 @@ export const zhHantDiagnostics = {
inputTitleNamed: session => `需要輸入 — ${session}`,
inputBody: 'Hermes 正在等待你的回應。',
turnDoneTitle: 'Hermes 已完成',
- turnDoneBody: '',
+ turnDoneBody: '訊息已完成。',
turnErrorTitle: '本輪失敗',
backgroundDoneTitle: '背景工作已完成',
backgroundFailedTitle: '背景工作失敗',
diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.ts
index 411f6113d05..af539a1e981 100644
--- a/apps/desktop/src/i18n/zh.ts
+++ b/apps/desktop/src/i18n/zh.ts
@@ -313,7 +313,7 @@ export const zh = defineLocale({
inputTitleNamed: session => `需要输入 — ${session}`,
inputBody: 'Hermes 正在等待你的回应。',
turnDoneTitle: 'Hermes 已完成',
- turnDoneBody: '',
+ turnDoneBody: '消息已完成。',
turnErrorTitle: '本轮失败',
backgroundDoneTitle: '后台任务已完成',
backgroundFailedTitle: '后台任务失败',
diff --git a/apps/desktop/src/lib/turn-done-notification-body.test.ts b/apps/desktop/src/lib/turn-done-notification-body.test.ts
new file mode 100644
index 00000000000..135505e8660
--- /dev/null
+++ b/apps/desktop/src/lib/turn-done-notification-body.test.ts
@@ -0,0 +1,44 @@
+import { describe, expect, it } from 'vitest'
+
+import {
+ TURN_DONE_BODY_FALLBACK,
+ TURN_DONE_BODY_MAX,
+ turnDoneNotificationBody
+} from './turn-done-notification-body'
+
+// Mirrors the minified Studio helper from #88488:
+// Xn(n?.content || e.title || "Message complete.", 140)
+function legacyStudioBody(sessionTitle: string, assistantContent?: string): string {
+ const raw = assistantContent || sessionTitle || TURN_DONE_BODY_FALLBACK
+ return raw.length <= TURN_DONE_BODY_MAX ? raw : raw.slice(0, TURN_DONE_BODY_MAX)
+}
+
+describe('turnDoneNotificationBody', () => {
+ it('uses the assistant reply when present', () => {
+ expect(turnDoneNotificationBody('The build is green.')).toBe('The build is green.')
+ })
+
+ it('truncates long replies to 140 characters', () => {
+ const reply = 'a'.repeat(200)
+ expect(turnDoneNotificationBody(reply)).toBe('a'.repeat(TURN_DONE_BODY_MAX))
+ expect(turnDoneNotificationBody(reply).length).toBe(TURN_DONE_BODY_MAX)
+ })
+
+ it('falls back to a generic phrase when content is missing, not the session title (#88488)', () => {
+ const sessionTitle = "what's the weather in Seoul?"
+
+ expect(legacyStudioBody(sessionTitle, undefined)).toBe(sessionTitle)
+ expect(legacyStudioBody(sessionTitle, '')).toBe(sessionTitle)
+
+ expect(turnDoneNotificationBody(undefined)).toBe(TURN_DONE_BODY_FALLBACK)
+ expect(turnDoneNotificationBody('')).toBe(TURN_DONE_BODY_FALLBACK)
+ expect(turnDoneNotificationBody(' ')).toBe(TURN_DONE_BODY_FALLBACK)
+ expect(turnDoneNotificationBody(undefined, TURN_DONE_BODY_FALLBACK)).toBe(TURN_DONE_BODY_FALLBACK)
+ expect(turnDoneNotificationBody('', TURN_DONE_BODY_FALLBACK)).not.toBe(sessionTitle)
+ })
+
+ it('ignores a blank i18n fallback and still avoids an empty body', () => {
+ expect(turnDoneNotificationBody('', '')).toBe(TURN_DONE_BODY_FALLBACK)
+ expect(turnDoneNotificationBody(null, ' ')).toBe(TURN_DONE_BODY_FALLBACK)
+ })
+})
diff --git a/apps/desktop/src/lib/turn-done-notification-body.ts b/apps/desktop/src/lib/turn-done-notification-body.ts
new file mode 100644
index 00000000000..d9301a07c93
--- /dev/null
+++ b/apps/desktop/src/lib/turn-done-notification-body.ts
@@ -0,0 +1,18 @@
+// Native turn-done notification body (#88488).
+// Prefer the assistant reply. If that text is missing, use a generic
+// completion phrase — never the session title (usually the user's first
+// message). The minified Studio builder was `content || session.title ||
+// "Message complete."`; title in that chain made the OS toast repeat the
+// question instead of the answer.
+
+export const TURN_DONE_BODY_MAX = 140
+export const TURN_DONE_BODY_FALLBACK = 'Message complete.'
+
+export function turnDoneNotificationBody(
+ content: string | null | undefined,
+ fallback: string = TURN_DONE_BODY_FALLBACK
+): string {
+ const reply = (content ?? '').trim()
+ const source = reply || fallback.trim() || TURN_DONE_BODY_FALLBACK
+ return source.length <= TURN_DONE_BODY_MAX ? source : source.slice(0, TURN_DONE_BODY_MAX)
+}