Skip to content

TUI Mode Support for kiro_cli Provider #159

@ianamazon

Description

@ianamazon

Description

The kiro_cli provider's status detection doesn't work with kiro-cli's --tui mode (the new default UI). The provider relies on regex patterns that match the legacy terminal UI prompt format ([agent-name] >), but the TUI renders a completely different layout using Ink/React.

This means CAO users must pass --legacy-ui to kiro-cli for agent orchestration to work, which will become a problem as kiro-cli moves toward TUI as the default.

Current behavior

When kiro-cli launches with --tui, the provider's get_status() never detects IDLE because the TUI prompt doesn't match the legacy pattern:

# Current pattern (legacy UI)
self._idle_prompt_pattern = rf"\[{re.escape(self._agent_profile)}\]\s*(?:\d+%\s*)?(?:\u03bb\s*)?!?>\s*"

The initialize() method times out after 120 seconds waiting for a status it can never detect.

TUI terminal output patterns

I captured the TUI's terminal output via tmux capture-pane and found reliable, parseable patterns:

Idle state:

────────────────────────────────────────────────────
agent-name · model-name · ◔ 3%              ~/path · (branch)

 Ask a question or describe a task ↵  ctrl+g: agent monitor

After a response (completed):

────────────────────────────────────────────────────
  user message here

  Agent's response here.

▸ Credits: 0.24 • Time: 3s

────────────────────────────────────────────────────
agent-name · model-name · ◔ 3%              ~/path · (branch)

 Ask a question or describe a task ↵  ctrl+g: agent monitor

Processing (no idle prompt visible):
The Ask a question or describe a task text disappears while the agent is thinking.

Proposed fix

Add TUI-aware status detection alongside the existing legacy patterns. Auto-detect which mode is active on the first get_status() call.

New patterns needed:

TUI_IDLE_PROMPT_PATTERN = r"Ask a question or describe a task"
TUI_CREDITS_PATTERN = r"▸ Credits:"

Status detection logic for TUI:

  • IDLE: TUI_IDLE_PROMPT_PATTERN is present, no TUI_CREDITS_PATTERN
  • PROCESSING: TUI_IDLE_PROMPT_PATTERN is absent
  • COMPLETED: TUI_CREDITS_PATTERN is present AND TUI_IDLE_PROMPT_PATTERN appears after it
  • WAITING_USER_ANSWER: Permission prompt pattern (same as legacy) with no idle prompt after it

Message extraction for TUI:
The response text is between the last separator line (────) and the ▸ Credits: line. The user's message is the first paragraph after the separator, the response is everything after the first double-newline.

Auto-detection:

# In __init__
self._tui_mode = None  # auto-detect

# In get_status
if self._tui_mode is None:
    self._tui_mode = bool(re.search(TUI_IDLE_PROMPT_PATTERN, clean_output))

This is backward-compatible — existing --legacy-ui users are unaffected. The detection is based on terminal output, not CLI flags, so it works regardless of how kiro-cli is launched.

Workaround

Pass --legacy-ui to kiro-cli via the CAO_KIRO_CLI wrapper:

#!/bin/bash
exec kiro-cli "$@" --trust-all-tools --legacy-ui

Environment

  • kiro-cli 1.29.0+
  • CAO (latest from pip/uvx)
  • macOS, tmux 3.6

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

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