Session View

Cell-based double-buffered TUI with 24-bit color, UTF-8 rendering, draggable overlays, and 4 operating modes. The session view is the primary interface for interacting with ScorpioX Code.

Operating Modes

🖥️ interactive

Full TUI with cell-based rendering, panels, input field, status bar, overlays, mouse support, and double-buffered drawing via sx_term

👻 headless

No TTY required — sx_term_init_headless(w,h) renders into cell buffer for daemon/SDK use. Enabled via --headless flag. Implies --emit-session for file-based message exchange

📥 piped

Stdin is a pipe (echo 'hi' | sx). Drains piped data, reopens /dev/tty, sends piped text as first message, then enters interactive TUI

⚙️ prompt

One-shot prompt via --prompt flag. Treated as piped input — sends message, receives response, then enters interactive TUI

⚙️ dry-run

Initialize everything, emit tools/system prompt, skip agentic loop. Enabled via -n/--dry-run flag

TUI Components

sx_term

Zero-dependency terminal library. Provides raw mode (termios/Win32), double-buffered cell-based rendering with diff-based present, 24-bit truecolor, UTF-8 input/output, mouse support (SGR protocol), resize handling (SIGWINCH), alternate screen, bracketed paste, text selection, OSC 52 clipboard, and headless mode for daemon rendering

scorpiox/sx_term.c scorpiox/sx_term.h
status_barcustomizable

5-line status bar at bottom showing: model name, stacked usage history (input/output/cache_read/cache_write tokens with color coding), cache keep-alive timer with color thresholds (green >3min, yellow 1-3min, red <1min), current working directory, git branch, background task count, bash running indicator, and callback status. Supports mouse click hit areas for cwd (file explorer toggle) and bash indicator

scorpiox/sx_statusbar.c scorpiox/sx_statusbar.h
input_field

Multi-line input field with cursor, UTF-8 editing, word-level operations (Ctrl+W delete word, Ctrl+Left/Right word navigation), kill line (Ctrl+K), blinking cursor, text wrapping, and input history (up to 100 entries with Up/Down navigation)

scorpiox/libsxui/sxui_input.c scorpiox/libsxui/sxui_input.h
chat_display

In-memory message display manager. Stores up to 512 cached messages of types: user, assistant, tool_call, tool_result, error, info, thinking. Rendered bottom-up as single page (no scrolling) in sx.c chat_render() with per-type color coding and optional gradient background

scorpiox/libsxui/sxui_display.c scorpiox/libsxui/sxui_display.h
ui_state

In-memory UI state management. Tracks input text, cursor position, UI mode (normal/completion/rewind), selected index for popups, loading state with start time, and dirty flag for triggering re-renders

scorpiox/libsxui/sxui_state.c scorpiox/libsxui/sxui_state.h
info_box

Draggable overlay widget (36x13) showing version, model, provider, tools status, session name, FPS, memory usage (RSS MB), CPU percentage, active forks, open file descriptors, and keyboard shortcuts. Toggled via /info command. Supports drag-to-move and click-to-close with mouse

scorpiox/libsxui/sxui_infobox.c scorpiox/libsxui/sxui_infobox.h
bash_terminal

Live bash terminal overlay widget (120x12) that streams command output in real-time when the Bash tool runs. Shows command name, rolling output buffer (8 lines x 256 chars), elapsed time, total bytes, exit code. States: hidden/running/done/error/minimized. Supports background button [BG], drag-to-move, suppress mode (/terminal off), and Ctrl+B to background

scorpiox/libsxui/sxui_bashterm.c scorpiox/libsxui/sxui_bashterm.h
file_explorer

File explorer overlay widget for browsing directories. Shows sorted file listing with icons, supports navigation (Enter to open, Backspace to go up), selection movement (Up/Down/Home/End/PgUp/PgDown), hidden file toggle, scrolling for long lists, mouse interaction, drag-to-move, and file selection callback

scorpiox/libsxui/sxui_fileexplorer.c scorpiox/libsxui/sxui_fileexplorer.h
resume_picker

Conversation resume picker overlay (60x12) for selecting and resuming previous conversations. Shows up to 50 conversation previews with 8 visible rows, scroll support, mouse interaction, drag-to-move, and selection callback. Toggled via /resume command

scorpiox/libsxui/sxui_resume.c scorpiox/libsxui/sxui_resume.h
callback_list

Draggable popup (52 wide) showing all active SetCallback timers with slot index, message preview, time remaining, repeat count, and pause state. Toggled via /callbacks command. GitHub dark theme styling

scorpiox/libsxui/sxui_callbacks.c scorpiox/libsxui/sxui_callbacks.h
completion_popup

Slash command autocomplete popup rendered inline above the input field. Shows matching commands as user types /. Separate argument completion popup for commands like /model (shows opus/sonnet/haiku) and /resume. Triggered by Tab key

scorpiox/sx.c None
loading_spinner

Animated spinner with 10 braille-pattern frames cycling at 80ms intervals. Shows elapsed time during API requests. WASM mode uses a separate JS-side spinner (requestAnimationFrame) that runs while the C stack is suspended by JSPI

scorpiox/sx.c None
welcome_screen

