Unreleased
Generated from the docstrings of Tau 0.16.0-dev (commit c439c401) by scripts/api_docs.py in the Tau repository. Not the 0.15 API.
The terminal UI¶
tau.tui: the Textual app tau opens, which a program can embed or drive, and the picture of the session it draws from.
Names: tui.FormingCall, tui.Holder, tui.LiveLayer, tui.SessionPicker, tui.SessionView, tui.Switch, tui.TauApp, tui.TauDialog
tau.tui.FormingCall¶
@dataclass
class FormingCall
id: str
tool: str
args: str = ''
A call the model is still writing: its provider id, the tool and the args text so far
(args_raw once it is a node).
tau.tui.Holder¶
@dataclass(frozen=True)
class Holder
state: str
detail: str = ''
Who has a session, as the picker shows it: a state (served: a live tau serve, which
opening attaches to; current: this very session; in use: another process holds its lease;
no reply: a serve record whose server did not answer hello) and the detail that says
more.
tau.tui.Holder.pickable¶
property pickable: bool
Whether opening it can work: not a session in use, nor one whose server is silent.
tau.tui.LiveLayer¶
@dataclass
class LiveLayer
at: int | None = None
text: str = ''
thinking: str = ''
calls: dict[int, FormingCall] = field(default_factory=lambda: {})
progress: dict[tuple[int, str], str] = field(default_factory=lambda: {})
retrying: Retrying | None = None
What a watched cursor's sample has said and the tree does not hold yet: the reply's text
and thinking so far, the calls forming (by their index in the reply), and each running
call's progress output keyed by (node, call_id). retrying is the Retrying the provider
last said, until the sample says anything else or ends. at is the cursor's node when the
first delta arrived: the layer is drawn over it.
tau.tui.LiveLayer.empty¶
property empty: bool
Whether there is nothing to draw.
tau.tui.LiveLayer.drop_reply¶
def drop_reply(self) -> None
Forget the reply's text, thinking and calls (the node arrived, or the step ended).
tau.tui.SessionPicker¶
class SessionPicker(TauDialog[SessionInfo | None])
AGE_WIDTH = 5
STATE_WIDTH = 6
CWD_WIDTH = 26
MIN_TITLE_WIDTH = 20
scope: reactive[Literal['here', 'all']] = reactive('here', init=False)
filter_text: reactive[str] = reactive('', init=False)
Pick a saved session, newest first. rows are tau.list_sessions of the sessions
directory (all of them); here is the working directory the "this directory" scope keeps
(rows with an error are always listed); held says who holds some of the sessions, by id
(session_holders): served, current, in use, no reply. Tab toggles this directory
and all; / filters; Enter picks; Esc leaves the filter, then cancels. Dismissed with the
row, or None. A row with an error, one in use or one whose server does not answer cannot
be picked: the status line says why. The current session can be (it dismisses
with its row; the caller does nothing).
tau.tui.SessionPicker.init¶
def __init__(
self,
rows: Sequence[SessionInfo],
here: Path,
*,
held: Mapping[str, Holder] | None = None,
scope: Literal['here', 'all'] = 'here',
title: str | None = None,
) -> None
tau.tui.SessionPicker.on_mount¶
def on_mount(self) -> None
List the rows and put the keyboard on the table.
tau.tui.SessionPicker.shown¶
def shown(self) -> list[SessionInfo]
The rows the scope and the filter admit, newest first.
tau.tui.SessionPicker.watch_scope¶
def watch_scope(self) -> None
The scope changed: list again.
tau.tui.SessionPicker.watch_filter_text¶
def watch_filter_text(self) -> None
The filter changed: list again.
tau.tui.SessionPicker.on_resize¶
def on_resize(self) -> None
The table's width changed: the title column takes what is left.
tau.tui.SessionPicker.action_toggle_scope¶
def action_toggle_scope(self) -> None
Tab: this directory, or every directory.
tau.tui.SessionPicker.action_focus_filter¶
def action_focus_filter(self) -> None
/: type a filter.
tau.tui.SessionPicker.on_input_changed¶
def on_input_changed(self, event: Input.Changed) -> None
Typing in the filter narrows the rows.
tau.tui.SessionPicker.on_input_submitted¶
def on_input_submitted(self, event: Input.Submitted) -> None
Enter in the filter returns to the list: picking is a second, deliberate Enter, so a half-typed filter never opens whatever sorts first.
tau.tui.SessionPicker.on_data_table_row_highlighted¶
def on_data_table_row_highlighted(self, event: DataTable.RowHighlighted) -> None
Say which session the highlighted row is, or why it cannot be opened.
tau.tui.SessionPicker.on_data_table_row_selected¶
def on_data_table_row_selected(self, event: DataTable.RowSelected) -> None
Enter on a row: pick its session, unless it cannot be opened.
tau.tui.SessionView¶
class SessionView
What the session's stream has told one client. Feed it every event, in order, with hear;
read views, gone, labels, nodes, live and notices. It makes no call and keeps no
widget: tau.tui.TauApp renders from it.
tau.tui.SessionView.init¶
def __init__(self) -> None
tau.tui.SessionView.hear¶
def hear(self, event: Event) -> None
Take one event into the picture.
tau.tui.SessionView.forget_live¶
def forget_live(self, cursor: int) -> None
Drop cursor's live layer: the client stopped watching it, so what the layer holds
would be heard again, from the start, if it is watched again.
tau.tui.SessionView.labels_of¶
def labels_of(self, cursor: int) -> tuple[str, ...]
The labels on cursor, in label order.
tau.tui.SessionView.path¶
def path(self, tip: int, at: int) -> list[Node] | None
The nodes after tip down to at, oldest first, if at descends from tip through
nodes this view holds ([] when they are the same node). None if it does not, or a node
on the way was never carried: the caller reads walk(at) instead.
tau.tui.Switch¶
@dataclass(frozen=True)
class Switch
session: str | None
served: bool = False
Where the person asked to go: the session id to open, or None for a new session.
served says that a live tau serve holds it, so the extensions and options of this run do
not carry (the server's are loaded already).
tau.tui.TauApp¶
class TauApp(App[None])
CSS_PATH = 'tau.tcss'
COMMANDS: ClassVar[set[type[Provider] | Callable[[], type[Provider]]]] = {TauCommands}
BINDINGS: ClassVar[list[BindingType]] = [Binding('escape', 'abort', 'Abort', show=False), Binding('ctrl+c', 'interrupt', 'Abort / quit', show=False, priority=True), Binding('ctrl+q', 'quit', 'Quit', show=False, priority=True), Binding('ctrl+r', "fold('thinking')", 'Fold thinking', show=False), Binding('ctrl+t', "fold('tools')", 'Fold tool boxes', show=False), Binding('alt+left', "move('previous')", 'Previous cursor', show=False), Binding('alt+right', "move('next')", 'Next cursor', show=False), Binding('ctrl+g', "move('tree')", 'The tree', show=False), Binding('ctrl+o', "move('sessions')", 'Sessions', show=False), Binding('ctrl+n', "move('new')", 'New session', show=False), Binding('ctrl+up', "scroll('up')", 'Scroll up', show=False), Binding('ctrl+down', "scroll('down')", 'Scroll down', show=False)]
The terminal UI of one session, over client, viewing cursor.
welcome is the server's (or the local start's) answer: the session id and working directory
the header shows (None for a session kept in memory, whose header shows cwd, the directory
it works in). snapshot are the events the client's
stream already gave up (Opened.snapshot); a client whose stream has not been read needs
none. theme names one of the themes (None: the default); user themes are read from
home, which is TAU_HOME. reconnect, for a remote client, makes a new client with the
same id; without it a stream that ends in ConnectionError ends the app's session: the
failure is shown, the transcript stays readable and return_code is 1 once the person quits.
The keys: Enter sends, Ctrl+J starts a new line, Tab completes, Esc aborts the cursor's step
(or declines the question the keyboard is in), Ctrl+C aborts if busy, else clears the draft,
else quits when pressed twice, Ctrl+R folds the thinking and Ctrl+T the tool boxes, Ctrl+Q
quits. / starts a command; one missing arguments opens a form for them.
tau.tui.TauApp.init¶
def __init__(
self,
client: Client,
cursor: int,
*,
welcome: Welcome | None,
home: Path,
cwd: Path,
snapshot: Sequence[Event] = (),
theme: str | None = None,
reconnect: Callable[[], Awaitable[Client]] | None = None,
sessions: Path | None = None,
) -> None
tau.tui.TauApp.compose¶
def compose(self) -> ComposeResult
The screen, top to bottom: header, cursor bar, transcript, open questions, pending lines, popup and editor, status bar.
tau.tui.TauApp.draft¶
property draft: str
The text in the editor.
tau.tui.TauApp.restore_draft¶
def restore_draft(self, text: str) -> None
Give the editor back a line that was not used.
tau.tui.TauApp.focus_editor¶
def focus_editor(self) -> None
Put the keyboard in the editor.
tau.tui.TauApp.complete_value¶
async def complete_value(self, schema: Json, text: str) -> list[str]
What could finish text as a value of schema (a question's answer).
tau.tui.TauApp.toast¶
def toast(
self,
text: str,
*,
title: str = '',
severity: SeverityLevel = 'information',
timeout: float = 5,
) -> None
Show a toast, and keep it in toasts.
tau.tui.TauApp.screen_text¶
def screen_text(self) -> str
What the screen says, without its styling: the header, the cursor bar, the transcript, the open questions, the pending lines, the popup and the status bar.
tau.tui.TauApp.view¶
async def view(self, cursor: int) -> None
View cursor, an open one: watch it (and so stop hearing the last one's Live), read
its walk again and show its state. LookupError for a cursor that is not open.
tau.tui.TauApp.action_abort¶
async def action_abort(self) -> None
Abort the viewed cursor's step (it declines the questions it has open).
tau.tui.TauApp.action_interrupt¶
async def action_interrupt(self) -> None
Ctrl+C: abort if busy, else clear the draft, else quit when pressed twice.
tau.tui.TauApp.action_quit¶
async def action_quit(self) -> None
Leave. The exit status is 1 if the session was lost.
tau.tui.TauApp.action_move¶
def action_move(self, what: str) -> None
Alt+Left, Alt+Right, Ctrl+Z, Ctrl+G, Ctrl+O, Ctrl+N: a move (tau.tui._moves), a task
of its own because it may ask a question.
tau.tui.TauApp.action_scroll¶
def action_scroll(self, direction: str) -> None
Ctrl+Up, Ctrl+Down: a page of the transcript; against its edge, the render window slides a turn.
tau.tui.TauApp.action_fold¶
def action_fold(self, what: str) -> None
Fold or unfold the thinking regions, or the tool boxes.
tau.tui.TauDialog¶
class TauDialog(ModalScreen[_T])
DIALOG_ID: ClassVar[str] = 'tau-dialog'
TITLE_TEXT: ClassVar[str] = ''
CANCEL_VALUE: ClassVar[Any] = None
BODY_ID: ClassVar[str | None] = None
BINDINGS: ClassVar[list[BindingType]] = [Binding('escape', 'cancel', 'Cancel', show=False)]
A centred modal with a title, a body, and escape meaning cancel.
Subclasses supply :meth:compose_body and, usually, :attr:TITLE_TEXT. What
they do NOT supply is the shell, the centering, the title styling or the cancel
binding — those are the things every dialog agreed on by accident before, and
the things a new dialog now gets without asking.
Attributes:
DIALOG_ID: The shell's widget id. Carries the two properties that genuinely
differ between dialogs (width, height); everything else comes
from the tau-dialog class.
TITLE_TEXT: The title, for a dialog whose title never varies. A dialog whose
title is supplied per instance passes it to __init__ instead.
CANCEL_VALUE: What escape dismisses with. None for a dialog returning
an optional value, False for a confirmation — a cancelled question is
never a hidden yes.
BODY_ID: Set it to give the dialog a scrolling body with that id between a
header (the title plus :meth:compose_header) and a footer
(:meth:compose_footer), both pinned, so the buttons stay on screen
however long the body is . None keeps the
plain stack.
tau.tui.TauDialog.init¶
def __init__(self, title: str | None = None) -> None
tau.tui.TauDialog.dialog_title¶
def dialog_title(self) -> str
The text of the title row.
tau.tui.TauDialog.compose_body¶
def compose_body(self) -> ComposeResult
Everything between the title and the bottom of the shell.
tau.tui.TauDialog.compose_header¶
def compose_header(self) -> ComposeResult
What stays pinned under the title when :attr:BODY_ID is set.
tau.tui.TauDialog.compose_footer¶
def compose_footer(self) -> ComposeResult
What stays pinned at the bottom when :attr:BODY_ID is set: hints, buttons.
tau.tui.TauDialog.compose¶
def compose(self) -> ComposeResult
The shell: a title and the body, pinned header and footer if BODY_ID is set.
tau.tui.TauDialog.action_cancel¶
def action_cancel(self) -> None
Esc: dismiss with CANCEL_VALUE.