CommandHistory class

Persistent, per-key command history backed by a KeyValueStore.

The browser counterpart to the omnyshell CLI's file-backed CommandHistory: it reuses the package's shared CommandHistoryBuffer for the entry rules (newest-last, capped, skip blanks and consecutive duplicates) and exposes the same HistoryCursor for Up/Down navigation, so history behaves identically to the CLI — only the storage differs. Each key (typically <principal>@<node>) maps to its own localStorage entry, so connecting to different nodes or as different principals never mixes histories. Entries are persisted as newline-joined lines.

Constructors

CommandHistory.inMemory({List<String>? entries, int maxEntries = 1000})
An in-memory history with no backing store (used by tests).
factory
CommandHistory.load({required KeyValueStore kv, required String key, int maxEntries = 1000, String prefix = storagePrefix})
Loads the history for key from kv, returning an empty history when none is stored yet. A corrupt or unreadable entry is treated as empty so it can never break the shell.
factory

Properties

entries List<String>
The entries, oldest first. The returned list is a copy.
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

add(String entry) → void
Records entry, skipping blank lines and consecutive duplicates, then persists. Storage failures are swallowed so the interactive session is never interrupted by a write error.
cursor() → HistoryCursor
A fresh Up/Down navigation cursor over this history's entries.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

storagePrefix → const String
Namespace for stored histories, kept distinct from settings/cache keys.