// `?shown=2` (with `?chats=N×tamps=1&files=1`): the subscribe reply
// carries the newer shown entries instead of the `shown=1` set, after the
// bench transcript's last answer: a dark-aware and a light-only HTML view, a
// run card running and one finished, a file changed since it was shown, an
// image that no longer exists, a web image the server fetched, and a diff of
// a revision limited to some paths.
import 'package:pipelines_app/core/api_gateway.dart';
int _at(int minute, int second) =>
DateTime.utc(2026, 11, 5, 9, minute, second).millisecondsSinceEpoch;
const String _darkAware = '''
Stage durations (follows the theme)
Build 2m 10s
Test 4m 02s
Release 38s
''';
const String _lightOnly = '''
Plain document (no dark styles)
Its own colours were chosen for a light page, so it stays light.
| Stage | Result |
| Build | passed |
| Test | failed |
''';
int get _now => DateTime.now().millisecondsSinceEpoch;
/// The retained entries the fixture's subscribe reply carries for `shown=2`.
JsonMap chatShownToolsFixture(Object? sessionId) => {
'session_id': sessionId,
'items': [
{
'id': 'shown-dark-html',
'kind': 'html',
'created_at': _at(19, 10),
'title': 'Stage durations',
'html': _darkAware,
'html_bytes': _darkAware.length,
'height_hint': 160,
},
{
'id': 'shown-light-html',
'kind': 'html',
'created_at': _at(19, 15),
'title': 'Light-only view',
'html': _lightOnly,
'html_bytes': _lightOnly.length,
'height_hint': 170,
},
{
'id': 'shown-run-live',
'kind': 'run',
'created_at': _at(19, 20),
'run': {
'id': 7,
'pipeline': 'Release',
'title': 'Publish the 4.2 release notes',
'status': 'running',
'current_stage': 'review',
'started_at': _now - 754000,
},
},
{
'id': 'shown-run-done',
'kind': 'run',
'created_at': _at(19, 25),
'run': {
'id': 6,
'pipeline': 'Feature',
'title': 'Add show_run to the chat tools',
'status': 'failed',
'outcome': 'tests_failed',
'started_at': _at(1, 0),
'finished_at': _at(9, 30),
},
},
{
'id': 'shown-changed',
'kind': 'file',
'created_at': _at(19, 30),
'path': '/srv/probe/release/server.log',
'name': 'server.log',
'size': 9437184,
'mime': 'text/plain',
'mod_time': _at(19, 0),
'sha256': 'f' * 64,
'state': 'changed',
},
{
'id': 'shown-missing',
'kind': 'image',
'created_at': _at(19, 35),
'title': 'Old screenshot',
'path': '/srv/probe/release/old-screenshot.png',
'name': 'old-screenshot.png',
'size': 8000000,
'mime': 'image/png',
'state': 'missing',
},
{
'id': 'shown-fetched',
'kind': 'image',
'created_at': _at(19, 40),
'path': '/srv/probe/.local/share/pipelines/chat-shown/s/f/icon.jpg',
'name': 'icon.jpg',
'size': 2400,
'mime': 'image/jpeg',
'snapshot': true,
'url': 'https://images.example.test/brand/icon.jpg',
},
{
'id': 'shown-head-diff',
'kind': 'diff',
'created_at': _at(19, 45),
'title': 'Run 123 against main',
'diff_bytes': 180,
'diff': {
'repo': '/srv/probe/pipelines',
'base': 'main',
'base_commit': '79e51834a1b2',
'head_revision': 'pipelines/run-123',
'paths': ['internal/chattools', '*.md'],
'files': 2,
'additions': 3,
'deletions': 1,
'changes': {
'status': 'complete',
'skipped': 0,
'files': [
{
'path': 'internal/chattools/tools.go',
'kind': 'modified',
'patch':
'@@ -6,2 +6,3 @@\n \tToolShowDiff = "show_diff"\n'
'-\tToolNotify = "notify"\n+\tToolShowRun = "show_run"\n'
'+\tToolNotify = "notify"\n',
},
{
'path': 'README.md',
'kind': 'modified',
'patch': '@@ -1 +1,2 @@\n line\n+show_run\n',
},
],
},
},
},
],
};