Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Nov 4, 2025

Fixes the jarring UI flicker that occurs when cancelling a task.

Problem

When cancelling a task, Task.dispose() caused the UI to briefly navigate to the home view before returning to the task, creating a jarring user experience.

Root Cause

The issue was in ClineProvider.createTaskWithHistoryItem() which always called removeClineFromStack() first, causing the task stack to be temporarily empty and triggering the home view.

Solution

  • Detection Logic: Added check for currentTask taskId === historyItem.id to identify task rehydration
  • In-Place Replacement: When rehydrating the current task, replace it directly in the stack instead of removing first
  • Event Cleanup: Properly clean up old event listeners and set up new ones
  • Backward Compatibility: Normal task creation flow unchanged

Changes

  • Modified ClineProvider.createTaskWithHistoryItem() to detect rehydration scenarios
  • Implemented flicker-free in-place task replacement
  • Added comprehensive unit tests in ClineProvider.flicker-free-cancel.spec.ts

Testing

  • ✅ All existing tests pass (32 passed, 4 skipped)
  • ✅ New flicker-free cancel tests pass (4/4)
  • ✅ Type checking passes
  • ✅ Linting passes

User Experience

Before: Cancel → Home flicker → Task view
After: Cancel → Seamless task rehydration

- Modify ClineProvider.createTaskWithHistoryItem() to detect when rehydrating current task
- Implement in-place task replacement to avoid empty stack state that causes UI flicker
- Add comprehensive unit tests for flicker-free cancel behavior
- Maintain backward compatibility and proper event listener cleanup

Fixes the jarring navigation to home view when cancelling tasks
@daniel-lxs daniel-lxs requested review from cte, jr and mrubens as code owners November 4, 2025 22:21
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. UI/UX UI/UX related or focused labels Nov 4, 2025
@roomote
Copy link

roomote bot commented Nov 4, 2025

See this task on Roo Code Cloud

Code Review Complete ✅

No issues found. The implementation correctly addresses the UI flicker during task cancellation through in-place task replacement. Event listeners are properly managed, and comprehensive tests verify all scenarios.

Previous Reviews

Mention @roomote in a comment to trigger your PR Fixer agent and make changes to this pull request.

… rehydration

- Call abortTask(true) on old task before replacement to stop processes and mark as abandoned
- This ensures proper cleanup and prevents memory leaks during task cancellation
- Add test verification for abortTask cleanup
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Nov 4, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Nov 4, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Nov 4, 2025
@hannesrudolph hannesrudolph added PR - Needs Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Nov 4, 2025
@mrubens mrubens merged commit e25b4e6 into main Nov 5, 2025
18 checks passed
@mrubens mrubens deleted the fix/flicker-free-task-cancel branch November 5, 2025 02:40
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Nov 5, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Nov 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer PR - Needs Review size:L This PR changes 100-499 lines, ignoring generated files. UI/UX UI/UX related or focused

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants