formatThought method
Implementation
String formatThought(ThoughtData thought) {
String prefix;
String context;
if (thought.isRevision == true) {
prefix = '🔄 Revision';
context = ' (revising thought ${thought.revisesThought})';
} else if (thought.branchFromThought != null) {
prefix = '🌿 Branch';
context =
' (from thought ${thought.branchFromThought}, ID: ${thought.branchId})';
} else {
prefix = '💭 Thought';
context = '';
}
final header =
'$prefix ${thought.thoughtNumber}/${thought.totalThoughts}$context';
final borderLength = [header.length, thought.thought.length]
.reduce((a, b) => a > b ? a : b) +
4;
final border = '─' * borderLength;
return '''
┌$border┐
│ ${header.padRight(borderLength - 2)} │
├$border┤
│ ${thought.thought.padRight(borderLength - 2)} │
└$border┘''';
}