latent.chat.widgets¶
Custom Textual widgets for the chat REPL.
Classes¶
RTLInput¶
Input widget with full Unicode BiDi support for mixed LTR+RTL text.
When the value contains RTL characters (Hebrew, Arabic, etc.):
- render_line displays the text in correct visual order using the
Unicode BiDi algorithm via python-bidi.
- The cursor is mapped from logical position to visual position using the
character reordering table produced by the BiDi algorithm.
- Arrow key navigation moves in visual order, not logical order.
- Word-jump navigation (Ctrl+←/→) operates on word boundaries in visual
order so it stays consistent with visual cursor movement.
Falls back to the default Textual Input rendering when the value
contains no RTL characters or when python-bidi is not installed.
Backspace, Delete, Home, and End need no override: - Backspace removes cursor_pos-1 (the last-typed character) — correct. - Delete removes cursor_pos — correct. - Home → logical pos 0. For RTL-dominant text this is the visual right (beginning of reading order); for LTR-dominant it is the visual left. Both are the correct "start" positions. - End → logical pos len(value) — symmetric to Home.
SelectableRichLog¶
RichLog extended with mouse click-drag text selection and clipboard copy.
- Click and drag to highlight text with reverse-video style.
- On mouse release, the selected plain text is copied to the clipboard.
- Appending new content while a drag is in progress clears the selection to avoid stale coordinate references.
- Ctrl+C is NOT intercepted here — it retains its stream-cancel behaviour.
SessionPicker¶
Interactive session picker with arrow navigation and Enter to load.
SessionPicker.Selected¶
Fired when a session is selected.
ToolCallCollapsible¶
Collapsible panel for a single tool call + result.
Shows a one-line summary when collapsed (tool name + truncated args), expands to show full JSON arguments and result. Click the title or press Enter to toggle.
Methods¶
RTLInput.action_cursor_left¶
RTLInput.action_cursor_left_word¶
RTLInput.action_cursor_right¶
RTLInput.action_cursor_right_word¶
RTLInput.render_line¶
SelectableRichLog.on_mouse_down¶
SelectableRichLog.on_mouse_move¶
SelectableRichLog.on_mouse_up¶
SelectableRichLog.render_line¶
SelectableRichLog.write¶
SessionPicker.on_option_list_option_selected¶
ToolCallCollapsible.set_result¶
Append tool result to the collapsible body.