fix(web,mobile): fold context compaction under settled turn folds (#9623)

Co-authored-by: maria-rcks <[email protected]>
This commit is contained in:
mariaandmaria-rcks authored and GitHub committed 2026-09-04 04:12:46 -04:00
1 parent ec3ec6f0b4
commit 5f878d2a85
2 files changed
+24 -9

No files matched your search

+10 -3
View File
@@ -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));
@@ -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));