KetraTerm
API · v0.3.0All versions

TerminalCompletionLearningCoordinator

Owns synchronous exact-command learning and optional fixed-path persistence.

One caller-owned worker hydrates the file once, observes last-value enablement, and checkpoints the latest dirty snapshot at a fixed interval. Recording and reset mutate memory synchronously and never wait for disk. Reset bypasses enablement and the checkpoint interval so persisted learning is replaced promptly. Shutdown awaits the final required write.

Constructors

Link copied to clipboard
constructor(learningStore: TerminalCompletionLearningStore, coroutineScope: CoroutineScope, persistencePath: Path, persistenceEnabled: Boolean, onPersistenceLoadFailure: (Throwable) -> Unit)

Creates a learning owner using Dispatchers.IO for blocking snapshot file access.

constructor(learningStore: TerminalCompletionLearningStore, coroutineScope: CoroutineScope, persistencePath: Path, persistenceEnabled: Boolean, ioDispatcher: CoroutineDispatcher, onPersistenceLoadFailure: (Throwable) -> Unit)

Creates a lifecycle-bound learning owner for one fixed persistence path.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
suspend fun closeAndFlush()

Stops accepting events and awaits the final dirty write when persistence is enabled.

Link copied to clipboard
suspend fun closeWithoutFlush()

Stops learning and awaits the worker without loading or saving pending state.

Link copied to clipboard
fun recordCommandResult(commandLine: String, successful: Boolean, profileId: String?, workingDirectoryUri: String?, usedAtEpochMillis: Long)

Records one completed command in memory and marks a changed snapshot dirty for optional persistence.

Link copied to clipboard
fun recordSuggestionFeedback(commandLine: String, feedback: TerminalCompletionFeedbackKind, profileId: String?, workingDirectoryUri: String?, feedbackAtEpochMillis: Long)

Records accepted or dismissed feedback for one exact suggested command.

Link copied to clipboard

Removes all completion learning and schedules immediate replacement of the persisted snapshot.

Link copied to clipboard

Enables or disables persistence for the fixed configured path.