renderState method

String renderState(
  1. ConsciousState state
)

Renders a ConsciousState as a formatted ASCII panel.

Implementation

String renderState(ConsciousState state) {
  final buf = StringBuffer();
  buf.writeln('╔══════════════════════════════════════════════╗');
  buf.writeln('║          🧠  CONSCIOUS STATE                 ║');
  buf.writeln('╠══════════════════════════════════════════════╣');
  buf.writeln('║ Focus     : ${_pad(state.focusedConceptId, 33)}║');
  buf.writeln(
      '║ Coherence : ${_bar(state.coherence)} ${_pct(state.coherence).padLeft(6)} ║');
  buf.writeln(
      '║ Timestamp : ${_pad(state.timestamp.toIso8601String().substring(0, 19), 33)}║');
  buf.writeln('╠══════════════════════════════════════════════╣');
  buf.writeln('║  Active workspace (${state.workspace.length} concepts):            ║');

  for (final c in state.workspace) {
    final label = c.content.length > 18
        ? '${c.content.substring(0, 15)}...'
        : c.content;
    buf.writeln(
      '║  • ${label.padRight(18)} ${_bar(c.activationLevel)} ${_pct(c.activationLevel).padLeft(6)} ║',
    );
  }

  if (state.inferencesGenerated.isNotEmpty) {
    buf.writeln('╠══════════════════════════════════════════════╣');
    buf.writeln('║  Inferences (${state.inferencesGenerated.length}):                        ║');
    for (final i in state.inferencesGenerated.take(5)) {
      final text = i.conclusion.length > 36
          ? '${i.conclusion.substring(0, 33)}...'
          : i.conclusion;
      buf.writeln('║  → ${text.padRight(42)}║');
    }
  }

  buf.writeln('╚══════════════════════════════════════════════╝');
  return buf.toString();
}