Skip to content

feat(tui): event-driven background task sync and log viewer#108

Merged
yishuiliunian merged 2 commits intomainfrom
feat/bg-task-event-sync
Apr 15, 2026
Merged

feat(tui): event-driven background task sync and log viewer#108
yishuiliunian merged 2 commits intomainfrom
feat/bg-task-event-sync

Conversation

@yishuiliunian
Copy link
Copy Markdown
Contributor

Summary

  • Background tasks synced from agent to TUI via event-driven bridge (replacing empty local store)
  • Three lifecycle events: BgTaskSpawnedBgTaskOutput (2s delta) → BgTaskCompleted
  • Log viewer SubPage (Enter on focused bg task) with auto-follow scrolling

Changes

  • Protocol: BgTaskDetail, BgTaskSpawned/Output/Completed events
  • Store: SpawnNotification + subscribe_spawns() on BackgroundTaskStore
  • Bridge: bg_task_bridge.rs — per-task select! monitors in JoinSet
  • Session: bg_task_state.rs — incremental state machine with IndexMap
  • TUI: Log viewer SubPage, panel shows all tasks, removed bg_store dependency
  • Tests: 19 new tests across store/session/bridge layers

Test plan

  • bazel build //... passes
  • bazel build //... --config=clippy zero warnings
  • bazel build //... --config=rustfmt passes
  • bazel test — all 4 affected test targets pass
  • CI passes

@yishuiliunian yishuiliunian force-pushed the feat/bg-task-event-sync branch from 898898a to 504bfe2 Compare April 15, 2026 13:47
Background tasks were invisible in the TUI because the agent process
and TUI process had separate BackgroundTaskStore instances (noted as
"future: sync from agent via IPC" in multiprocess.rs).

Replace the polling-based reporter with event-driven sync matching the
ToolProgress pattern:

- BackgroundTaskStore emits SpawnNotification on insert, carrying Arc
  handles for per-task monitoring
- bg_task_bridge subscribes and spawns per-task select! monitors:
  output sampler (2s delta) + completion watcher (await watch_rx)
- Three protocol events: BgTaskSpawned, BgTaskOutput, BgTaskCompleted
- Session state builds incrementally from events (IndexMap for O(1))
- TUI reads from session state; panel shows all tasks; Enter opens
  full-screen log viewer SubPage with auto-follow

Removes TUI dependency on loopal-tool-background (bg_store was always
empty in the TUI process).
@yishuiliunian yishuiliunian force-pushed the feat/bg-task-event-sync branch from 504bfe2 to 79f200e Compare April 15, 2026 14:17
@yishuiliunian yishuiliunian merged commit a759ec4 into main Apr 15, 2026
4 checks passed
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.

1 participant