Files
pipelines/app/lib/features/chat/domain/chat_cell_numbers.dart
T
alan 113063b040 Notebook design: numbered In/Out cells, tool sub-cells and an input-cell composer
Adds the Notebook design (TranscriptStyle.cells, ComposerStyle.cell), a
white/charcoal IDE theme with light grey cells, hairlines and 5px corners.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 23:24:03 +00:00

26 lines
955 B
Dart

import '../../../core/api_gateway.dart';
/// A notebook transcript's cell numbers by row key: each operator turn
/// (a `user` row, typed or sent on the operator's behalf) takes the next
/// number from 1 in transcript order, and every agent row (`assistant`) that
/// follows takes its prompt's number, so `In [n]:` and `Out [n]:` pair up.
///
/// Derived from the turn's position, never stored: the same history always
/// numbers the same way, so a reload keeps every cell's number. An agent
/// row before any operator turn has none (`Out [ ]:`).
Map<String, int> chatCellNumbers(Iterable<JsonMap> rows) {
final numbers = <String, int>{};
var turn = 0;
for (final row in rows) {
final key = '${row['key'] ?? ''}';
switch (row['kind']) {
case 'user':
turn++;
if (key.isNotEmpty) numbers[key] = turn;
case 'assistant':
if (turn > 0 && key.isNotEmpty) numbers[key] = turn;
}
}
return numbers;
}