You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: prevent UI flicker and enable resumption after task cancellation
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
0 commit comments