Skip to content
Draft
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
12 changes: 9 additions & 3 deletions apps/desktop/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ const withMakaRoot: Decorator = (Story, context) => {
// lines are ~1.8× the width of the Chinese copy, so a row that fits in zh
// overflows, truncates, or clips in en. Stories were locked to `zh`, which
// is exactly why those breakages only ever showed up in the shipped app.
const locale = context.globals.locale === 'en' ? 'en' : 'zh';
const locale =
context.globals.locale === 'en'
? 'en'
: context.globals.locale === 'zh-TW'
? 'zh-TW'
: 'zh-CN';

root.classList.toggle('dark', colorScheme === 'dark');
root.style.colorScheme = colorScheme;
Expand Down Expand Up @@ -96,7 +101,8 @@ const preview: Preview = {
toolbar: {
icon: 'globe',
items: [
{ title: '中文', value: 'zh' },
{ title: '简体中文', value: 'zh-CN' },
{ title: '繁體中文', value: 'zh-TW' },
{ title: 'English', value: 'en' },
],
},
Expand All @@ -114,7 +120,7 @@ const preview: Preview = {
},
initialGlobals: {
colorScheme: 'light',
locale: 'zh',
locale: 'zh-CN',
palette: 'default',
},
parameters: {
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/e2e/accessibility-coverage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ test('every settings page exposes named actionable controls', async ({ window: p
const sectionLabels = (await navigation.getByRole('button').allTextContents())
.map((label) => label.trim().replace(/\s*Beta$/, ''))
.filter((label) => label.length > 0 && label !== '返回应用');
const expectedSectionLabels = groupedNav('zh')
const expectedSectionLabels = groupedNav('zh-CN')
.flatMap(({ items }) => items)
.filter(({ enabled }) => enabled)
.map(({ label }) => label);
Expand Down
24 changes: 12 additions & 12 deletions apps/desktop/e2e/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ async function seedE2eConnection(userDataDir: string): Promise<void> {
}
}

async function seedE2eLocale(userDataDir: string, locale: 'zh' | 'en'): Promise<void> {
async function seedE2eLocale(userDataDir: string, locale: 'zh-CN' | 'zh-TW' | 'en' | 'ko'): Promise<void> {
const workspaceRoot = path.join(userDataDir, 'workspaces', 'default');
await createSettingsStore(workspaceRoot).update({
personalization: { uiLocale: locale },
Expand Down Expand Up @@ -397,7 +397,7 @@ async function withE2eWindow(
seed: boolean;
readinessSelector: string;
e2eFixtureScenario?: string;
locale?: 'zh' | 'en';
locale?: 'zh-CN' | 'zh-TW' | 'en' | 'ko';
/** Opt this window back into animated scrolling; see `scroll-motion-policy`. */
scrollMotion?: 'auto' | 'smooth';
/** #1312: force app:info's platform so the window boots natively into that platform's `data-os` cascade. */
Expand Down Expand Up @@ -523,13 +523,13 @@ export const test = base.extend<{
},
// Seeded: a pre-staged connection clears onboarding so the composer is ready.
window: async ({}, use) => {
await withE2eWindow({ seed: true, readinessSelector: COMPOSER_INPUT, locale: 'zh' }, use);
await withE2eWindow({ seed: true, readinessSelector: COMPOSER_INPUT, locale: 'zh-CN' }, use);
},
onboardingWindow: async ({}, use) => {
await withE2eWindow({
seed: false,
readinessSelector: '[data-maka-contract="onboarding-card"]',
locale: 'zh',
locale: 'zh-CN',
showWindow: true,
}, use);
},
Expand All @@ -538,7 +538,7 @@ export const test = base.extend<{
{
seed: true,
readinessSelector: COMPOSER_INPUT,
locale: 'zh',
locale: 'zh-CN',
gitReviewExtraFiles: 0,
},
async (page, context) => {
Expand All @@ -554,7 +554,7 @@ export const test = base.extend<{
await withE2eWindow({
seed: true,
readinessSelector: COMPOSER_INPUT,
locale: 'zh',
locale: 'zh-CN',
invocableSkills: true,
}, use);
},
Expand All @@ -573,7 +573,7 @@ export const test = base.extend<{
await withE2eWindow({
seed: true,
readinessSelector: COMPOSER_INPUT,
locale: 'zh',
locale: 'zh-CN',
newTaskProject: true,
showWindow: true,
}, use);
Expand All @@ -583,7 +583,7 @@ export const test = base.extend<{
seed: false,
readinessSelector: '[data-maka-contract="search-modal"][open]',
e2eFixtureScenario: 'sidebar-search-modal-open',
locale: 'zh',
locale: 'zh-CN',
showWindow: true,
}, use);
},
Expand All @@ -592,7 +592,7 @@ export const test = base.extend<{
{
seed: true,
readinessSelector: COMPOSER_INPUT,
locale: 'zh',
locale: 'zh-CN',
parentRemovalSessions: true,
},
use,
Expand All @@ -603,7 +603,7 @@ export const test = base.extend<{
{
seed: true,
readinessSelector: COMPOSER_INPUT,
locale: 'zh',
locale: 'zh-CN',
railRenderSessions: true,
},
use,
Expand All @@ -630,7 +630,7 @@ export const test = base.extend<{
seed: false,
readinessSelector: '[data-turn-id]',
e2eFixtureScenario: 'chat-partial-history',
locale: 'zh',
locale: 'zh-CN',
showWindow: true,
}, use);
},
Expand All @@ -656,7 +656,7 @@ export const test = base.extend<{
seed: false,
readinessSelector: '.settingsSurface',
e2eFixtureScenario: 'settings-models',
locale: 'zh',
locale: 'zh-CN',
showWindow: true,
}, use);
},
Expand Down
46 changes: 46 additions & 0 deletions apps/desktop/e2e/ko-locale.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { ensureSidebarExpanded, expect, test } from './fixtures';

test('persists Korean locale preference through reload', async ({ window: page }) => {
await ensureSidebarExpanded(page);
await page.getByRole('button', { name: 'Settings', exact: true }).click();
await expect(page.getByRole('main', { name: 'Settings content' })).toBeVisible();
await page.getByRole('button', { name: 'General', exact: true }).click();
await expect(page.getByText('UI language', { exact: true }).first()).toBeVisible();
await page.keyboard.press('Escape');

await page.evaluate(async () => {
await window.maka.settings.update({ personalization: { uiLocale: 'ko' } });
});
await page.reload();
await page.waitForSelector('.maka-composer-editor');
await ensureSidebarExpanded(page);

const locale = await page.evaluate(async () => {
const settings = await window.maka.settings.read();
return settings.personalization.uiLocale;
});
expect(locale).toBe('ko');

await page.getByRole('button', { name: 'Settings', exact: true }).click();
await page.getByRole('button', { name: 'General', exact: true }).click();
await expect(page.getByText('UI language', { exact: true }).first()).toBeVisible();
});
2 changes: 1 addition & 1 deletion apps/desktop/e2e/request-header-row-contract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { getProviderSettingsCopy } from '../src/renderer/locales/settings-provid
* surfaces as they first render, and this editor is three clicks deep.
*/

const copy = getProviderSettingsCopy('zh').detail;
const copy = getProviderSettingsCopy('zh-CN').detail;

test('the request header remove button centres on its field', async ({
requestHeaderRowWindow: page,
Expand Down
42 changes: 42 additions & 0 deletions apps/desktop/e2e/zh-tw-locale.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { ensureSidebarExpanded, expect, test } from './fixtures';

test('switches General Settings from Simplified to Traditional Chinese', async ({
window: page,
}) => {
await ensureSidebarExpanded(page);
await page.getByRole('button', { name: '设置', exact: true }).click();
await expect(page.getByRole('main', { name: '设置内容' })).toBeVisible();
await page.getByRole('button', { name: '通用', exact: true }).click();
await expect(page.getByText('界面语言', { exact: true }).first()).toBeVisible();
await page.keyboard.press('Escape');

await page.evaluate(async () => {
await window.maka.settings.update({ personalization: { uiLocale: 'zh-TW' } });
});
await page.reload();
await page.waitForSelector('.maka-composer-editor');
await ensureSidebarExpanded(page);
await page.getByRole('button', { name: '設定', exact: true }).click();
await expect(page.getByRole('main', { name: '設定內容' })).toBeVisible();
await page.getByRole('button', { name: '通用', exact: true }).click();
await expect(page.getByText('介面語言', { exact: true }).first()).toBeVisible();
});
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ describe('Boundary decisions notify the read model', () => {
function handlersWithRecorder() {
const boundaryChanges: string[] = [];
const handlers = createAppShellSessionEventHandlers({
uiLocale: 'zh',
uiLocale: 'zh-CN',
activeIdRef: { current: 'session-a' },
liveTurnBySessionRef: { current: {} },
refreshMessages: async () => true,
Expand Down
30 changes: 30 additions & 0 deletions apps/desktop/src/main/__tests__/agent-graph-panel-copy.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import assert from 'node:assert/strict';
import { test } from 'node:test';
import { getAgentGraphPanelCopy } from '../../renderer/agent-graph-panel.js';

test('Traditional Chinese Agent Graph copy does not use Simplified fallbacks', () => {
const copy = getAgentGraphPanelCopy('zh-TW');
assert.equal(copy.loading, '正在讀取 Graph 狀態…');
assert.equal(copy.openSession, '開啟子任務');
assert.equal(copy.currentEpoch, '目前');
assert.equal(copy.status('active'), '執行中');
});
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function createHarness(options: {
});

const actions = createAppShellSessionSettingsActions({
uiLocale: 'zh',
uiLocale: 'zh-CN',
activeIdRef,
connections: options.connections ?? ([{ slug: 'e2e', name: 'E2E' }] as LlmConnection[]),
messages: options.messages ?? [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ test('rebuilds an active Computer Use menu when its resolved locale changes', ()
assert.deepEqual(menus.at(-1)?.map((row) => row.label), ['Stop Using Safari']);

locale.observe(mergeSettings(createDefaultSettings(), {
personalization: { uiLocale: 'zh' },
personalization: { uiLocale: 'zh-CN' },
}));
assert.deepEqual(menus.at(-1)?.map((row) => row.label), ['停止操作 Safari']);

Expand Down
21 changes: 21 additions & 0 deletions apps/desktop/src/main/__tests__/config-transfer-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,27 @@ describe('config-transfer-service', () => {
assert.deepEqual(writtenMemory, ['# imported memory']);
});

it('canonicalizes a legacy zh preference before the imported settings reach observers', async () => {
const { deps, updatedSettings } = makeDeps();
const bundle = {
schemaVersion: 1,
exportedAt: '',
appVersion: '0.1.0',
includedData: ['settings'] as const,
data: {
settings: {
personalization: { uiLocale: 'zh', displayName: 'Maka user' },
},
},
};

await applyConfigImport(bundle as any, 'skip', deps);

assert.deepEqual(updatedSettings, [
{ personalization: { uiLocale: 'zh-CN', displayName: 'Maka user' } },
]);
});

it('restores the selection a backup states instead of re-enabling its default', async () => {
// A backup can hold a connection whose default model the user had disabled.
// `save()` cannot tell a stated selection from one a sync echoed back, so it
Expand Down
Loading