Repository navigation
[Fix] Context limit in task header stays stale when user switches provider mid-task and restores - #973
[Fix] Context limit in task header stays stale when user switches provider mid-task and restores#973ghost wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Review statusThanks for contributing. This comment tracks the review sequence and the next action. Current step: Resolve the merge conflicts. The review sequence resumes after the branch is mergeable. Review-state labels are managed by this workflow; do not edit them manually. |
|
This PR has been awaiting author changes for 14 days and will be automatically closed in 7 days. Please address the review comments or leave a comment if you need more time. |
|
Closing due to author inactivity after requested changes. Feel free to reopen once the requested changes have been addressed. |
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