Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(pipe-ndjson): promote trailing assistant text to a content block

Louis Beaumont72fffdaf360f
diff --git a/apps/screenpipe-app-tauri/lib/pipe-ndjson-to-chat.ts b/apps/screenpipe-app-tauri/lib/pipe-ndjson-to-chat.ts
index 5bb530b42..12cdd60a6 100644
--- a/apps/screenpipe-app-tauri/lib/pipe-ndjson-to-chat.ts
+++ b/apps/screenpipe-app-tauri/lib/pipe-ndjson-to-chat.ts
@@ -148,6 +148,22 @@ export function parsePipeNdjsonToMessages(raw: string): ChatMessage[] {
function flushAssistant() {
if (!inAssistantTurn) return;
const text = currentText.trim();
+ // Trailing prose that arrived after the last toolcall_start (or
+ // when no tool call ever fired) is still sitting in currentText
+ // and was never converted into a content-block. The chat renderer
+ // iterates contentBlocks exclusively when blocks exist, so a
+ // message with content="<long response>" + blocks=[thinking] would
+ // render as just the thinking pill — the prose was on disk but
+ // invisible. Promote the trailing text to a final text block here
+ // so the renderer actually shows it.
+ if (text) {
+ const last = currentBlocks[currentBlocks.length - 1];
+ if (last?.type === "text") {
+ last.text = ((last.text ?? "") + (last.text ? "\n" : "") + text).trim();
+ } else {
+ currentBlocks.push({ type: "text", text });
+ }
+ }
if (text || currentBlocks.length > 0) {
messages.push({
id: `pipe-msg-${messageCounter++}`,