feat(app): expose recorded human decisions in native run detail

This commit is contained in:
2026-10-21 20:18:55 +01:00
parent c970aa5d16
commit 1400780ee2
7 changed files with 268 additions and 8 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ or scratch servers only, never real operator sessions/runs/workflows.
| Rename run | Preview | verified exact accepted title fold; no live production mutation tested |
| Cancel run | Preview | exact confirm/server-accepted detail+list fold; production cancellation not tested |
| Retry/restart | Source actions/dialogs | actual detail controls, accepted new-run navigation, stale/refusal handling |
| Human decisions | Source action/dialog | waiting card, exact recorded options/feedback, attention/action URL entry |
| Human decisions | Preview waiting card/native prompt/exact accepted reply | attention/action URL entry; no production decision answered during tests |
| Run graph | Source projection/visits | executed/unvisited routes, live activity, graph clicks open latest RECORDED visit, no definition by default |
| Timeline/recorded visit pane | Preview text rows only | visit selection, status/outcome/duration/model/target/verdict, artifacts/session/input/output/definition tabs |
| Changes/diffs | Source; active detail wiring67 | settled-run aggregate gate, per-visit capture, paging/raw/rendered/copy and keyboard/back routes |
@@ -0,0 +1,54 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../../ui/adaptive/host.dart';
import '../actions/decision_action.dart';
import '../actions/decision_wording.dart';
import '../domain/run_decisions.dart';
/// A recorded human checkpoint, never an audit-export/resource wait.
class RunDecisionNotice extends StatelessWidget {
const RunDecisionNotice({
super.key,
required this.run,
required this.gateway,
required this.onRunChanged,
});
final JsonMap run;
final ApiGateway gateway;
final ValueChanged<JsonMap> onRunChanged;
@override
Widget build(BuildContext context) {
final pending = pendingDecision(run);
if (pending == null) return const SizedBox.shrink();
final content = Padding(
padding: const EdgeInsets.all(16),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Semantics(header: true, child: const Text(decisionWaitingTitle)),
Text(decisionMeta(pending)),
HumanDecisionAction(
run: run,
gateway: gateway,
onRunChanged: onRunChanged,
),
],
),
);
if (usesCupertinoHost(context)) {
return CupertinoListSection.insetGrouped(
children: [
DefaultTextStyle(
style: CupertinoTheme.of(context).textTheme.textStyle,
child: content,
),
],
);
}
return Card(child: content);
}
}
@@ -3,6 +3,7 @@ import 'package:flutter/widgets.dart';
import '../../../core/api_gateway.dart';
import '../actions/cancel_run_action.dart';
import '../actions/title_action.dart';
import 'run_decision_notice.dart';
/// Native actions on the loaded run, all using the app's one gateway and
/// applying only accepted server detail through the same controller callback.
@@ -19,10 +20,25 @@ class RunDetailActions extends StatelessWidget {
final ValueChanged<JsonMap> onRunChanged;
@override
Widget build(BuildContext context) => Wrap(
Widget build(BuildContext context) => Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
RunTitleAction(run: run, gateway: gateway, onRunChanged: onRunChanged),
CancelRunAction(run: run, gateway: gateway, onRunChanged: onRunChanged),
Wrap(
children: [
RunTitleAction(
run: run,
gateway: gateway,
onRunChanged: onRunChanged,
),
CancelRunAction(
run: run,
gateway: gateway,
onRunChanged: onRunChanged,
),
],
),
RunDecisionNotice(run: run, gateway: gateway, onRunChanged: onRunChanged),
],
);
}
+19
View File
@@ -0,0 +1,19 @@
# Recorded human decisions in run detail
RunDecisionNotice reuses pendingDecision and HumanDecisionAction. A standard
Material card or Cupertino section names the recorded checkpoint and offers
Decide. The existing native prompt owns option/feedback/confirmation/refusal
semantics; export/resource waits do not become invented human checkpoints.
Accepted server detail flows through the same lifecycle/list update as Cancel.
New actual-screen tests failed before wiring and now pass on both hosts: recorded
instructions, selection sends nothing, exact run/stage/option and trimmed feedback
only on confirmation, accepted result removes the card. Integrated614 tests pass;
analysis and normal web build are clean.
Real normal-app browser fixture passes28 captures, including actual Cupertino
waiting card and prompt, Material card/prompt/accepted result, Cancel/Keep and
the existing history/reconnect/Settings checks. The fixture records one exact
decide_run for its synthetic run5; opening/Cancel send nothing. Card and prompt
PNGs inspected in approved temp/decision-wired-browser. No production decision
was answered; mobile and live authenticated mutations remain unverified.
@@ -0,0 +1,109 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/runs/actions/decision_wording.dart';
import 'package:pipelines_app/features/runs/screen.dart';
class _DecisionGateway implements ApiGateway {
final events = StreamController<JsonMap>.broadcast();
final decisions = <JsonMap>[];
final reply = Completer<JsonMap>();
final JsonMap run = {
'id': 9,
'title': 'Human checkpoint',
'name': 'fixture',
'status': 'waiting',
'executing': false,
'current_stage': 'gate',
'graph': {
'stages': [
{
'key': 'gate',
'type': 'human',
'edges': {'approve': '#success'},
},
],
},
'steps': [
{
'sequence': 1,
'stage': 'gate',
'status': 'waiting',
'output': {
'prompt': 'Please review this recorded checkpoint.',
'options': ['approve'],
},
},
],
};
@override
Stream<JsonMap> get frames => events.stream;
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) =>
switch (type) {
'list_runs' => Future.value({
'runs': [run],
}),
'get_run' => Future.value({'run_detail': run}),
'decide_run' => _decide(fields),
_ => Future.error(UnsupportedError(type)),
};
Future<JsonMap> _decide(JsonMap fields) {
decisions.add(fields);
return reply.future;
}
}
void main() {
for (final cupertino in [false, true]) {
testWidgets(
'actual detail exposes and confirms recorded decision ($cupertino)',
(tester) async {
final gateway = _DecisionGateway();
addTearDown(gateway.events.close);
final screen = RunsScreen(gateway: gateway, initialRunId: 9);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: screen))
: MaterialApp(home: Scaffold(body: screen)),
);
await tester.pumpAndSettle();
expect(find.text(decisionWaitingTitle), findsOneWidget);
await tester.tap(find.byKey(decisionActionKey));
await tester.pumpAndSettle();
expect(
find.text('Please review this recorded checkpoint.'),
findsOneWidget,
);
await tester.tap(find.text('approve'));
await tester.enterText(find.byKey(decisionFeedbackKey), ' checked ');
await tester.pump();
expect(gateway.decisions, isEmpty);
await tester.tap(find.text(decisionConfirmLabel));
await tester.pump();
expect(gateway.decisions.single, {
'run_id': 9,
'stage': 'gate',
'option': 'approve',
'feedback': 'checked',
});
gateway.reply.complete({
'run_detail': {
...gateway.run,
'status': 'succeeded',
'executing': false,
},
});
await tester.pumpAndSettle();
expect(find.byKey(decisionActionKey), findsNothing);
expect(find.text(decisionWaitingTitle), findsNothing);
expect(find.text('succeeded'), findsOneWidget);
await tester.pumpWidget(const SizedBox.shrink());
},
);
}
}
+34 -2
View File
@@ -110,7 +110,7 @@ try {
const semanticText = () => evaluate(`(() => {
const chunks = [];
for (const el of document.querySelectorAll('flt-semantics')) {
for (const el of document.querySelectorAll('flt-semantics, [aria-label], [aria-valuetext]')) {
const label = el.getAttribute('aria-label');
if (label) chunks.push(label);
const value = el.getAttribute('aria-valuetext');
@@ -153,7 +153,7 @@ try {
return label === wanted || (${contains} && label.includes(wanted));
});
const interactive = candidates.find((el) =>
['button', 'tab', 'link', 'checkbox', 'menuitem'].includes(el.getAttribute('role')),
['button', 'tab', 'link', 'checkbox', 'radio', 'menuitem'].includes(el.getAttribute('role')),
);
const target = interactive ?? candidates[0];
if (!target) return false;
@@ -384,8 +384,17 @@ try {
await assertBody('Cancel run 4?');
captures.push(await capture('cancel-cupertino-confirm'));
await clickText('Keep');
await assertBody('Original prompt');
const kept = await (await fetch(`${fixture.url}/fixture/state`)).json();
if (kept.cancelRequests.length) throw new Error('Keep sent a cancellation');
await clickText('Back', { contains: true });
await clickText('Fixture human run', { contains: true });
captures.push(await capture('decision-cupertino-card'));
await assertBody('Waiting for your decision');
await clickText('Decide');
await assertBody('Please review this recorded checkpoint.');
captures.push(await capture('decision-cupertino-confirm'));
await clickText('Cancel');
// Material host: the same deep link and route must render standard Material
// controls (the Cupertino host was selected by the macOS browser above).
@@ -431,7 +440,30 @@ try {
await assertBody('Fixture cancel run');
await assertBody('canceled');
await clickText('Fixture human run', { contains: true });
await assertBody('Waiting for your decision');
captures.push(await capture('decision-material-card'));
await clickText('Decide');
await assertBody('Please review this recorded checkpoint.');
captures.push(await capture('decision-material-confirm'));
const pendingDecision = await (await fetch(`${fixture.url}/fixture/state`)).json();
if (pendingDecision.decisionRequests.length) throw new Error('Opening decision sent a reply');
await clickText('approve', { contains: true });
await clickText('Confirm decision');
await assertBody('succeeded');
if ((await semanticText()).includes('Waiting for your decision')) {
throw new Error('Accepted human decision left the waiting card behind');
}
captures.push(await capture('decision-material-accepted'));
await clickText('Back to list');
await assertBody('Fixture cancel run');
await assertBody('canceled');
const fixtureState = await (await fetch(`${fixture.url}/fixture/state`)).json();
if (JSON.stringify(fixtureState.decisionRequests) !==
JSON.stringify([{ run_id: 5, stage: 'gate', option: 'approve' }])) {
throw new Error('Decision sent the wrong payload or repeated the request');
}
if (JSON.stringify(fixtureState.cancelRequests) !== JSON.stringify([{ run_id: 4 }])) {
throw new Error('Cancel sent the wrong payload or repeated the request');
}
+32 -2
View File
@@ -50,8 +50,25 @@ const RUNS = [
status: 'running', executing: true,
created_at: '2026-10-21T09:00:00Z', pipeline_id: 10,
},
{
id: 5, title: 'Fixture human run', name: 'fixture-human',
status: 'waiting', executing: false,
created_at: '2026-10-21T08:00:00Z', pipeline_id: 10,
},
];
function humanDetail(accepted) {
return {
...RUNS.find((run) => run.id === 5),
status: accepted ? 'succeeded' : 'waiting', current_stage: 'gate',
input: { prompt: 'Fixture human decision' },
graph: { stages: [{ key: 'gate', type: 'human', edges: { approve: '#success' } }] },
steps: [{ sequence: 1, stage: 'gate', status: accepted ? 'completed' : 'waiting',
output: { prompt: 'Please review this recorded checkpoint.', options: ['approve'] },
}],
};
}
const LIVE_EVENT = {
type: 'run_event',
run_id: 1,
@@ -269,6 +286,8 @@ export async function startFixture({ root }) {
let getRun = 0;
const canceled = new Set();
const cancelRequests = [];
let decisionAccepted = false;
const decisionRequests = [];
const dropConnections = () => {
for (const connection of connections) connection.close();
@@ -316,6 +335,7 @@ export async function startFixture({ root }) {
listRuns,
getRun,
cancelRequests,
decisionRequests,
}));
return;
}
@@ -366,7 +386,8 @@ export async function startFixture({ root }) {
if (request.type === 'list_runs') {
listRuns++;
client.send({ id: request.id, type: 'runs', runs: RUNS.map((run) =>
canceled.has(run.id) ? { ...run, status: 'canceled', executing: false } : run), usage: null });
canceled.has(run.id) ? { ...run, status: 'canceled', executing: false }
: run.id === 5 && decisionAccepted ? { ...run, status: 'succeeded' } : run), usage: null });
return;
}
if (request.type === 'get_run') {
@@ -388,7 +409,8 @@ export async function startFixture({ root }) {
});
return;
}
client.send({ id: request.id, type: 'run', run_detail: detail(id, live, canceled.has(id)) });
client.send({ id: request.id, type: 'run', run_detail: id === 5
? humanDetail(decisionAccepted) : detail(id, live, canceled.has(id)) });
return;
}
if (request.type === 'cancel_run' && request.run_id === 4) {
@@ -397,6 +419,14 @@ export async function startFixture({ root }) {
client.send({ id: request.id, type: 'run', run_detail: detail(4, live, true) });
return;
}
if (request.type === 'decide_run' && request.run_id === 5 &&
request.stage === 'gate' && request.option === 'approve') {
decisionRequests.push({ run_id: request.run_id, stage: request.stage,
option: request.option, ...(request.feedback ? { feedback: request.feedback } : {}) });
decisionAccepted = true;
client.send({ id: request.id, type: 'run', run_detail: humanDetail(true) });
return;
}
client.send({
id: request.id,
type: 'error',