Skip to main content

Module terminal

Module terminal 

Source
Expand description

The per-seat terminals: the registry, the hand-off that parks on the person, and the idle clock.

The terminal belongs to the seat, not the occupant. It is keyed by the slot and created lazily on first use; /new, /resume and a handoff leave the PTY, its shell and its scrollback exactly where they were. It lives as long as the seat: a release ends the seat and its terminal, and an explicit close, the shell exiting or forge exiting also ends it.

No approval gate. Bash through the CLI already reaches the shell here, so the terminal adds no capability a session does not have. The one thing that is gated is the person’s own input, through the hand-off or through their own take-control of the raised surface.

Lock order: terminal_handoffs before terminals. Every path that needs both takes them in that order, so a claim, an answer, a typed byte and the idle sweep can never deadlock against each other. A path that needed the other order has to drop one guard before taking the other.

Re-exportsΒ§

use std::path::PathBuf; πŸ”’
use std::sync::Arc; πŸ”’
use std::sync::atomic::AtomicU64; πŸ”’
use std::sync::atomic::AtomicUsize; πŸ”’
use std::sync::atomic::Ordering; πŸ”’
use std::time::Duration; πŸ”’
use std::time::Instant; πŸ”’
use forge_primitives::SessionSlot; πŸ”’
use forge_primitives::browser::HandOffEnding; πŸ”’
use forge_primitives::terminal::TerminalExit; πŸ”’
use forge_primitives::terminal::TerminalHandOff; πŸ”’
use forge_primitives::terminal::TerminalHandOffAnswer; πŸ”’
use forge_primitives::terminal::TerminalInputExpected; πŸ”’
use forge_primitives::terminal::TerminalInputKind; πŸ”’
use forge_primitives::terminal::TerminalSource; πŸ”’
use forge_primitives::terminal::TerminalState; πŸ”’
use forge_primitives::terminal::TerminalSummary; πŸ”’
use parking_lot::Mutex; πŸ”’
use tokio::sync::oneshot; πŸ”’
use crate::protocol::SessionUpdate; πŸ”’
use crate::workspace::Workspace; πŸ”’

StructsΒ§

OutputChunk
One chunk of a terminal’s output, re-exported so a server half can name the type its stream carries without depending on the crate directly. One chunk of the terminal’s output, with its per-terminal sequence.
TerminalEntry
One seat’s terminal, as the registry holds it.

ConstantsΒ§

CLOCK_TICK πŸ”’
How often the idle clock looks at the registry.
DEFAULT_COLS πŸ”’
The size a terminal opens at before a client’s attach resizes it.
DEFAULT_ROWS πŸ”’

FunctionsΒ§

wire_state πŸ”’
The wire state, from the crate’s own.