feat: show compaction history in chat#118
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds chat-visible compaction history by preserving compaction entries in the UI message stream and rendering them with a dedicated “compaction” custom message view, including parsed file-metadata extracted from the compaction summary.
Changes:
lib/session-reader.ts: stop trimming UI history at the last compaction; convert compaction entries into UI-visible custom messages.lib/compaction-summary.ts+ test: parse trailing<read-files>/<modified-files>blocks out of compaction summaries.components/MessageView.tsx+app/globals.css: render compaction custom messages with summary markdown and expandable file metadata.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/session-reader.ts | Builds UI history from full branch path and maps compaction entries into UI messages. |
| lib/compaction-summary.ts | Implements compaction summary parsing for read/modified file metadata sections. |
| lib/compaction-summary.test.mjs | Adds node test coverage for compaction summary parsing behavior. |
| components/MessageView.tsx | Renders compaction custom messages with markdown + file metadata details. |
| app/globals.css | Adds styling for compaction message markdown and file metadata sections. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+100
to
+106
| // Build UI history from the FULL branch path (leaf to root), without trimming. | ||
| // pi's buildSessionContext targets LLM context: it drops everything before the last | ||
| // compaction's firstKeptEntryId. Correct for the model, but it would hide compacted | ||
| // history from the UI. We keep piCtx only for thinkingLevel/model, and render every | ||
| // displayable entry on the path ourselves; compaction/branch_summary entries become | ||
| // inline summary messages so the user still sees where context was compressed. | ||
| const messages: AgentMessage[] = []; |
Comment on lines
+149
to
+158
| case "custom_message": | ||
| if (!entry.display) return null; | ||
| return { | ||
| role: "custom", | ||
| customType: entry.customType, | ||
| content: entry.content, | ||
| display: entry.display, | ||
| details: entry.details, | ||
| timestamp: Date.parse(entry.timestamp) || undefined, | ||
| }; |
| tokensBefore: entry.tokensBefore, | ||
| firstKeptEntryId: entry.firstKeptEntryId, | ||
| }, | ||
| timestamp: Date.parse(entry.timestamp) || undefined, |
| return { | ||
| role: "user", | ||
| content: `*The conversation briefly explored another branch and returned with this summary:*\n\n${entry.summary}`, | ||
| timestamp: Date.parse(entry.timestamp) || undefined, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why
After compaction, the UI previously lost useful context about what was summarized. Showing compacted history helps users understand why later assistant messages have less visible prior context.
Validation