feat: provider compaction + context trim + archive-and-new + review flow#108
feat: provider compaction + context trim + archive-and-new + review flow#108harrryyd wants to merge 3 commits into
Conversation
- Add thread.context.compact + thread.context.summarize command schemas - Add thread.context-compacted + thread.context-summarized event schemas - Add optional summary field to ContextTrimPoint and ThreadContextTrimCommand - Decider: validate and emit events for compact and summarize commands - Decider: include summary in trim point when provided via thread.context.trim - ProviderAdapter: add compactThread method to interface - CodexSessionRuntime: implement compactThread via thread/compact/start RPC - Claude/OpenCode/Cursor adapters: return unsupported error for compactThread - ProviderService: delegate compactThread to adapter - ProviderCommandReactor: process thread.context.compact — call provider, emit summarize + trim - Composer: parse /compact, register in autocomplete, dispatch in ChatView - ContextSummaryBanner component: blue-tinted 'Context compacted' callout - MessagesTimeline: render summary banner above trim divider when summary present - Tests: contracts schemas, decider validation, composer parsing
- Capture token usage from message_start/message_delta stream events - Stop emitting token-usage events from task_progress/task_notification - Accumulated totals still tracked as totalProcessedTokens for cost
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7b9cef7d08
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| summary = String( | ||
| (item as Record<string, unknown>).encrypted_content ?? "", | ||
| ); |
There was a problem hiding this comment.
Do not use encrypted compaction content as the summary
When Codex compaction succeeds, this stores the encrypted_content field as the human-readable summary that is later dispatched into thread.context.trim and rendered in ContextSummaryBanner. The generated Codex schema describes compaction/context_compaction items as encrypted content, not plaintext, so successful /compact runs will persist and display an opaque encrypted blob instead of a readable context summary. Use a plaintext summary source from the provider, or leave the summary empty when only encrypted content is available.
Useful? React with 👍 / 👎.
| yield* client | ||
| .handleServerNotification("thread/compacted", (_payload) => |
There was a problem hiding this comment.
Avoid leaking one-shot compaction notification handlers
Each call to compactThread registers another thread/compacted notification handler, but handleServerNotification appends handlers to the client's internal list and this code never removes or reuses them. In a long-lived Codex session, every later /compact will invoke all stale handlers and issue extra thread/read requests, growing linearly with the number of previous compactions. Register a single handler for the runtime or add a cleanup/unsubscribe path for this one-shot wait.
Useful? React with 👍 / 👎.
Summary
/compactcommand — provider compaction with summary banner context/clear+/clear N— core trim infrastructure; expand/collapse trimmed messages behind a divider/new— archives current thread and creates a new inheriting oneClaudeAdapterTesting
thread.archive-and-new(archiveAndNew),thread.context.trim(contextTrim), and projectorClaudeAdapter,CodexAdapter,ProviderService,ProviderAdapterRegistrytestsReviewDraftStoreandReviewService(inc. draft) tests;GitVcsDrivertestsContextSummaryBanner,ContextTrimPointDivider,MessagesTimelineMessagesTimeline.logic, composer slash-command search, session-logic, orchestrationEventEffectsDiffCommentPaneltests; updatedContracts/orchestrationschema tests