SessionManager
Category: Session
Source: session_manager.dart
Enums
SessionReplayKind
| Value | Description |
|---|---|
user | |
assistant | |
toolCall | |
toolResult | |
subagentSpawned | |
subagentEvent | |
subagentCompleted |
Classes
SessionReplayEntry
Constructor
dart
factory SessionReplayEntry.user(String text)dart
factory SessionReplayEntry.assistant(String text)dart
factory SessionReplayEntry.toolCall(
String name,
Map<String, dynamic> arguments,
)dart
factory SessionReplayEntry.toolResult(String text)dart
factory SessionReplayEntry.subagentSpawned({
required String subagentId,
required String task,
int? index,
int? total,
})dart
factory SessionReplayEntry.subagentEvent({
required String subagentId,
required SessionReplayEntry inner,
})dart
factory SessionReplayEntry.subagentCompleted({
required String subagentId,
String? error,
})Properties
| Property | Type | Description |
|---|---|---|
kind | SessionReplayKind | |
text | String | |
toolName | String? | |
toolArguments | Map<String, dynamic>? | |
subagentId | String? | |
subagentIndex | int? | |
subagentTotal | int? | |
subagentInner | SessionReplayEntry? | |
subagentError | String? |
SessionReplay
Constructor
dart
const SessionReplay({
required this.entries,
required this.userCount,
required this.assistantCount,
required this.totalUsage,
this.firstUserMessage,
this.latestUserMessage,
this.firstAssistantMessage,
this.latestAssistantMessage,
this.toolNames = const [],
})Properties
| Property | Type | Description |
|---|---|---|
entries | List<SessionReplayEntry> | |
userCount | int | |
assistantCount | int | |
firstUserMessage | String? | |
latestUserMessage | String? | |
firstAssistantMessage | String? | |
latestAssistantMessage | String? | |
toolNames | List<String> | |
totalUsage | UsageReport | Per-role token totals aggregated from persisted usage JSONL rows. Always non-null but may have an empty rows list when no usage was ever recorded (Ollama session, very old session predating recordUsage). |
SessionResumeResult
Constructor
dart
const SessionResumeResult({
required this.message,
required this.hasConversation,
required this.replay,
})Properties
| Property | Type | Description |
|---|---|---|
message | String | |
hasConversation | bool | |
replay | SessionReplay |
SessionForkResult
Constructor
dart
const SessionForkResult({
required this.message,
required this.draftText,
required this.replay,
})Properties
| Property | Type | Description |
|---|---|---|
message | String | |
draftText | String | |
replay | SessionReplay |
TitleContext
Handles session lifecycle operations independent of UI rendering.
Constructor
dart
const TitleContext({
this.firstUserMessage,
this.latestUserMessage,
this.firstAssistantMessage,
this.latestAssistantMessage,
this.toolNames = const [],
this.cwdBasename,
})Properties
| Property | Type | Description |
|---|---|---|
firstUserMessage | String? | |
latestUserMessage | String? | |
firstAssistantMessage | String? | |
latestAssistantMessage | String? | |
toolNames | List<String> | |
cwdBasename | String? |
SessionManager
Constructor
dart
SessionManager({
required this.environment,
SessionStore? sessionStore,
Observability? observability,
})Properties
| Property | Type | Description |
|---|---|---|
environment | Environment | |
titleInitialRequested | bool | |
titleReevaluationRequested | bool | |
titleManuallyOverridden | bool | |
currentStore | SessionStore? get | |
currentSessionId | SessionId? get | |
currentStore | SessionStore? get | |
currentSessionId | SessionId? get |
Methods
void markManuallyRenamed()
Marks the session as manually renamed (e.g., from /rename). Sets all three flags so background title generation does not overwrite the user-chosen title.
List<SessionMeta> listSessions()
`SessionStore ensureSessionStore({
required String cwd,
required String modelRef,
})`
void switchToSessionStore(SessionMeta meta)
void updateSessionModel({required String modelRef})
void logEvent(String type, Map<String, dynamic> data)
void recordUsage(UsageStats stats, {required String role})
Records [stats] against the current session under [role] (e.g. 'main', 'subagent', 'title'). Updates the persisted token counters on SessionMeta and writes a usage JSONL row so a surface or replay can attribute costs to where they came from.
No-op when no session store is active.
Future<void> closeCurrent()
`Future<void> generateTitle({
required String userMessage,
required Future<String?> Function(String userMessage) generate,
})`
Future<void> renameTitle(String title)
`Future<void> reevaluateTitle({
required TitleContext context,
required Future<String?> Function(TitleContext context) generate,
})`
`SessionResumeResult resumeSession({
required SessionMeta session,
required AgentCore agent,
})`
`SessionForkResult? forkSession({
required int userMessageIndex,
required String messageText,
required AgentCore agent,
})`