TUI workflow and worker contracts

Search transitions live in src/tui/search_state.rs; terminal rendering, channel transport, database execution, rows and selection remain outside that module.

Worker inventory

WorkerQueued requestsIn-flight workReply/closureShutdown
SearchKeep newest queuedRuns to completionActive search ID only; pane changes retain sessionClose sender, join
DetailKeep newest queuedRuns to completionActive detail ID onlyClose sender, join
DiffKeep newest queuedRuns to completionActive diff ID onlyClose sender, join
FolderKeep newest queuedRuns to completionActive folder ID onlyClose sender, join
StatsKeep newest queuedRuns to completionActive stats ID onlyClose sender, join
File checkKeep newest queuedSubprocess deadline, shutdown cancellationActive file-check ID onlySet cancel flag, close sender, join
InspectionKeep newest queuedRuns to completionActive page ID only; closed pages discard repliesSender/receiver drop; thread exits after current work
Command workflowOne dialog operationSubprocess cancellation; doctor has 50-second deadlineDialog owns response; disconnect becomes visible errorSet subprocess cancellation flag; thread is detached

Coalescing and rejecting stale responses are not cancellation. Database workers do not promise bounded shutdown: joining waits for current work (and already queued work) to finish. No new interruption mechanism is introduced for these local catalog reads. File checks can touch network filesystems and already use an isolated subprocess with a six-second deadline and cancellation before join; their worker tests cover timeout, queued replacement and shutdown.

For a new workflow, define ownership across navigation, the active ID and terminal states first. Keep execution and rendering separate, reject late replies before mutating rows, and document whether close merely discards replies or actually interrupts execution. Add interruption/deadlines when the operation’s blocking behavior requires them, rather than describing ID invalidation as cancellation.

Search transition tests inject replies directly without thread timing. TUI tests cover result selection, navigation, debounce and idle/render behavior; worker tests cover database errors, response IDs and existing file-check interruption guarantees.