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(mobile): Auto 故障确认卡走五语 i18n,不再直接渲染英文

MagicLizi22675b92cbd6
diff --git a/apps/mobile/src/__tests__/interactionModel.test.ts b/apps/mobile/src/__tests__/interactionModel.test.ts
index 1a8b668608..44e4b0f21f 100644
--- a/apps/mobile/src/__tests__/interactionModel.test.ts
+++ b/apps/mobile/src/__tests__/interactionModel.test.ts
@@ -164,6 +164,7 @@ describe('interactionModel', () => {
});
expect(presentation).toEqual({
+ autoReviewUnavailable: false,
canAlwaysAllow: false,
code: 'pnpm --filter mobile test',
description: 'Run the requested test command.',
@@ -177,6 +178,24 @@ describe('interactionModel', () => {
});
});
+ it('localizes auto-review unavailable confirmation copy instead of the English fallback', () => {
+ const presentation = buildPermissionReviewPresentation({
+ kind: 'permission',
+ requestId: 'p-unavailable',
+ toolName: 'Bash',
+ description: 'Automatic review could not finish, so this action needs your confirmation.',
+ metadata: { autoReviewUnavailable: true },
+ input: { command: 'npx tsc --noEmit' },
+ });
+ expect(presentation.autoReviewUnavailable).toBe(true);
+
+ const interactionPanelSource = readFileSync(resolve(process.cwd(), 'src/session/InteractionPanel.tsx'), 'utf8');
+ expect(interactionPanelSource).toContain("t('interaction.permission.autoReviewUnavailable')");
+ expect(i18n.t('interaction.permission.autoReviewUnavailable')).not.toBe(
+ 'interaction.permission.autoReviewUnavailable',
+ );
+ });
+
it('projects ask question review presentation through the shared mobile model', () => {
const presentation = buildAskQuestionReviewPresentation({
currentIndex: 1,
diff --git a/apps/mobile/src/i18n/locales/en/interaction.json b/apps/mobile/src/i18n/locales/en/interaction.json
index 0cd624e64f..8a49d61eaa 100644
--- a/apps/mobile/src/i18n/locales/en/interaction.json
+++ b/apps/mobile/src/i18n/locales/en/interaction.json
@@ -19,7 +19,8 @@
"allowOnce": "Allow once",
"allowOnceAccessibility": "Allow permission request once",
"allowOnceConfirm": "Confirm allow once",
- "highRisk": "High risk"
+ "highRisk": "High risk",
+ "autoReviewUnavailable": "Automatic review could not finish. Confirm whether to allow this action."
},
"planMode": {
"label": "Plan mode",
diff --git a/apps/mobile/src/i18n/locales/ja/interaction.json b/apps/mobile/src/i18n/locales/ja/interaction.json
index c6b837d439..4466fdb60f 100644
--- a/apps/mobile/src/i18n/locales/ja/interaction.json
+++ b/apps/mobile/src/i18n/locales/ja/interaction.json
@@ -19,7 +19,8 @@
"allowOnce": "1回だけ許可",
"allowOnceAccessibility": "権限リクエストを1回だけ許可",
"allowOnceConfirm": "1回だけ許可を確認",
- "highRisk": "高リスク"
+ "highRisk": "高リスク",
+ "autoReviewUnavailable": "自動レビューを完了できませんでした。この操作を許可するか確認してください。"
},
"planMode": {
"label": "プランモード",
diff --git a/apps/mobile/src/i18n/locales/ko/interaction.json b/apps/mobile/src/i18n/locales/ko/interaction.json
index 979debdaf3..ae44b4a17b 100644
--- a/apps/mobile/src/i18n/locales/ko/interaction.json
+++ b/apps/mobile/src/i18n/locales/ko/interaction.json
@@ -19,7 +19,8 @@
"allowOnce": "한 번 허용",
"allowOnceAccessibility": "권한 요청 한 번 허용",
"allowOnceConfirm": "한 번 허용 확인",
- "highRisk": "고위험"
+ "highRisk": "고위험",
+ "autoReviewUnavailable": "자동 리뷰를 끝내지 못했습니다. 이 작업을 허용할지 확인해 주세요."
},
"planMode": {
"label": "플랜 모드",
diff --git a/apps/mobile/src/i18n/locales/zh-CN/interaction.json b/apps/mobile/src/i18n/locales/zh-CN/interaction.json
index 01ac968f2c..4519103ffc 100644
--- a/apps/mobile/src/i18n/locales/zh-CN/interaction.json
+++ b/apps/mobile/src/i18n/locales/zh-CN/interaction.json
@@ -19,7 +19,8 @@
"allowOnce": "允许一次",
"allowOnceAccessibility": "允许一次权限请求",
"allowOnceConfirm": "确认允许一次",
- "highRisk": "高风险"
+ "highRisk": "高风险",
+ "autoReviewUnavailable": "自动审批没完成,请确认要不要允许这次操作。"
},
"planMode": {
"label": "计划模式",
diff --git a/apps/mobile/src/i18n/locales/zh-TW/interaction.json b/apps/mobile/src/i18n/locales/zh-TW/interaction.json
index a9ff294eb2..bed5df3c62 100644
--- a/apps/mobile/src/i18n/locales/zh-TW/interaction.json
+++ b/apps/mobile/src/i18n/locales/zh-TW/interaction.json
@@ -19,7 +19,8 @@
"allowOnce": "允許一次",
"allowOnceAccessibility": "允許一次權限請求",
"allowOnceConfirm": "確認允許一次",
- "highRisk": "高風險"
+ "highRisk": "高風險",
+ "autoReviewUnavailable": "自動審批沒完成,請確認要不要允許這次操作。"
},
"planMode": {
"label": "計劃模式",
diff --git a/apps/mobile/src/session/InteractionPanel.tsx b/apps/mobile/src/session/InteractionPanel.tsx
index c8e827ef4c..126932f040 100644
--- a/apps/mobile/src/session/InteractionPanel.tsx
+++ b/apps/mobile/src/session/InteractionPanel.tsx
@@ -703,8 +703,12 @@ function PermissionEvidence({
{presentation.toolName}
</Text>
</View>
- {presentation.description ? (
- <Text style={styles.permissionDescription}>{presentation.description}</Text>
+ {presentation.autoReviewUnavailable || presentation.description ? (
+ <Text style={styles.permissionDescription}>
+ {presentation.autoReviewUnavailable
+ ? t('interaction.permission.autoReviewUnavailable')
+ : presentation.description}
+ </Text>
) : null}
{riskWarningText ? (
<View
diff --git a/packages/maker-shared/src/__tests__/interaction.test.ts b/packages/maker-shared/src/__tests__/interaction.test.ts
index 655e508181..8c68d27f82 100644
--- a/packages/maker-shared/src/__tests__/interaction.test.ts
+++ b/packages/maker-shared/src/__tests__/interaction.test.ts
@@ -183,6 +183,28 @@ describe('interaction shared model', () => {
});
});
+ it('marks auto-review unavailable handoffs so mobile can localize the confirmation copy', () => {
+ const presentation = buildPermissionReviewPresentation({
+ kind: 'permission',
+ requestId: 'p-unavailable',
+ toolName: 'Bash',
+ description: 'Automatic review could not finish, so this action needs your confirmation.',
+ metadata: { autoReviewUnavailable: true },
+ input: { command: 'npx tsc --noEmit' },
+ });
+
+ expect(presentation.autoReviewUnavailable).toBe(true);
+ expect(presentation.description).toBe(
+ 'Automatic review could not finish, so this action needs your confirmation.',
+ );
+ expect(buildPermissionReviewPresentation({
+ kind: 'permission',
+ requestId: 'p-plain',
+ toolName: 'Bash',
+ description: 'Allow this command?',
+ }).autoReviewUnavailable).toBe(false);
+ });
+
it('builds ask question review presentation for mobile answer cards', () => {
const presentation = buildAskQuestionReviewPresentation({
currentIndex: 4,
diff --git a/packages/maker-shared/src/interaction.ts b/packages/maker-shared/src/interaction.ts
index a22439e309..0d3a6b2f0d 100644
--- a/packages/maker-shared/src/interaction.ts
+++ b/packages/maker-shared/src/interaction.ts
@@ -35,6 +35,7 @@ export interface IssueConfirmPayload {
}
export interface PermissionReviewPresentation {
+ autoReviewUnavailable: boolean;
canAlwaysAllow: boolean;
code: string;
description: string | null;
@@ -201,6 +202,7 @@ export function buildPermissionReviewPresentation(
const canAlwaysAllow = sessionScopedPermissionSuggestions(request.suggestions).length > 0;
return {
+ autoReviewUnavailable: permissionAutoReviewUnavailable(request),
canAlwaysAllow,
code: formatPermissionInput(toolName, input),
description: permissionDescription(request),
@@ -789,6 +791,10 @@ export function permissionDescription(request: InteractionRequestLike): string |
return readString(request.description);
}
+export function permissionAutoReviewUnavailable(request: InteractionRequestLike): boolean {
+ return isRecord(request.metadata) && request.metadata.autoReviewUnavailable === true;
+}
+
export function permissionToolName(request: InteractionRequestLike): string {
return readString(request.toolName) || 'Tool';
}