App: dark-aware HTML views, run cards, changed/missing file notes, one card width, dense diff rows

show_html documents that declare dark support follow the app theme; others
stay light. Tool description and skill docs say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-02 19:54:58 +00:00
parent d204ce3187
commit f02ff56dfe
27 changed files with 1086 additions and 61 deletions
@@ -144,4 +144,51 @@ void main() {
findsOneWidget,
);
});
testWidgets('a head revision and paths are named in the comparison', (
tester,
) async {
final item = _item();
final diff = item['diff'] as JsonMap;
diff['head_revision'] = 'pipelines/run-123';
diff['paths'] = ['app/lib', '*.go', 'docs', 'web'];
await _pump(tester, item);
expect(
find.text(
'pipelines · pipelines/run-123 vs main · app/lib, *.go, docs +1',
),
findsOneWidget,
);
});
testWidgets('file rows are one dense line each', (tester) async {
await _pump(tester, _item());
final row = find.byType(ChangeFileRow).first;
expect(tester.getSize(row).height, lessThanOrEqualTo(48));
// The counts share the path's line instead of a subtitle below it.
expect(
tester.getCenter(find.text('app/lib/a.dart')).dy,
closeTo(tester.getCenter(row).dy, 2),
);
});
test('run items are a recorded kind and show_run calls are hidden', () {
expect(chatShownKinds, contains('run'));
expect(
chatPipelinesToolRepresented({
'type': 'tool',
'name': 'pipelines_show_run',
'state': {'status': 'completed'},
}),
isTrue,
);
expect(
chatPipelinesToolRepresented({
'type': 'tool',
'name': 'mcp__pipelines__schedule_followup',
'state': {'status': 'completed'},
}),
isFalse,
);
});
}
@@ -0,0 +1,209 @@
import 'dart:convert';
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/artifacts/ui/artifact_viewer_fetch.dart';
import 'package:pipelines_app/features/chat/chat_run_opener.dart';
import 'package:pipelines_app/features/chat/files/files_urls.dart';
import 'package:pipelines_app/features/chat/files/files_viewer.dart';
import 'package:pipelines_app/features/chat/ui/transcript/shown/chat_shown_card.dart';
import 'package:pipelines_app/features/chat/ui/transcript/shown/chat_shown_run_card.dart';
import 'package:pipelines_app/features/chat/ui/transcript/shown/chat_shown_surface.dart';
const _png =
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==';
final _start = DateTime.utc(2026, 12, 1, 9);
JsonMap _run(String status, {int? finishedMinutes, String stage = 'review'}) =>
{
'id': 'r',
'kind': 'run',
'created_at': 1,
'run': {
'id': 42,
'pipeline': 'Feature',
'title': 'Add show_run',
'status': status,
'current_stage': stage,
'started_at': _start.millisecondsSinceEpoch,
if (finishedMinutes != null)
'finished_at': _start
.add(Duration(minutes: finishedMinutes))
.millisecondsSinceEpoch,
},
};
void main() {
late FileUrlResolver original;
final fetched = <Uri>[];
final opened = <int>[];
setUp(() {
original = resolveFileUrls;
resolveFileUrls = (endpoint, path) => fileUrls(endpoint, path);
fetched.clear();
opened.clear();
});
tearDown(() => resolveFileUrls = original);
final viewer = FilesViewer(
fetch: (uri) async {
fetched.add(uri);
final path = uri.queryParameters['path'] ?? '';
return ArtifactFetchResult(
status: 200,
bytes: path.endsWith('.png')
? base64Decode(_png)
: utf8.encode('line one\n'),
);
},
);
Future<void> pump(WidgetTester tester, Widget card) async {
await tester.binding.setSurfaceSize(const Size(1400, 900));
addTearDown(() => tester.binding.setSurfaceSize(null));
await tester.pumpWidget(
ChatRunOpener(
openRun: opened.add,
child: MaterialApp(
home: Scaffold(body: SingleChildScrollView(child: card)),
),
),
);
await tester.pump();
await tester.pump();
}
Widget shown(JsonMap item) => ChatShownCard(
row: {'kind': 'shown', 'item': item},
endpoint: 'ws://peer.example.test/peers/abc/connect',
viewer: viewer,
htmlBuilder: (_, _) => const SizedBox.expand(),
);
testWidgets('a changed live file says so and still opens', (tester) async {
await pump(
tester,
shown({
'id': 'c',
'kind': 'file',
'path': '/home/demo/notes.txt',
'size': 40,
'state': 'changed',
}),
);
await tester.pumpAndSettle();
expect(find.text('Changed since shown'), findsOneWidget);
expect(find.byKey(const Key('chat-shown-file-lines')), findsOneWidget);
expect(find.byType(InkWell), findsOneWidget);
});
testWidgets('a missing file says so and loads nothing', (tester) async {
await pump(
tester,
shown({
'id': 'm',
'kind': 'image',
'path': '/home/demo/gone.png',
'size': 10,
'state': 'missing',
}),
);
await tester.pumpAndSettle();
expect(find.text('No longer exists'), findsOneWidget);
expect(find.byType(Image), findsNothing);
expect(fetched, isEmpty);
expect(find.byType(InkWell), findsNothing);
});
testWidgets('a fetched web image draws its snapshot and names the address', (
tester,
) async {
await pump(
tester,
shown({
'id': 'w',
'kind': 'image',
'path': '/home/demo/.local/share/pipelines/chat-shown/s/w/cat.png',
'name': 'cat.png',
'snapshot': true,
'url': 'https://images.example.test/cat.png',
}),
);
expect(find.text('images.example.test'), findsOneWidget);
expect(find.text('https://images.example.test/cat.png'), findsOneWidget);
expect(find.text('No longer exists'), findsNothing);
});
testWidgets('a running run ticks its duration and opens the run', (
tester,
) async {
var now = _start.add(const Duration(minutes: 2, seconds: 5));
await pump(tester, ChatShownRunCard(item: _run('running'), now: () => now));
expect(find.text('Add show_run'), findsOneWidget);
expect(find.text('Feature'), findsOneWidget);
expect(find.text('Running'), findsOneWidget);
expect(find.text('#42 · review · 2m 5s'), findsOneWidget);
expect(find.bySemanticsLabel(RegExp('Shown run Add show_run')), findsOne);
now = now.add(const Duration(seconds: 3));
await tester.pump(const Duration(seconds: 1));
expect(find.text('#42 · review · 2m 8s'), findsOneWidget);
await tester.tap(find.text('Add show_run'));
expect(opened, [42]);
});
testWidgets('a finished run shows its outcome and final duration', (
tester,
) async {
final item = _run('failed', finishedMinutes: 7);
(item['run'] as Map)['outcome'] = 'tests_failed';
await pump(tester, shown(item));
expect(find.text('Failed · tests_failed'), findsOneWidget);
expect(find.text('#42 · 7m 0s'), findsOneWidget);
expect(find.byIcon(Icons.error_outline), findsOneWidget);
});
testWidgets('a replaced run item updates the same card in place', (
tester,
) async {
final now = _start.add(const Duration(minutes: 1));
Widget card(JsonMap item) => ChatShownRunCard(
key: const ValueKey('chat-shown-r'),
item: item,
now: () => now,
);
await pump(tester, card(_run('running')));
final state = tester.state(find.byType(ChatShownRunCard));
await pump(tester, card(_run('succeeded', finishedMinutes: 4)));
expect(tester.state(find.byType(ChatShownRunCard)), same(state));
expect(find.text('Succeeded'), findsOneWidget);
expect(find.text('#42 · 4m 0s'), findsOneWidget);
});
testWidgets('file, image, view, diff and run cards share one width', (
tester,
) async {
final items = <JsonMap>[
{'id': 'f', 'kind': 'file', 'path': '/home/demo/a.txt', 'size': 1},
{'id': 'i', 'kind': 'image', 'path': '/home/demo/a.png', 'size': 1},
{'id': 'h', 'kind': 'html', 'html': '<p>x</p>', 'html_bytes': 8},
{
'id': 'd',
'kind': 'diff',
'diff': {'repo': '/r', 'files': 0, 'additions': 0, 'deletions': 0},
},
_run('running'),
];
for (final item in items) {
await pump(tester, shown(item));
final card = find.byType(Card);
expect(card, findsOneWidget, reason: '${item['kind']}');
expect(
tester.getSize(card).width,
chatShownCardMaxWidth,
reason: '${item['kind']}',
);
}
});
}