fix(kiro_cli): detect TUI Initializing... to prevent false IDLE (#211)#215
Merged
Merged
Conversation
The new Kiro CLI TUI renders the idle-prompt placeholder ("Ask a
question or describe a task") before the "● Initializing..." phase
completes. CAO's get_status() matched the placeholder and declared IDLE
~1s into launch, so the first user message was sent before Kiro could
accept input and was silently dropped.
Add TUI_INITIALIZING_PATTERN and check for it before the idle check in
get_status(). Unlike "Kiro is working" (which lingers as ghost text after
in-place redraws and needs position-aware handling), "Initializing..."
is always cleared once startup finishes, so its presence unconditionally
means PROCESSING.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
Author
|
@ci-duarte would you like to review ? |
carlosiduarte
approved these changes
Apr 28, 2026
carlosiduarte
left a comment
There was a problem hiding this comment.
Thanks for the quick fix! I was able to reproduce the false IDLE issue — the TUI renders the idle prompt placeholder before Initializing... completes, causing CAO to send the first message too early and the session to appear stuck. This fix correctly blocks IDLE detection while the initializing indicator is present. Tested locally and confirmed it works. 🙌
5 tasks
haofeif
added a commit
that referenced
this pull request
Apr 30, 2026
…220) (#221) Addresses issue #220. cao launch (non-headless) attached to the tmux session the moment the API returned, before the provider's TUI had finished wiring its input handler. The attach-time pty resize would then race with init and the TUI would silently drop keystrokes — most visible on profiles with many MCP servers where init takes longer. The headless-with-message path already waits via wait_until_terminal_status(IDLE/COMPLETED, timeout=120). This change mirrors that wait on the non-headless path. When the wait times out we still attach so the user can inspect a slow-initializing session rather than orphan it in tmux; a yellow warning is printed. With PR #215 (false-IDLE during Initializing...) already landed, this wait reliably blocks through init instead of returning early on the idle-prompt placeholder. Changes - src/cli_agent_orchestrator/cli/commands/launch.py: insert wait_until_terminal_status before subprocess.run(["tmux", "attach-session", ...]) with a warn-and-proceed fallback on timeout. - test/cli/commands/test_launch.py: add regression guards (test_launch_non_headless_waits_for_idle_before_attach, test_launch_non_headless_attaches_even_if_wait_times_out); update the four existing non-headless tests to patch wait_until_terminal_status and include the terminal id in their mocked API response. Verification - 21/21 test/cli/commands/test_launch.py - 1523 passed, 1 skipped under CI's ignore set - black --check and isort --check-only clean on touched files
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
Fixes #211. The new Kiro CLI TUI renders the idle-prompt placeholder (
Ask a question or describe a task) before the● Initializing...phase completes. CAO'sget_status()matched the placeholder and declaredIDLE~1s into launch, so the first user message was sent before Kiro could accept input — the message was silently dropped and the session appeared stuck.Root cause
get_status()had three processing-related checks:TUI_PROCESSING_PATTERN(Kiro is working) — position-aware (lingers as ghost text in buffer after in-place redraws).PROCESSING.Nothing covered the startup phase: the TUI paints the full layout (separator, agent header, idle-prompt line) while
Initializing...is still animating, so the naive idle match fires and the caller sees IDLE before Kiro is ready.Fix
Add
TUI_INITIALIZING_PATTERN = r"Initializing\.\.\."and check for it at the top ofget_status()— before any idle-prompt match. UnlikeKiro is working,Initializing...is always cleared by Kiro once startup completes, so its presence unconditionally meansPROCESSING. No position-aware logic needed.Failing session (before fix)
After fix
Changes
src/cli_agent_orchestrator/providers/kiro_cli.py:TUI_INITIALIZING_PATTERNconstant with a comment explaining the asymmetry withKiro is working.get_status(), add a pre-idle check: ifInitializing...is present anywhere in the buffer, returnPROCESSING.test/providers/test_kiro_cli_unit.py:test_tui_initializing_yields_processing_despite_idle_placeholder— reproduces issue fix(kiro_cli): false IDLE detection during TUI initialization #211: buffer containsInitializing...+ separator + idle-prompt placeholder, must returnPROCESSING.test_tui_initializing_cleared_allows_idle— onceInitializing...is gone, IDLE resolves normally.test_tui_initializing_pattern— pattern matches expected forms; rejects bareInitializing/Initializedto avoid false positives on agent output.Test plan
test/providers/test_kiro_cli_unit.pypasses (94 tests, +3 new)black --checkclean on changed filescao launchon a fresh kiro-cli 2.x session: first user message arrives after the real idle, not duringInitializing...