Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/34827-ai-drawer-title.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 2 additions & 2 deletions ui/packages/app-shell/src/layout/ChatDock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ export function ChatDockPanel({
<div className="flex h-11 shrink-0 items-center justify-between border-b px-3">
<span className="inline-flex items-center gap-1.5 text-xs font-semibold text-foreground/80">
<MessagesSquare className="size-3.5" />
{title ?? t('console.ai.dock.title', { defaultValue: 'Assistant' })}
{title ?? t('console.ai.dock.title', { defaultValue: 'AI Assistant' })}
</span>
<span className="flex items-center gap-0.5">
{/* ADR-0057 #8 — proactive AI usage indicator (hides itself when the
Expand Down Expand Up @@ -470,7 +470,7 @@ export function ChatDockMobileSheet({
<div className="flex items-center gap-1 pr-8">
<SheetTitle className="inline-flex items-center gap-1.5 text-sm font-semibold">
<MessagesSquare className="size-4" />
{title ?? t('console.ai.dock.title', { defaultValue: 'Assistant' })}
{title ?? t('console.ai.dock.title', { defaultValue: 'AI Assistant' })}
</SheetTitle>
{/* ADR-0057 #8 — usage indicator, mirrored on the mobile sheet header. */}
<AiUsageIndicator apiBase={apiBase} />
Expand Down
Original file line number Diff line number Diff line change
@@ -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> = {}): 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(
<I18nProvider config={{ defaultLanguage: lang, detectBrowserLanguage: false }} persistLanguage={false}>
<MemoryRouter>{node}</MemoryRouter>
</I18nProvider>,
);
}

const at = (pack: unknown, path: string): unknown =>
path.split('.').reduce<unknown>((n, k) => (n as Record<string, unknown> | 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, (
<>
<AssistantTopBarButton />
<ChatDockPanel dock={dockState()}>
<div />
</ChatDockPanel>
</>
));
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, (
<ChatDockPanel dock={dockState({ fullWindow: true })}>
<div />
</ChatDockPanel>
));
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', (
<ChatDockMobileSheet open onOpenChange={() => {}}>
<div />
</ChatDockMobileSheet>
));
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);
}
});
});
37 changes: 15 additions & 22 deletions ui/packages/i18n/src/__tests__/console-namespace-3546.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<unknown>((n, k) => (n as Record<string, unknown> | undefined)?.[k], pack);
Expand Down Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/i18n/src/locales/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2477,7 +2477,7 @@ const ar = {
unavailableRetry: "إعادة المحاولة",
unavailableHome: "العودة إلى الرئيسية",
dock: {
title: "المساعد",
title: "مساعد الذكاء الاصطناعي",
description: "محادثة مساعد الذكاء الاصطناعي",
resize: "تغيير حجم المحادثة",
collapse: "طي المحادثة",
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/i18n/src/locales/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/i18n/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/i18n/src/locales/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/i18n/src/locales/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/i18n/src/locales/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2224,7 +2224,7 @@ const ja = {
unavailableRetry: "再試行",
unavailableHome: "ホームに戻る",
dock: {
title: "アシスタント",
title: "AI アシスタント",
description: "AI アシスタントのチャット",
resize: "チャットのサイズを変更",
collapse: "チャットを折りたたむ",
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/i18n/src/locales/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2222,7 +2222,7 @@ const ko = {
unavailableRetry: "다시 시도",
unavailableHome: "홈으로 돌아가기",
dock: {
title: "어시스턴트",
title: "AI 어시스턴트",
description: "AI 어시스턴트 채팅",
resize: "채팅 크기 조정",
collapse: "채팅 접기",
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/i18n/src/locales/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/i18n/src/locales/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2356,7 +2356,7 @@ const ru = {
unavailableRetry: "Повторить",
unavailableHome: "На главную",
dock: {
title: "Ассистент",
title: "ИИ-ассистент",
description: "Чат с ассистентом ИИ",
resize: "Изменить размер чата",
collapse: "Свернуть чат",
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/i18n/src/locales/zh-Hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2506,7 +2506,7 @@ const zh = {
unavailableRetry: '重试',
unavailableHome: '返回首页',
dock: {
title: '助手',
title: 'AI 助手',
description: 'AI 助手对话',
resize: '调整对话宽度',
collapse: '收起对话',
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/i18n/src/locales/zh-Hant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2506,7 +2506,7 @@ const zhHant = {
unavailableRetry: '重試',
unavailableHome: '返回首頁',
dock: {
title: '助手',
title: 'AI 助手',
description: 'AI 助手對話',
resize: '調整對話寬度',
collapse: '收起對話',
Expand Down
Loading