TerminalShellIntegrationState

class TerminalShellIntegrationState(capacity: Int = DEFAULT_CAPACITY, maxCommandTextLength: Int = DEFAULT_SHELL_INTEGRATION_COMMAND_TEXT_LENGTH, epochMillis: () -> Long = System::currentTimeMillis)

Session-owned OSC 133 shell command timeline.

This model intentionally lives outside terminal core. Core owns bytes already committed to the terminal grid; shell integration markers are host metadata about prompt and command lifecycle. Records are anchored to stable core line identities, not absolute row numbers, so scrollback movement and resize reflow do not detach decorations from the content they describe.

Storage is data-oriented: each command field is a primitive column, records are append-only until bounded eviction, and paint paths consume only projected primitive arrays. All methods are thread-safe. Writers are normally invoked from the serialized session parser path; readers are UI threads that snapshot visible rows before painting.

Parameters

capacity

maximum retained command records before oldest-record eviction.

maxCommandTextLength

maximum retained UTF-16 command-text length per record; longer extracted text is stored as unknown.

epochMillis

wall-clock source used for command metadata timestamps.

Constructors

Link copied to clipboard
constructor(capacity: Int = DEFAULT_CAPACITY, maxCommandTextLength: Int = DEFAULT_SHELL_INTEGRATION_COMMAND_TEXT_LENGTH, epochMillis: () -> Long = System::currentTimeMillis)

Functions

Link copied to clipboard
fun clear()

Clears all stored prompt and command timeline records.

Link copied to clipboard
fun commandAnchorLineId(recordId: Int): Long

Returns the preferred navigation anchor line for recordId.

Link copied to clipboard

Returns an immutable metadata snapshot for recordId.

Link copied to clipboard

Returns the retained command record that owns lineId.

Link copied to clipboard
fun commandText(recordId: Int): String?

Returns the retained command text for recordId.

Link copied to clipboard

Returns the OSC 7 working-directory URI snapshotted when recordId began.

Link copied to clipboard
fun copyCommandOutputRange(recordId: Int, destination: LongArray, destinationOffset: Int = 0): Boolean

Copies the command-output line range for recordId.

Link copied to clipboard
fun copyRecords(recordIds: IntArray, lifecycleStates: IntArray, promptStartLineIds: LongArray, promptEndLineIds: LongArray, commandStartLineIds: LongArray, commandEndLineIds: LongArray, exitCodes: IntArray, destinationOffset: Int, maxRecords: Int): Int

Copies retained shell command records into caller-owned primitive arrays.

Link copied to clipboard
fun copyViewport(lineIds: LongArray, rowCount: Int, promptStarts: BooleanArray, commandStarts: BooleanArray, commandEnds: BooleanArray, commandRecordIds: IntArray, commandLifecycleStates: IntArray, failedCommandRails: BooleanArray? = null, destinationOffset: Int = 0)

Copies projected shell decorations for a visible viewport.

Link copied to clipboard

Returns the latest accepted OSC 7 URI, or null before one is received.

Link copied to clipboard

Returns whether lineId belongs to a failed command range.

Link copied to clipboard

Returns whether lineId has a prompt-start marker.

Link copied to clipboard

Returns the newest retained command record id, skipping prompt-only records.

Link copied to clipboard
fun nextCommandRecordId(recordId: Int): Int

Returns the next retained command record after recordId.

Link copied to clipboard

Returns the nearest retained command record after lineId.

Link copied to clipboard
fun observeLiveBottomRow(bottomAbsoluteRow: Long)

Observes the newest live viewport bottom row.

Link copied to clipboard

Returns the previous retained command record before recordId.

Link copied to clipboard

Returns the nearest retained command record before lineId.

Link copied to clipboard
fun recordCommandFinished(lineId: Long, exitCode: Int?)

Records command completion.

Link copied to clipboard
fun recordCommandStart(lineId: Long, includeLine: Boolean, commandText: String? = null, workingDirectoryUri: String? = null)

Records command execution start.

Link copied to clipboard

Returns the current number of retained shell command records.

Link copied to clipboard

Records the latest host-validated OSC 7 current-working-directory URI.

Link copied to clipboard
fun recordPromptEnd(lineId: Long)

Records the end of the active shell prompt.

Link copied to clipboard
fun recordPromptStart(lineId: Long)

Records the start of a shell prompt.