Files
pipelines/app/lib/features/runs/ui/run_detail_visit_sections.dart
T
alan 87016ef5dc Engine: check stages, harness-agnostic delivery, read-only enforcement, complete captures
- New `type=check` stage: the server runs a `commands` block (sh -c, per
  command_timeout, workspace env) and routes on pass/fail; per-command status,
  exit code, duration and bounded output are recorded and the failing output is
  the handoff. With delivery=true it is the landing gate (commit leftovers,
  merge moved main, checks in a fresh candidate worktree, fast-forward main).
  Parser/registry, lint (silent guards), format docs, CLI inspect, app graph and
  run detail rendering.
- delivery=true is accepted on every harness (and on check stages).
- permissions.shell on claude stages maps to Bash(cmd) / Bash(prefix:*) rules
  instead of a bare Bash allow; stages without edit that change the workspace
  fail the visit with the changed files listed (allow_workspace_changes=true
  opts out; artifacts, public and harness state dirs are ignored).
- File-change capture: symlinks compared by target, untouched protected files no
  longer make captures partial, untracked caches/dependency/build output left
  out, lockfiles listed without patch, huge files compared by metadata, raised
  patch/line limits. Outcome repair follow-ups are logged and counted on the
  step (control.outcome_repairs).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 12:52:16 +00:00

263 lines
8.3 KiB
Dart

