113063b040
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>
26 lines
955 B
Dart
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;
|
|
}
|