TerminalShellIntegration
Selected producer of a terminal's shell metadata and active editing context.
A session owns observation, not the producer's lifetime. Implementations must not start background jobs during construction. commandLineChanges supports independent subscriptions; the session shares its collection and cancels it when no consumer needs it. state is the bounded terminal-facing projection of the producer's model. Only that producer may write it; OSC reports never supplement a host model.
Host adapters normally use TerminalShellIntegrationFactory.host rather than implement this runtime contract. The optional OSC implementation uses the synchronous protocol callbacks below; they run under session serialization.
Properties
Opaque nonnegative edit revisions; unavailable/equal intermediate states may conflate.
Whether the host configured this producer to supply prompt markers from startup.
True only while the shell can accept a startup command at its live prompt.
Thread-safe command metadata and primitive viewport projection.
Functions
Current immutable editing context, or null when unavailable; must be safe from any thread.
Reports a local clear after the active screen and history have been erased. Called synchronously under session mutation serialization, before later output. Invalidate producer-owned anchors for buffer; preserve metadata for the other buffer. Old line identities cannot resolve after this callback. Host models keep ownership of their text, metadata, and notifications. Do not block on UI work, mutate the session, or close it. Exceptions propagate to the clear caller after the grid has changed.
Optional OSC 133 interpretation, called at the marker's exact output position.
Optional accepted OSC 7 interpretation. Hosts keep their own directory authority.
Optional synchronous finalization after a parser batch, before startup submission.
Runs a short conditional-edit action under the producer's revision guard. The revision must change for every authoritative editing update, including changes away from and back to an equal snapshot. The callback must finish before another producer update can become visible.