Skip to content

fix(composer): refresh context usage after compacting a failed turn - #2412

Merged
vastsa merged 2 commits into
vastsa:mainfrom
Seraph-x:fix/2410-compaction-usage
Nov 20, 2026
Merged

vastsa merged 2 commits into
vastsa:mainfrom
Seraph-x:fix/2410-compaction-usage

Conversation

@Seraph-x

Copy link
Copy Markdown
Contributor

Fixes #2410.

Reproduction

  1. Open a conversation whose last reply failed or was stopped after reporting token usage.
  2. Run /compact and wait for the completion notification.
  3. The composer can keep showing the previous request's usage until the next turn. A failed reply remains visible in the transcript, but the runtime can anchor its checkpoint to the preceding user message. The inspector previously treated every usage-bearing row after that anchor as a newer request.

I reproduced this on current main with the production runtime. The checkpoint estimated 4,876 tokens while the composer continued to report 82,000.

Change

Carry the checkpoint's existing creation time into its lightweight mark. When a failed or stopped reply follows a known anchor, the inspector can now distinguish usage recorded before compaction from usage reported afterward. The provider breakdown continues to display the last real request. Older marks without a timestamp retain their existing ordering behavior.

Verification

  • Reproduced the stale percentage in two failing regression cases before the fix. All 60 targeted Desktop tests, 15 shared checkpoint tests, and 6 runtime compaction tests pass.
  • Ran the complete Electron app on macOS arm64 with a temporary Rust Host profile and a loopback test provider. Submitting /compact changed the displayed usage from 82% to 7% after the summary response. Reloading the session preserved 7%. Sending a subsequent prompt changed it to 16% from the provider's new usage.
  • Desktop typecheck and production build, documentation checks, architecture checks and style-token checks passed.

Seraph-x and others added 2 commits November 18, 2026 08:49
A failed or stopped reply can report provider usage without entering
model history. Its transcript row can therefore follow the checkpoint
anchor even when the reply predates a manual compaction.

Carry the recorded checkpoint time into the inspector so the ring uses
the compacted estimate immediately and later requests take precedence.

Fixes vastsa#2410
@vastsa
vastsa merged commit dbceb84 into vastsa:main Nov 20, 2026
6 checks passed
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.

[Bug] 0.22版本,手动压缩上下文后,界面没有及时更新的bug又回来了!

2 participants