Skip to content

fix: ESC interrupt lost + background agent results not delivered to root#59

Merged
yishuiliunian merged 2 commits intomainfrom
fix/interrupt-and-bg-agent-delivery
Apr 1, 2026
Merged

fix: ESC interrupt lost + background agent results not delivered to root#59
yishuiliunian merged 2 commits intomainfrom
fix/interrupt-and-bg-agent-delivery

Conversation

@yishuiliunian
Copy link
Copy Markdown
Contributor

Summary

  • ESC interrupt silently stops working after first use due to duplicate AwaitingInput event resetting TUI's agent_idle flag
  • Background sub-agent completion results never reach root agent because start_agent_io lacks completion_tx channel
  • Both regressions introduced in c29b548 (agent state machine refactor)

Changes

  • runner.rs: Make transition() idempotent — skip event emission when already in target status
  • agent_io.rs: Create completion_tx + bridge in start_agent_io for root agent, matching sub-agent path
  • spawn_manager.rs: Export spawn_completion_bridge as pub
  • Diagnostic tracing added to interrupt signal chain (ESC → TUI → Session → Hub → forward_loop)

Test plan

  • bazel test //crates/loopal-runtime:loopal-runtime_test passes
  • bazel test //crates/loopal-tui:loopal-tui_test passes
  • bazel test //crates/loopal-agent-hub:loopal-agent-hub_test passes
  • CI passes

…d agent results not delivered to root

Two bugs introduced in c29b548 (agent state machine refactor):

1. ESC interrupt silently ignored after first use:
   `emit_interrupted()` sets status to WaitingForInput, then the loop's
   `transition(WaitingForInput)` emits a duplicate AwaitingInput event.
   The second event resets TUI's `agent_idle` to true even while the agent
   is executing tools, making all subsequent ESC presses no-ops.
   Fix: make `transition()` idempotent — skip emission when already in
   the target status.

2. Background sub-agent results never reach root agent:
   `start_agent_io` (root agent registration) called `register_connection`
   without a `completion_tx`. When background children finish, Hub's
   `prepare_parent_delivery` finds no channel and silently drops the result.
   Root agent blocks in `recv_input()` forever.
   Fix: create completion_tx + bridge in `start_agent_io`, matching the
   sub-agent path in `register_agent_connection`.

Also adds diagnostic tracing to the interrupt signal chain (ESC → TUI →
SessionController → Hub → forward_loop) for future debugging.
@yishuiliunian yishuiliunian merged commit 290f6f5 into main Apr 1, 2026
3 checks passed
yishuiliunian added a commit that referenced this pull request Apr 1, 2026
Introduce FocusMode enum (Input / AgentPanel) to replace implicit
conditional checks for agent panel navigation. Different modes produce
different key behaviors, and the agent list now scrolls when there are
more than 5 agents.

Key changes:
- FocusMode dispatches handle_normal_key into mode-specific handlers
- AgentPanel mode: Up/Down navigate agents, Enter drills in, Tab/Esc exit
- Typing auto-switches back to Input mode
- Scrollable agent list with ↑/↓ indicators
- Ctrl+P/N are mode-aware (agent nav in AgentPanel, history in Input)
- Stale focused_agent auto-recovers on re-entry
- 46 new test cases across 4 test files
yishuiliunian added a commit that referenced this pull request Apr 1, 2026
* feat: centralized FocusMode state machine for TUI input dispatch (#59)

Introduce FocusMode enum (Input / AgentPanel) to replace implicit
conditional checks for agent panel navigation. Different modes produce
different key behaviors, and the agent list now scrolls when there are
more than 5 agents.

Key changes:
- FocusMode dispatches handle_normal_key into mode-specific handlers
- AgentPanel mode: Up/Down navigate agents, Enter drills in, Tab/Esc exit
- Typing auto-switches back to Input mode
- Scrollable agent list with ↑/↓ indicators
- Ctrl+P/N are mode-aware (agent nav in AgentPanel, history in Input)
- Stale focused_agent auto-recovers on re-entry
- 46 new test cases across 4 test files

* fix: rustfmt — alphabetical module order in suite.rs, line wrapping
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