import 'package:flutter/material.dart';
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';
import 'run_detail_visit_artifacts.dart';
import 'run_detail_visit_definition.dart';
import 'run_detail_visit_facts.dart';
import 'run_detail_visit_session.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
/// The visit pane's recorded sections, in the Android audit order the web
/// client follows: the turn's Input and Output, its Artifacts, the files this
/// visit changed, its Session and the authored Definition.
enum RunVisitSection {
summary('Summary', Icons.summarize_outlined),
more('More', Icons.more_horiz),
input('Input', Icons.input),
output('Output', Icons.output),
artifacts('Artifacts', Icons.inventory_2_outlined),
changes('Changes', Icons.difference_outlined),
session('Session', Icons.forum_outlined),
definition('Definition', Icons.description_outlined);
const RunVisitSection(this.label, this.icon);
final String label;
final IconData icon;
}
/// The stage page's tabs: the app's floating glass tab bar, full width on a
/// phone and sized to its tabs at the right edge of a wide pane. Float it over
/// the section with `FloatingBarOverlay`. The whole bar is keyed
/// `run-visit-tabs`, each tab `run-visit-tab-<name>`.
class RunVisitSectionStrip extends StatelessWidget {
const RunVisitSectionStrip({
super.key,
required this.selected,
required this.onSelected,
});
final RunVisitSection selected;
final ValueChanged<RunVisitSection> onSelected;
@override
Widget build(BuildContext context) {
final index = shownVisitSections.indexOf(visitTabFor(selected));
return KeyedSubtree(
key: const Key('run-visit-tabs'),
child: FloatingDestinationBar(
// Named on screen: a phone has no tooltip to name an icon.
showLabels: true,
maxLabelScale: 1.3,
currentIndex: index < 0 ? 0 : index,
onTap: (value) => onSelected(shownVisitSections[value]),
items: [
for (final section in shownVisitSections)
FloatingDestinationItem(
key: ValueKey('run-visit-tab-${section.name}'),
icon: Icon(section.icon),
label: section.label,
),
],
),
);
}
}
/// The stage page's tabs: Summary (Input and Output), Artifacts, Changes and
/// Session. The finer sections stay addressable.
const shownVisitSections = [
RunVisitSection.summary,
RunVisitSection.artifacts,
RunVisitSection.changes,
RunVisitSection.session,
];
/// The tab that shows [section].
RunVisitSection visitTabFor(RunVisitSection section) => switch (section) {
RunVisitSection.input || RunVisitSection.output => RunVisitSection.summary,
// The stage's definition lives on the pipeline, not on a run's visit.
RunVisitSection.more || RunVisitSection.definition => RunVisitSection.session,
_ => section,
};
/// The selected section's body for one recorded visit.
Widget runVisitSectionBody({
required RunVisitSection section,
required JsonMap run,
required JsonMap step,
required int visitIndex,
required String stageKey,
required List<JsonMap> runSteps,
required ApiGateway gateway,
required ValueChanged<JsonMap> onRunChanged,
required String configuredEndpoint,
void Function(String draft)? onSendToChat,
Widget? facts,
}) {
Widget body(RunVisitSection section) => runVisitSectionBody(
section: section,
run: run,
step: step,
visitIndex: visitIndex,
stageKey: stageKey,
runSteps: runSteps,
gateway: gateway,
onRunChanged: onRunChanged,
configuredEndpoint: configuredEndpoint,
onSendToChat: onSendToChat,
);
switch (section) {
case RunVisitSection.summary:
// Input then Output, each a sticky collapsible with a copy button; Output
// starts open.
return _VisitSummary(
key: ValueKey('run-visit-summary-$visitIndex'),
input: step['input'],
output: step['output'],
facts: facts,
);
case RunVisitSection.more:
return body(RunVisitSection.session);
case RunVisitSection.input:
return runDetailFieldTab(
tabKey: 'visit-input',
value: step['input'],
empty: visitEmptyInput,
);
case RunVisitSection.output:
return runDetailFieldTab(
tabKey: 'visit-output',
value: step['output'],
empty: visitEmptyOutput,
);
case RunVisitSection.artifacts:
return RunVisitArtifacts(
step: step,
visitIndex: visitIndex,
runSteps: runSteps,
configuredEndpoint: configuredEndpoint,
run: run,
onSendToChat: onSendToChat,
);
case RunVisitSection.changes:
// Only this visit's own capture; the run's final state is the run's
// Changes tab.
final viewer = ChangesViewer(
key: ValueKey('run-visit-changes-$visitIndex'),
steps: [step],
showSummary: false,
);
// The viewer's own header leads it, so it starts below the bar.
return BelowTopBar(child: viewer);
case RunVisitSection.session:
return RunVisitSession(
run: run,
step: step,
gateway: gateway,
onRunChanged: onRunChanged,
configuredEndpoint: configuredEndpoint,
onSendToChat: onSendToChat,
);
case RunVisitSection.definition:
return RunVisitDefinition(run: run, stageKey: stageKey);
}
}
class _VisitSummary extends StatefulWidget {
const _VisitSummary({
super.key,
required this.input,
required this.output,
this.facts,
});
final dynamic input;
final dynamic output;
/// The visit's facts, leading the scroll below the top bar.
final Widget? facts;
@override
State<_VisitSummary> createState() => _VisitSummaryState();
}
class _VisitSummaryState extends State<_VisitSummary> {
/// The sections the operator has closed. Input starts closed; Output starts
/// open, and this set is per visit view.
final Set<String> _closed = {'Input'};
String? _copied;
Future<void> _copy(String name, dynamic value) async {
await Clipboard.setData(ClipboardData(text: runFieldCopyText(value)));
if (mounted) setState(() => _copied = name);
}
/// [lazy] builds the field as a sliver, for a section open by default (the
/// Output): a long one then lays out only the fields on screen.
Widget _section(
String name,
dynamic value,
String empty, {
bool lazy = false,
}) {
final copy = IconButton(
key: ValueKey('run-visit-copy-$name'),
tooltip: 'Copy $name',
onPressed: () => _copy(name, value),
icon: Icon(_copied == name ? Icons.check : Icons.copy),
);
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,
open: open,
onToggle: () => setState(() {
if (!_closed.remove(name)) _closed.add(name);
}),
trailing: [copy],
body: sliver
? null
: Padding(
padding: padding,
child: check != null
? RunCheckOutputView(output: check)
: RunFieldBody(value: value, empty: empty),
),
sliverBody: sliver
? SliverPadding(
padding: padding,
sliver: RunFieldSliver(value: value, empty: empty),
)
: null,
);
}
@override
Widget build(BuildContext context) => CustomScrollView(
key: const Key('run-visit-body-summary'),
slivers: [
// Starts below the page's bar and scrolls behind it; the sticky
// sections pin just below the bar.
const SliverTopBarClearance(),
if (widget.facts case final facts?) SliverToBoxAdapter(child: facts),
_section('Input', widget.input, visitEmptyInput),
_section('Output', widget.output, visitEmptyOutput, lazy: true),
const SliverFloatingBarClearance(),
],
);
}