Skip to main content

session

Function session 

Source
pub async fn session(
    beamfile: &Path,
    project: Project,
    sources: SourceMap,
    selection: Selection,
    options: RunOptions,
    executors: Executors,
    events: UnboundedSender<RunEvent>,
    commands: Option<UnboundedReceiver<SessionCommand>>,
    watch_enabled: bool,
    cancel: CancellationToken,
    watcher: Box<dyn Watcher>,
    render_error: &mut (dyn FnMut(&SessionError) -> String + Send),
) -> WatchExit
Expand description

Runs selection and keeps re-running it — for a relevant change while watch_enabled, for a SessionCommand from commands — until cancel fires, a Shutdown arrives, or the watcher dies.

project and sources are taken owned: the session outlives the caller’s own copy, and both are cheap to clone.

A selection this project cannot resolve — an unknown beam, or a git reference that does not exist — is not an error here: it parks the session like any other project it cannot work from, because mid-session the fix is one Beamfile save away and a session that quit on a renamed beam would be a session that quits while the user is typing. A caller that wants the other answer — the exit code 2 an unknown target earns on the command line — asks alba_core::execution_subgraph before starting the session, which is exactly what the CLI does: it is only at startup that “no such beam” means the invocation was wrong rather than the edit unfinished.