Skip to content

Commit cb7d514

Browse files
fix(i18n): title the AI drawer with the top-bar button's name in every locale (#34930)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBNgJrQDxaUNx2so1ektgf6A)_ repo:objectstack#3 · os-support-ai · session_01WGufzfrh8TiPJf1i2kMSoa Fixes #34827 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:AI 助手抽屉的标题(侧边抽屉、铺满后、手机底部面板三处)现在和顶栏按钮同名,zh-Hans/zh-Hant 是「AI 助手」,en 是 "AI Assistant",其余 8 种语言也都用各自顶栏按钮那个词。 - 为什么改:验收时看到顶栏按钮叫「AI 助手」,点开后抽屉标题只写「助手」,同一个东西两个名字。 - 风险与回滚:只改了 11 个语言包里 `console.ai.dock.title` 的值,外加抽屉组件里同一个键的英文兜底文字;不动布局和行为。回滚即 revert 本 PR。 - 先看:`ui/packages/i18n/src/locales/zh-Hans.ts` 与 `en.ts` 的 `dock.title` 一行;`ui/packages/app-shell/src/layout/ChatDock.tsx` 两处 `defaultValue`;新测试 `ChatDock.titleMatchesTopBar-34827.test.tsx`。 - 两分钟验证:`pnpm --dir ui exec vitest run packages/app-shell/src/layout/__tests__/ChatDock.titleMatchesTopBar-34827.test.tsx`,预期 4 个用例全过;或在中文界面点顶栏机器人,抽屉标题与按钮提示同为「AI 助手」。 - 需要你做的:无,席位落地。 ## What changes - `console.ai.dock.title` now carries the same value as `topbar.aiAssistant` (the key the top-bar robot reads for its `aria-label` and `title`) in all eleven built-in packs: | pack | before | after | |:--|:--|:--| | en | Assistant | AI Assistant | | zh-Hans / zh-Hant | 助手 | AI 助手 | | ja | アシスタント | AI アシスタント | | ko | 어시스턴트 | AI 어시스턴트 | | de | Assistent | KI-Assistent | | fr | Assistant | Assistant IA | | es / pt-BR | Asistente / Assistente | Asistente de IA / Assistente de IA | | ru | Ассистент | ИИ-ассистент | | ar | المساعد | مساعد الذكاء الاصطناعي | - That one key is the title of all three drawer forms: the side rail and the window-filling form (`ChatDockPanel`, the same header in both) and the phone sheet (`ChatDockMobileSheet`). Nothing passes a `title` prop to either in the Console (`useConsoleChatDock` mounts both without one), and the Studio panel no longer mounts `ChatDockPanel`, so the value change reaches exactly the drawer. - `ChatDock.tsx`: the two inline `defaultValue`s for that key change from `'Assistant'` to `'AI Assistant'`. This is not optional: `check-i18n-call-site-keys` requires every literal inline default to equal the en value, and its test (`scripts/__tests__/check-i18n-call-site-keys.test.ts`, "main carries no drift") went red on the value change alone. No layout or behaviour change. - The dispatch named the en button as `aiChat: 'AI assistant'`. That key is `console.shortcuts.groups.aiChat`, the keyboard-shortcuts dialog's group heading. The robot reads `topbar.aiAssistant` (`AssistantTopBarButton`), whose en value is `AI Assistant`, so that is the value matched. - `console-namespace-3546.test.tsx` carried French `dock.title` = `Assistant` as its one permitted en-identical cognate; French now reads `Assistant IA`, so the exemption set is empty and the test now pins that the three French values containing the word differ from en. One comment in `marketplace-preview-namespace-3546.test.tsx` that counted that cognate is corrected. ### Item 2: other self-names in the same panel Checked against the keys the drawer actually renders (`ChatDock.tsx`, `ChatDockConversation.tsx` and what it mounts: `ChatPane` from `AiChatPage.tsx`, `ConversationsSidebar.tsx`): | key | zh-Hans / en | verdict | |:--|:--|:--| | `console.ai.dock.description` (phone sheet, screen-reader only) | AI 助手对话 / AI assistant chat | already uses the full name; unchanged | | `ConversationsSidebar` (history list): `chats`, `noChatsYet`, `noChatsDescription`, `searchChats`, `newChat` | 对话 / Chats, … | no self-name; unchanged | | `console.ai.empty.build.*`, `console.ai.empty.ask.*` (empty states) | 用 AI 搭建 / Build with AI, 向你的数据提问 / Ask your data | no self-name; unchanged | | `console.ai.unavailableTitle` / `unavailableDescription` | AI 助手不可用 / AI assistant unavailable | already the full name; unchanged | | `console.ai.switchAssistant`, `chooseAgent`, `loadingAgents`, `offlineDemoMode` | 切换助手, 选择助手…, … | 助手 here means an agent in the picker, not the panel's name; unchanged | | `console.ai.assistant` | 助手 / Assistant | the agent-label fallback in `ChatPane` when no agent is found. `ChatPane` is shared with the Studio panel (`StudioAiCopilot`), so changing it would rename text there too (#34725's scope); unchanged | | `console.ai.emptyDescription` | 可以直接提问,助手会结合… / Ask anything — the assistant has access… | generic empty state in the same shared `ChatPane`; same reason; unchanged | | `console.ai.dock.open` | 打开助手 / Open assistant | read only by `ChatDockLauncher`, which no Console path mounts (only its own test renders it); unchanged | ## Tests - New `ui/packages/app-shell/src/layout/__tests__/ChatDock.titleMatchesTopBar-34827.test.tsx` (its own file because the existing ChatDock harnesses mock `useObjectTranslation` with the inline defaults and cannot see a pack value). Real `AssistantTopBarButton`, `ChatDockPanel`, `ChatDockMobileSheet`, real `I18nProvider` and packs: - zh and en: the rail and the full window show the button's accessible name; **control**: the resize handle's name from the same pack (`调整对话宽度` / `Resize chat`), so a pack that never loaded is not read as a pass; - zh: the phone sheet heading; - every built-in pack: `console.ai.dock.title === topbar.aiAssistant`. - Ablation (one-shot, not kept): `scripts/ablation-replace.mjs` put zh-Hans `dock.title` back to `'助手'` (the mutated blob `77e56f98` equals the zh-Hans blob on `origin/main`), and the pin went red on the three zh cases with the en case green (`Tests 3 failed | 1 passed (4)`); restore verified by blob hash against HEAD and an empty `git diff HEAD`. ## Verification All readings below are on head `b34dabff8` (the branch with `origin/main` `fc5913e1` merged in), on a shared container. <details><summary>Pin, package tests and type-check (through the shared verification lock)</summary> - `pnpm --dir ui exec vitest run packages/i18n/ packages/app-shell/src/layout/`: `Test Files 243 passed (243)`, `Tests 2890 passed | 13 skipped (2903)`; the new pin is in that set. - `pnpm --dir ui exec vitest run scripts/__tests__/check-i18n-call-site-keys.test.ts`: `Tests 152 passed (152)` (this file was red, 3 failures, before the `defaultValue` alignment). - `pnpm --filter @object-ui/i18n run type-check` exit 0; `pnpm --filter @object-ui/app-shell run type-check` exit 0. - ESLint on the three changed test files and `en.ts`, from the ui root and from each package dir: exit 0, no output. - The full app-shell suite is left to CI's `Test UI`: the diff changes one string literal in app-shell, and no app-shell test outside `layout/` reads that key. </details> <details><summary>Eager budget (merged tree)</summary> `pnpm --dir ui/apps/console exec vite build`, then `pnpm --dir ui run check:eager-closure` exit 0: `i18n-locale-en 60.4 KB / 60.5 KB ceiling (headroom 0.2 KB)`; the report gives the chunk as `gzipBytes: 61818` against the `62_000` ceiling, so 182 bytes are left. The ceiling is not touched. </details> <details><summary>Derived gate families</summary> `node scripts/pm/dispatch-gates.mjs --commands` derived 40 commands. 39 were re-run on `b34dabff8`, each `:: exit 0`. The 40th, `pnpm --dir ui exec vitest run scripts/`, was run on `6069d44b` (before the `defaultValue` fix): `Test Files 1 failed | 170 passed | 2 skipped (173)`, and the one failing file is the call-site-keys test, now green as shown above. `--ran` reconciliation: `40 derived, 40 run, 0 NOT-MEASURED, 0 UNRUN`. Also run: `check-i18n-call-site-keys.mjs`, `check-i18n-en-drift.mjs` (`Every changed en value was followed by all 10 translation packs.`), `check-i18n-dead-keys.mjs`, `check:new-line-citations` (`0 new citation(s)`), each exit 0. `overlap-check`: `VERDICT clean exit 0` before the first content push and on the merge head `b34dabff8` (that run came right after its push, not before). </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01WGufzfrh8TiPJf1i2kMSoa)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WGufzfrh8TiPJf1i2kMSoa <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufzfrh8TiPJf1i2kMSoa --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 97cd541 commit cb7d514

