TypeScript
fix(web,mobile): fold context compaction under settled turn folds (#9623)
maria5f878d2a8580
diff --git a/apps/mobile/src/lib/threadActivity.ts b/apps/mobile/src/lib/threadActivity.tsindex 6233bdf355d..a034330006c 100644--- a/apps/mobile/src/lib/threadActivity.ts+++ b/apps/mobile/src/lib/threadActivity.ts@@ -1375,9 +1375,6 @@ function deriveThreadFeedTurnFolds(pendingUserBoundary = entry.message.createdAt;continue;}- if (entry.type === "activity-group" && isContextCompactionActivityGroup(entry)) {- continue;- }const turnId =entry.type === "message" && entry.message.role === "assistant"? entry.message.turnId@@ -1423,6 +1420,16 @@ function deriveThreadFeedTurnFolds(if (hiddenEntryIds.size === 0) {continue;}+ // A lone compaction row stays visible on its own; it only folds away as+ // part of a turn that already folds other work.+ const hidesNonCompactionWork = entries.some(+ (entry) =>+ hiddenEntryIds.has(entry.id) &&+ !(entry.type === "activity-group" && isContextCompactionActivityGroup(entry)),+ );+ if (!hidesNonCompactionWork) {+ continue;+ }const firstEntry = entries[0];const firstHiddenEntry = entries.find((entry) => hiddenEntryIds.has(entry.id));diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.ts b/apps/web/src/components/chat/MessagesTimeline.logic.tsindex 413b2c0f907..6883a5c74c7 100644--- a/apps/web/src/components/chat/MessagesTimeline.logic.ts+++ b/apps/web/src/components/chat/MessagesTimeline.logic.ts@@ -619,17 +619,15 @@ function deriveTurnFolds(input: {if (entry.id === group.terminalEntry?.id) {continue;}- if (index > terminalEntryIndex) {+ const isCompaction =+ entry.kind === "work" && entry.entry.sourceActivityKind === "context-compaction";+ if (!isCompaction && index > terminalEntryIndex) {continue;}// Agent-spawn CTA rows never fold: workflows outlive their launching// turn (dynamic spawns, background execution), and folding the CTA// when the turn settles makes a still-running fleet invisible.- if (- entry.kind === "work" &&- (entry.entry.agentSpawn !== undefined ||- entry.entry.sourceActivityKind === "context-compaction")- ) {+ if (entry.kind === "work" && entry.entry.agentSpawn !== undefined) {continue;}hiddenEntryIds.add(entry.id);@@ -637,6 +635,16 @@ function deriveTurnFolds(input: {if (hiddenEntryIds.size === 0) {continue;}+ // A lone compaction row stays visible on its own; it only folds away as+ // part of a turn that already folds other work.+ const hidesNonCompactionWork = group.entries.some(+ (entry) =>+ hiddenEntryIds.has(entry.id) &&+ !(entry.kind === "work" && entry.entry.sourceActivityKind === "context-compaction"),+ );+ if (!hidesNonCompactionWork) {+ continue;+ }const firstEntry = group.entries[0];const firstHiddenEntry = group.entries.find((entry) => hiddenEntryIds.has(entry.id));