Quieter transcript metadata: day dividers, time-only rows, muted meta rows

- Date once per calendar day: a muted centred divider above each day's
  first timed row (chatDayDividers); rows show only their time ("10:16"),
  with the full date and time kept in the tooltip and semantics. The user's
  time shares the delivery line; a harness notice's time trails its line.
- Activity line and turn chips are secondary: bodyMedium, regular weight,
  onSurfaceVariant (error colour kept for failures), a small chevron_right
  that turns down while its details are open (replaces expand_less).
- Copy / Read aloud: 18 px muted icons; on pointer devices shown only while
  the reply is hovered or an action is focused (also without the gutter);
  touch keeps them visible with a full tap target. The time leads the
  footer so hidden actions leave no gap.
- Settled questions: the question on one line, the operator's answer in
  full on its own line beneath it.
- Meta rows (activity, chips, notices, compaction line) start at the reply
  text's leading edge; turn chips sit in their own column under the answer.
- Scroll fixture: ?timestamps=1 spreads messages over two days.

Row keys are unchanged; the divider joins a row without replacing it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 11:10:51 +00:00
parent 33874005c4
commit a3a59adb30
23 changed files with 993 additions and 180 deletions
@@ -0,0 +1,69 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/ui/transcript/chat_message_timestamp.dart';
import '../shell/chat_shell_fixtures.dart';
JsonMap _message(String id, String role, DateTime at) => {
'id': id,
'role': role,
'created_at': at.millisecondsSinceEpoch,
'parts': [
{'type': 'text', 'text': 'Text of $id'},
],
};
void main() {
testWidgets('the transcript dates each day once and each row by its time', (
tester,
) async {
tester.view.physicalSize = const Size(900, 2400);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final gateway = ShellGateway()
..messages = [
_message('u1', 'user', DateTime(2026, 11, 24, 9, 5)),
_message('a1', 'assistant', DateTime(2026, 11, 24, 9, 6)),
_message('u2', 'user', DateTime(2026, 11, 24, 17, 40)),
_message('a2', 'assistant', DateTime(2026, 11, 24, 17, 41)),
_message('u3', 'user', DateTime(2026, 11, 25, 10, 16)),
_message('a3', 'assistant', DateTime(2026, 11, 25, 10, 17)),
];
addTearDown(gateway.close);
await tester.pumpWidget(shellThread(gateway));
await tester.pump();
await tester.pump();
final dividers = find.byType(ChatDayDivider);
expect(dividers, findsNWidgets(2));
expect(find.text('24 November 2026'), findsOneWidget);
expect(find.text('25 November 2026'), findsOneWidget);
// The first day's divider precedes its first message; the second day's
// sits between the last message of the 24th and the first of the 25th.
final first = tester.getRect(find.text('24 November 2026'));
final second = tester.getRect(find.text('25 November 2026'));
expect(first.bottom, lessThan(tester.getRect(find.text('Text of u1')).top));
expect(
second.top,
greaterThan(tester.getRect(find.text('Text of a2')).top),
);
expect(
second.bottom,
lessThan(tester.getRect(find.text('Text of u3')).top),
);
// Every row shows its time alone; no row repeats the date.
expect(find.byType(ChatMessageTimestamp), findsNWidgets(6));
for (final time in ['09:05', '09:06', '17:40', '17:41', '10:16', '10:17']) {
expect(find.text(time), findsOneWidget);
}
expect(find.textContaining('November 2026 ·'), findsNothing);
// The divider names its day for assistive technology as a heading.
expect(
tester.getSemantics(dividers.first),
isSemantics(label: '24 November 2026', isHeader: true),
);
});
}
@@ -0,0 +1,79 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import '../shell/chat_shell_fixtures.dart';
const _reply = 'The reply text';
final List<JsonMap> _messages = [
{
'id': 'u1',
'role': 'user',
'parts': [
{'type': 'text', 'text': 'Question'},
],
},
{
'id': 'a1',
'role': 'assistant',
'parts': [
{'type': 'reasoning', 'text': 'Thinking it over.'},
{
'type': 'tool',
'id': 't1',
'name': 'read',
'state': 'completed',
'input': {'path': 'lib/main.dart'},
},
{'type': 'text', 'text': _reply},
],
},
{
'id': 'n1',
'role': 'user',
'kind': 'notice',
'parts': [
{'type': 'text', 'text': 'The harness compacted the context.'},
],
},
];
void main() {
for (final width in [390.0, 1400.0]) {
testWidgets('at ${width.toInt()} px every meta row starts at the reply '
'text\'s edge', (tester) async {
tester.view.physicalSize = Size(width, 1200);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final gateway = ShellGateway()..messages = _messages;
addTearDown(gateway.close);
await tester.pumpWidget(shellThread(gateway));
await tester.pump();
await tester.pump();
final text = tester.getRect(find.text(_reply)).left;
// The activity line's label.
final activity = find.descendant(
of: find.byKey(const Key('chat-turn-activity')),
matching: find.byType(Text),
);
expect(tester.getRect(activity.first).left, text);
// The harness notice's icon.
expect(tester.getRect(find.byIcon(Icons.info_outline)).left, text);
// The activity label is secondary: smaller than the reply, regular
// weight, in the muted colour.
final label = tester.widget<Text>(activity.first);
final context = tester.element(activity.first);
final theme = Theme.of(context);
expect(label.style?.color, theme.colorScheme.onSurfaceVariant);
expect(label.style?.fontWeight, FontWeight.w400);
expect(
label.style?.fontSize,
lessThan(theme.textTheme.bodyLarge!.fontSize!),
);
});
}
}
@@ -514,7 +514,9 @@ void main() {
await tester.pumpAndSettle();
// The answered question leaves the card list (chat_question_group_test).
expect(find.text(chatQuestionWaiting), findsNothing);
expect(find.text('Colour · Red · +1 more'), findsOneWidget);
// Collapsed: the question on one line, the answer in full on its own.
expect(find.text('Colour'), findsOneWidget);
expect(find.text('Red · +1 more'), findsOneWidget);
});
testWidgets('a refused question keeps the card open with the server reason', (
@@ -0,0 +1,105 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/conversation/chat_question_group.dart';
const _answer =
'Postgres 16 on the managed cluster, with read replicas in both regions '
'and nightly backups kept for thirty days';
JsonMap _form() => {
'id': 'form-1',
'title': 'Database',
'resolved': true,
'answers': {'q0': _answer},
'fields': [
{
'key': 'q0',
'title': 'Which database should the release use?',
'type': 'string',
'custom': true,
'options': [
{'value': 'Postgres', 'label': 'Postgres'},
],
},
],
};
final _chip = find.byKey(const ValueKey('chat-question-chip-form-1'));
final _answerLine = find.byKey(const ValueKey('chat-question-answer-form-1'));
Future<void> _pump(WidgetTester tester) async {
await tester.binding.setSurfaceSize(const Size(390, 844));
addTearDown(() => tester.binding.setSurfaceSize(null));
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Align(
alignment: AlignmentDirectional.topStart,
child: ChatQuestionChip(form: _form()),
),
),
),
);
}
void main() {
test('the summary splits into the question and its outcome', () {
final parts = chatQuestionSummaryParts(_form());
expect(parts.question, 'Which database should the release use?');
expect(parts.outcome, _answer);
expect(
chatQuestionSummary(_form()),
'Which database should the release use? · $_answer',
);
});
testWidgets('a settled question shows its whole answer on its own line', (
tester,
) async {
await _pump(tester);
final question = find.text('Which database should the release use?');
expect(question, findsOneWidget);
expect(find.text(_answer), findsOneWidget);
// The answer wraps in full rather than ellipsizing on the question's line.
final answer = tester.widget<Text>(_answerLine);
expect(answer.maxLines, isNull);
expect(answer.overflow, isNot(TextOverflow.ellipsis));
final line = tester.getRect(question);
final rect = tester.getRect(_answerLine);
expect(rect.top, greaterThanOrEqualTo(line.bottom));
expect(rect.height, greaterThan(line.height * 1.5));
// Both lines start together, after the leading icon.
expect(rect.left, line.left);
// It is emphasised above the muted question.
final context = tester.element(_answerLine);
expect(answer.style?.color, Theme.of(context).colorScheme.onSurface);
expect(tester.takeException(), isNull);
});
testWidgets('its chevron is the expand affordance and turns while open', (
tester,
) async {
await _pump(tester);
expect(find.byIcon(Icons.expand_less), findsNothing);
expect(
find.descendant(of: _chip, matching: find.byIcon(Icons.chevron_right)),
findsOneWidget,
);
double turns() => tester
.widget<AnimatedRotation>(
find.descendant(of: _chip, matching: find.byType(AnimatedRotation)),
)
.turns;
expect(turns(), 0);
await tester.tap(_chip);
await tester.pumpAndSettle();
expect(find.byKey(const Key('chat-question-sheet')), findsOneWidget);
expect(turns(), 0.25);
Navigator.of(
tester.element(find.byKey(const Key('chat-question-sheet'))),
).pop();
await tester.pumpAndSettle();
expect(turns(), 0);
});
}
@@ -55,6 +55,13 @@ JsonMap _form({String id = 'form-1'}) => {
const _chip = 'Which database? · Postgres';
/// One line of the settled question's chip: the question, or the recorded
/// outcome on its own line beneath it.
Finder _settledLine(String text) => find.descendant(
of: find.byKey(const ValueKey('chat-question-chip-form-1')),
matching: find.text(text),
);
/// A chat whose agent turn `a1` is the one the question arrives during.
Future<FakeChatGateway> _open(WidgetTester tester, Size size) async {
await tester.binding.setSurfaceSize(size);
@@ -97,12 +104,13 @@ void _expectCollapsed() {
expect(find.text(chatQuestionWaiting), findsNothing);
expect(find.text(chatQuestionSubmit), findsNothing);
expect(find.text(chatQuestionAnswered), findsNothing);
expect(find.text(_chip), findsOneWidget);
// The chip sits in its turn's footer, under the turn that asked.
expect(_settledLine('Which database?'), findsOneWidget);
expect(_settledLine('Postgres'), findsOneWidget);
// The chip sits among its turn's chips, under the turn that asked.
expect(
find.descendant(
of: find.byKey(const Key('chat-message-footer')),
matching: find.text(_chip),
of: find.byKey(const Key('chat-turn-chips')),
matching: find.byKey(const ValueKey('chat-question-chip-form-1')),
),
findsOneWidget,
);
@@ -194,12 +202,15 @@ void main() {
await tester.pumpAndSettle();
_expectCollapsed();
await tester.tap(find.text(_chip));
await tester.tap(find.byKey(const ValueKey('chat-question-chip-form-1')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('chat-question-sheet')), findsOneWidget);
expect(find.text('Which database?'), findsOneWidget);
expect(find.text('Postgres'), findsOneWidget);
expect(find.text(chatQuestionAnswered), findsOneWidget);
final sheet = find.byKey(const Key('chat-question-sheet'));
expect(sheet, findsOneWidget);
Finder inSheet(String text) =>
find.descendant(of: sheet, matching: find.text(text));
expect(inSheet('Which database?'), findsOneWidget);
expect(inSheet('Postgres'), findsOneWidget);
expect(inSheet(chatQuestionAnswered), findsOneWidget);
expect(tester.takeException(), isNull);
});
@@ -213,7 +224,10 @@ void main() {
expect(find.textContaining('no longer awaiting'), findsOneWidget);
expect(find.text(chatQuestionWaiting), findsOneWidget);
expect(find.text(chatQuestionSubmit), findsOneWidget);
expect(find.text(_chip), findsNothing);
expect(
find.byKey(const ValueKey('chat-question-chip-form-1')),
findsNothing,
);
});
}
@@ -227,7 +241,8 @@ void main() {
});
await tester.pumpAndSettle();
expect(find.text(chatQuestionWaiting), findsNothing);
expect(find.text('Which database? · Closed'), findsOneWidget);
expect(_settledLine('Which database?'), findsOneWidget);
expect(_settledLine('Closed'), findsOneWidget);
});
testWidgets('a cancelled question collapses as expired', (tester) async {
@@ -239,7 +254,8 @@ void main() {
});
await tester.pumpAndSettle();
expect(find.text(chatQuestionWaiting), findsNothing);
expect(find.text('Which database? · Expired'), findsOneWidget);
expect(_settledLine('Which database?'), findsOneWidget);
expect(_settledLine('Expired'), findsOneWidget);
});
testWidgets('OpenCode: ack then form.replied leaves one collapsed row', (