Skip to content

Latest commit

 

History

History
76 lines (50 loc) · 3.06 KB

File metadata and controls

76 lines (50 loc) · 3.06 KB

TUI Client (llm-tui)

llm-tui is a terminal client for LocalScript, built with Rust, Ratatui, and Crossterm. It renders a generation session as a chat interface and lets you drive the full plan → code → done workflow without writing curl commands.


Table of Contents


Running the TUI

With the full stack up (see Quick Start):

docker compose run --rm --no-deps -it llm-tui

Locally (requires llm-service running):

cd llm-tui
LLM_SERVICE_URL=http://localhost:8080 cargo run

The TUI connects to the URL in the LLM_SERVICE_URL environment variable (default http://localhost:8080). It sends each user message as a POST /generate request — the first message creates the session, subsequent ones continue it with the returned session_id.


Key bindings

Key Action
Enter Submit the current input line.
Esc / Ctrl+C / Ctrl+Q Quit the TUI.
Backspace Delete the last character.
F3 Copy the last generated code to the clipboard and export it to files (see below).
F4 Cancel the in-flight request, or reset the session if idle.
/ Scroll the message history.
Paste Bracketed paste is supported (newlines/tabs are collapsed to spaces).

Workflow

  1. Enter a task. Type your natural-language description and press Enter. The TUI sends it and, when the plan arrives, displays it and transitions to the awaiting-plan state.
  2. Approve or revise the plan. Send an approval word (e.g. approve) to move to code generation, or type revision feedback to get an updated plan.
  3. Approve or revise the code. The validated code is shown together with any sandbox_feedback. Send подтвердить to complete the session, or type revision feedback for another iteration.
  4. Done. The session shows the final approved code.

The status bar shows the current session state and whether a request is in flight. Input is disabled while a request is loading.


Exporting generated code

Pressing F3 (Copy Last Code):

  1. Copies the latest generated code to the system clipboard (arboard).
  2. Writes it to:
    • /app/exports/llm_last_code.lua — the raw Lua source.
    • /app/exports/llm_last_code.json — the source wrapped for the LowCode import format: {"result": "lua{...}lua"} with indentation normalized to tabs.

When running under Docker, ./exports on the host is bind-mounted to /app/exports inside the container, so the files appear in your project's exports/ directory.


Logging

The TUI writes structured logs to llm-tui.log in the current working directory (created automatically). The default level is info; override with the RUST_LOG environment variable. Logs include each HTTP request and response shape (task length, plan length, state, etc.), which is useful for debugging a session.