KetraTerm
API · DevelopmentAll versions

host

fun host(state: TerminalShellIntegrationView, commandLine: TerminalShellCommandLineState, promptReady: StateFlow<Boolean> = MutableStateFlow(false).asStateFlow()): TerminalShellIntegrationFactory

Selects a host-owned versioned projection that supports atomic conditional edit admission. Publish through commandLine so model updates and the final revision check share its guard. state and promptReady retain the same ownership as in the StateFlow overload.


fun host(state: TerminalShellIntegrationState, commandLine: StateFlow<TerminalShellCommandLineSnapshot?> = MutableStateFlow<TerminalShellCommandLineSnapshot?>( null, ).asStateFlow(), promptReady: StateFlow<Boolean> = MutableStateFlow(false).asStateFlow()): TerminalShellIntegrationFactory

Selects a host-owned shell model without installing any protocol recorder.

The host publishes semantic prompt/command/directory updates to state, and keeps commandLine and promptReady current. Capture stable line IDs through the session frame reader after the corresponding output and before consuming later bytes. In particular, IDE document offsets are not terminal line identities. Host callbacks must preserve that ordering.

Each subscription signals the current editing context, including null, so consumers can revalidate snapshots captured before observation starts. Null editing values are authoritative. Readiness is separate from shell initialization and command completion. Publish false when the prompt becomes unavailable, including alternate-screen programs. A supplied startup command can use this readiness through the normal session queue.

Closing a session stops its observation without clearing state or cancelling the host's flows. Use a distinct projection per session. This StateFlow-only overload supports observation, not atomic conditional edits; use TerminalShellCommandLineState for that capability.