[Fix] Context limit in task header stays stale when user switches provider mid-task and restores#973
Draft
zoomote[bot] wants to merge 1 commit into
Draft
[Fix] Context limit in task header stays stale when user switches provider mid-task and restores#973zoomote[bot] wants to merge 1 commit into
zoomote[bot] wants to merge 1 commit into
Conversation
Contributor
Author
This was referenced Jul 21, 2026
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Related GitHub Issue
Closes: #970
Description
The task header's context-usage bar derives its context-window denominator from the live global
apiConfiguration, while the token numerator comes from the task's persisted messages. On the stop → switch provider → restore flow,createTaskWithHistoryItemunconditionally reactivated the provider profile stored inHistoryItem.apiConfigName, silently reverting the provider switch the user had just made. The header then kept dividing by the old provider's context window (e.g., 128k) against the accumulated token count, so the limit never updated and the bar could exceed 100%.The fix is a single guard in
createTaskWithHistoryItem: when restoring a task, if the user's currently active provider profile differs from the history item's stale sticky profile, the current profile is kept (no reactivation) and the history item'sapiConfigNameis corrected so the new selection persists on the next save. When the profiles match, the original restore path runs unchanged. The webview needs no change — the bar followsapiConfigurationautomatically once restore stops reverting it.Test Procedure
ClineProvider.sticky-profile.spec.ts: new regression test verifies that restoring a task whose saved profile differs from the current profile does not reactivate the stale profile and updates the sticky name to the current one; a companion test verifies the restore path still runs when the profiles match. Existing restore-path tests (mode override, missing profile, failing profile, empty profile) were kept intact by aligning their fixtures with the seeded current profile.pnpm testpasses (full monorepo suite),pnpm lintandpnpm check-typespass.Pre-Submission Checklist
Screenshots / Videos
No UI components were modified; this is an extension-host behavior fix. The header bar updates as a consequence of the provider profile no longer being reverted on restore.
Documentation Updates
Related PRs
Additional Notes
The same guard also covers checkpoint restore and parent-task resume after subtasks, since both flow through
createTaskWithHistoryItem— consistent with the "current profile wins on restore" semantics.Get in Touch
Reachable via the linked Roomote task or GitHub mentions.
Linked work items
Closes #970