fix(web): preserve Claude insight line breaks (#4344)
This commit is contained in:
1 parent
672216d7e1
commit
1e87029261
3 files changed
+18
No files matched your search
@@ -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([
|
||||
|
||||
@@ -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})`;
|
||||
|
||||
@@ -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: "mess
|
||||
cwd={ctx.markdownCwd}
|
||||
threadRef={ctx.threadRef ?? undefined}
|
||||
isStreaming={Boolean(row.message.streaming)}
|
||||
lineBreaks={shouldPreserveAssistantLineBreaks(messageText)}
|
||||
skills={ctx.skills}
|
||||
/>
|
||||
<AssistantChangedFilesSection
|
||||
|
||||
Reference in new issue
Block a user