Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
fix(web): preserve Claude insight line breaks (#4344)
Yukun Shan1e87029261f9
diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.test.ts b/apps/web/src/components/chat/MessagesTimeline.logic.test.tsindex 6d74204bc..70a330d46 100644--- a/apps/web/src/components/chat/MessagesTimeline.logic.test.ts+++ b/apps/web/src/components/chat/MessagesTimeline.logic.test.ts@@ -5,8 +5,20 @@ import {deriveMessagesTimelineRows,normalizeCompactToolLabel,resolveAssistantMessageCopyState,+ shouldPreserveAssistantLineBreaks,} from "./MessagesTimeline.logic";+describe("shouldPreserveAssistantLineBreaks", () => {+ it("preserves Claude insight formatting without changing regular markdown", () => {+ expect(+ shouldPreserveAssistantLineBreaks(+ "★ Insight ─────────────────\\nFirst observation\\nSecond observation\\n─────────────────",+ ),+ ).toBe(true);+ expect(shouldPreserveAssistantLineBreaks("A normal\\nmarkdown paragraph")).toBe(false);+ });+});+describe("computeMessageDurationStart", () => {it("returns message createdAt when there is no preceding user message", () => {const result = computeMessageDurationStart([diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.ts b/apps/web/src/components/chat/MessagesTimeline.logic.tsindex 6bc0a2a62..c89bbd055 100644--- a/apps/web/src/components/chat/MessagesTimeline.logic.ts+++ b/apps/web/src/components/chat/MessagesTimeline.logic.ts@@ -52,6 +52,10 @@ export function resolveTimelineIsAtEnd(return contentLength - scroll - scrollLength - endInset <= TIMELINE_FOLLOW_REARM_THRESHOLD_PX;}+export function shouldPreserveAssistantLineBreaks(text: string): boolean {+ return /^★ Insight(?:\s|─)/mu.test(text);+}+export function resolveTimelineMinimapHeightStyle(itemCount: number): string {const naturalHeight = Math.max(1, (itemCount - 1) * TIMELINE_MINIMAP_ITEM_SPACING);return `min(${naturalHeight}px, ${TIMELINE_MINIMAP_MAX_HEIGHT_CSS})`;diff --git a/apps/web/src/components/chat/MessagesTimeline.tsx b/apps/web/src/components/chat/MessagesTimeline.tsxindex f9ad57ff3..f5c529ff3 100644--- a/apps/web/src/components/chat/MessagesTimeline.tsx+++ b/apps/web/src/components/chat/MessagesTimeline.tsx@@ -83,6 +83,7 @@ import {resolveTimelineMinimapIndexFromPointer,resolveTimelineMinimapInteractiveWidth,resolveTimelineMinimapTopPercent,+ shouldPreserveAssistantLineBreaks,type StableMessagesTimelineRowsState,type MessagesTimelineRow,TIMELINE_MINIMAP_MIN_ITEMS,@@ -1113,6 +1114,7 @@ function AssistantTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "messcwd={ctx.markdownCwd}threadRef={ctx.threadRef ?? undefined}isStreaming={Boolean(row.message.streaming)}+ lineBreaks={shouldPreserveAssistantLineBreaks(messageText)}skills={ctx.skills}/><AssistantChangedFilesSection