The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(desktop): pin the localized notification fallback; reword Studio comment
Brooklyn Nicholson3bf1032ffa20
diff --git a/apps/desktop/src/lib/turn-done-notification-body.test.ts b/apps/desktop/src/lib/turn-done-notification-body.test.tsindex 50ed6d7f7af..354b741974c 100644--- a/apps/desktop/src/lib/turn-done-notification-body.test.ts+++ b/apps/desktop/src/lib/turn-done-notification-body.test.ts@@ -6,8 +6,11 @@ import {turnDoneNotificationBody} from './turn-done-notification-body'-// Mirrors the minified Studio helper from #88488:+// Mirrors the minified 0.20.0 Studio bundle helper quoted in #88488:// Xn(n?.content || e.title || "Message complete.", 140)+// That chain lived in the released dist/client bundle, not this repo's+// source; this app's own chain never read the title (see the helper's+// comment). Kept as the "never again" guard below.function legacyStudioBody(sessionTitle: string, assistantContent?: string): string {const raw = assistantContent || sessionTitle || TURN_DONE_BODY_FALLBACK@@ -38,6 +41,32 @@ describe('turnDoneNotificationBody', () => {expect(turnDoneNotificationBody('', TURN_DONE_BODY_FALLBACK)).not.toBe(sessionTitle)})+ // The localized fallback is the only channel the i18n copy reaches the result+ // through; every earlier fallback assertion passed TURN_DONE_BODY_FALLBACK itself,+ // so deleting the whole fallback parameter kept the suite green (review follow-up).+ // These pin the real per-locale values from the i18n files so a broken fallback+ // path or an emptied locale string flips a test.+ it('uses the caller-supplied localized fallback, not the hardcoded English one', () => {+ expect(turnDoneNotificationBody('', '消息已完成。')).toBe('消息已完成。')+ expect(turnDoneNotificationBody(null, '訊息已完成。')).toBe('訊息已完成。')+ expect(turnDoneNotificationBody(' ', 'メッセージが完了しました。')).toBe('メッセージが完了しました。')+ expect(turnDoneNotificationBody(undefined, 'اكتملت الرسالة.')).toBe('اكتملت الرسالة.')+ })++ it('never falls back to the session title', () => {+ const sessionTitle = "what's the weather in Seoul?"++ // The helper takes its fallback from the caller; the only production call site+ // (use-message-stream/index.ts) passes translateNow('...turnDoneBody'), never the+ // title. With no fallback supplied the hardcoded phrase wins over the title.+ expect(turnDoneNotificationBody(undefined)).not.toBe(sessionTitle)+ expect(turnDoneNotificationBody('', TURN_DONE_BODY_FALLBACK)).not.toBe(sessionTitle)+ })++ it('truncates a localized fallback to the same 140-character cap', () => {+ expect(turnDoneNotificationBody(undefined, '完'.repeat(200)).length).toBe(TURN_DONE_BODY_MAX)+ })+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.tsindex 47b55e9625a..a525f413a1f 100644--- a/apps/desktop/src/lib/turn-done-notification-body.ts+++ b/apps/desktop/src/lib/turn-done-notification-body.ts@@ -1,9 +1,12 @@// 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.+// message). The title-in-the-chain behavior was reported from the 0.20.0+// Studio bundle (`dist/client/assets/js/chat-*.js`), which the issue quotes+// from minified release output; this app's own chain never read the title —+// it was `text.slice(0, 140) || i18n fallback`, whose only real defect was+// the empty body when the reply was missing and the fallback shipped blank.+// The title guard test below keeps the title from ever re-entering the chain.export const TURN_DONE_BODY_MAX = 140export const TURN_DONE_BODY_FALLBACK = 'Message complete.'