feat(tui): implement tool call expand states (5 modes) #1219

Closed
hurui200320 wants to merge 1 commits from feature/m8-tui-tool-call-expand into master

1 Commits

Author SHA1 Message Date
hurui200320 4ea39aa873 feat(tui): implement tool call expand states (5 modes)
CI / lint (pull_request) Successful in 23s
CI / quality (pull_request) Successful in 1m7s
CI / security (pull_request) Successful in 1m7s
CI / build (pull_request) Successful in 15s
CI / helm (pull_request) Successful in 22s
CI / typecheck (pull_request) Successful in 3m57s
CI / coverage (pull_request) Failing after 2s
CI / unit_tests (pull_request) Successful in 6m20s
CI / docker (pull_request) Successful in 1m38s
CI / e2e_tests (pull_request) Successful in 17m12s
CI / integration_tests (pull_request) Successful in 21m24s
CI / status-check (pull_request) Failing after 1s
CI / benchmark-publish (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Successful in 54m55s
Implement the tools.expand TUI setting per the specification
(§ Conversation Block Details > Tool Call States).  The new
ToolCallBlock presentation model supports a 4-state visual
state machine (pending, completed-collapsed, completed-expanded,
failed) driven by a 5-value ToolExpandMode enum (never, always,
success, fail, both).

Key design decisions:
- ToolExpandMode (StrEnum) with default FAIL, matching the
  specification choices setting (type: choices, default: fail).
- ToolCallSetting frozen dataclass captures the schema descriptor
  for tools.expand (key, type, default, choices, description).
- should_auto_expand() pure function encapsulates the expand
  decision logic, including kind:"read" suppression (read-kind
  tool calls never auto-expand regardless of mode).  Explicit
  exhaustiveness guard raises ValueError for unhandled modes.
- ToolCallBlock dataclass manages state transitions via
  complete(), fail(), and toggle() methods with strict argument
  validation and state guards.  Not thread-safe; intended for
  single-threaded (UI-thread) use only.
- Rendering helpers (indicator, chevron, render_header, render)
  produce the specification visual indicators.

Tests:
- 60 Behave scenarios covering all 5 modes, read suppression,
  manual toggle, error handling, and rendering.
- 3 Robot integration tests verifying end-to-end lifecycle,
  five-mode behavior, and render output correctness.
- Overall coverage: 97%, tool_call_block.py at 99%.

ISSUES CLOSED: #1000
2026-04-02 08:24:18 +00:00