diff --git a/.changeset/34827-ai-drawer-title.md b/.changeset/34827-ai-drawer-title.md new file mode 100644 index 00000000000..d8bdd6751d1 --- /dev/null +++ b/.changeset/34827-ai-drawer-title.md @@ -0,0 +1,11 @@ +--- +'@object-ui/i18n': patch +'@object-ui/app-shell': patch +--- + +fix(i18n): the AI drawer is titled with the top-bar button's name in every language + +Clause-②: no +Metadata-protocol: none + +The top-bar button that opens the AI drawer is named "AI Assistant" (zh-Hans 「AI 助手」), but the drawer's title, in the side panel, in the window-filling form and on the phone sheet, read only "Assistant" (「助手」). `console.ai.dock.title` now carries the same value as `topbar.aiAssistant` in all eleven built-in packs, so the button and the panel it opens use one name. The drawer's inline English fallback for that key reads "AI Assistant" too. diff --git a/ui/packages/app-shell/src/layout/ChatDock.tsx b/ui/packages/app-shell/src/layout/ChatDock.tsx index 667b99f2180..02756454abf 100644 --- a/ui/packages/app-shell/src/layout/ChatDock.tsx +++ b/ui/packages/app-shell/src/layout/ChatDock.tsx @@ -326,7 +326,7 @@ export function ChatDockPanel({
- {title ?? t('console.ai.dock.title', { defaultValue: 'Assistant' })} + {title ?? t('console.ai.dock.title', { defaultValue: 'AI Assistant' })} {/* ADR-0057 #8 — proactive AI usage indicator (hides itself when the @@ -470,7 +470,7 @@ export function ChatDockMobileSheet({
- {title ?? t('console.ai.dock.title', { defaultValue: 'Assistant' })} + {title ?? t('console.ai.dock.title', { defaultValue: 'AI Assistant' })} {/* ADR-0057 #8 — usage indicator, mirrored on the mobile sheet header. */} diff --git a/ui/packages/app-shell/src/layout/__tests__/ChatDock.titleMatchesTopBar-34827.test.tsx b/ui/packages/app-shell/src/layout/__tests__/ChatDock.titleMatchesTopBar-34827.test.tsx new file mode 100644 index 00000000000..2f940da39c5 --- /dev/null +++ b/ui/packages/app-shell/src/layout/__tests__/ChatDock.titleMatchesTopBar-34827.test.tsx @@ -0,0 +1,120 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * objectstack#34827 — the AI drawer is titled with the top-bar button's own + * name, in the rail, in the window-filling form and on the phone sheet, in + * every language. + * + * ## Real subjects + * + * The real `AssistantTopBarButton`, `ChatDockPanel` and `ChatDockMobileSheet` + * under the real `I18nProvider` and the real locale packs. The other ChatDock + * harnesses mock `useObjectTranslation` with the inline defaults, so they + * cannot see a pack value; that is why this pin is its own file. The body is + * overridden through `children`: the title is the subject, not the chat. + * + * ## Control + * + * Each rendered case also reads one neighbouring dock string from the same + * pack (the resize handle's name), so a run where the requested pack never + * loaded, and both surfaces fell back to their English defaults, is told + * apart from a pass. + */ + +import '@testing-library/jest-dom/vitest'; +import { describe, it, expect, vi, afterEach, beforeEach } from 'vitest'; +import React from 'react'; +import { render, screen, cleanup, within } from '@testing-library/react'; +import { MemoryRouter } from 'react-router-dom'; +import { I18nProvider, BUILT_IN_LANGUAGE_CODES, loadBuiltInLocale } from '@object-ui/i18n'; +import { AssistantTopBarButton } from '../AssistantTopBarButton'; +import { ChatDockPanel, ChatDockMobileSheet, type ChatDockState } from '../ChatDock'; + +// The default body drags in the whole chat graph; every case overrides it. +vi.mock('../../console/ai/AiChatPage', () => ({ + ChatPane: () => null, + resolveApiBase: (explicit?: string) => explicit ?? '/api/v1/ai', +})); +vi.mock('../ChatDockConversation', () => ({ ChatDockConversation: () => null })); +vi.mock('../AiUsageIndicator', () => ({ AiUsageIndicator: () => null })); + +function dockState(overrides: Partial = {}): ChatDockState { + return { + expanded: true, + width: 420, + dragging: false, + fullWindow: false, + setFullWindow: vi.fn(), + toggle: vi.fn(), + expand: vi.fn(), + collapse: vi.fn(), + onResizePointerDown: vi.fn(), + ...overrides, + }; +} + +function inLanguage(lang: string, node: React.ReactNode) { + return render( + + {node} + , + ); +} + +const at = (pack: unknown, path: string): unknown => + path.split('.').reduce((n, k) => (n as Record | undefined)?.[k], pack); + +beforeEach(() => window.localStorage.clear()); +afterEach(() => cleanup()); + +describe('the AI drawer is titled with the top-bar button name (objectstack#34827)', () => { + it.each([ + ['zh', 'AI 助手', '调整对话宽度'], + ['en', 'AI Assistant', 'Resize chat'], + ])('%s: the rail and the full window read the button name', async (lang, name, resizeControl) => { + inLanguage(lang, ( + <> + + +
+ + + )); + const button = await screen.findByTestId('topbar-ai-assistant'); + expect(button).toHaveAccessibleName(name); + // Control: the neighbouring dock string comes from the same pack. + expect(screen.getByRole('separator')).toHaveAccessibleName(resizeControl); + const rail = screen.getByTestId('chat-dock-panel'); + expect(within(rail).getByText(name)).toBeInTheDocument(); + + cleanup(); + inLanguage(lang, ( + +
+ + )); + const full = await screen.findByTestId('chat-dock-panel'); + expect(full).toHaveAttribute('data-full-window', 'true'); + expect(within(full).getByText(name)).toBeInTheDocument(); + }); + + it('zh: the phone sheet title reads the button name too', async () => { + inLanguage('zh', ( + {}}> +
+ + )); + const sheet = await screen.findByTestId('chat-dock-mobile-sheet'); + expect(within(sheet).getByRole('heading', { name: 'AI 助手' })).toBeInTheDocument(); + }); + + it('every built-in pack titles the drawer with its own top-bar button name', async () => { + expect(BUILT_IN_LANGUAGE_CODES.length).toBeGreaterThan(1); + for (const lang of BUILT_IN_LANGUAGE_CODES) { + const pack = await loadBuiltInLocale(lang); + const button = at(pack, 'topbar.aiAssistant'); + expect(typeof button, `${lang} topbar.aiAssistant`).toBe('string'); + expect(at(pack, 'console.ai.dock.title'), lang).toBe(button); + } + }); +}); diff --git a/ui/packages/i18n/src/__tests__/console-namespace-3546.test.tsx b/ui/packages/i18n/src/__tests__/console-namespace-3546.test.tsx index bfe75ebec10..7fbd19a5df3 100644 --- a/ui/packages/i18n/src/__tests__/console-namespace-3546.test.tsx +++ b/ui/packages/i18n/src/__tests__/console-namespace-3546.test.tsx @@ -151,17 +151,15 @@ const LANGS = Object.keys(builtInLocales) as LocaleCode[]; /** * `lang :: key` pairs whose value is legitimately byte-identical to `en`. * - * Exactly one, and for one reason: `Assistant` is spelled identically in French. - * It is a true cognate, not an untranslated string — the same class slice two - * pinned with 12 pairs and slice three with 18. Every other French value in this - * slice differs from `en`, including the two that merely CONTAIN the word - * (`dock.description`, `shortcuts.groups.aiChat`), which is what proves the - * exemption is about this one word and not about the French pack being lazy. + * None. The one this slice used to carry, French `dock.title` = `Assistant`, left + * when the drawer title took the top-bar button's name in every pack + * (objectstack#34827): French now reads `Assistant IA` against English + * `AI Assistant`. * - * Set equality, not a subset: a second identical value fails, and localising - * this one fails too and forces the line out. + * Set equality, not a subset: a first identical value fails, and must be + * justified here the way the other slices justify their cognates. */ -const UNTRANSLATED_COGNATES = ['fr :: console.ai.dock.title']; +const UNTRANSLATED_COGNATES: string[] = []; const at = (pack: unknown, path: string): unknown => path.split('.').reduce((n, k) => (n as Record | undefined)?.[k], pack); @@ -228,19 +226,14 @@ describe('objectui#3546 slice four — the console namespace', () => { } } expect(identical.sort()).toEqual(UNTRANSLATED_COGNATES); - // 1 permitted pair out of 414 — i.e. every key is translated in every pack - // except the French cognate. The set equality above is vacuous if the packs - // were empty, so pin the facts it rests on separately: the exempt value - // really is the cognate, and the two French neighbours that embed the same - // word really are NOT identical to en. - expect(UNTRANSLATED_COGNATES).toHaveLength(1); - expect(at(builtInLocales.fr, 'console.ai.dock.title')).toBe('Assistant'); - expect(at(builtInLocales.fr, 'console.ai.dock.description')).not.toBe( - at(builtInLocales.en, 'console.ai.dock.description'), - ); - expect(at(builtInLocales.fr, 'console.shortcuts.groups.aiChat')).not.toBe( - at(builtInLocales.en, 'console.shortcuts.groups.aiChat'), - ); + // Every key is translated in every pack. The empty set above is vacuous if + // the packs were empty, so pin the facts it rests on separately: the French + // values that embed the word `Assistant` really are NOT identical to en. + expect(UNTRANSLATED_COGNATES).toHaveLength(0); + for (const key of ['console.ai.dock.title', 'console.ai.dock.description', 'console.shortcuts.groups.aiChat']) { + expect(at(builtInLocales.fr, key), key).toMatch(/assistant/i); + expect(at(builtInLocales.fr, key), key).not.toBe(at(builtInLocales.en, key)); + } }); it('no key in this slice interpolates — so no pack may invent a placeholder', () => { diff --git a/ui/packages/i18n/src/__tests__/marketplace-preview-namespace-3546.test.tsx b/ui/packages/i18n/src/__tests__/marketplace-preview-namespace-3546.test.tsx index 0ac5c9dcf1e..99558eef081 100644 --- a/ui/packages/i18n/src/__tests__/marketplace-preview-namespace-3546.test.tsx +++ b/ui/packages/i18n/src/__tests__/marketplace-preview-namespace-3546.test.tsx @@ -235,7 +235,7 @@ describe('objectui#3546 slice five — the marketplace and preview namespaces', // sets and placeholder shape, and never looks at what a value SAYS. // // Set equality against the EMPTY set, not a subset: unlike slice two (12 - // pairs), three (18) and four (1 — French "Assistant"), this slice has no + // pairs), three (18) and four (none left), this slice has no // legitimate cognate at all. 0 of 360 pairs is identical to `en`. A first // identical pair fails here and must be justified on the line below, the way // those slices justified theirs. diff --git a/ui/packages/i18n/src/locales/ar.ts b/ui/packages/i18n/src/locales/ar.ts index b8e2d76ac5a..5c08e171321 100644 --- a/ui/packages/i18n/src/locales/ar.ts +++ b/ui/packages/i18n/src/locales/ar.ts @@ -2477,7 +2477,7 @@ const ar = { unavailableRetry: "إعادة المحاولة", unavailableHome: "العودة إلى الرئيسية", dock: { - title: "المساعد", + title: "مساعد الذكاء الاصطناعي", description: "محادثة مساعد الذكاء الاصطناعي", resize: "تغيير حجم المحادثة", collapse: "طي المحادثة", diff --git a/ui/packages/i18n/src/locales/de.ts b/ui/packages/i18n/src/locales/de.ts index 19e4ef1d927..aba3847d201 100644 --- a/ui/packages/i18n/src/locales/de.ts +++ b/ui/packages/i18n/src/locales/de.ts @@ -2222,7 +2222,7 @@ const de = { unavailableRetry: "Erneut versuchen", unavailableHome: "Zurück zur Startseite", dock: { - title: "Assistent", + title: "KI-Assistent", description: "KI-Assistent-Chat", resize: "Chatbreite anpassen", collapse: "Chat einklappen", diff --git a/ui/packages/i18n/src/locales/en.ts b/ui/packages/i18n/src/locales/en.ts index 05dc3eac472..774bfb5e4bd 100644 --- a/ui/packages/i18n/src/locales/en.ts +++ b/ui/packages/i18n/src/locales/en.ts @@ -2991,7 +2991,7 @@ const en = { unavailableRetry: 'Try again', unavailableHome: 'Back to home', dock: { - title: 'Assistant', + title: 'AI Assistant', description: 'AI assistant chat', resize: 'Resize chat', collapse: 'Collapse chat', diff --git a/ui/packages/i18n/src/locales/es.ts b/ui/packages/i18n/src/locales/es.ts index 18596c01fb4..80c037e943e 100644 --- a/ui/packages/i18n/src/locales/es.ts +++ b/ui/packages/i18n/src/locales/es.ts @@ -2288,7 +2288,7 @@ const es = { unavailableRetry: "Reintentar", unavailableHome: "Volver al inicio", dock: { - title: "Asistente", + title: "Asistente de IA", description: "Chat con el asistente de IA", resize: "Redimensionar el chat", collapse: "Contraer el chat", diff --git a/ui/packages/i18n/src/locales/fr.ts b/ui/packages/i18n/src/locales/fr.ts index 008363ecffa..7bf1f54e747 100644 --- a/ui/packages/i18n/src/locales/fr.ts +++ b/ui/packages/i18n/src/locales/fr.ts @@ -2284,7 +2284,7 @@ const fr = { unavailableRetry: "Réessayer", unavailableHome: "Retour à l'accueil", dock: { - title: "Assistant", + title: "Assistant IA", description: "Discussion avec l'assistant IA", resize: "Redimensionner la discussion", collapse: "Réduire la discussion", diff --git a/ui/packages/i18n/src/locales/ja.ts b/ui/packages/i18n/src/locales/ja.ts index 42ea9c925b3..38190f82c34 100644 --- a/ui/packages/i18n/src/locales/ja.ts +++ b/ui/packages/i18n/src/locales/ja.ts @@ -2224,7 +2224,7 @@ const ja = { unavailableRetry: "再試行", unavailableHome: "ホームに戻る", dock: { - title: "アシスタント", + title: "AI アシスタント", description: "AI アシスタントのチャット", resize: "チャットのサイズを変更", collapse: "チャットを折りたたむ", diff --git a/ui/packages/i18n/src/locales/ko.ts b/ui/packages/i18n/src/locales/ko.ts index 6bb204167d0..c36c4d94f7f 100644 --- a/ui/packages/i18n/src/locales/ko.ts +++ b/ui/packages/i18n/src/locales/ko.ts @@ -2222,7 +2222,7 @@ const ko = { unavailableRetry: "다시 시도", unavailableHome: "홈으로 돌아가기", dock: { - title: "어시스턴트", + title: "AI 어시스턴트", description: "AI 어시스턴트 채팅", resize: "채팅 크기 조정", collapse: "채팅 접기", diff --git a/ui/packages/i18n/src/locales/pt-BR.ts b/ui/packages/i18n/src/locales/pt-BR.ts index b4a7a70058a..82eedfc3d9b 100644 --- a/ui/packages/i18n/src/locales/pt-BR.ts +++ b/ui/packages/i18n/src/locales/pt-BR.ts @@ -2283,7 +2283,7 @@ const pt = { unavailableRetry: "Tentar novamente", unavailableHome: "Voltar ao início", dock: { - title: "Assistente", + title: "Assistente de IA", description: "Conversa com o assistente de IA", resize: "Redimensionar a conversa", collapse: "Recolher a conversa", diff --git a/ui/packages/i18n/src/locales/ru.ts b/ui/packages/i18n/src/locales/ru.ts index ff3b4d5b044..936b2affc74 100644 --- a/ui/packages/i18n/src/locales/ru.ts +++ b/ui/packages/i18n/src/locales/ru.ts @@ -2356,7 +2356,7 @@ const ru = { unavailableRetry: "Повторить", unavailableHome: "На главную", dock: { - title: "Ассистент", + title: "ИИ-ассистент", description: "Чат с ассистентом ИИ", resize: "Изменить размер чата", collapse: "Свернуть чат", diff --git a/ui/packages/i18n/src/locales/zh-Hans.ts b/ui/packages/i18n/src/locales/zh-Hans.ts index 094504a6ffb..c7dc8bfa4e8 100644 --- a/ui/packages/i18n/src/locales/zh-Hans.ts +++ b/ui/packages/i18n/src/locales/zh-Hans.ts @@ -2506,7 +2506,7 @@ const zh = { unavailableRetry: '重试', unavailableHome: '返回首页', dock: { - title: '助手', + title: 'AI 助手', description: 'AI 助手对话', resize: '调整对话宽度', collapse: '收起对话', diff --git a/ui/packages/i18n/src/locales/zh-Hant.ts b/ui/packages/i18n/src/locales/zh-Hant.ts index 993f6f4677a..6c6e0ed9ac3 100644 --- a/ui/packages/i18n/src/locales/zh-Hant.ts +++ b/ui/packages/i18n/src/locales/zh-Hant.ts @@ -2506,7 +2506,7 @@ const zhHant = { unavailableRetry: '重試', unavailableHome: '返回首頁', dock: { - title: '助手', + title: 'AI 助手', description: 'AI 助手對話', resize: '調整對話寬度', collapse: '收起對話',