Skip to content
This repository was archived by the owner on Aug 6, 2026. It is now read-only.

Commit e322639

Browse files
authored
fix: Fix compact boundary rendering and type notification params (#1224)
Closes https://github.com/PostHog/code/issues/1218 1. Fix compact boundaries not rendering after the virtualization upgrade (fixes #1218) 2. Type notification params with explicit interfaces instead of forwarding raw msg.params objects 3. Mark compacting status spinner as complete when compact_boundary arrives 4. Fix negative duration shown after force-completed turns
1 parent dc9187f commit e322639

2 files changed

Lines changed: 61 additions & 10 deletions

File tree

apps/code/src/renderer/features/sessions/components/SessionFooter.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ export function SessionFooter({
5555
const wasCancelled =
5656
lastStopReason === "cancelled" || lastStopReason === "refusal";
5757

58-
if (lastGenerationDuration !== null && !wasCancelled) {
58+
if (
59+
lastGenerationDuration !== null &&
60+
lastGenerationDuration > 0 &&
61+
!wasCancelled
62+
) {
5963
return (
6064
<Box className="pb-1">
6165
<Text

apps/code/src/renderer/features/sessions/components/buildConversationItems.ts

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ export function buildConversationItems(
158158
if (isPromptPending === false) {
159159
for (const turn of b.pendingPrompts.values()) {
160160
turn.isComplete = true;
161+
turn.durationMs = 0;
161162
turn.context.turnComplete = true;
162163
}
163164
}
@@ -335,17 +336,63 @@ function handleNotification(
335336
return;
336337
}
337338

338-
if (
339-
isPosthogMethod(msg.method, "compact_boundary") ||
340-
isPosthogMethod(msg.method, "status") ||
341-
isPosthogMethod(msg.method, "task_notification")
342-
) {
343-
if (!b.currentTurn) {
344-
ensureImplicitTurn(b, ts);
345-
}
346-
pushItem(b, msg.params as RenderItem);
339+
if (isPosthogMethod(msg.method, "compact_boundary")) {
340+
if (!b.currentTurn) ensureImplicitTurn(b, ts);
341+
const params = msg.params as {
342+
trigger: "manual" | "auto";
343+
preTokens: number;
344+
};
345+
markCompactingStatusComplete(b);
346+
pushItem(b, {
347+
sessionUpdate: "compact_boundary",
348+
trigger: params.trigger,
349+
preTokens: params.preTokens,
350+
});
347351
return;
348352
}
353+
354+
if (isPosthogMethod(msg.method, "status")) {
355+
if (!b.currentTurn) ensureImplicitTurn(b, ts);
356+
const params = msg.params as { status: string; isComplete?: boolean };
357+
pushItem(b, {
358+
sessionUpdate: "status",
359+
status: params.status,
360+
isComplete: params.isComplete,
361+
});
362+
return;
363+
}
364+
365+
if (isPosthogMethod(msg.method, "task_notification")) {
366+
if (!b.currentTurn) ensureImplicitTurn(b, ts);
367+
const params = msg.params as {
368+
taskId: string;
369+
status: "completed" | "failed" | "stopped";
370+
summary: string;
371+
outputFile: string;
372+
};
373+
pushItem(b, {
374+
sessionUpdate: "task_notification",
375+
taskId: params.taskId,
376+
status: params.status,
377+
summary: params.summary,
378+
outputFile: params.outputFile,
379+
});
380+
return;
381+
}
382+
}
383+
384+
function markCompactingStatusComplete(b: ItemBuilder) {
385+
for (let i = b.items.length - 1; i >= 0; i--) {
386+
const item = b.items[i];
387+
if (
388+
item.type === "session_update" &&
389+
item.update.sessionUpdate === "status" &&
390+
item.update.status === "compacting"
391+
) {
392+
item.update.isComplete = true;
393+
return;
394+
}
395+
}
349396
}
350397

351398
function ensureImplicitTurn(b: ItemBuilder, ts: number) {

0 commit comments

Comments
 (0)