Fix DirectoryWidget freeze when cancelling workers#110
Merged
Conversation
- Add raw JSON content to error logs when parsing fails - Initialize json_content variable to prevent unbound variable errors - Clarify router prompt to emphasize /code command usage
…targeted cancellation - Introduce `launched_workers` list to keep references of active workers - Replace `workers.cancel_all()` with selective cancellation of tracked workers - Clean up finished workers from the list on state change - DirectoryTree widget was being frozen from `workers.cancel_all()` as the tree has a worker watching the tree
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.
Overview
This pull request resolves a critical bug in the Textual UI where the DirectoryWidget would become unresponsive after cancelling running tasks. The issue stemmed from the global
workers.cancel_all()call inadvertently affecting UI components. The fix introduces targeted worker management, ensuring only application-level workers are cancelled while preserving UI responsiveness.What This Means for Users
Users can now safely cancel long-running operations without the file browser locking up. Previously, hitting the stop button could leave the directory tree in an unusable state; the interface now remains fully interactive after cancellation.
A Closer Look at the Changes
Worker lifecycle management
launched_workers: List[Worker]to track only the workers created by the application.workers.cancel_all()with a targeted loop that cancels only workers inlaunched_workers.SUCCESS,ERROR, orCANCELLED), preventing memory leaks.Minor refinements
/codeshould be used for any code generation or editing.Generated by JrDev AI using moonshotai/kimi-k2