Skip to content

feat: show compaction history in chat#118

Merged
agegr merged 1 commit into
agegr:mainfrom
zhudatou630:codex/compaction-ui
Jul 6, 2026
Merged

feat: show compaction history in chat#118
agegr merged 1 commit into
agegr:mainfrom
zhudatou630:codex/compaction-ui

Conversation

@zhudatou630

Copy link
Copy Markdown
Contributor

Summary

  • Preserve compaction entries while reading session history and render them as chat-visible custom messages.
  • Parse compaction summaries for read/modified file metadata.
  • Keep the model-facing context behavior unchanged while making the user's visible history easier to understand.

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

  • node --test lib/compaction-summary.test.mjs
  • node_modules/.bin/tsc --noEmit
  • npm run lint

@zhudatou630 zhudatou630 marked this pull request as ready for review July 5, 2026 15:14
Copilot AI review requested due to automatic review settings July 5, 2026 15:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 thread lib/session-reader.ts
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 thread lib/session-reader.ts
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,
};
Comment thread lib/session-reader.ts
tokensBefore: entry.tokensBefore,
firstKeptEntryId: entry.firstKeptEntryId,
},
timestamp: Date.parse(entry.timestamp) || undefined,
Comment thread lib/session-reader.ts
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,
@agegr agegr merged commit e123bc0 into agegr:main Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants