Skip to main content

dispatch_app_server

Function dispatch_app_server 

Source
pub(super) fn dispatch_app_server(
    turn: Turn<'_>,
    app_server_ctrl: &AppServerController,
    tracker: Option<Arc<TurnActivityTracker>>,
) -> Result<(), String>
Expand description

App Server owns a persistent thread/turn process and has its own typed protocol path. Keep it ahead of the legacy stream-json branches.

KNOWN GAP (#3215, tracked for a follow-up, not fixed here): the turn’s env vars (including this turn’s freshly-resolved identity bindings from inject_identity_env_async) are computed but never reach this branch — send_message carries no env, and the App Server child was already spawned earlier using only command_from_meta’s cmd:env snapshot. Unlike the subprocess/persistent controllers, this isn’t a missing plumbing call: env vars are fixed at process exec() time, so an already-running App Server process cannot pick up a per-turn identity change at all without being torn down and respawned. Deciding when to force that respawn (e.g. on every identity-binding change vs. only between turns) is a real design question, not a mechanical fix, so it’s deliberately left for a follow-up PR rather than rushed in here.

A message the pane held during a turn joins that turn (turn-model spec §4.3, J3). The persistent controller carries it on the input itself; the others start passes with no labelled input, so their tracker is told just before the dispatch, never earlier: a failure in the preparation must not leave the hint armed for a later message (#4492).