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
+160
View File
@@ -0,0 +1,160 @@
// `?shown=2` (with `?chats=N&timestamps=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 = '''
<!doctype html><html><head><style>
:root{color-scheme:light dark}
body{margin:0;padding:12px;font:14px system-ui;background:#fafafa;color:#1b1b1f}
.bar{height:18px;border-radius:4px;background:#1e88e5;margin:6px 0}
@media (prefers-color-scheme: dark){
body{background:#1b1b1f;color:#e6e1e5}
.bar{background:#90caf9}
}
</style></head><body>
<strong>Stage durations (follows the theme)</strong>
<div class="bar" style="width:40%"></div><div>Build 2m 10s</div>
<div class="bar" style="width:80%"></div><div>Test 4m 02s</div>
<div class="bar" style="width:15%"></div><div>Release 38s</div>
</body></html>''';
const String _lightOnly = '''
<!doctype html><html><body style="margin:0;padding:12px;font:14px system-ui">
<strong>Plain document (no dark styles)</strong>
<p>Its own colours were chosen for a light page, so it stays light.</p>
<table border="1" cellpadding="4" style="border-collapse:collapse">
<tr><th>Stage</th><th>Result</th></tr>
<tr><td>Build</td><td style="color:#2e7d32">passed</td></tr>
<tr><td>Test</td><td style="color:#c62828">failed</td></tr>
</table></body></html>''';
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',
},
],
},
},
},
],
};