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:
@@ -0,0 +1,160 @@
|
||||
// `?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 = '''
|
||||
<!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',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -36,6 +36,7 @@ import 'chat_question_fixture.dart';
|
||||
import 'chat_shell_fixture.dart';
|
||||
import 'terminal_fixture.dart';
|
||||
import 'chat_shown_fixture.dart';
|
||||
import 'chat_shown_tools_fixture.dart';
|
||||
import 'chat_scroll_fixture.dart';
|
||||
|
||||
Map<String, String> _params = const {};
|
||||
@@ -341,6 +342,10 @@ JsonMap? perfChatReply(JsonMap request) {
|
||||
'chat_shown': chatShownFixture(
|
||||
(request['chat_subscribe'] as Map?)?['session_id'],
|
||||
),
|
||||
if (_params['shown'] == '2')
|
||||
'chat_shown': chatShownToolsFixture(
|
||||
(request['chat_subscribe'] as Map?)?['session_id'],
|
||||
),
|
||||
};
|
||||
case 'chat_prompt':
|
||||
// Accepted, as the server does; no reply follows, so a capture can
|
||||
|
||||
Reference in New Issue
Block a user