Current state
poll_sessions is called from inside tokio::spawn in the TUI's stream_interval tick, but it performs blocking filesystem I/O (std::fs::read_dir and std::fs::read_to_string) synchronously on the tokio worker thread. Hub's Rust conventions require using tokio::fs rather than std::fs equivalents inside async contexts. The scan visits every file in the sessions directory for every in-progress task on every tick, holding the worker thread for the full duration of the scan.
Ideal state
poll_sessions uses tokio::fs::read_dir and tokio::fs::read_to_string (making read_session_snapshot async), or the call site in main.rs wraps poll_sessions in tokio::task::spawn_blocking
- The tokio worker thread is never held while reading session files from disk
Starting points
workflows/src/agent_session.rs lines 174–199 — read_session_snapshot contains the blocking std::fs::read_dir (line 178) and std::fs::read_to_string (line 195)
ui/tui/src/main.rs line 295 — the tokio::spawn call site that invokes poll_sessions
QA plan
- Open
workflows/src/agent_session.rs — confirm read_session_snapshot is not async fn and uses std::fs::read_dir at line 178 and std::fs::read_to_string at line 195
- Open
ui/tui/src/main.rs line 295 — confirm poll_sessions is called inside tokio::spawn(async move { ... }) without spawn_blocking
- After the fix: confirm either
read_session_snapshot uses tokio::fs equivalents and poll_sessions is async fn, or the call site in main.rs wraps the call in tokio::task::spawn_blocking
- Run
just check — expect no warnings or errors
- Run
just test — expect all tests to pass
Done when
poll_sessions does not hold the tokio worker thread while reading session files from disk.
Current state
poll_sessionsis called from insidetokio::spawnin the TUI'sstream_intervaltick, but it performs blocking filesystem I/O (std::fs::read_dirandstd::fs::read_to_string) synchronously on the tokio worker thread. Hub's Rust conventions require usingtokio::fsrather thanstd::fsequivalents inside async contexts. The scan visits every file in the sessions directory for every in-progress task on every tick, holding the worker thread for the full duration of the scan.Ideal state
poll_sessionsusestokio::fs::read_dirandtokio::fs::read_to_string(makingread_session_snapshotasync), or the call site inmain.rswrapspoll_sessionsintokio::task::spawn_blockingStarting points
workflows/src/agent_session.rslines 174–199 —read_session_snapshotcontains the blockingstd::fs::read_dir(line 178) andstd::fs::read_to_string(line 195)ui/tui/src/main.rsline 295 — thetokio::spawncall site that invokespoll_sessionsQA plan
workflows/src/agent_session.rs— confirmread_session_snapshotis notasync fnand usesstd::fs::read_dirat line 178 andstd::fs::read_to_stringat line 195ui/tui/src/main.rsline 295 — confirmpoll_sessionsis called insidetokio::spawn(async move { ... })withoutspawn_blockingread_session_snapshotusestokio::fsequivalents andpoll_sessionsisasync fn, or the call site inmain.rswraps the call intokio::task::spawn_blockingjust check— expect no warnings or errorsjust test— expect all tests to passDone when
poll_sessionsdoes not hold the tokio worker thread while reading session files from disk.