Merge branch 'worktree-agent-add3194df2bcbd3c5'
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -111,7 +111,7 @@ String? noPatchReasonMessage(String? reason) => switch (reason) {
|
||||
'budget' =>
|
||||
'The workspace snapshot ran out of text budget, so no diff text was '
|
||||
'recorded.',
|
||||
'lines' => 'The change is over 5,000 lines, so no diff text was recorded.',
|
||||
'lines' => 'The change is over 20,000 lines, so no diff text was recorded.',
|
||||
'evidence_size' =>
|
||||
"This visit's recorded changes reached their size limit, so this patch "
|
||||
'was dropped.',
|
||||
@@ -121,6 +121,15 @@ String? noPatchReasonMessage(String? reason) => switch (reason) {
|
||||
'baseline' =>
|
||||
"The file's content at stage start couldn't be recovered from Git, so no "
|
||||
'diff was recorded.',
|
||||
'symlink' => 'Symbolic link; only the change to its target was recorded.',
|
||||
'protected' =>
|
||||
'A protected file (secrets, credentials or a database); its content is '
|
||||
'never read, only that it changed.',
|
||||
'generated' =>
|
||||
'A lockfile, minified or generated file; it is listed without a diff.',
|
||||
'large' =>
|
||||
'This file is too large to hash, so it was compared by size and '
|
||||
'modification time only.',
|
||||
_ => null,
|
||||
};
|
||||
|
||||
|
||||
@@ -36,8 +36,10 @@ class FileChange {
|
||||
final bool truncated;
|
||||
|
||||
/// Why the server recorded no (complete) patch: `binary`, `file_size`,
|
||||
/// `budget`, `lines`, `evidence_size`, `git_status` or `baseline`. Null from
|
||||
/// an older server or when a patch was recorded.
|
||||
/// `budget`, `lines`, `evidence_size`, `git_status`, `baseline`, `symlink`,
|
||||
/// `protected` (content never read), `generated` (lockfile/minified) or
|
||||
/// `large` (compared by size and mtime only). Null from an older server or
|
||||
/// when a patch was recorded; an unknown value gets the generic wording.
|
||||
final String? noPatchReason;
|
||||
final String? beforeMode;
|
||||
final String? afterMode;
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
// The `check` stage type: a model-free stage that runs shell commands and
|
||||
// routes `pass`/`fail` (plus `error`). Its `delivery` config marks the landing
|
||||
// gate, which runs the commands in a fresh worktree and fast-forwards main on
|
||||
// pass. Pure data only; an older graph simply has no check stages.
|
||||
|
||||
/// The stage type word the server uses for a check stage.
|
||||
const String checkStageType = 'check';
|
||||
|
||||
/// Whether [stage] (a graph stage declaration) is a check stage.
|
||||
bool isCheckStage(dynamic stage) =>
|
||||
stage is Map && '${stage['type'] ?? ''}'.trim() == checkStageType;
|
||||
|
||||
/// Whether a check [stage] is the delivery (landing) gate.
|
||||
///
|
||||
/// Configs are strings on the wire (`"true"`); a JSON boolean is accepted too.
|
||||
bool isDeliveryGate(dynamic stage) {
|
||||
if (!isCheckStage(stage)) return false;
|
||||
final configs = (stage as Map)['configs'];
|
||||
if (configs is! Map) return false;
|
||||
final value = configs['delivery'];
|
||||
return value == true || '${value ?? ''}'.trim().toLowerCase() == 'true';
|
||||
}
|
||||
|
||||
/// The check stage's commands, one per non-blank line of `blocks.commands`
|
||||
/// (a list of strings is read item by item), in declared order.
|
||||
List<String> checkCommands(dynamic stage) {
|
||||
if (stage is! Map) return const <String>[];
|
||||
final blocks = stage['blocks'];
|
||||
if (blocks is! Map) return const <String>[];
|
||||
final raw = blocks['commands'];
|
||||
final lines = raw is List
|
||||
? [for (final item in raw) '${item ?? ''}']
|
||||
: '${raw ?? ''}'.split('\n');
|
||||
return [
|
||||
for (final line in lines)
|
||||
if (line.trim().isNotEmpty) line.trimRight(),
|
||||
];
|
||||
}
|
||||
|
||||
/// The short kind a graph node shows under its name: `Check` or
|
||||
/// `Delivery gate`, or null for every other stage type.
|
||||
String? checkStageCaption({required String type, required bool delivery}) {
|
||||
if (type.trim() != checkStageType) return null;
|
||||
return delivery ? 'Delivery gate' : 'Check';
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'check_stage.dart';
|
||||
import 'graph_protocol.dart';
|
||||
|
||||
/// The graph definition: nodes and edges declared by a pipeline, never the
|
||||
@@ -70,11 +71,27 @@ class GraphEdge {
|
||||
/// One graph definition node: a declared stage, or a terminal the definition
|
||||
/// routes to.
|
||||
class GraphNode {
|
||||
const GraphNode({required this.key, required this.terminal, this.stageIndex});
|
||||
const GraphNode({
|
||||
required this.key,
|
||||
required this.terminal,
|
||||
this.stageIndex,
|
||||
this.type = '',
|
||||
this.delivery = false,
|
||||
});
|
||||
|
||||
final String key;
|
||||
final bool terminal;
|
||||
|
||||
/// The stage's declared `type` exactly as recorded (blank reads `model`);
|
||||
/// empty for a terminal.
|
||||
final String type;
|
||||
|
||||
/// Whether this is a check stage marked as the delivery gate.
|
||||
final bool delivery;
|
||||
|
||||
/// `Check` or `Delivery gate` for a check stage, otherwise null.
|
||||
String? get kindCaption => checkStageCaption(type: type, delivery: delivery);
|
||||
|
||||
/// The node's stage declaration index, or null for a terminal.
|
||||
final int? stageIndex;
|
||||
|
||||
@@ -142,7 +159,15 @@ List<GraphNode> graphNodes(dynamic graph) {
|
||||
for (var index = 0; index < stages.length; index += 1) {
|
||||
final key = _stageKey(stages[index]);
|
||||
if (key.isEmpty || !seen.add(key)) continue;
|
||||
nodes.add(GraphNode(key: key, terminal: false, stageIndex: index));
|
||||
nodes.add(
|
||||
GraphNode(
|
||||
key: key,
|
||||
terminal: false,
|
||||
stageIndex: index,
|
||||
type: '${stages[index]['type'] ?? ''}',
|
||||
delivery: isDeliveryGate(stages[index]),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (graphEdges(graph).any((edge) => edge.isTerminal)) {
|
||||
nodes.add(const GraphNode(key: failureEnd, terminal: true));
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'check_stage.dart';
|
||||
import 'graph_definition.dart';
|
||||
import 'graph_protocol.dart';
|
||||
|
||||
@@ -9,13 +10,22 @@ import 'graph_protocol.dart';
|
||||
/// reads run visits, so a definition can be inspected without claiming that a
|
||||
/// stage executed.
|
||||
class StageDefinitionField {
|
||||
const StageDefinitionField(this.label, this.value, {this.block = false});
|
||||
const StageDefinitionField(
|
||||
this.label,
|
||||
this.value, {
|
||||
this.block = false,
|
||||
this.monospace = false,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final String value;
|
||||
|
||||
/// Multi-line content (prompt, output, outcomes, tools, memory, routes).
|
||||
final bool block;
|
||||
|
||||
/// Literal code (a check stage's commands): always shown verbatim in a
|
||||
/// monospace block, never rendered as markdown.
|
||||
final bool monospace;
|
||||
}
|
||||
|
||||
/// The one stage declaration [key] names, or null when this version does not
|
||||
@@ -58,6 +68,12 @@ String stageConfigLabel(String key) {
|
||||
return 'Budget (tokens)';
|
||||
case 'harness':
|
||||
return 'Harness';
|
||||
case 'command_timeout':
|
||||
return 'Command timeout';
|
||||
case 'keep_going':
|
||||
return 'Keep going';
|
||||
case 'delivery':
|
||||
return 'Delivery gate';
|
||||
default:
|
||||
return key;
|
||||
}
|
||||
@@ -69,10 +85,27 @@ String stageConfigLabel(String key) {
|
||||
/// interpreted here; the pane keeps the stage's raw JSON so they stay visible.
|
||||
List<StageDefinitionField> stageDefinitionFields(dynamic stage) {
|
||||
if (stage is! Map) return const <StageDefinitionField>[];
|
||||
final type = effectiveStageType(stage['type']);
|
||||
final fields = <StageDefinitionField>[
|
||||
StageDefinitionField('Type', effectiveStageType(stage['type'])),
|
||||
StageDefinitionField(
|
||||
'Type',
|
||||
isDeliveryGate(stage) ? '$type (delivery gate)' : type,
|
||||
),
|
||||
];
|
||||
|
||||
// A check stage runs commands where a model stage has its prompt.
|
||||
final commands = checkCommands(stage);
|
||||
if (isCheckStage(stage) && commands.isNotEmpty) {
|
||||
fields.add(
|
||||
StageDefinitionField(
|
||||
'Commands',
|
||||
commands.join('\n'),
|
||||
block: true,
|
||||
monospace: true,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final prompt = _text(stage['prompt']);
|
||||
if (prompt.trim().isNotEmpty) {
|
||||
fields.add(StageDefinitionField('Prompt', prompt, block: true));
|
||||
|
||||
@@ -45,10 +45,7 @@ class GraphStageNode extends StatelessWidget {
|
||||
return status != null && status.trim().isNotEmpty ? status : null;
|
||||
}
|
||||
|
||||
String get _label {
|
||||
final status = _status;
|
||||
return status == null ? node.label : '${node.label}\n$status';
|
||||
}
|
||||
String get _label => graphNodeSemanticsLabel(node, _status);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -112,11 +109,13 @@ class GraphStageNode extends StatelessWidget {
|
||||
graphStatusState(status),
|
||||
Theme.of(context).colorScheme,
|
||||
);
|
||||
final caption = node.kindCaption;
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(_breakable(node.label), softWrap: true),
|
||||
if (caption != null) _kind(context, caption),
|
||||
if (status != null)
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -144,6 +143,29 @@ class GraphStageNode extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// A check stage's kind under its name: the check icon (a gate icon for the
|
||||
/// delivery gate) and `Check`/`Delivery gate` in the muted label role.
|
||||
Widget _kind(BuildContext context, String caption) {
|
||||
final theme = Theme.of(context);
|
||||
final color = theme.colorScheme.onSurfaceVariant;
|
||||
final style = (theme.textTheme.labelSmall ?? const TextStyle()).copyWith(
|
||||
color: color,
|
||||
);
|
||||
return Row(
|
||||
key: ValueKey('graph-node-kind-${node.key}'),
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
checkStageIcon(delivery: node.delivery),
|
||||
size: (style.fontSize ?? 11) * 1.4,
|
||||
color: color,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Flexible(child: Text(caption, style: style, softWrap: true)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// The web node uses `overflow-wrap: anywhere`; Flutter text does not break a
|
||||
/// long unbroken key, so the same invisible break opportunities are added.
|
||||
/// The visible text and the semantics label stay unchanged.
|
||||
@@ -265,6 +287,18 @@ class StageActivityHaloPainter extends CustomPainter {
|
||||
oldDelegate.color != color || oldDelegate.progress != progress;
|
||||
}
|
||||
|
||||
/// The icon for a check stage; the delivery gate gets the landing icon.
|
||||
IconData checkStageIcon({required bool delivery}) =>
|
||||
delivery ? Icons.verified_outlined : Icons.fact_check_outlined;
|
||||
|
||||
/// A node's accessible name: its label, a check stage's kind, then the run's
|
||||
/// recorded status when there is one.
|
||||
String graphNodeSemanticsLabel(GraphNode node, String? status) => [
|
||||
node.label,
|
||||
?node.kindCaption,
|
||||
if (status != null && status.trim().isNotEmpty) status,
|
||||
].join('\n');
|
||||
|
||||
/// The run state a recorded step status colours as: done is green, an error or
|
||||
/// a block is red, running is blue, waiting teal, anything else grey.
|
||||
String graphStatusState(String status) {
|
||||
|
||||
@@ -341,7 +341,7 @@ class RunGraphNode extends StatelessWidget {
|
||||
}
|
||||
return Semantics(
|
||||
container: true,
|
||||
label: status == null ? node.label : '${node.label}\n$status',
|
||||
label: graphNodeSemanticsLabel(node, status),
|
||||
child: ExcludeSemantics(
|
||||
child: IgnorePointer(
|
||||
child: GraphStageNode(
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import '../../../ui/text/markdown_source_view.dart';
|
||||
import '../../../ui/text/monospace.dart';
|
||||
import '../../chat/ui/transcript/chat_markdown_view.dart';
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
@@ -190,8 +191,15 @@ class _StageDefinitionFieldView extends StatelessWidget {
|
||||
children: [
|
||||
Text(field.label, style: style.label),
|
||||
const SizedBox(height: 4),
|
||||
// Commands are literal code: verbatim and monospace in either mode.
|
||||
if (field.monospace)
|
||||
_SelectableDefinitionText(
|
||||
key: ValueKey('stage-definition-${field.label}'),
|
||||
value: field.value,
|
||||
style: style.value.copyWith(fontFamily: appMonospaceFamily),
|
||||
)
|
||||
// An authored text block (a prompt) is markdown: rendered or raw.
|
||||
if (field.block && raw)
|
||||
else if (field.block && raw)
|
||||
_SelectableDefinitionText(value: field.value, style: style.value)
|
||||
else if (field.block)
|
||||
ChatMarkdownView(text: field.value)
|
||||
@@ -215,7 +223,11 @@ class _StageDefinitionFieldView extends StatelessWidget {
|
||||
/// fallback font with taller metrics and double-space only that block. It is
|
||||
/// the host's own line metrics, not a font override or a fixed height.
|
||||
class _SelectableDefinitionText extends StatelessWidget {
|
||||
const _SelectableDefinitionText({required this.value, required this.style});
|
||||
const _SelectableDefinitionText({
|
||||
super.key,
|
||||
required this.value,
|
||||
required this.style,
|
||||
});
|
||||
|
||||
final String value;
|
||||
final TextStyle style;
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
// A check stage visit's recorded output: the per-command results the server
|
||||
// ran for a `check` stage, read without widget imports.
|
||||
//
|
||||
// Only an output map carrying a `checks` list is a check output; older
|
||||
// servers never send one, so every other step keeps its ordinary rendering.
|
||||
|
||||
/// How one command ended. [unknown] keeps a status this client does not know
|
||||
/// (its raw word stays in [CheckCommandResult.statusWord]).
|
||||
enum CheckCommandStatus { passed, failed, timedOut, notRun, unknown }
|
||||
|
||||
CheckCommandStatus checkCommandStatus(String word) =>
|
||||
switch (word.trim().toLowerCase()) {
|
||||
'passed' => CheckCommandStatus.passed,
|
||||
'failed' => CheckCommandStatus.failed,
|
||||
'timed_out' => CheckCommandStatus.timedOut,
|
||||
'not_run' => CheckCommandStatus.notRun,
|
||||
_ => CheckCommandStatus.unknown,
|
||||
};
|
||||
|
||||
/// The status as the row reads it; an unknown status shows its raw word.
|
||||
String checkStatusLabel(CheckCommandResult check) => switch (check.status) {
|
||||
CheckCommandStatus.passed => 'Passed',
|
||||
CheckCommandStatus.failed => 'Failed',
|
||||
CheckCommandStatus.timedOut => 'Timed out',
|
||||
CheckCommandStatus.notRun => 'Not run',
|
||||
CheckCommandStatus.unknown =>
|
||||
check.statusWord.isEmpty ? 'Unknown status' : check.statusWord,
|
||||
};
|
||||
|
||||
/// One command's recorded result.
|
||||
class CheckCommandResult {
|
||||
const CheckCommandResult({
|
||||
required this.command,
|
||||
required this.statusWord,
|
||||
this.exitCode,
|
||||
this.durationMs,
|
||||
this.output = '',
|
||||
this.truncated = false,
|
||||
});
|
||||
|
||||
final String command;
|
||||
|
||||
/// The server's status word verbatim.
|
||||
final String statusWord;
|
||||
|
||||
/// Null when not recorded (a command that never ran has none).
|
||||
final int? exitCode;
|
||||
final int? durationMs;
|
||||
final String output;
|
||||
|
||||
/// Whether the server cut [output] at its capture limit.
|
||||
final bool truncated;
|
||||
|
||||
CheckCommandStatus get status => checkCommandStatus(statusWord);
|
||||
|
||||
/// `exit 1 · 51s`, leaving out whichever fact was not recorded.
|
||||
String get meta => [
|
||||
if (exitCode != null) 'exit $exitCode',
|
||||
if (durationMs != null) formatCheckDuration(durationMs!),
|
||||
].join(' · ');
|
||||
}
|
||||
|
||||
/// A check visit's whole recorded output.
|
||||
class CheckStepOutput {
|
||||
const CheckStepOutput({
|
||||
required this.checks,
|
||||
this.summary,
|
||||
this.markdown,
|
||||
this.delivery = false,
|
||||
});
|
||||
|
||||
final List<CheckCommandResult> checks;
|
||||
|
||||
/// The server's one-line summary (`1 of 2 checks failed: go test ./...`).
|
||||
final String? summary;
|
||||
|
||||
/// The handoff document the next stage reads.
|
||||
final String? markdown;
|
||||
|
||||
/// Whether this visit was the delivery gate.
|
||||
final bool delivery;
|
||||
}
|
||||
|
||||
/// The check output recorded in [output], or null when it is not one.
|
||||
CheckStepOutput? checkStepOutput(dynamic output) {
|
||||
if (output is! Map) return null;
|
||||
final checks = output['checks'];
|
||||
if (checks is! List) return null;
|
||||
return CheckStepOutput(
|
||||
checks: [
|
||||
for (final item in checks)
|
||||
if (item is Map) _check(item),
|
||||
],
|
||||
summary: _text(output['summary']),
|
||||
markdown: _text(output['markdown']),
|
||||
delivery: output['delivery'] == true,
|
||||
);
|
||||
}
|
||||
|
||||
CheckCommandResult _check(Map item) => CheckCommandResult(
|
||||
command: '${item['command'] ?? ''}',
|
||||
statusWord: '${item['status'] ?? ''}'.trim(),
|
||||
exitCode: _int(item['exit_code']),
|
||||
durationMs: _int(item['duration_ms']),
|
||||
output: item['output'] is String ? item['output'] as String : '',
|
||||
truncated: item['truncated'] == true,
|
||||
);
|
||||
|
||||
/// A command duration: `850ms`, `2.1s`, `51s`, `3m 05s`.
|
||||
String formatCheckDuration(int ms) {
|
||||
if (ms < 1000) return '${ms}ms';
|
||||
if (ms < 10000) {
|
||||
final tenths = (ms / 100).round();
|
||||
return tenths % 10 == 0 ? '${tenths ~/ 10}s' : '${tenths / 10}s';
|
||||
}
|
||||
final seconds = (ms / 1000).round();
|
||||
if (seconds < 60) return '${seconds}s';
|
||||
final minutes = seconds ~/ 60;
|
||||
final rest = (seconds % 60).toString().padLeft(2, '0');
|
||||
if (minutes < 60) return '${minutes}m ${rest}s';
|
||||
return '${minutes ~/ 60}h ${(minutes % 60).toString().padLeft(2, '0')}m';
|
||||
}
|
||||
|
||||
int? _int(dynamic value) {
|
||||
if (value is num) return value.toInt();
|
||||
if (value is String) return int.tryParse(value.trim());
|
||||
return null;
|
||||
}
|
||||
|
||||
String? _text(dynamic value) {
|
||||
if (value is! String) return null;
|
||||
return value.trim().isEmpty ? null : value;
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/status/run_status_icon.dart';
|
||||
import '../../../ui/text/monospace.dart';
|
||||
import '../../chat/ui/transcript/chat_markdown_view.dart';
|
||||
import '../domain/check_step_output.dart';
|
||||
|
||||
/// The note under a command whose recorded output the server cut short.
|
||||
const String checkOutputTruncated =
|
||||
'The server truncated this output at its capture limit.';
|
||||
|
||||
/// The body of a command that recorded no output.
|
||||
const String checkOutputEmpty = 'No output recorded.';
|
||||
|
||||
/// A check visit's Output: its summary, a delivery-gate marker, one
|
||||
/// expandable row per command and the handoff document the next stage reads.
|
||||
class RunCheckOutputView extends StatelessWidget {
|
||||
const RunCheckOutputView({super.key, required this.output});
|
||||
|
||||
final CheckStepOutput output;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final summary = output.summary;
|
||||
final markdown = output.markdown;
|
||||
return Column(
|
||||
key: const Key('run-check-output'),
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
if (output.delivery)
|
||||
Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: Chip(
|
||||
key: const Key('run-check-delivery'),
|
||||
avatar: const Icon(Icons.verified_outlined),
|
||||
label: const Text('Delivery gate'),
|
||||
),
|
||||
),
|
||||
if (summary != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: SelectableText(summary, style: theme.textTheme.bodyLarge),
|
||||
),
|
||||
if (output.checks.isEmpty)
|
||||
const Text('No commands were recorded.')
|
||||
else
|
||||
for (final (index, check) in output.checks.indexed)
|
||||
RunCheckCommandRow(
|
||||
key: ValueKey('run-check-command-$index'),
|
||||
check: check,
|
||||
),
|
||||
if (markdown != null) ...[
|
||||
const SizedBox(height: 12),
|
||||
Text('Handoff', style: theme.textTheme.titleSmall),
|
||||
const SizedBox(height: 4),
|
||||
ChatMarkdownView(text: markdown),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// One command: a status icon, the command, its status, exit code and
|
||||
/// duration; expanding it shows the recorded output as selectable monospace.
|
||||
class RunCheckCommandRow extends StatelessWidget {
|
||||
const RunCheckCommandRow({super.key, required this.check});
|
||||
|
||||
final CheckCommandResult check;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final mono = (theme.textTheme.bodyMedium ?? const TextStyle()).copyWith(
|
||||
fontFamily: appMonospaceFamily,
|
||||
);
|
||||
final color = runStatusColor(_state(check.status), theme.colorScheme);
|
||||
final meta = check.meta;
|
||||
return ExpansionTile(
|
||||
tilePadding: EdgeInsets.zero,
|
||||
childrenPadding: const EdgeInsets.only(bottom: 12),
|
||||
expandedCrossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
leading: Icon(
|
||||
_icon(check.status),
|
||||
color: color,
|
||||
semanticLabel: checkStatusLabel(check),
|
||||
),
|
||||
title: Text(
|
||||
check.command.isEmpty ? '(no command)' : check.command,
|
||||
style: mono,
|
||||
),
|
||||
subtitle: Text(
|
||||
[checkStatusLabel(check), if (meta.isNotEmpty) meta].join(' · '),
|
||||
),
|
||||
children: [
|
||||
if (check.output.isEmpty)
|
||||
const Text(checkOutputEmpty)
|
||||
else
|
||||
DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: SelectableText(check.output, style: mono),
|
||||
),
|
||||
),
|
||||
if (check.truncated)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: Text(
|
||||
checkOutputTruncated,
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
static String _state(CheckCommandStatus status) => switch (status) {
|
||||
CheckCommandStatus.passed => 'succeeded',
|
||||
CheckCommandStatus.failed || CheckCommandStatus.timedOut => 'failed',
|
||||
CheckCommandStatus.notRun || CheckCommandStatus.unknown => 'unknown',
|
||||
};
|
||||
|
||||
static IconData _icon(CheckCommandStatus status) => switch (status) {
|
||||
CheckCommandStatus.passed => Icons.check_circle_outline,
|
||||
CheckCommandStatus.failed => Icons.cancel_outlined,
|
||||
CheckCommandStatus.timedOut => Icons.timer_off_outlined,
|
||||
CheckCommandStatus.notRun => Icons.remove_circle_outline,
|
||||
CheckCommandStatus.unknown => Icons.help_outline,
|
||||
};
|
||||
}
|
||||
@@ -133,6 +133,22 @@ String? detailVisitSkills(JsonMap step) {
|
||||
return (option: option, reason: reason);
|
||||
}
|
||||
|
||||
/// How many times the server sent its one "missing `# outcome`" repair
|
||||
/// follow-up for this visit (`control.outcome_repairs`); 0 when not recorded,
|
||||
/// which older servers and unrepaired visits both mean.
|
||||
int detailVisitOutcomeRepairs(JsonMap step) {
|
||||
final control = step['control'];
|
||||
if (control is! Map) return 0;
|
||||
final value = control['outcome_repairs'];
|
||||
if (value is num) return value.toInt();
|
||||
return int.tryParse('${value ?? ''}'.trim()) ?? 0;
|
||||
}
|
||||
|
||||
/// The note a repaired visit shows under its facts.
|
||||
String outcomeRepairNote(int repairs) => repairs == 1
|
||||
? 'Outcome repaired by follow-up'
|
||||
: 'Outcome repaired by follow-up ($repairs times)';
|
||||
|
||||
/// The visit's diagnostic exactly as recorded, or null when it is blank.
|
||||
String? detailVisitDiagnostic(JsonMap step) => _text(step['diagnostic']);
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ class RunVisitFactsView extends StatelessWidget {
|
||||
final facts = detailVisitFacts(step);
|
||||
final verdict = detailVisitVerdict(step);
|
||||
final diagnostic = detailVisitDiagnostic(step);
|
||||
final repairs = detailVisitOutcomeRepairs(step);
|
||||
return Padding(
|
||||
key: const Key('run-visit-facts'),
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 12),
|
||||
@@ -28,6 +29,23 @@ class RunVisitFactsView extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_FactGrid(facts: facts, style: style),
|
||||
if (repairs > 0) ...[
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
key: const Key('run-visit-outcome-repaired'),
|
||||
children: [
|
||||
Icon(
|
||||
Icons.build_circle_outlined,
|
||||
size: 16,
|
||||
color: style.muted.color,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Flexible(
|
||||
child: Text(outcomeRepairNote(repairs), style: style.muted),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
if (verdict != null) ...[
|
||||
const SizedBox(height: 8),
|
||||
Text('Verdict', style: style.heading),
|
||||
@@ -57,10 +75,14 @@ class _FactGrid extends StatelessWidget {
|
||||
static String _stateOf(VisitFact fact) {
|
||||
final value = fact.value.trim().toLowerCase();
|
||||
if (fact.label == 'Outcome') {
|
||||
if (value == 'error' || value == 'failed' || value == 'blocked') {
|
||||
if (value == 'error' ||
|
||||
value == 'failed' ||
|
||||
value == 'fail' ||
|
||||
value == 'blocked') {
|
||||
return 'failed';
|
||||
}
|
||||
if (value == 'success') return 'succeeded';
|
||||
// A check stage routes `pass`/`fail`.
|
||||
if (value == 'success' || value == 'pass') return 'succeeded';
|
||||
return 'running';
|
||||
}
|
||||
return graphStatusState(fact.value);
|
||||
|
||||
@@ -4,6 +4,8 @@ import 'package:flutter/services.dart';
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/adaptive/floating_destination_bar.dart';
|
||||
import '../../changes/changes.dart';
|
||||
import '../domain/check_step_output.dart';
|
||||
import 'run_check_output_view.dart';
|
||||
import 'run_detail_tab_bodies.dart';
|
||||
import 'run_field_body.dart';
|
||||
import '../../../ui/layout/sticky_section.dart';
|
||||
@@ -216,6 +218,9 @@ class _VisitSummaryState extends State<_VisitSummary> {
|
||||
);
|
||||
final open = !_closed.contains(name);
|
||||
const padding = EdgeInsets.fromLTRB(16, 0, 16, 16);
|
||||
// A check visit's Output is its command results, not a field map.
|
||||
final check = name == 'Output' ? checkStepOutput(value) : null;
|
||||
final sliver = lazy && check == null;
|
||||
return StickySection(
|
||||
key: ValueKey('run-visit-section-$name'),
|
||||
title: name,
|
||||
@@ -224,13 +229,15 @@ class _VisitSummaryState extends State<_VisitSummary> {
|
||||
if (!_closed.remove(name)) _closed.add(name);
|
||||
}),
|
||||
trailing: [copy],
|
||||
body: lazy
|
||||
body: sliver
|
||||
? null
|
||||
: Padding(
|
||||
padding: padding,
|
||||
child: RunFieldBody(value: value, empty: empty),
|
||||
child: check != null
|
||||
? RunCheckOutputView(output: check)
|
||||
: RunFieldBody(value: value, empty: empty),
|
||||
),
|
||||
sliverBody: lazy
|
||||
sliverBody: sliver
|
||||
? SliverPadding(
|
||||
padding: padding,
|
||||
sliver: RunFieldSliver(value: value, empty: empty),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../domain/check_step_output.dart';
|
||||
import 'run_detail_visit_export.dart';
|
||||
import 'run_detail_visit_recorded.dart';
|
||||
|
||||
@@ -18,6 +19,10 @@ const String visitSessionNoIdentity =
|
||||
'Runtime error: this model stage has no recorded session identity.';
|
||||
const String visitSessionNone = 'This visit has no harness session.';
|
||||
|
||||
/// A check stage runs commands, never a model, so it has no session at all.
|
||||
const String visitSessionCheck =
|
||||
'A check stage runs commands without a model; it has no harness session.';
|
||||
|
||||
/// An export that exists but cannot be resolved through the configured server.
|
||||
const String visitSessionEndpointMissing =
|
||||
'Set the server URL in Settings to open the session.';
|
||||
@@ -94,6 +99,7 @@ String _noSessionMessage(JsonMap step) {
|
||||
if (status == 'canceled' || status == 'interrupted') {
|
||||
return visitSessionStopped;
|
||||
}
|
||||
if (checkStepOutput(step['output']) != null) return visitSessionCheck;
|
||||
final model =
|
||||
recordedText(step['provider']) != null ||
|
||||
recordedText(step['model']) != null;
|
||||
|
||||
Reference in New Issue
Block a user