lastMessageHasOnlyThinkingContent method

bool lastMessageHasOnlyThinkingContent()

True when the last message contains thinking tags and either the tag is not yet closed or the visible text outside thinking is empty (so we keep showing the loading indicator).

Implementation

bool lastMessageHasOnlyThinkingContent() {
  final PupauMessage? last = messages.firstOrNull;
  if (last == null) return false;
  final String answer = last.answer;
  if (!answer.contains(TagService.thinkingOpeningTag)) return false;
  if (!answer.contains(TagService.thinkingClosingTag)) return true;
  final String withoutThinking = answer
      .replaceAll(TagService.thinkingRegex, '')
      .trim();
  return withoutThinking.isEmpty;
}