fix(cli): preserve spacing in thinking/assistant blocks during streaming (#802)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
Kevin Lin
2026-02-03 15:28:18 -08:00
committed by GitHub
parent 103a630833
commit 8bc50b58ee
2 changed files with 4 additions and 4 deletions

View File

@@ -5,12 +5,12 @@ import { MarkdownDisplay } from "./MarkdownDisplay.js";
import { Text } from "./Text";
// Helper function to normalize text - copied from old codebase
// NOTE: Less aggressive than before to preserve spacing when content is split across chunks
const normalize = (s: string) =>
s
.replace(/\r\n/g, "\n")
.replace(/[ \t]+$/gm, "")
.replace(/\n{3,}/g, "\n\n")
.replace(/^\n+|\n+$/g, "");
.replace(/^\n+/g, ""); // Only trim leading newlines, preserve trailing ones
type AssistantLine = {
kind: "assistant";

View File

@@ -5,12 +5,12 @@ import { MarkdownDisplay } from "./MarkdownDisplay.js";
import { Text } from "./Text";
// Helper function to normalize text - copied from old codebase
// NOTE: Less aggressive than before to preserve spacing when content is split across chunks
const normalize = (s: string) =>
s
.replace(/\r\n/g, "\n")
.replace(/[ \t]+$/gm, "")
.replace(/\n{3,}/g, "\n\n")
.replace(/^\n+|\n+$/g, "");
.replace(/^\n+/g, ""); // Only trim leading newlines, preserve trailing ones
type ReasoningLine = {
kind: "reasoning";