Skip to main content

Module tui

Module tui 

Source
Expand description

rq show’s interactive TUI: a cursive (crossterm backend) SelectView of tracked reviews. Up/down and j/k move the cursor between reviews, skipping over an expanded review’s diffstat lines rather than stepping into them (see move_selection) - arrow keys are intercepted via an OnEventView since SelectView’s own built-in handling would otherwise land on those lines like any other row. Left/right (and h/l) expand/collapse the selected review’s diffstat (fetched by rq sync and read straight out of state.json - no network calls here). o opens the review in a browser. Enter opens it locally: fetching it on demand if needed (the same sync::fetch_local a plain rq fetch <id> runs), then suspending the TUI to drop the user into a subshell in its worktree (or run the configured open_command), resuming once they exit it - see run_event_loop for why that means tearing down and recreating the whole backend rather than just toggling raw mode. See crate::sync’s module docs for why rq sync itself never creates workspaces. d deletes the selected review’s workspace (sync::remove_workspace), confirming first and always discarding any local changes. Once confirmed the dialog closes and the deletion runs on a background thread (begin_delete) with the same row spinner as a fetch.

Fetching a review with no local worktree yet asks to confirm first (prompt_confirm_fetch) - fetch_local may clone a repo or shell out to a source’s checkout command, either of which can take a while. Once confirmed the dialog closes and begin_fetch runs it on a background thread so the event loop stays responsive: the review’s row shows a spinner (ticked via Cursive::cb_sink) where its workspace icon goes, and d on that row cancels. The underlying git/jj calls have no cancellation points of their own, so cancelling doesn’t interrupt them - it just detaches from the operation, which keeps running (spinner turns red); finish_fetch still runs when it completes, and removes whatever workspace it created instead of opening a shell into it. f skips both the confirmation and the subshell: it just fetches (or refreshes) the selected review in the background.

Functions§

run
Run the TUI until the user quits. Blocks the current thread; call from within a Tokio runtime (needed for the open-locally hotkey, which drives sync::fetch_local to completion synchronously).