resolveChatThreadStatusFromStore function
ChatThreadStatusState
resolveChatThreadStatusFromStore({
- required AgentThreadMessageStatusStore store,
- required String path,
- ChatThreadStatusState? previous,
- bool supportsAgentMessages = true,
Implementation
ChatThreadStatusState resolveChatThreadStatusFromStore({
required AgentThreadMessageStatusStore store,
required String path,
ChatThreadStatusState? previous,
bool supportsAgentMessages = true,
}) {
final hasMessageStatus = store.hasThread(path);
final messageState = store.state(path: path, previous: previous, supportsAgentMessages: hasMessageStatus || supportsAgentMessages);
String? nextStatus = messageState.text;
String? nextMode = messageState.mode;
DateTime? nextStartedAt = messageState.startedAt;
String? nextTurnId = messageState.turnId;
List<PendingAgentMessage> nextPendingMessages = messageState.pendingMessages;
String? nextPendingItemId = messageState.pendingItemId;
int? nextTotalBytes = messageState.totalBytes;
int? nextLinesAdded = messageState.linesAdded;
int? nextLinesRemoved = messageState.linesRemoved;
bool nextSupportsAgentMessages = messageState.supportsAgentMessages;
if (nextStatus != null) {
nextMode ??= "busy";
nextStartedAt ??= DateTime.now();
}
return ChatThreadStatusState(
text: nextStatus,
startedAt: nextStartedAt,
mode: nextMode,
turnId: nextTurnId,
pendingMessages: nextPendingMessages,
pendingItemId: nextPendingItemId,
totalBytes: nextTotalBytes,
linesAdded: nextLinesAdded,
linesRemoved: nextLinesRemoved,
supportsAgentMessages: nextSupportsAgentMessages,
);
}