Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): 隐藏目标模式回复末尾的裁决块 (#5448)
Dash889a8d8a371b
diff --git a/apps/desktop/src/renderer/components/chat/AssistantMessage.tsx b/apps/desktop/src/renderer/components/chat/AssistantMessage.tsxindex d21555b6a0..c407fee0ee 100644--- a/apps/desktop/src/renderer/components/chat/AssistantMessage.tsx+++ b/apps/desktop/src/renderer/components/chat/AssistantMessage.tsx@@ -45,7 +45,7 @@ import { useTranslation } from 'react-i18next';import { Loader2, TriangleAlert } from 'lucide-react';import { cn } from '@/lib/utils';import { formatModelShortLabel } from '@/lib/modelShortLabel';-import { stripGoalVerdictBlock } from '@/lib/goalVerdict';+import { stripGoalVerdictBlock } from '@cindy/maker-shared/goal-verdict';import { getGhostCardEntry, subscribeGhostCards } from '@/cindy-brain/ghostCardStore';import { GhostToolCard } from './GhostToolCard';import type { KnownLocalFileRef } from '@/lib/localPathResolver';diff --git a/apps/mobile/src/__tests__/messageNormalize.test.ts b/apps/mobile/src/__tests__/messageNormalize.test.tsindex bbffdb4c9e..b0df555f29 100644--- a/apps/mobile/src/__tests__/messageNormalize.test.ts+++ b/apps/mobile/src/__tests__/messageNormalize.test.ts@@ -106,6 +106,23 @@ describe('normalizeRemoteMessages', () => {]);});+ it('hides the trailing /goal verdict block from assistant text like desktop', () => {+ const verdict = '```json\n{"goal_status":"continue","reason":"下一步补齐合并检查。"}\n```';+ const [assistant, user] = normalizeRemoteMessages([+ message({ id: 'goal-a', role: 'assistant', content: `已核对现有 CI。\n\n${verdict}` }),+ message({+ id: 'goal-u',+ role: 'user',+ content: { text: `看这段\n${verdict}`, images: [] },+ createdAt: '2026-01-01T00:00:01.000Z',+ }),+ ]);++ expect(assistant).toMatchObject({ kind: 'assistant', body: '已核对现有 CI。' });+ expect(buildMobileMessageCopyText(assistant!)).not.toContain('goal_status');+ expect(user?.body).toContain('goal_status');+ });+it('extracts assistant turn cost from desktop agentMeta', () => {const items = normalizeRemoteMessages([message({diff --git a/apps/mobile/src/session/messageNormalize.ts b/apps/mobile/src/session/messageNormalize.tsindex db98bc201d..822c365a78 100644--- a/apps/mobile/src/session/messageNormalize.ts+++ b/apps/mobile/src/session/messageNormalize.ts@@ -22,6 +22,7 @@ import {type AgentTaskTerminalStatus,} from '@cindy/maker-shared/agent-task';import { isSyntheticTriggerText } from '@cindy/maker-shared/synthetic-trigger';+import { stripGoalVerdictBlock } from '@cindy/maker-shared/goal-verdict';import {formatToolResultCompactionBytes,parseToolResultCompactionMarker,@@ -496,7 +497,9 @@ export function normalizeRemoteMessages(}const rawBody = userContent ? userContent.text : contentToPreview(message.content);const hookSource = message.role === 'user' ? readHookSource(message, rawBody) : undefined;- const body = hookSource?.userText ?? rawBody;+ // /goal 裁决块只给 Desktop 驱动续跑,与 Desktop 一致只在显示层剥掉(原文仍在 source)。+ const body = hookSource?.userText+ ?? (message.role === 'assistant' ? stripGoalVerdictBlock(rawBody) : rawBody);const turnCost = readTurnCost(message);result.push({key: messageNormalizeKey(message),diff --git a/packages/maker-shared/package.json b/packages/maker-shared/package.jsonindex c22a8b6a86..e1460c93e0 100644--- a/packages/maker-shared/package.json+++ b/packages/maker-shared/package.json@@ -29,6 +29,7 @@"./file-browser-grid": "./src/fileBrowserGrid.ts","./file-preview": "./src/filePreview.ts","./fixtures": "./src/fixtures.ts",+ "./goal-verdict": "./src/goalVerdict.ts","./history-gap": "./src/historyGap.ts","./image-annotation": "./src/imageAnnotation.ts","./interaction": "./src/interaction.ts",diff --git a/apps/desktop/src/renderer/__tests__/goalVerdict.test.ts b/packages/maker-shared/src/__tests__/goalVerdict.test.tssimilarity index 97%rename from apps/desktop/src/renderer/__tests__/goalVerdict.test.tsrename to packages/maker-shared/src/__tests__/goalVerdict.test.tsindex bf35b654be..151ba0bc9e 100644--- a/apps/desktop/src/renderer/__tests__/goalVerdict.test.ts+++ b/packages/maker-shared/src/__tests__/goalVerdict.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from 'vitest';-import { stripGoalVerdictBlock } from '@/lib/goalVerdict';+import { stripGoalVerdictBlock } from '../goalVerdict';describe('stripGoalVerdictBlock', () => {it('strips a trailing fenced json verdict block', () => {diff --git a/apps/desktop/src/renderer/lib/goalVerdict.ts b/packages/maker-shared/src/goalVerdict.tssimilarity index 85%rename from apps/desktop/src/renderer/lib/goalVerdict.tsrename to packages/maker-shared/src/goalVerdict.tsindex 33d8c26ff3..ba28d2148b 100644--- a/apps/desktop/src/renderer/lib/goalVerdict.ts+++ b/packages/maker-shared/src/goalVerdict.ts@@ -1,8 +1,8 @@/**- * 显示层剥离 /goal 协议块。+ * 显示层剥离 /goal 协议块(Desktop 与 Mobile 共用,两端必须一致)。*- * /goal 协议要求模型在末尾吐一个结构化 JSON 块,main 用代码解析它驱动流程:- * - 每个执行轮:`{"goal_status":...}` 裁决块(verdict.ts 解析,驱动续跑/停)+ * /goal 协议要求模型在末尾吐一个结构化 JSON 块,Desktop main 用代码解析它驱动流程:+ * - 每个执行轮:`{"goal_status":...}` 裁决块(goal-host/verdict.ts 解析,驱动续跑/停)* - 历史版本可能残留的 `{"goal_setup":...}` 配置块* 这些块对用户都是噪声,显示时剥掉;**原文仍保留在 DB / transcript**(只动渲染,不动数据)。*diff --git a/packages/maker-shared/src/index.ts b/packages/maker-shared/src/index.tsindex 4805502f7b..101e496b68 100644--- a/packages/maker-shared/src/index.ts+++ b/packages/maker-shared/src/index.ts@@ -15,6 +15,7 @@ export * from './fixtures.js';export * from './deviceLinkContract.js';export * from './errorRedaction.js';export * from './expandedBlockMemory.js';+export * from './goalVerdict.js';export * from './interaction.js';export * from './internalCitation.js';export * from './liveTaskPriority.js';