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(review): preserve formatting in completed findings

Chrisa3cba212f2f5
diff --git a/apps/desktop/src/main/localDb/__tests__/conversationSearch.pure.test.ts b/apps/desktop/src/main/localDb/__tests__/conversationSearch.pure.test.ts
index 061422032e..b851b42b09 100644
--- a/apps/desktop/src/main/localDb/__tests__/conversationSearch.pure.test.ts
+++ b/apps/desktop/src/main/localDb/__tests__/conversationSearch.pure.test.ts
@@ -6,6 +6,7 @@ import {
mergeConversationSearchResults,
normalizeConversationContentPreview,
textPreview,
+ visibleMessageText,
visibleMessageTextForConversationSearch,
} from '../conversationSearch.pure';
import type { ConversationSearchSessionSummary } from '../../../shared/conversationSearch';
@@ -33,6 +34,19 @@ function session(
}
describe('conversationSearch.pure', () => {
+ it('preserves findings and code indentation for result cards while search stays one line', () => {
+ const findings = '## Findings\n\n- P1: Discount\n- P2: Shipping\n\n```ts\nif (ready) {\n ship();\n}\n```';
+ for (const content of [findings, JSON.stringify([
+ { type: 'thinking', thinking: 'private reasoning' },
+ { type: 'text', text: findings },
+ ])]) {
+ expect(visibleMessageText('assistant', content)).toBe(findings);
+ expect(visibleMessageTextForConversationSearch('assistant', content)).toBe(
+ findings.replace(/\s+/g, ' '),
+ );
+ }
+ });
+
it('scores and highlights fuzzy title matches', () => {
const match = fuzzyTitleMatch('Chat History', 'ch');
expect(match).not.toBeNull();
diff --git a/apps/desktop/src/main/localDb/conversationSearch.pure.ts b/apps/desktop/src/main/localDb/conversationSearch.pure.ts
index 2db2557a6a..6aa9441e55 100644
--- a/apps/desktop/src/main/localDb/conversationSearch.pure.ts
+++ b/apps/desktop/src/main/localDb/conversationSearch.pure.ts
@@ -255,10 +255,15 @@ export function normalizeConversationContentPreview(
}
export function visibleMessageTextForConversationSearch(role: string, content: unknown): string {
+ return visibleMessageText(role, content).replace(/\s+/g, ' ').trim();
+}
+
+/** Full visible content for result rendering; only search previews flatten Markdown. */
+export function visibleMessageText(role: string, content: unknown): string {
const parsed = typeof content === 'string' ? tryParseJsonLike(content) : content;
const rawText = roleVisibleText(role, parsed);
const text = role === 'assistant' ? stripInternalWebCitations(rawText) : rawText;
- return text.replace(/\s+/g, ' ').trim();
+ return text.trim();
}
function roleVisibleText(role: string, content: unknown): string {
diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.ts
index 368d11ba59..198cf9e3f6 100644
--- a/apps/desktop/src/main/maker-ipc/register.ts
+++ b/apps/desktop/src/main/maker-ipc/register.ts
@@ -372,7 +372,7 @@ import {
} from '../localDb/ipc/messages.js';
import { invalidateWorkersByLeadSingleFlight } from '../localDb/ipc/orcaWorkerListSingleFlight.js';
import { messageToCamel, setSessionRuntimeProjector } from '../localDb/mapper.js';
-import { visibleMessageTextForConversationSearch } from '../localDb/conversationSearch.pure.js';
+import { visibleMessageText, visibleMessageTextForConversationSearch } from '../localDb/conversationSearch.pure.js';
import { buildReviewPrompt } from '../reviewer/reviewPrompt.js';
import { resolveReviewScope, withSessionReviewWorkspace } from '../git-review/scopeResolver.js';
import { selectReviewWorkspace, shouldSelectReviewWorkspace } from '../reviewer/reviewWorkspaceSelection.js';
@@ -8964,7 +8964,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
.orderBy(desc(messages.createdAt), desc(messages.id))
.limit(8);
for (const row of rows) {
- const text = visibleMessageTextForConversationSearch('assistant', row.content);
+ const text = visibleMessageText('assistant', row.content);
if (text) return text;
}
return '';