Skip to content

kiro_cli TUI: input unresponsive when tmux attach runs before kiro finishes initializing #220

@carlosiduarte

Description

@carlosiduarte

Problem

When launching a session with cao launch (non-headless), tmux attach-session is called immediately after the session is created, before kiro CLI TUI has finished initializing its input handler.

This causes keystrokes to be silently dropped — the TUI appears responsive visually but does not accept any input. The issue is most noticeable on agents with many MCP servers (longer init time).

Root Cause

In cli/commands/launch.py, the non-headless path does:

if not headless:
    subprocess.run(["tmux", "attach-session", "-t", terminal["session_name"]])

The headless path already uses wait_until_terminal_status(IDLE/COMPLETED, timeout=120) before sending a message, but the non-headless path has no equivalent wait.

When the user attaches while kiro is still initializing, tmux resizes the pty and kiro's input handler ends up in a broken state.

Fix

Add wait_until_terminal_status before tmux attach-session in the non-headless path:

if not headless:
    wait_until_terminal_status(
        terminal["id"],
        {TerminalStatus.IDLE, TerminalStatus.COMPLETED},
        timeout=120,
    )
    subprocess.run(["tmux", "attach-session", "-t", terminal["session_name"]])

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions