Keyboard shortcuts

Press ← or β†’ to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

tui

Start the interactive terminal UI.

xrat tui

The TUI has no command-specific flags. It uses the same global flags as other commands, including --database, --config, --xray, --v2ray, --sing-box, -v, and -q.

The TUI is an interactive view over xrat’s shared database, source, testing, runtime, and diagnostics services. It does not keep a separate copy of business logic: config changes, imports, tests, and runtime operations use the same app services as the CLI commands.

Views

KeyViewPurpose
1ConfigsBrowse, filter, start, enable, disable, delete, and share configs
2SourcesInspect subscription sources, refresh/import sources, and share source/API URLs
3TestsStart/cancel background test batches and inspect recent results

The TUI opens in the Configs view. The bottom bar shows view shortcuts, help and quit actions, active filters, task state, and the latest status message.

Global Keys

KeyAction
1-3Switch primary view
TabCycle primary views
j, kMove focus down/up
arrow keysMove focus down/up
?Open help
EscClose modal, leave search, or go back
q, Ctrl+CQuit

Configs View

The Configs view shows stored configs with latest test summaries and config state. The status marker column uses ● for active, βœ• for soft-deleted, β—‹ for disabled, and ! for failed configs. Long names are truncated in the table. It supports focused actions, test batches, and managed runtime controls.

KeyAction
/Edit config search
Ctrl+UClear search while editing
SCycle sort field
FCycle filter: all, enabled, failed, has-delay
PCycle protocol filter
TShow or hide soft-deleted configs
EnterStart the focused config
e, xEnable or disable the focused config
dSoft-delete the focused config after confirmation
DPurge the focused config after confirmation
rRestore the focused soft-deleted config
tStart a test batch for the current Configs scope
aTest all enabled, non-deleted configs
vTest visible configs matching current filters
KStop/disconnect the managed runtime
RRestart the managed runtime
yShow a QR code for the focused config URI
cCopy the focused config URI

Search matches the displayed config fields. Sorting can cycle through latency, ID, name, protocol, source, last-tested time, and imported time. Deleted configs are hidden by default; press T to include them.

Soft delete hides a config from normal views and workflows. Purge permanently deletes it. Both destructive actions require confirmation.

The Runtime panel inside the Configs view shows the current managed runtime state, active config, current task, proxy endpoint, config counts, and failure message when present. Runtime actions use the same runtime service as xrat connect, xrat disconnect, and xrat status. The same runtime prerequisites apply: the configured Xray/V2Ray binary must be available, runtime paths must be writable, and daemon/runtime configuration must be valid.

Focus a config in the Configs view and press Enter to start or switch the runtime. Runtime operations run in the background and reload TUI data after completion.

Sources View

The Sources view lists subscription sources and source metadata. The detail panel also shows the local HTTP API base64 subscription URL when it is available.

KeyAction
rRefresh the focused source
RRefresh all sources with stored values
iOpen the import modal
nRename the focused source
dDelete the focused source and its configs
yShow a QR code for the focused source URL
cCopy the focused source URL
uShow a QR code for the HTTP API /b64 subscription URL
UCopy the HTTP API /b64 subscription URL

The import modal accepts the same input forms as xrat import: subscription URL, file path, raw config link, raw link list, base64 subscription text, SIP008 JSON, or Xray JSON. Press Enter to import and Esc to cancel.

Source refresh and import run as background tasks. When they finish, the TUI reloads database-backed data so the Configs and Sources views reflect the new state.

Tests View

The Tests view shows the latest test run summary, current test settings, progress, and recent results.

KeyAction
sStart a background test batch
cCancel the running test batch

The current implementation starts a batch for all enabled, non-deleted configs. It runs TCP and real-delay tests with concurrency 4 and skips download, upload, and ICMP stages. The scope, mode, and concurrency are displayed in the view, but there are not yet keybindings to change them interactively.

While a batch is running, the progress bar updates without blocking navigation. Cancelling requests cooperative cancellation; the active operation reports cancelled once the shared test executor observes the cancellation request.

Runtime, Failures, and Help

The Configs view shows the merged runtime panel, which summarizes runtime, database, source, API, and config-count state alongside the active and selected configs. The adjacent Failures and Event Log panel lists per-config failures and recent TUI task messages.

Press ? from any view to open the help modal. Press Esc to close it.

QR and Clipboard Behavior

QR modals are available for focused config URIs, source URLs, and the HTTP API subscription URL. Press Esc or q to close a QR modal.

Clipboard actions use the host clipboard. They can fail in SSH, tmux, Wayland, X11, or headless sessions depending on environment support. When clipboard access fails, the TUI reports the error in the status area.

QR generation can fail if a URI is too long for the QR renderer. When that happens, the QR modal reports the failure instead of crashing.

WorkflowCLI equivalent
Manage config stateconfig management
Start or stop runtimeruntime
Run teststest
Inspect sourceslist subscriptions
Import sourcesimport
Serve API URLserve

Troubleshooting

If the TUI cannot start, check that the terminal supports alternate-screen raw mode and run with a higher log level:

xrat -vv tui

If runtime actions fail, verify the equivalent CLI flow first:

xrat daemon start
xrat connect <id>
xrat status

If source/API QR or copy actions report that a URL is unavailable, ensure the source has a stored value and that the HTTP API subscription URL can be built from the current app configuration.