fix: trim leading newlines from streaming/block-flush text output
Co-authored-by: Zach Canepa <zcanepa19@gmail.com>
This commit is contained in:
parent
c13011e2d0
commit
38ba14ea9f
@ -81,7 +81,7 @@ function collapseConsecutiveDuplicateBlocks(text: string): string {
|
||||
const trimmed = text.trim();
|
||||
if (!trimmed) return text;
|
||||
const blocks = trimmed.split(/\n{2,}/);
|
||||
if (blocks.length < 2) return text;
|
||||
if (blocks.length < 2) return trimmed;
|
||||
|
||||
const normalizeBlock = (value: string) => value.trim().replace(/\s+/g, " ");
|
||||
const result: string[] = [];
|
||||
@ -344,7 +344,7 @@ export function sanitizeUserFacingText(text: string): string {
|
||||
return formatRawAssistantErrorForUi(trimmed);
|
||||
}
|
||||
|
||||
return collapseConsecutiveDuplicateBlocks(stripped);
|
||||
return collapseConsecutiveDuplicateBlocks(stripped).trim();
|
||||
}
|
||||
|
||||
export function isRateLimitAssistantError(msg: AssistantMessage | undefined): boolean {
|
||||
|
||||
@ -359,7 +359,7 @@ export function subscribeEmbeddedPiSession(params: SubscribeEmbeddedPiSessionPar
|
||||
const emitBlockChunk = (text: string) => {
|
||||
if (state.suppressBlockChunks) return;
|
||||
// Strip <think> and <final> blocks across chunk boundaries to avoid leaking reasoning.
|
||||
const chunk = stripBlockTags(text, state.blockState).trimEnd();
|
||||
const chunk = stripBlockTags(text, state.blockState).trim();
|
||||
if (!chunk) return;
|
||||
if (chunk === state.lastBlockReplyText) return;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user