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:
@@ -12,6 +12,8 @@ class ChatShownDiff {
|
||||
required this.base,
|
||||
required this.baseCommit,
|
||||
required this.head,
|
||||
this.headRevision = '',
|
||||
this.paths = const [],
|
||||
required this.committedOnly,
|
||||
required this.files,
|
||||
required this.additions,
|
||||
@@ -29,6 +31,12 @@ class ChatShownDiff {
|
||||
base: _text(body['base']),
|
||||
baseCommit: _text(body['base_commit']),
|
||||
head: _text(body['head']),
|
||||
headRevision: _text(body['head_revision']),
|
||||
paths: [
|
||||
if (body['paths'] case final List paths)
|
||||
for (final path in paths)
|
||||
if (_text(path).isNotEmpty) _text(path),
|
||||
],
|
||||
committedOnly: body['committed_only'] == true,
|
||||
files: _count(body['files']),
|
||||
additions: _count(body['additions']),
|
||||
@@ -43,6 +51,13 @@ class ChatShownDiff {
|
||||
final String base;
|
||||
final String baseCommit;
|
||||
final String head;
|
||||
|
||||
/// The revision compared instead of the work tree (`show_diff` head), or
|
||||
/// empty.
|
||||
final String headRevision;
|
||||
|
||||
/// The paths or globs the comparison is limited to; empty for all.
|
||||
final List<String> paths;
|
||||
final bool committedOnly;
|
||||
final int files;
|
||||
final int additions;
|
||||
@@ -57,14 +72,25 @@ class ChatShownDiff {
|
||||
return parts.isEmpty ? repo : parts.last;
|
||||
}
|
||||
|
||||
/// What was compared, in words: the branch against its base and whether
|
||||
/// uncommitted work is included.
|
||||
/// What was compared, in words: the branch (or the given revision) against
|
||||
/// its base, whether uncommitted work is included, and the paths it is
|
||||
/// limited to.
|
||||
String get comparison {
|
||||
final limited = paths.isEmpty
|
||||
? ''
|
||||
: ' · ${paths.length <= 3 ? paths.join(', ') : '${paths.take(3).join(', ')} +${paths.length - 3}'}';
|
||||
return '${_compared()}$limited';
|
||||
}
|
||||
|
||||
String _compared() {
|
||||
final where = repoName.isEmpty ? '' : '$repoName · ';
|
||||
if (headRevision.isNotEmpty) {
|
||||
return '$where$headRevision vs ${base.isEmpty ? 'HEAD' : base}';
|
||||
}
|
||||
final head = this.head.isEmpty ? 'HEAD' : this.head;
|
||||
final against = base.isEmpty
|
||||
? (baseCommit.isEmpty ? 'no commits yet' : 'uncommitted changes')
|
||||
: '$head vs $base${committedOnly ? ' · committed only' : ' · with uncommitted work'}';
|
||||
final where = repoName.isEmpty ? '' : '$repoName · ';
|
||||
return base.isEmpty ? '$where$head · $against' : '$where$against';
|
||||
}
|
||||
|
||||
|
||||
@@ -2,15 +2,18 @@ import '../../../core/api_gateway.dart';
|
||||
import 'chat_transcript.dart';
|
||||
|
||||
/// Entries a chat's model showed the operator through the Pipelines tools
|
||||
/// (`show_file`, `show_image`, `show_html`, `show_diff`, `notify`).
|
||||
/// (`show_file`, `show_image`, `show_html`, `show_diff`, `show_run`,
|
||||
/// `notify`).
|
||||
///
|
||||
/// The server keeps them per chat, outside the harness transcript: the
|
||||
/// `chat_subscribe` reply carries the retained list (oldest first) and a
|
||||
/// pushed `chat_shown` frame carries each new or updated item. Items are keyed
|
||||
/// by `id`; a later copy replaces the held one in place.
|
||||
/// by `id`; a later copy replaces the held one in place. The server sends one
|
||||
/// when the model replaces a card (`replace`) and when a shown run changes;
|
||||
/// either keeps the item's `created_at`, so the card stays where it was.
|
||||
|
||||
/// The recorded kinds.
|
||||
const chatShownKinds = {'file', 'image', 'html', 'diff', 'notify'};
|
||||
const chatShownKinds = {'file', 'image', 'html', 'diff', 'run', 'notify'};
|
||||
|
||||
/// The transcript row kind an item is drawn as.
|
||||
const String chatShownRowKind = 'shown';
|
||||
@@ -52,7 +55,7 @@ List<JsonMap> mergeChatShownItems(
|
||||
/// `pipelines/show_file`.
|
||||
final RegExp _pipelinesTool = RegExp(
|
||||
r'^(?:mcp__pipelines__|pipelines_|pipelines/)'
|
||||
r'(?:show_file|show_image|show_html|show_diff|notify)$',
|
||||
r'(?:show_file|show_image|show_html|show_diff|show_run|notify)$',
|
||||
);
|
||||
|
||||
/// Whether [part] is a call of a Pipelines tool whose result the transcript
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../pipelines/pipeline_format.dart' show formatDuration;
|
||||
import '../../runs/domain/run_events.dart' show isTerminalRunStatus;
|
||||
|
||||
/// A `show_run` item's run, as the server records it
|
||||
/// (`internal/protocol/chat_shown.go` ChatShownRunBody). The server pushes the
|
||||
/// item again whenever the run changes, so this is always its latest state.
|
||||
class ChatShownRun {
|
||||
const ChatShownRun({
|
||||
required this.id,
|
||||
required this.pipeline,
|
||||
required this.title,
|
||||
required this.status,
|
||||
required this.outcome,
|
||||
required this.currentStage,
|
||||
required this.startedAt,
|
||||
required this.finishedAt,
|
||||
});
|
||||
|
||||
/// The run of a `run` item, or null for any other item or a malformed one.
|
||||
static ChatShownRun? of(JsonMap item) {
|
||||
final body = item['run'];
|
||||
if (item['kind'] != 'run' || body is! Map) return null;
|
||||
final id = body['id'];
|
||||
if (id is! num || id <= 0) return null;
|
||||
return ChatShownRun(
|
||||
id: id.toInt(),
|
||||
pipeline: _text(body['pipeline']),
|
||||
title: _text(body['title']),
|
||||
status: _text(body['status']),
|
||||
outcome: _text(body['outcome']),
|
||||
currentStage: _text(body['current_stage']),
|
||||
startedAt: _millis(body['started_at']),
|
||||
finishedAt: _millis(body['finished_at']),
|
||||
);
|
||||
}
|
||||
|
||||
final int id;
|
||||
final String pipeline;
|
||||
final String title;
|
||||
final String status;
|
||||
final String outcome;
|
||||
final String currentStage;
|
||||
final int? startedAt;
|
||||
final int? finishedAt;
|
||||
|
||||
/// Whether the run has ended (succeeded, failed, canceled, interrupted).
|
||||
bool get finished => isTerminalRunStatus(status);
|
||||
|
||||
/// The status in words: the outcome of a finished run when it says more.
|
||||
String get statusLabel {
|
||||
final word = status.isEmpty ? 'unknown' : status;
|
||||
final label = '${word[0].toUpperCase()}${word.substring(1)}';
|
||||
return finished && outcome.isNotEmpty && outcome != status
|
||||
? '$label · $outcome'
|
||||
: label;
|
||||
}
|
||||
|
||||
/// How long it ran, or has been running at [now] (epoch milliseconds); null
|
||||
/// without a start time.
|
||||
String? duration(int now) {
|
||||
final start = startedAt;
|
||||
if (start == null) return null;
|
||||
final end = finishedAt ?? (finished ? null : now);
|
||||
if (end == null) return null;
|
||||
return formatDuration((end - start) ~/ 1000);
|
||||
}
|
||||
}
|
||||
|
||||
String _text(Object? value) => '${value ?? ''}'.trim();
|
||||
|
||||
int? _millis(Object? value) => value is num && value > 0 ? value.toInt() : null;
|
||||
Reference in New Issue
Block a user