refactor(tui): inject dependencies into EventHandlerRegistry instead of app reference#1000
Merged
Merged
Conversation
…app reference Replace the TaskdogTUI app reference in EventHandlerRegistry and WebSocketHandler with individual callables (notify, reload_tasks, set_client_id, get_client_id), removing tight coupling to the App class and aligning with the dependency-injection style already used by TaskUIManager. The schedule_fn (call_later) callable from the proposal is omitted: the registry never uses call_later, so injecting it would be dead weight. Closes #772
There was a problem hiding this comment.
The refactoring successfully decouples EventHandlerRegistry and WebSocketHandler from the TaskdogTUI app class by injecting specific callables. The dependency injection pattern is correctly implemented across all files, tests are properly updated, and the changes maintain functional correctness. No defects blocking merge identified.
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
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.
Summary
Removes the tight coupling between
EventHandlerRegistry/WebSocketHandlerand theTaskdogTUIapp class by injecting individual callables instead of the whole app instance. This aligns these services with the dependency-injection style already used byTaskUIManager.Closes #772.
Changes
event_handler_registry.py: drop theappparameter; injectnotify,reload_tasks,set_client_id,get_client_id. Add aNotifyFnProtocol for the notify signature. The_reload_tasksmethod is replaced by the injected callable of the same name.websocket_handler.py: accept the same four callables and forward them to the registry; no longer holds anappreference.app.py: wire the callables when constructingWebSocketHandler(get_client_idislambda: self.api_client.client_id).mock_app; remove the obsoletetask_ui_manager is Nonetest (the registry no longer touchestask_ui_manager).Deviation from the proposal
The proposed
schedule_fn(forcall_later) is not injected: the registry never callscall_later, so adding it would be dead weight.Verification
grep -r "self\.app" .../event_handler_registry.py→ 0 matchesgrep -r "self\.app" .../websocket_handler.py→ 0 matchesmake check→ passed (lint + typecheck + codespell + vulture)make test-ui→ 1095 passed