///|
/// Process-lifetime mutable state that bridge tasks share. `run_bridge`
/// constructs one and passes it to `pty_reader`, `local_stdin_task`,
/// and `run_retry_loop`. Replaces the pty_ref + shell_exited_ref +
/// log + next_id + send_queue_ref + clients tuple that used to be
/// threaded around.
///
/// `current` collapses `send_queue_ref` and the peer-level `clients`
/// map — both were always set or cleared together, so a single
/// `Ref[RelaySession?]` makes "a relay session is active" a single
/// None/Some check. `terminal` holds whichever implementation the
/// virtual `@terminal` package resolves to at link time.
struct BridgeState {
mut pty : @pty.Pty?
shell_exited : Ref[Bool]
replay : ReplayLog
current : Ref[RelaySession?]
terminal : @terminal.Terminal
}
///|
fn BridgeState::new(terminal : @terminal.Terminal) -> BridgeState {
{
pty: None,
shell_exited: { val: false },
replay: ReplayLog::new(),
current: { val: None },
terminal,
}
}