Skip to main content

Module engine

Module engine 

Source
Expand description

CodeEngine: the trusty_code_tui::TuiEngine adapter driving a long-lived tcode serve --http daemon (issue #3415, DOC-50 §3.3/§3.4).

Why: see crate::tui_client’s module docs for the ephemeral---stdio vs. long-lived---http client distinction. This module is the TuiEngine impl itself — everything else in tui_client (discovery, rpc, sse) exists to support it. Split across sibling files (issue #610’s 500-SLOC production-file cap): engine_state.rs holds [super::engine_state::EngineState] (the actual session/cache/streaming logic), session_events.rs holds the pure Event -> ReplEvent mapping, workstream_subscription.rs holds the background workstream-activation SSE loop. This file keeps only the public CodeEngine wrapper and the TuiEngine impl that delegates into EngineState. What: CodeEngine is a thin Arc<EngineState> wrapper so the background workstream-subscription task spawned by subscribe_workstream_events can share the SAME state (and refresh the SAME caches) without a second, divergent copy. trusty-code-tui Slice 1.5 (#3428, merged) added the SYNCHRONOUS TuiEngine::commands()/ picker(name) accessors this impl TuiEngine block implements directly (not as inherent methods — see the impl TuiEngine for CodeEngine block’s commands/picker for why serving from EngineState’s std::sync::Mutex-guarded caches, populated during setup(), is the only way to satisfy a synchronous trait method with no I/O on the calling path). Test: engine_tests::* (in the sibling engine_tests.rs, included below) for the pure event-mapping/parsing helpers this module’s siblings define; the full discover -> setup -> stream -> cancel -> workstream-activation flow against a mock HTTP daemon lives in tests/tui_client_engine.rs.

Structs§

CodeEngine
The trusty_code_tui::TuiEngine adapter for tcode tui — see module docs.

Functions§

build_http_client
The pooled reqwest::Client every CodeEngine call (discovery ping, POST /rpc, SSE) shares.