Welcome screen rendered when no messages exist. Shows provider/model info with gradient background (if enabled). Info box rendered separately as overlay

scorpiox/sx.c None
gradient_backgroundcustomizable

Optional gradient background drawn behind chat messages and welcome screen. Controlled by enable_gradient config option via sx_state_get_enable_gradient()

scorpiox/sx.c None
text_selection

Mouse-based text selection with highlight overlay. Tracks start/end coordinates, active/valid states. Selection applied to back buffer before present. Copy via OSC 52 clipboard protocol. Supports press/drag/release mouse states

scorpiox/sx_term.c scorpiox/sx_term.h
tmux_backendcustomizable

Backend abstraction for session multiplexing. Vtable interface supporting tmux CLI (shells out to tmux binary) or sxmux (native scorpiox-multiplexer API). Auto-detects best backend, override via TMUX_BACKEND config. Provides list/create/kill sessions, capture pane, send keys, resume

scorpiox/sxtmux_backend_tmux.c scorpiox/sxtmux_backend.h
shortcut_registry

Centralized keyboard shortcut registry — single source of truth for all keybindings. Categorized as Editing, Navigation, Actions, Tools, Mouse, Other. Provides match_ctrl() lookup for dispatch, formatted help text generation for /help, and enumeration for info box display

scorpiox/libsxutil/sx_shortcut.c scorpiox/libsxutil/sx_shortcut.h
slash_commandscustomizable

Slash command system with auto-completion. Sources: system built-ins, embedded skills, embedded commands, user commands (~/.claude/commands/), project commands (./.claude/commands/), user skills, project skills. System commands include /exit, /clear, /help, /model, /save, /load, /rewind, /config, /transcript, /continue, /info, /resume, /keepalive, /context_resize, /terminal, /history, /compact, /cd, /voice, /callbacks

scorpiox/libsxutil/sx_slashcmd.c scorpiox/libsxutil/sx_slashcmd.h
rewind_system

Conversation checkpoint and rewind system. Each user message creates a checkpoint (up to 100). Users can rewind to any previous checkpoint via /rewind command, discarding subsequent messages. Stores message preview, full text, API/display indices, and timestamp

scorpiox/libsxutil/sx_rewind.c scorpiox/libsxutil/sx_rewind.h
cache_keepalivecustomizable

Background thread that auto-sends a keep-alive message through the normal agent path when idle for ~4:30 to maintain Claude prompt cache. Timer displayed in status bar with color-coded urgency. Toggled via /keepalive command

scorpiox/sx_cache_keepalive.c scorpiox/sx_cache_keepalive.h

Color System

Message Colors
Usage / Token Colors
Cache Timer Colors

Rendering Pipeline

✅ double buffered✅ diff based present✅ cell based❌ markdown❌ syntax highlighting❌ diff view✅ unicode✅ wide char support✅ emoji support✅ gradient background✅ alternate screen✅ bracketed paste

Keybindings

Other

Enter Send message input
Escape Cancel generation / close dialog global
Tab Autocomplete command input
Ctrl+C Quit global
Ctrl+L Clear input line input
Ctrl+U Clear input line (alt) input
Ctrl+W Delete word backward input
Ctrl+K Kill to end of line input
Ctrl+A Move to start of line input
Ctrl+E Move to end of line input
Ctrl+X Open external editor (vim/nano) input
Ctrl+O Open transcript viewer global
Ctrl+B Send foreground task to background global
Backspace Delete character backward (UTF-8 aware) input
Delete Delete character forward input
Left Move cursor left input
Right Move cursor right input
Ctrl+Left Move to previous word input
Ctrl+Right Move to next word input
Up Previous input / history input
Down Next input / history input
Home Move to start of line input
End Move to end of line input
Left-click Select text / interact with UI widgets global
Right-click Paste from clipboard global
Left-drag Text selection / drag widgets global
Scroll-up Scroll (overlay context dependent) overlay
Scroll-down Scroll (overlay context dependent) overlay
!command Run bash command directly input

Terminal Requirements

min width 40
max width 1024
max height 512
max width wasm 256
max height wasm 64
color support 24-bit truecolor (with fallback constants for 256-color)
unicode required False
mouse protocol SGR (1006)
clipboard protocol OSC 52
alternate screen True
raw mode termios (Unix) / Win32 Console API (Windows) / xterm.js (WASM)

Session Configuration

Set these keys in scorpiox-env.txt to customize session behavior.

AGENTLESS_MODE Run in agentless mode (no sub-agents) 0
AGENT_MAX_RECURSION_DEPTH Maximum recursion depth for nested agent calls 10
ASKUSER_TIMEOUT Timeout in seconds for AskUserQuestion prompts 120
AUTO_ACCEPT_PLAN Auto-accept plans without user confirmation 1
BASH_DEFAULT_TIMEOUT Default timeout in ms for Bash tool execution 30000
BASH_MIN_TIMEOUT Minimum timeout in ms for Bash tool (0 = no minimum) 0
LOG_DIR Directory for session logs .scorpiox/logs
LOG_LEVEL Logging verbosity level INFO
SESSION_RETENTION_DAYS Days to retain session logs 7