Repository navigation
Fix Claude context indicator after compaction - #1461
Merged
Merged
Conversation
baron
marked this pull request as ready for review
October 23, 2026 09:26
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
Fixes #972.
Claude's
compact_boundaryreportspre_tokens, not post-compaction occupancy. The old estimator retained that count, its active-turn observation, and historical fallback; UI projections could then substitute the whole transcript's character estimate and label unknown usage Live. Reopening a session could rebuild the same pre-compaction count.?, not zero, and nil occupancy is not labelled Live.contextCompactedusage-ledger fence. The builder never scans across that fence, including normal hydration and reopening from history. Existing usage/billing records remain intact; legacy rows decode with no fence.session_id,uuid) throughClaudeSDKNDJSONTranslatorand the actual view-model stream handler. Exercise non-empty transcript analytics viaupdate(snapshot:), manual compaction with no post-size, same-turn automatic compaction with fresh usage before result, Task-prose negatives, legacy decoding, hydration, and history reopen.Relevance and integration overlap
Issue #972 remained open/reproducible on base
ab84d47e6; no existing #972 PR was found. Draft #1458 (#1019) is functionally distinct but does have textual merge conflicts inClaudeContextUsageEstimator.swift, verified withgit merge-treeusing original heads3e92c3eand39355a0. It was not merged into this branch.Draft #1458 still has a simple adjacent-line conflict in
ClaudeContextUsageEstimator.swift; no merge was performed. When integrating #1458, keep this PR’s unconditional marker-aware rebuild and add itsconfiguredContextWindow(for:)capacity fallback and this PR's marker-aware replay/pending flag. This follow-up removes the oldcanRebuildContextgate because the persisted fence makes rebuilding safe. The integrated builder should receiveexistingUsage?.modelContextWindow ?? configuredContextWindow(for: session); retain both the pending-state helper and #1458's configured-window helper. Do not resolve the conflict by dropping either behavior.Validation
All builds/tests used this worktree's conductor daemon; SwiftFormat mutation was limited to changed files.
4c0e1ee4).make dev-test FILTER='ClaudeCompactionContextUsageTests|ClaudeCompatiblePluginBridgeTests|AgentSessionLinkContextLoadTests|AgentRuntimeSidebarViewModelTests'— 65 tests passed (ticket323155f3; reconnected to the same ticket after one client timeout).make dev-swift-build PRODUCT=RepoPrompt: passed (ticketfb170bda).make dev-provider-test: all 20 tests passed (ticket384691ff).make dev-lint: passed (ticket034425bd).An intermediate expanded run compiled successfully and passed 63/65 tests; the two failures correctly exposed an empty test fixture, fixed by saving an explicit non-empty canonical transcript. The corrected run above includes both hydration paths. The initial cold-build attempt before the first implementation hit XCBuild input/database I/O errors; the coordinated retry supplied the fail-first evidence.
Not run: full root suite,
pr-ready, packaging/release validation, or live UI/provider/MCP smoke. Live smoke is out of scope for these lanes. No visible app launch, stop, or relaunch. Draft retained for independent adversarial verification.Round-2 review follow-up
awaitingPostCompactionUsagewhen the provider changes, so pending Claude occupancy does not leak into ACP. Preserve the known window and restore the estimated transcript fallback immediately.fd229c43).ae986fe8); app product build passed (2cc33f12); changed-files-only formatting andmake dev-lintpassed (54aea581). Provider-package sources were unchanged in this follow-up; prior 20-test package validation still applies.