Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(i18n): 修正移动端语言刷新展示

davidf10e525293ae
diff --git a/apps/mobile/app/automations/[deviceId].tsx b/apps/mobile/app/automations/[deviceId].tsx
index 63b219261d..0da3d170b1 100644
--- a/apps/mobile/app/automations/[deviceId].tsx
+++ b/apps/mobile/app/automations/[deviceId].tsx
@@ -1072,11 +1072,6 @@ function ScheduleFormCard({
<View style={styles.formCard} testID="automations.form">
<View style={styles.formHeader}>
<View>
- <Text style={styles.sectionTitle}>
- {mode === 'edit'
- ? t('devices.automations.form.title.edit')
- : t('devices.automations.form.title.create')}
- </Text>
<Text style={styles.formTitle}>{mode === 'edit' ? t('devices.automations.form.title.edit') : t('devices.automations.form.title.create')}</Text>
</View>
{busy ? <ActivityIndicator color={colors.textSecondary} /> : null}
diff --git a/apps/mobile/app/sessions/[sessionId].tsx b/apps/mobile/app/sessions/[sessionId].tsx
index bd745d6553..a7bf54a1bd 100644
--- a/apps/mobile/app/sessions/[sessionId].tsx
+++ b/apps/mobile/app/sessions/[sessionId].tsx
@@ -2425,6 +2425,7 @@ export default function SessionScreen() {
composerQuoteCount,
composerSendUnavailableReason,
draft,
+ i18nInstance.language,
queueBusy,
sending,
voiceState,
diff --git a/apps/mobile/src/__tests__/mobilePresentationRefresh.test.ts b/apps/mobile/src/__tests__/mobilePresentationRefresh.test.ts
new file mode 100644
index 0000000000..11973431f1
--- /dev/null
+++ b/apps/mobile/src/__tests__/mobilePresentationRefresh.test.ts
@@ -0,0 +1,33 @@
+import { readFileSync } from 'node:fs';
+import { resolve } from 'node:path';
+
+import { describe, expect, it } from 'vitest';
+
+const APP_ROOT = resolve(__dirname, '..', '..');
+
+function read(relPath: string): string {
+ return readFileSync(resolve(APP_ROOT, relPath), 'utf8');
+}
+
+describe('mobile localized presentation refresh', () => {
+ it('renders the automation form title once', () => {
+ const source = read('app/automations/[deviceId].tsx');
+ const formHeader = source.slice(
+ source.indexOf('<View style={styles.formHeader}>'),
+ source.indexOf('{error ? <Text style={styles.formError}>'),
+ );
+
+ expect(formHeader.match(/devices\.automations\.form\.title\.edit/g)).toHaveLength(1);
+ expect(formHeader.match(/devices\.automations\.form\.title\.create/g)).toHaveLength(1);
+ });
+
+ it('rebuilds the cached composer presentation when the language changes', () => {
+ const source = read('app/sessions/[sessionId].tsx');
+ const composerProjection = source.slice(
+ source.indexOf('const composerLayout = useMemo'),
+ source.indexOf('const compactComposer ='),
+ );
+
+ expect(composerProjection).toContain('i18nInstance.language');
+ });
+});