Skip to content

refactor(tui): inject dependencies into EventHandlerRegistry instead of app reference#1000

Merged
Kohei-Wada merged 1 commit into
mainfrom
refactor/772-event-handler-di
Jun 6, 2026
Merged

refactor(tui): inject dependencies into EventHandlerRegistry instead of app reference#1000
Kohei-Wada merged 1 commit into
mainfrom
refactor/772-event-handler-di

Conversation

@Kohei-Wada
Copy link
Copy Markdown
Owner

Summary

Removes the tight coupling between EventHandlerRegistry / WebSocketHandler and the TaskdogTUI app class by injecting individual callables instead of the whole app instance. This aligns these services with the dependency-injection style already used by TaskUIManager.

Closes #772.

Changes

  • event_handler_registry.py: drop the app parameter; inject notify, reload_tasks, set_client_id, get_client_id. Add a NotifyFn Protocol for the notify signature. The _reload_tasks method 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 an app reference.
  • app.py: wire the callables when constructing WebSocketHandler (get_client_id is lambda: self.api_client.client_id).
  • tests: inject mock callables instead of mock_app; remove the obsolete task_ui_manager is None test (the registry no longer touches task_ui_manager).

Deviation from the proposal

The proposed schedule_fn (for call_later) is not injected: the registry never calls call_later, so adding it would be dead weight.

Verification

  • grep -r "self\.app" .../event_handler_registry.py → 0 matches
  • grep -r "self\.app" .../websocket_handler.py → 0 matches
  • make check → passed (lint + typecheck + codespell + vulture)
  • make test-ui → 1095 passed

…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
Copy link
Copy Markdown

@amazon-q-developer amazon-q-developer Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Kohei-Wada Kohei-Wada merged commit 87c47b5 into main Jun 6, 2026
15 checks passed
@Kohei-Wada Kohei-Wada deleted the refactor/772-event-handler-di branch June 6, 2026 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(tui): inject dependencies into EventHandlerRegistry instead of app reference

1 participant