fix: ESC interrupt lost + background agent results not delivered to root#59
Merged
yishuiliunian merged 2 commits intomainfrom Apr 1, 2026
Merged
Conversation
…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
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
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
AwaitingInputevent resetting TUI'sagent_idleflagstart_agent_iolackscompletion_txchannelChanges
runner.rs: Maketransition()idempotent — skip event emission when already in target statusagent_io.rs: Createcompletion_tx+ bridge instart_agent_iofor root agent, matching sub-agent pathspawn_manager.rs: Exportspawn_completion_bridgeaspubTest plan
bazel test //crates/loopal-runtime:loopal-runtime_testpassesbazel test //crates/loopal-tui:loopal-tui_testpassesbazel test //crates/loopal-agent-hub:loopal-agent-hub_testpasses