16 files changed

Lines changed: 160 additions & 36 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@object-ui/i18n': patch
3+
'@object-ui/app-shell': patch
4+
---
5+
6+
fix(i18n): the AI drawer is titled with the top-bar button's name in every language
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
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.

‎ui/packages/app-shell/src/layout/ChatDock.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ export function ChatDockPanel({
326326
<div className="flex h-11 shrink-0 items-center justify-between border-b px-3">
327327
<span className="inline-flex items-center gap-1.5 text-xs font-semibold text-foreground/80">
328328
<MessagesSquare className="size-3.5" />
329-
{title ?? t('console.ai.dock.title', { defaultValue: 'Assistant' })}
329+
{title ?? t('console.ai.dock.title', { defaultValue: 'AI Assistant' })}
330330
</span>
331331
<span className="flex items-center gap-0.5">
332332
{/* ADR-0057 #8 — proactive AI usage indicator (hides itself when the
@@ -470,7 +470,7 @@ export function ChatDockMobileSheet({
470470
<div className="flex items-center gap-1 pr-8">
471471
<SheetTitle className="inline-flex items-center gap-1.5 text-sm font-semibold">
472472
<MessagesSquare className="size-4" />
473-
{title ?? t('console.ai.dock.title', { defaultValue: 'Assistant' })}
473+
{title ?? t('console.ai.dock.title', { defaultValue: 'AI Assistant' })}
474474
</SheetTitle>
475475
{/* ADR-0057 #8 — usage indicator, mirrored on the mobile sheet header. */}
476476
<AiUsageIndicator apiBase={apiBase} />
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* objectstack#34827 — the AI drawer is titled with the top-bar button's own
5+
* name, in the rail, in the window-filling form and on the phone sheet, in
6+
* every language.
7+
*
8+
* ## Real subjects
9+
*
10+
* The real `AssistantTopBarButton`, `ChatDockPanel` and `ChatDockMobileSheet`
11+
* under the real `I18nProvider` and the real locale packs. The other ChatDock
12+
* harnesses mock `useObjectTranslation` with the inline defaults, so they
13+
* cannot see a pack value; that is why this pin is its own file. The body is
14+
* overridden through `children`: the title is the subject, not the chat.
15+
*
16+
* ## Control
17+
*
18+
* Each rendered case also reads one neighbouring dock string from the same
19+
* pack (the resize handle's name), so a run where the requested pack never
20+
* loaded, and both surfaces fell back to their English defaults, is told
21+
* apart from a pass.
22+
*/
23+
24+
import '@testing-library/jest-dom/vitest';
25+
import { describe, it, expect, vi, afterEach, beforeEach } from 'vitest';
26+
import React from 'react';
27+
import { render, screen, cleanup, within } from '@testing-library/react';
28+
import { MemoryRouter } from 'react-router-dom';
29+
import { I18nProvider, BUILT_IN_LANGUAGE_CODES, loadBuiltInLocale } from '@object-ui/i18n';
30+
import { AssistantTopBarButton } from '../AssistantTopBarButton';
31+
import { ChatDockPanel, ChatDockMobileSheet, type ChatDockState } from '../ChatDock';
32+
33+
// The default body drags in the whole chat graph; every case overrides it.
34+
vi.mock('../../console/ai/AiChatPage', () => ({
35+
ChatPane: () => null,
36+
resolveApiBase: (explicit?: string) => explicit ?? '/api/v1/ai',
37+
}));
38+
vi.mock('../ChatDockConversation', () => ({ ChatDockConversation: () => null }));
39+
vi.mock('../AiUsageIndicator', () => ({ AiUsageIndicator: () => null }));
40+
41+
function dockState(overrides: Partial<ChatDockState> = {}): ChatDockState {
42+
return {
43+
expanded: true,
44+
width: 420,
45+
dragging: false,
46+
fullWindow: false,
47+
setFullWindow: vi.fn(),
48+
toggle: vi.fn(),
49+
expand: vi.fn(),
50+
collapse: vi.fn(),
51+
onResizePointerDown: vi.fn(),
52+
...overrides,
53+
};
54+
}
55+
56+
function inLanguage(lang: string, node: React.ReactNode) {
57+
return render(
58+
<I18nProvider config={{ defaultLanguage: lang, detectBrowserLanguage: false }} persistLanguage={false}>
59+
<MemoryRouter>{node}</MemoryRouter>
60+
</I18nProvider>,
61+
);
62+
}
63+
64+
const at = (pack: unknown, path: string): unknown =>
65+
path.split('.').reduce<unknown>((n, k) => (n as Record<string, unknown> | undefined)?.[k], pack);
66+
67+
beforeEach(() => window.localStorage.clear());
68+
afterEach(() => cleanup());
69+
70+
describe('the AI drawer is titled with the top-bar button name (objectstack#34827)', () => {
71+
it.each([
72+
['zh', 'AI 助手', '调整对话宽度'],
73+
['en', 'AI Assistant', 'Resize chat'],
74+
])('%s: the rail and the full window read the button name', async (lang, name, resizeControl) => {
75+
inLanguage(lang, (
76+
<>
77+
<AssistantTopBarButton />
78+
<ChatDockPanel dock={dockState()}>
79+
<div />
80+
</ChatDockPanel>
81+
</>
82+
));
83+
const button = await screen.findByTestId('topbar-ai-assistant');
84+
expect(button).toHaveAccessibleName(name);
85+
// Control: the neighbouring dock string comes from the same pack.
86+
expect(screen.getByRole('separator')).toHaveAccessibleName(resizeControl);
87+
const rail = screen.getByTestId('chat-dock-panel');
88+
expect(within(rail).getByText(name)).toBeInTheDocument();
89+
90+
cleanup();
91+
inLanguage(lang, (
92+
<ChatDockPanel dock={dockState({ fullWindow: true })}>
93+
<div />
94+
</ChatDockPanel>
95+
));
96+
const full = await screen.findByTestId('chat-dock-panel');
97+
expect(full).toHaveAttribute('data-full-window', 'true');
98+
expect(within(full).getByText(name)).toBeInTheDocument();
99+
});
100+
101+
it('zh: the phone sheet title reads the button name too', async () => {
102+
inLanguage('zh', (
103+
<ChatDockMobileSheet open onOpenChange={() => {}}>
104+
<div />
105+
</ChatDockMobileSheet>
106+
));
107+
const sheet = await screen.findByTestId('chat-dock-mobile-sheet');
108+
expect(within(sheet).getByRole('heading', { name: 'AI 助手' })).toBeInTheDocument();
109+
});
110+
111+
it('every built-in pack titles the drawer with its own top-bar button name', async () => {
112+
expect(BUILT_IN_LANGUAGE_CODES.length).toBeGreaterThan(1);
113+
for (const lang of BUILT_IN_LANGUAGE_CODES) {
114+
const pack = await loadBuiltInLocale(lang);
115+
const button = at(pack, 'topbar.aiAssistant');
116+
expect(typeof button, `${lang} topbar.aiAssistant`).toBe('string');
117+
expect(at(pack, 'console.ai.dock.title'), lang).toBe(button);
118+
}
119+
});
120+
});

‎ui/packages/i18n/src/__tests__/console-namespace-3546.test.tsx‎

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,15 @@ const LANGS = Object.keys(builtInLocales) as LocaleCode[];
151151
/**
152152
* `lang :: key` pairs whose value is legitimately byte-identical to `en`.
153153
*
154-
* Exactly one, and for one reason: `Assistant` is spelled identically in French.
155-
* It is a true cognate, not an untranslated string — the same class slice two
156-
* pinned with 12 pairs and slice three with 18. Every other French value in this
157-
* slice differs from `en`, including the two that merely CONTAIN the word
158-
* (`dock.description`, `shortcuts.groups.aiChat`), which is what proves the
159-
* exemption is about this one word and not about the French pack being lazy.
154+
* None. The one this slice used to carry, French `dock.title` = `Assistant`, left
155+
* when the drawer title took the top-bar button's name in every pack
156+
* (objectstack#34827): French now reads `Assistant IA` against English
157+
* `AI Assistant`.
160158
*
161-
* Set equality, not a subset: a second identical value fails, and localising
162-
* this one fails too and forces the line out.
159+
* Set equality, not a subset: a first identical value fails, and must be
160+
* justified here the way the other slices justify their cognates.
163161
*/
164-
const UNTRANSLATED_COGNATES = ['fr :: console.ai.dock.title'];
162+
const UNTRANSLATED_COGNATES: string[] = [];
165163

166164
const at = (pack: unknown, path: string): unknown =>
167165
path.split('.').reduce<unknown>((n, k) => (n as Record<string, unknown> | undefined)?.[k], pack);
@@ -228,19 +226,14 @@ describe('objectui#3546 slice four — the console namespace', () => {
228226
}
229227
}
230228
expect(identical.sort()).toEqual(UNTRANSLATED_COGNATES);
231-
// 1 permitted pair out of 414 — i.e. every key is translated in every pack
232-
// except the French cognate. The set equality above is vacuous if the packs
233-
// were empty, so pin the facts it rests on separately: the exempt value
234-
// really is the cognate, and the two French neighbours that embed the same
235-
// word really are NOT identical to en.
236-
expect(UNTRANSLATED_COGNATES).toHaveLength(1);
237-
expect(at(builtInLocales.fr, 'console.ai.dock.title')).toBe('Assistant');
238-
expect(at(builtInLocales.fr, 'console.ai.dock.description')).not.toBe(
239-
at(builtInLocales.en, 'console.ai.dock.description'),
240-
);
241-
expect(at(builtInLocales.fr, 'console.shortcuts.groups.aiChat')).not.toBe(
242-
at(builtInLocales.en, 'console.shortcuts.groups.aiChat'),
243-
);
229+
// Every key is translated in every pack. The empty set above is vacuous if
230+
// the packs were empty, so pin the facts it rests on separately: the French
231+
// values that embed the word `Assistant` really are NOT identical to en.
232+
expect(UNTRANSLATED_COGNATES).toHaveLength(0);
233+
for (const key of ['console.ai.dock.title', 'console.ai.dock.description', 'console.shortcuts.groups.aiChat']) {
234+
expect(at(builtInLocales.fr, key), key).toMatch(/assistant/i);
235+
expect(at(builtInLocales.fr, key), key).not.toBe(at(builtInLocales.en, key));
236+
}
244237
});
245238

246239
it('no key in this slice interpolates — so no pack may invent a placeholder', () => {

‎ui/packages/i18n/src/__tests__/marketplace-preview-namespace-3546.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ describe('objectui#3546 slice five — the marketplace and preview namespaces',
235235
// sets and placeholder shape, and never looks at what a value SAYS.
236236
//
237237
// Set equality against the EMPTY set, not a subset: unlike slice two (12
238-
// pairs), three (18) and four (1 — French "Assistant"), this slice has no
238+
// pairs), three (18) and four (none left), this slice has no
239239
// legitimate cognate at all. 0 of 360 pairs is identical to `en`. A first
240240
// identical pair fails here and must be justified on the line below, the way
241241
// those slices justified theirs.

‎ui/packages/i18n/src/locales/ar.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2479,7 +2479,7 @@ const ar = {
24792479
unavailableRetry: "إعادة المحاولة",
24802480
unavailableHome: "العودة إلى الرئيسية",
24812481
dock: {
2482-
title: "المساعد",
2482+
title: "مساعد الذكاء الاصطناعي",
24832483
description: "محادثة مساعد الذكاء الاصطناعي",
24842484
resize: "تغيير حجم المحادثة",
24852485
collapse: "طي المحادثة",

‎ui/packages/i18n/src/locales/de.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2224,7 +2224,7 @@ const de = {
22242224
unavailableRetry: "Erneut versuchen",
22252225
unavailableHome: "Zurück zur Startseite",
22262226
dock: {
2227-
title: "Assistent",
2227+
title: "KI-Assistent",
22282228
description: "KI-Assistent-Chat",
22292229
resize: "Chatbreite anpassen",
22302230
collapse: "Chat einklappen",

‎ui/packages/i18n/src/locales/en.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2993,7 +2993,7 @@ const en = {
29932993
unavailableRetry: 'Try again',
29942994
unavailableHome: 'Back to home',
29952995
dock: {
2996-
title: 'Assistant',
2996+
title: 'AI Assistant',
29972997
description: 'AI assistant chat',
29982998
resize: 'Resize chat',
29992999
collapse: 'Collapse chat',

‎ui/packages/i18n/src/locales/es.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2290,7 +2290,7 @@ const es = {
22902290
unavailableRetry: "Reintentar",
22912291
unavailableHome: "Volver al inicio",
22922292
dock: {
2293-
title: "Asistente",
2293+
title: "Asistente de IA",
22942294
description: "Chat con el asistente de IA",
22952295
resize: "Redimensionar el chat",
22962296
collapse: "Contraer el chat",

‎ui/packages/i18n/src/locales/fr.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2286,7 +2286,7 @@ const fr = {
22862286
unavailableRetry: "Réessayer",
22872287
unavailableHome: "Retour à l'accueil",
22882288
dock: {
2289-
title: "Assistant",
2289+
title: "Assistant IA",
22902290
description: "Discussion avec l'assistant IA",
22912291
resize: "Redimensionner la discussion",
22922292
collapse: "Réduire la discussion",

0 commit comments

Comments
 (0)