-
Notifications
You must be signed in to change notification settings - Fork 29
🤖 fix: refresh post-compaction context after plan writes #1119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Change-Id: I7fa5e5c4f22cbd7bfa57dc0b65c4810293717857 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I0475383e5384c2f7e8968239e43bdaf9165edb86 Signed-off-by: Thomas Kosiewski <tk@coder.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Change-Id: Id054d125f88bfb4c2573e5374a226e6cfc989cc4 Signed-off-by: Thomas Kosiewski <tk@coder.com>
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Change-Id: I738acdd7101ccb04c6053b03693df4fb39c02769 Signed-off-by: Thomas Kosiewski <tk@coder.com>
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
|
Codex Review: Didn't find any major issues. Another round soon, please! ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
🤖 Fix post-compaction context sidebar staleness after plan writes.
postCompactionstate) after relevant tool completions (file_edit_*,propose_plan) when the experiment is enabled.WorkspaceServiceto coalesce rapid tool sequences.Validation:
make static-check📋 Implementation Plan
Fix: Post-compaction context UI not updating when plan is written
Summary
When the Post-Compaction Context experiment is enabled, the right-sidebar section (Costs tab) should show a “Plan file” item as soon as the agent writes the plan file. Currently it doesn’t update until the user toggles the experiment off/on.
Repro (current behavior)
file_edit_*tools to create/update the plan file).Root cause (why this happens)
Frontend data source is stale.
UI path:
CostsTab.tsxrenders<PostCompactionSection … />only whenpostCompactionEnabled.usePostCompactionState(workspaceId)readsworkspaceMetadata.get(workspaceId)?.postCompactionfromWorkspaceContext.planPathisnull, the section won’t render (it early-returns when there’s no plan and no tracked files).Where does
workspaceMetadata[*].postCompactioncome from?WorkspaceContext.loadWorkspaceMetadata()callsapi.workspace.list({ includePostCompaction: true }).ExperimentsSection.tsxcallingrefreshWorkspaceMetadata()).Critically:
file_edit_*tools → creates history entries and writes the plan file on disk.onCompactionCompletecallback wired inWorkspaceService.getOrCreateSession).So the UI is correct given its inputs; it’s just never told to recompute/reload post-compaction state when plan/file edits happen.
Recommended fix (Approach A): backend-driven metadata refresh on tool completion
Goal: after a
file_edit_*tool finishes (and afterpropose_plan), emit an updated workspace metadata event that includes freshpostCompactionstate.This keeps the UI model simple:
WorkspaceContextalready subscribes to metadata events and will updateworkspaceMetadata, which will flow intousePostCompactionStateand re-render the right sidebar.Implementation plan
1) Add a new “post-compaction state may have changed” callback to
AgentSessionAgentSessionconstructor args to include something like:onPostCompactionStateChange?: () => void2) Trigger that callback on relevant tool completions
In
AgentSession.attachAiListeners():"tool-call-end"handler, afteremitChatEvent(payload):file_edit_insertfile_edit_replace_stringpropose_plan(since it can create/validate plan state)this.onPostCompactionStateChange?.().Optional gating: only do this if the session has seen
options?.experiments?.postCompactionContext === truerecently.this.postCompactionExperimentEnabledfrom the latestsendMessageoptions.3) Implement the callback in
WorkspaceService(debounced + safe)In
WorkspaceService.getOrCreateSession()pass:onPostCompactionStateChange: () => schedulePostCompactionMetadataRefresh(workspaceId)Implement
schedulePostCompactionMetadataRefreshinWorkspaceService:const metadata = await this.getInfo(workspaceId)const postCompaction = await this.getPostCompactionState(workspaceId)this.sessions.get(workspaceId)?.emitMetadata({ ...metadata, postCompaction })4) Ensure metadata updates don’t accidentally drop postCompaction
postCompaction.Validation
Tests
AgentSessionreceiving atool-call-endevent forfile_edit_*.onPostCompactionStateChangecallback is invoked (and debounced once for bursts).WorkspaceServiceunit test for debounced refresh:getInfo()andgetPostCompactionState().session.emitMetadata()with enriched metadata.Net LoC estimate (product code)
Alternative fix (Approach B): frontend-driven fetch of post-compaction state
Instead of relying on
workspaceMetadata.postCompaction, updateusePostCompactionStateto callapi.workspace.getPostCompactionState({ workspaceId }):Pros
getPostCompactionState) without expanding backend event behavior.Cons
Net LoC estimate (product code)
Decision
Proceed with Approach A (backend-driven metadata refresh):
Generated with
mux