Files
cleveragents-core/robot/tui_llm_dispatch.robot
hamza.khyari 652769c46c
CI / push-validation (pull_request) Successful in 31s
CI / helm (pull_request) Successful in 42s
CI / build (pull_request) Successful in 42s
CI / lint (pull_request) Successful in 1m6s
CI / quality (pull_request) Successful in 1m6s
CI / typecheck (pull_request) Successful in 1m12s
CI / security (pull_request) Successful in 1m25s
CI / integration_tests (pull_request) Successful in 3m17s
CI / unit_tests (pull_request) Successful in 4m37s
CI / docker (pull_request) Successful in 1m26s
CI / coverage (pull_request) Successful in 11m50s
CI / status-check (pull_request) Successful in 5s
feat(tui): wire normal text input to LLM via A2A facade
Wires the TUI normal text input path to the LLM via A2aLocalFacade,
closing the gap where typing a message produced no LLM call. All
infrastructure (facade, SessionWorkflow, ProviderRegistry) already
existed in the CLI; this PR adds the TUI wiring on top.

Key changes:
- _run_llm_dispatch(): module-level, Textual-free dispatch function
  covering all domain exception paths with user-friendly messages
- _format_worker_outcome(): testable worker result/error translator
- _create_tui_session(): DB-backed session with persona actor binding
- _build_tui_facade(): wired A2aLocalFacade + SessionWorkflow singleton
- run_worker(thread=True, exclusive=True): non-blocking, serialised
- _dispatch_gen counter: prevents cancelled worker callbacks from
  corrupting the multi-turn transcript
- SessionView.transcript: accumulated conversation history, pre-escaped
- Markup escaping: _escape() applied before transcript storage
- on_mount focus: prompt.focus() so keyboard input is received

Tests: 18 BDD scenarios + 6 Robot Framework integration tests with
FakeListLLM (no real API keys required).

ISSUES CLOSED: #11230
2026-05-22 15:12:04 +00:00

83 lines
3.6 KiB
Plaintext

*** Settings ***
Documentation Integration tests for TUI normal text input → A2A facade → LLM dispatch.
...
... Verifies that:
... - _create_tui_session() creates a real database-backed session
... - _build_tui_facade() produces a wired A2aLocalFacade
... - CleverAgentsTuiApp dispatches normal text to the facade
... and renders the assistant response
...
... Uses a FakeListLLM stub — no real API keys required.
Resource ${CURDIR}/common.resource
Suite Setup Setup Test Environment With Database Isolation
Suite Teardown Cleanup Test Environment
*** Variables ***
${HELPER} ${CURDIR}/helper_tui_llm_dispatch.py
*** Test Cases ***
TUI Create Session Returns Real Session ID
[Documentation] Verify _create_tui_session() creates a DB-backed session.
[Tags] tui_llm_dispatch
${result}= Run Process ${PYTHON} ${HELPER} create-session
... cwd=${WORKSPACE}
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} tui-create-session-ok
TUI Build Facade Returns Wired Facade
[Documentation] Verify _build_tui_facade() returns a non-None A2aLocalFacade.
[Tags] tui_llm_dispatch
${result}= Run Process ${PYTHON} ${HELPER} build-facade
... cwd=${WORKSPACE}
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} tui-build-facade-ok
TUI Normal Text Dispatches To Facade And Renders Response
[Documentation] Verify CleverAgentsTuiApp dispatches normal text to
... the facade and updates the conversation widget with the
... assistant response from a FakeListLLM.
[Tags] tui_llm_dispatch
${result}= Run Process ${PYTHON} ${HELPER} dispatch-message
... cwd=${WORKSPACE}
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} tui-dispatch-message-ok
TUI No Actor Error Renders Friendly Message
[Documentation] Verify that when no actor is configured,
... the TUI shows a friendly error rather than crashing.
[Tags] tui_llm_dispatch
${result}= Run Process ${PYTHON} ${HELPER} no-actor-error
... cwd=${WORKSPACE}
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} tui-no-actor-error-ok
TUI DatabaseError Renders Friendly Message
[Documentation] Verify _run_llm_dispatch returns a user-readable error
... string when a DatabaseError is raised during dispatch.
[Tags] tui_llm_dispatch
${result}= Run Process ${PYTHON} ${HELPER} database-error
... cwd=${WORKSPACE}
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} tui-database-error-ok
TUI SessionNotFoundError Renders Friendly Message
[Documentation] Verify _run_llm_dispatch returns a user-readable error
... string when the session is missing at dispatch time.
[Tags] tui_llm_dispatch
${result}= Run Process ${PYTHON} ${HELPER} session-not-found
... cwd=${WORKSPACE}
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} tui-session-not-found-ok