-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: prevent UI flicker and enable resumption after task cancellation #8986
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
Merged
Conversation
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
Problem: - Clicking Terminate during streaming caused the entire chat view to blink - Task would close, user pushed to home, then back into the task - Cancel → Resume flow would grey the Resume button but not restart the loop - Input would become disabled and messages couldn't be sent Root causes: 1. Hard abort (abandoned=true) was disposing the task instance immediately 2. Provider was rehydrating a new task instance from disk after abort 3. Abort flags stayed set (abort=true) preventing loop resumption 4. No deterministic spinner stopping on cancellation 5. Streaming state wasn't reset on resume Solution: - Soft-interrupt: Cancel now uses abortTask(false) to keep instance alive - No rehydration: Provider skips task recreation for user_cancelled aborts - Resume pipeline: Added presentResumableAsk() for in-place resume flow - Abort state reset: Clear abort flags and streaming state before resuming - Spinner determinism: Inject cancelReason into last api_req_started - Transactional UI: Pause state updates during checkpoint operations Changes: - Task.presentResumableAsk(): New method for soft-interrupt resume - Task.resumeTaskFromHistory(): Reset abort/streaming state after user confirms - Task.abortTask(): Distinguish soft (keep alive) vs hard abort (dispose) - ClineProvider.cancelTask(): Soft abort + schedule presentResumableAsk() - ClineProvider.onTaskAborted: Skip rehydration for user_cancelled - ChatView: Handle cancelReason for deterministic streaming state Tests: - Task.presentResumableAsk.abort-reset.spec.ts: Verify abort flag reset - ClineProvider.cancelTask.present-ask.spec.ts: Verify soft-interrupt flow - Task.spec.ts: Updated abort semantics (soft vs hard) Result: - No UI flicker or navigation on Cancel - Resume button successfully restarts the agent loop - Input remains enabled throughout cancel/resume cycle - Spinner stops deterministically on cancellation - Task history stable, no duplicate entries
Contributor
|
All previously identified issues have been resolved. No new issues found in the latest commit.
Previous ReviewsMention @roomote in a comment to trigger your PR Fixer agent and make changes to this pull request. |
The logic was inverted - when cost is defined in api_req_started, it means the API request has finished (streaming is complete), so should return false, not true.
When api_req_started exists without cost or cancelReason fields, the API request is still in progress and should be treated as streaming. Only return false when cost (completed) or cancelReason (cancelled) are present.
b8bafd1 to
ac57bd0
Compare
daniel-lxs
added a commit
that referenced
this pull request
Nov 3, 2025
…SON parsing - Extract duplicated abort/streaming state reset logic into private helper method resetAbortAndStreamingState() - Update resumeTaskFromHistory() and presentResumableAsk() to use the helper method - Replace unsafe JSON.parse() with safeJsonParse() in ClineProvider.ts for better error handling Addresses review feedback from @mrubens on PR #8986
…SON parsing - Extract duplicated abort/streaming state reset logic into private helper method resetAbortAndStreamingState() - Update resumeTaskFromHistory() and presentResumableAsk() to use the helper method - Replace unsafe JSON.parse() with safeJsonParse() in ClineProvider.ts for better error handling Addresses review feedback from @mrubens on PR #8986
mrubens
approved these changes
Nov 3, 2025
mini2s
added a commit
to zgsm-ai/costrict
that referenced
this pull request
Nov 4, 2025
Problem
Clicking Terminate during streaming caused several issues:
Root Causes
Solution
Soft-Interrupt Pattern
State Management
Changes
Core Logic
UI
Tests
Result
Testing Steps
Related Issues
Fixes the UI blink issue when terminating tasks during streaming.
Important
Implements soft-interrupt pattern and state management improvements to prevent UI flicker and enable task resumption after cancellation.
abortTask(false)to prevent task instance disposal on cancel.presentResumableAsk()inTask.tsfor in-place resume flow.cancelReasonintoapi_req_startedfor deterministic spinner stop.Task.presentResumableAsk()andTask.resumeTaskFromHistory()for task resumption.Task.abortTask()to distinguish between soft and hard aborts.ClineProvider.cancelTask()to handle soft aborts and schedulepresentResumableAsk().ChatView.tsxto handlecancelReasonfor streaming state management.Task.presentResumableAsk.abort-reset.spec.tsto verify abort flag reset.ClineProvider.cancelTask.present-ask.spec.tsto verify soft-interrupt flow.Task.spec.tsfor new abort semantics.This description was created by
for 1520618. You can customize this summary. It will automatically update as commits are pushed.