Skip to content

feat(tui): structured event bus for live attack monitoring#390

Merged
Nicola Franco (franconicola) merged 1 commit into
mainfrom
379-using-litellm-adapter-for-every-agent-type
May 23, 2026
Merged

feat(tui): structured event bus for live attack monitoring#390
Nicola Franco (franconicola) merged 1 commit into
mainfrom
379-using-litellm-adapter-for-every-agent-type

Conversation

@franconicola
Copy link
Copy Markdown
Member

The TUI previously regex-parsed stringified log lines to populate its Actions tab, which meant the panel was effectively dead (the matcher was never instantiated outside tests) and the per-attack progress bar was a 2-second time-based fake. The Tracker/StepTracker already produced structured events for the same data — they just never reached the TUI live.

This change wires a thread-safe TUIEventBus (subscribe/unsubscribe/ emit) end-to-end from HackAgent.hack(...) through orchestrator .execute(...) and TrackingCoordinator into Tracker and StepTracker, replaces the orphan _tui_app/_tui_log_callback parameters with _tui_event_bus, and has the Actions viewer subscribe to goal_started / goal_finalized / step_started / trace_added events. The progress bar now advances against real expected_total_ goals. The Logs viewer gains a structured _records buffer with per-level filters, case-insensitive search, and save-to-file. Dead code (actions_logger.py, views/dashboard.py, attach_tui_handler/ detach_tui_handler) is removed; HackAgentTUI.show_* notification helpers and action_refresh now actually work.

The TUI previously regex-parsed stringified log lines to populate its
Actions tab, which meant the panel was effectively dead (the matcher
was never instantiated outside tests) and the per-attack progress bar
was a 2-second time-based fake. The Tracker/StepTracker already
produced structured events for the same data — they just never reached
the TUI live.

This change wires a thread-safe `TUIEventBus` (subscribe/unsubscribe/
emit) end-to-end from `HackAgent.hack(...)` through `orchestrator
.execute(...)` and `TrackingCoordinator` into `Tracker` and
`StepTracker`, replaces the orphan `_tui_app`/`_tui_log_callback`
parameters with `_tui_event_bus`, and has the Actions viewer subscribe
to `goal_started` / `goal_finalized` / `step_started` / `trace_added`
events. The progress bar now advances against real `expected_total_
goals`. The Logs viewer gains a structured `_records` buffer with
per-level filters, case-insensitive search, and save-to-file. Dead
code (`actions_logger.py`, `views/dashboard.py`, `attach_tui_handler`/
`detach_tui_handler`) is removed; `HackAgentTUI.show_*` notification
helpers and `action_refresh` now actually work.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@franconicola Nicola Franco (franconicola) linked an issue May 23, 2026 that may be closed by this pull request
with tracker.track_step("Failing", "STEP_X"):
raise RuntimeError("boom")

assert len(received) == 1
path = v.save_logs_to_file()
assert path is not None
assert path.startswith(str(tmp_path))
content = open(path).read()
def _on_event(event: Any) -> None:
try:
app.call_from_thread(self._handle_event, event)
except Exception:
Comment thread hackagent/cli/tui/app.py
if hasattr(descendant, "refresh_data"):
descendant.refresh_data()
return
except Exception:
return
try:
subs.remove(callback)
except ValueError:
try:
log_widget = self.query_one("#attack-log-display", RichLog)
log_widget.clear()
except Exception:
@franconicola Nicola Franco (franconicola) merged commit fedf9cc into main May 23, 2026
23 checks passed
@franconicola Nicola Franco (franconicola) deleted the 379-using-litellm-adapter-for-every-agent-type branch May 23, 2026 19:42
@codecov
Copy link
Copy Markdown

codecov Bot commented May 23, 2026

Codecov Report

❌ Patch coverage is 53.12500% with 30 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
hackagent/router/tracking/step.py 48.57% 18 Missing ⚠️
hackagent/attacks/orchestrator.py 35.71% 9 Missing ⚠️
hackagent/router/tracking/tracker.py 78.57% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

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.

Using LiteLLM adapter for every agent type

1 participant