Skip to content

SessionStore

Category: Storage

Source: session_store.dart

Enums

SessionTitleSource

Metadata for a saved session, including model ref and timing.

ValueDescription
auto
user

SessionTitleState

ValueDescription
provisional
stable

Classes

SessionMeta

Constructor

dart
SessionMeta({
    this.schemaVersion = currentSchemaVersion,
    required this.id,
    required this.cwd,
    this.projectPath,
    required this.modelRef,
    required this.startTime,
    this.endTime,
    this.forkedFrom,
    this.worktreePath,
    this.branch,
    this.baseBranch,
    this.repoRemote,
    this.headSha,
    this.title,
    this.titleSource,
    this.titleState,
    this.titleGenerationCount = 0,
    this.titleGeneratedAt,
    this.titleLastEvaluatedAt,
    this.titleRenamedAt,
    this.tags = const [],
    this.prUrl,
    this.prStatus,
    this.tokenCount,
    this.cacheReadTokens,
    this.cacheCreationTokens,
    this.messageCount,
    this.summary,
    this.runtimeId,
    this.sandboxId,
    this.runtimeBootstrapSha,
    this.runtimeRemoteUrl,
    this.runtimePatchPath,
    this.runtimeClosedAt,
  })
dart
factory SessionMeta.fromJson(Map<String, dynamic> json)

Properties

PropertyTypeDescription
currentSchemaVersionconst int
schemaVersionint
idSessionId
cwdString
projectPathString?
modelRefStringFully-qualified model reference: &lt;provider&gt;/&lt;model&gt;. Schema v3+ writes this as model_ref. Schema ≤ 2 is read-compatible: if the stored value has no slash, the legacy provider field is prepended on read (see [fromJson]).
startTimeDateTime
endTimeDateTime?
forkedFromString?
worktreePathString?
branchString?
baseBranchString?
repoRemoteString?
headShaString?
titleString?
titleSourceSessionTitleSource?
titleStateSessionTitleState?
titleGenerationCountint
titleGeneratedAtDateTime?
titleLastEvaluatedAtDateTime?
titleRenamedAtDateTime?
tagsList&lt;String&gt;
prUrlString?
prStatusString?
tokenCountint?
cacheReadTokensint?
cacheCreationTokensint?
messageCountint?
summaryString?
runtimeIdString?
sandboxIdString?
runtimeBootstrapShaString?
runtimeRemoteUrlString?
runtimePatchPathString?
runtimeClosedAtDateTime?
sessionDirString
metaSessionMeta

Methods

`void setTitle(
String title, {
SessionTitleSource? source,
SessionTitleState? state,
int? generationCount,
DateTime? generatedAt,
DateTime? lastEvaluatedAt,
DateTime? renamedAt,

})`

void updateMeta()

Writes the current metadata to disk.

void logEvent(String type, Map&lt;String, dynamic&gt; data)

Appends a timestamped event record to the conversation log.

Future&lt;void&gt; close()

Closes this session, recording the end time.

static List&lt;SessionMeta&gt; listSessions(String sessionsDir)

Lists all saved sessions in [sessionsDir], sorted newest first.

SessionStore

Persistent storage for a single session's metadata and conversation log.

Constructor

dart
SessionStore({required this.sessionDir, required this.meta})

Properties

PropertyTypeDescription
sessionDirString
metaSessionMeta

Methods

`void setTitle(
String title, {
SessionTitleSource? source,
SessionTitleState? state,
int? generationCount,
DateTime? generatedAt,
DateTime? lastEvaluatedAt,
DateTime? renamedAt,

})`

void updateMeta()

Writes the current metadata to disk.

void logEvent(String type, Map&lt;String, dynamic&gt; data)

Appends a timestamped event record to the conversation log.

Future&lt;void&gt; close()

Closes this session, recording the end time.

static List&lt;SessionMeta&gt; listSessions(String sessionsDir)

Lists all saved sessions in [sessionsDir], sorted newest first.

Released under the MIT License.