feat(app): wire native cancel and track complete port acceptance
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
# Flutter port acceptance
|
||||
|
||||
Target: current `web/src/` behavior and latest entries in `web/PARITY.md`, NOT
|
||||
web CSS. Native Material/Cupertino controls, typography, semantic colours and
|
||||
content-driven sizing take precedence over visual-review styling suggestions.
|
||||
`WORK.md` is the run/commit queue; this file tracks what remains for a full port.
|
||||
|
||||
## Evidence vocabulary
|
||||
|
||||
- **Preview**: registered in the normal app and published to8096, with fixture
|
||||
browser interaction/captures. This does NOT imply live production mutations.
|
||||
- **Source**: landed/tested reusable code, not a delivered screen.
|
||||
- **Active**: assigned implementation, not accepted or deployed.
|
||||
- **Missing**: still required; no implied fallback or scope waiver.
|
||||
|
||||
Live authenticated data, OS sharing/notifications and Android/iOS device behavior
|
||||
remain unverified unless explicitly recorded. Test mutations use isolated fakes
|
||||
or scratch servers only, never real operator sessions/runs/workflows.
|
||||
|
||||
## Functional inventory
|
||||
|
||||
| Area | Current state | Remaining acceptance |
|
||||
| --- | --- | --- |
|
||||
| Shared transport/settings connection | Preview | foreground recovery, persisted endpoint boot, protocol warning, complete refresh semantics |
|
||||
| Native shell/run URLs | Preview | pipeline/version/stage/template/chat URLs, action/visit queries and native deep-link handling |
|
||||
| Pipeline list/filter/sort/detail/source/versions | Preview | latest summary metadata/miniatures, pinned detail URLs |
|
||||
| Definition graph | Source nodes/layout/routes/edges; active canvas71 | compose measured native nodes+labels, graph tab, pan/zoom, expanded view, definition stage pane |
|
||||
| Start a pipeline | Missing | native prompt/workspace/notify dialog, exact pinned run request, response-loss intent |
|
||||
| Templates | Source repository; active create dialog73 | gallery/detail/source, Settings entry, validate/create-only dialog integration and refresh |
|
||||
| Runs list/filter/sort/live fold | Preview | full time/status/provenance filters, recency/day groups, shell live/attention state |
|
||||
| Run detail/input/output/copy/metrics | Preview | latest summary tabs/fields and exact empty/unknown states |
|
||||
| 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 |
|
||||
| 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 |
|
||||
| Artifact groups | Source model/list | actual visit/run gallery integration and truthful unavailable capture facts |
|
||||
| Artifact preview | Missing | image-primary in-app viewer, video/doc/text/markdown, paging, focus/back, authenticated fetch errors |
|
||||
| Artifact actions | Source safe URL resolution | separate external-open/copy/download; SHARE REAL NAMED MIME FILES, not links; slow activation/cancel/errors |
|
||||
| Session audit/export repair facts | Missing UI | session.html read-only open, partial/missing/skipped/repair choices without fabricating complete evidence |
|
||||
| Chat session management | Source | normal Chat destination, directory groups/history/search, shared rename/star/close/reopen/create, local hide/undo/seen state |
|
||||
| Chat history/live transport | Source pure fold; active controller72 | authoritative reconnect, opaque older-page cursor, one-turn grouping and stable session navigation |
|
||||
| Chat message surfaces | Active native body70 | integrate thread, markdown (safe links/headings/lists/tables/fences), exact attachments and unknown-part retention |
|
||||
| Chat activity/reasoning/tools | Source raw fields only | one activity line, compaction, native reasoning/tools overlays, lifecycle/input/output/error/duration/edit diff |
|
||||
| Chat composer | Missing | per-chat persisted drafts, Enter newline/Ctrl-Cmd+Enter send, Send beside Stop, optimistic identity, queued/refused restore |
|
||||
| Chat attachments | Source request facade | picker/paste, latest1MiB total wire bound, base64 files, removable named chips, exact history reconciliation |
|
||||
| Chat permissions/questions | Source request facade | native approval/risk cards and form option/free-text answers; pending/resolved/stale/error states |
|
||||
| Chat model/Info/background tasks | Source request facade | current-model selection, numeric Info modal (unknown !=0), bounded running shell pages |
|
||||
| Chat commands/notices/scroll | Missing | slash palette/actions, unknown-command send-as-message, dismissible local notices, saved scroll/follow intent |
|
||||
| Saved schedule list | Source | pipeline entry and route registration, exact timer provenance vocabulary |
|
||||
| Schedule editor | Active lossless draft74 | native fields, stable create key, revision-CAS edit/pause/delete, conflict keeps draft, Schedule this run seed |
|
||||
| Search | Source screen | shell entry, close/focus/selection retention, exact pipeline/version/run/field/visit/artifact target routing |
|
||||
| Needs you | Missing | derived failed/waiting counts, native list/sheet, open/dismiss/clear snapshot, persisted identities |
|
||||
| Notifications | Missing | explicit permission/rationale, secure/unsupported/denied states, transition-only dedupe, background question notices |
|
||||
| Mobile replacement build | Scaffold only | Android build at end; all source portable to iOS, isolated IDs; device/OS behavior clearly separate |
|
||||
|
||||
## Current-reference corrections
|
||||
|
||||
Latest behavior supersedes older parity rows: Enter inserts a newline and
|
||||
Ctrl/Cmd+Enter sends; chat rename/star are server-shared; chat usage is behind
|
||||
Info; graph clicks open recorded visits; image artifacts preview internally;
|
||||
artifact Share carries bytes as a named file, never a URL; attachments use the
|
||||
latest bounded attachment envelope. Native layout differences are intentional;
|
||||
missing behavior is not a native-layout difference.
|
||||
|
||||
## Completion gate
|
||||
|
||||
Every row must have actual normal-app registration, request/state regression
|
||||
coverage, and real-browser evidence for visible/interactive states. Recheck
|
||||
integrated analysis/tests/build and publish the verified preview. Produce the
|
||||
requested Android testing build only after development acceptance; do not use
|
||||
the personal delivery device for tests. Distinguish code, landing, publication,
|
||||
authenticated smoke, native build and device/OS verification in the final report.
|
||||
@@ -0,0 +1,28 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../actions/cancel_run_action.dart';
|
||||
import '../actions/title_action.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.
|
||||
class RunDetailActions extends StatelessWidget {
|
||||
const RunDetailActions({
|
||||
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) => Wrap(
|
||||
children: [
|
||||
RunTitleAction(run: run, gateway: gateway, onRunChanged: onRunChanged),
|
||||
CancelRunAction(run: run, gateway: gateway, onRunChanged: onRunChanged),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import 'run_detail_content.dart';
|
||||
Widget buildCupertinoRunDetail({
|
||||
required BuildContext context,
|
||||
required JsonMap run,
|
||||
required Widget titleAction,
|
||||
required Widget headerActions,
|
||||
required bool detailLoading,
|
||||
required String? error,
|
||||
required bool copying,
|
||||
@@ -65,7 +65,7 @@ Widget buildCupertinoRunDetail({
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 0),
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: titleAction,
|
||||
child: headerActions,
|
||||
),
|
||||
),
|
||||
if (detailLoading) const _CupertinoNotice('Refreshing run details…'),
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'run_detail_content.dart';
|
||||
Widget buildMaterialRunDetail({
|
||||
required BuildContext context,
|
||||
required JsonMap run,
|
||||
required Widget titleAction,
|
||||
required Widget headerActions,
|
||||
required bool detailLoading,
|
||||
required String? error,
|
||||
required bool copying,
|
||||
@@ -42,7 +42,7 @@ Widget buildMaterialRunDetail({
|
||||
Chip(label: Text(runStatusLabel(run))),
|
||||
Text('Run ${run['id']}'),
|
||||
Text('Pipeline ${detailPipeline(run)}'),
|
||||
titleAction,
|
||||
headerActions,
|
||||
],
|
||||
),
|
||||
if (detailLoading) const _Notice('Refreshing run details…'),
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:flutter/services.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../actions/title_action.dart';
|
||||
import 'run_detail_actions.dart';
|
||||
import 'run_detail_content.dart';
|
||||
import 'run_detail_cupertino.dart';
|
||||
import 'run_detail_material.dart';
|
||||
@@ -40,7 +40,7 @@ class _RunDetailViewState extends State<RunDetailView> {
|
||||
final run = widget.controller.detail;
|
||||
if (run == null) return _placeholder(context, cupertino: cupertino);
|
||||
final prompt = detailPrompt(run);
|
||||
final titleAction = RunTitleAction(
|
||||
final headerActions = RunDetailActions(
|
||||
run: run,
|
||||
gateway: widget.gateway,
|
||||
onRunChanged: widget.controller.acceptRunDetail,
|
||||
@@ -49,7 +49,7 @@ class _RunDetailViewState extends State<RunDetailView> {
|
||||
? buildCupertinoRunDetail(
|
||||
context: context,
|
||||
run: run,
|
||||
titleAction: titleAction,
|
||||
headerActions: headerActions,
|
||||
detailLoading: widget.controller.detailLoading,
|
||||
error: widget.controller.error,
|
||||
copying: _copying,
|
||||
@@ -60,7 +60,7 @@ class _RunDetailViewState extends State<RunDetailView> {
|
||||
: buildMaterialRunDetail(
|
||||
context: context,
|
||||
run: run,
|
||||
titleAction: titleAction,
|
||||
headerActions: headerActions,
|
||||
detailLoading: widget.controller.detailLoading,
|
||||
error: widget.controller.error,
|
||||
copying: _copying,
|
||||
|
||||
@@ -114,12 +114,32 @@ class RunsController extends ChangeNotifier {
|
||||
if (id == null) return;
|
||||
var changed = false;
|
||||
if (detail?['id'] == id) {
|
||||
++_detailGeneration;
|
||||
_cancelDetailRefresh();
|
||||
detail = run;
|
||||
detailLoading = false;
|
||||
error = null;
|
||||
changed = true;
|
||||
}
|
||||
final index = runs.indexWhere((row) => row['id'] == id);
|
||||
if (index >= 0) {
|
||||
runs = [...runs]..[index] = {...runs[index], 'title': run['title'] ?? ''};
|
||||
// A cancel/decision reply changes lifecycle fields as well as title.
|
||||
// Keep sparse/unknown summary fields, without copying bulky detail-only
|
||||
// payloads into the held list or inventing missing values.
|
||||
const detailOnly = {
|
||||
'steps',
|
||||
'input',
|
||||
'output',
|
||||
'graph',
|
||||
'usage',
|
||||
'notifications',
|
||||
};
|
||||
runs = [...runs]
|
||||
..[index] = {
|
||||
...runs[index],
|
||||
for (final entry in run.entries)
|
||||
if (!detailOnly.contains(entry.key)) entry.key: entry.value,
|
||||
};
|
||||
changed = true;
|
||||
}
|
||||
if (changed) notifyListeners();
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# Cancel from the actual run detail
|
||||
|
||||
The loaded detail's native action row reuses CancelRunAction alongside Rename.
|
||||
No new confirmation or protocol implementation: Keep sends nothing, only Confirm
|
||||
sends the exact run_id, and no canceled state appears before server acceptance.
|
||||
The accepted run detail now folds lifecycle fields into the held list row as well
|
||||
as the detail (the previous title-only update was insufficient for Cancel).
|
||||
Detail-only payloads are not duplicated into the summary list; pending old detail
|
||||
refreshes are invalidated after acceptance. Foreign run replies cannot replace
|
||||
the open detail. Native controls still own sizing and appearance.
|
||||
|
||||
## Actual checks
|
||||
|
||||
- New normal-screen Material/Cupertino tests failed before registration, then
|
||||
passed: Keep/no request, Confirm exact id, delayed accepted canceled state,
|
||||
action disappears, Back shows canceled list row.
|
||||
- 601 integrated tests pass; analyzer and normal web build pass.
|
||||
- Normal-app real Chrome fixture probe passes23 captures, including Cupertino
|
||||
confirm/Keep, Material confirm and accepted detail/list. The fixture records
|
||||
exactly one cancel_run for its own synthetic run4. No real run was canceled.
|
||||
- Fresh Cupertino-confirm and Material-accepted PNGs inspected in approved
|
||||
temp/cancel-wired-browser. Existing history/reconnect/Settings checks pass too.
|
||||
- Mobile and authenticated production mutations remain unverified.
|
||||
@@ -0,0 +1,93 @@
|
||||
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/cancel_wording.dart';
|
||||
import 'package:pipelines_app/features/runs/screen.dart';
|
||||
|
||||
class _Gateway implements ApiGateway {
|
||||
final events = StreamController<JsonMap>.broadcast();
|
||||
final requests = <({String type, JsonMap fields})>[];
|
||||
final canceled = Completer<JsonMap>();
|
||||
final JsonMap run = {
|
||||
'id': 7,
|
||||
'title': 'Controlled run',
|
||||
'name': 'fixture',
|
||||
'status': 'running',
|
||||
'executing': true,
|
||||
'steps': <JsonMap>[],
|
||||
};
|
||||
|
||||
@override
|
||||
Stream<JsonMap> get frames => events.stream;
|
||||
|
||||
@override
|
||||
Future<JsonMap> call(String type, [JsonMap fields = const {}]) {
|
||||
requests.add((type: type, fields: fields));
|
||||
return switch (type) {
|
||||
'list_runs' => Future.value({
|
||||
'runs': [Map.of(run)],
|
||||
}),
|
||||
'get_run' => Future.value({'run_detail': Map.of(run)}),
|
||||
'cancel_run' => canceled.future,
|
||||
_ => Future.error(UnsupportedError(type)),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets(
|
||||
'actual detail confirms cancel and folds accepted state ($cupertino)',
|
||||
(tester) async {
|
||||
final gateway = _Gateway();
|
||||
addTearDown(gateway.events.close);
|
||||
final screen = RunsScreen(gateway: gateway, initialRunId: 7);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: screen))
|
||||
: MaterialApp(home: Scaffold(body: screen)),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(cancelActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Cancel run 7?'), findsOneWidget);
|
||||
expect(gateway.requests.where((r) => r.type == 'cancel_run'), isEmpty);
|
||||
await tester.tap(find.byKey(cancelKeepKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(gateway.requests.where((r) => r.type == 'cancel_run'), isEmpty);
|
||||
|
||||
await tester.tap(find.byKey(cancelActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(cancelConfirmKey));
|
||||
await tester.pump();
|
||||
expect(
|
||||
gateway.requests.where((r) => r.type == 'cancel_run').single.fields,
|
||||
{'run_id': 7},
|
||||
);
|
||||
expect(find.text('canceled'), findsNothing);
|
||||
gateway.canceled.complete({
|
||||
'run_detail': {
|
||||
...gateway.run,
|
||||
'status': 'canceled',
|
||||
'executing': false,
|
||||
},
|
||||
});
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(cancelActionKey), findsNothing);
|
||||
expect(find.text('canceled'), findsOneWidget);
|
||||
await tester.tap(find.text(cupertino ? 'Back' : 'Back to list'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.textContaining('canceled'),
|
||||
findsWidgets,
|
||||
reason:
|
||||
'The accepted server state must also update the held list row',
|
||||
);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -377,6 +377,16 @@ try {
|
||||
if ((await path()) !== '/settings') throw new Error('Settings did not update route');
|
||||
captures.push(await capture('settings-cupertino-registered-phone'));
|
||||
|
||||
await clickText('Runs');
|
||||
await clickText('Fixture cancel run', { contains: true });
|
||||
await assertBody('Original prompt');
|
||||
await clickText('Cancel run');
|
||||
await assertBody('Cancel run 4?');
|
||||
captures.push(await capture('cancel-cupertino-confirm'));
|
||||
await clickText('Keep');
|
||||
const kept = await (await fetch(`${fixture.url}/fixture/state`)).json();
|
||||
if (kept.cancelRequests.length) throw new Error('Keep sent a cancellation');
|
||||
|
||||
// Material host: the same deep link and route must render standard Material
|
||||
// controls (the Cupertino host was selected by the macOS browser above).
|
||||
await send(
|
||||
@@ -408,7 +418,23 @@ try {
|
||||
}
|
||||
captures.push(await capture('settings-material-registered-phone'));
|
||||
|
||||
await clickText('Runs');
|
||||
await clickText('Fixture cancel run', { contains: true });
|
||||
await assertBody('Original prompt');
|
||||
await clickText('Cancel run');
|
||||
await assertBody('Cancel run 4?');
|
||||
captures.push(await capture('cancel-material-confirm'));
|
||||
await clickText('Cancel run');
|
||||
await assertBody('canceled');
|
||||
captures.push(await capture('cancel-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.cancelRequests) !== JSON.stringify([{ run_id: 4 }])) {
|
||||
throw new Error('Cancel sent the wrong payload or repeated the request');
|
||||
}
|
||||
if (fixtureState.subscribed < 2) throw new Error(`App never resubscribed: ${JSON.stringify(fixtureState)}`);
|
||||
if (fixtureState.listRuns < 2) throw new Error(`App never reloaded: ${JSON.stringify(fixtureState)}`);
|
||||
if (fixtureState.getRun < 2) throw new Error(`Detail was not rehydrated: ${JSON.stringify(fixtureState)}`);
|
||||
|
||||
@@ -45,6 +45,11 @@ const RUNS = [
|
||||
created_at: '2026-10-21T10:00:00Z',
|
||||
pipeline_id: 10,
|
||||
},
|
||||
{
|
||||
id: 4, title: 'Fixture cancel run', name: 'fixture-cancel',
|
||||
status: 'running', executing: true,
|
||||
created_at: '2026-10-21T09:00:00Z', pipeline_id: 10,
|
||||
},
|
||||
];
|
||||
|
||||
const LIVE_EVENT = {
|
||||
@@ -57,13 +62,15 @@ const LIVE_EVENT = {
|
||||
finished_at: '2026-10-21T12:05:00Z',
|
||||
};
|
||||
|
||||
function detail(id, live) {
|
||||
const status = id === 1 && live ? 'succeeded' : id === 3 ? 'failed' : 'running';
|
||||
function detail(id, live, canceled = false) {
|
||||
const status = canceled ? 'canceled'
|
||||
: id === 1 && live ? 'succeeded' : id === 3 ? 'failed' : 'running';
|
||||
return {
|
||||
id,
|
||||
title: RUNS.find((run) => run.id === id)?.title ?? `Run ${id}`,
|
||||
name: 'fixture-pipeline',
|
||||
status,
|
||||
executing: status === 'running',
|
||||
input: {
|
||||
prompt: ' fixture prompt with spaces ',
|
||||
note: 'input payload',
|
||||
@@ -260,6 +267,8 @@ export async function startFixture({ root }) {
|
||||
let dropped = 0;
|
||||
let listRuns = 0;
|
||||
let getRun = 0;
|
||||
const canceled = new Set();
|
||||
const cancelRequests = [];
|
||||
|
||||
const dropConnections = () => {
|
||||
for (const connection of connections) connection.close();
|
||||
@@ -306,6 +315,7 @@ export async function startFixture({ root }) {
|
||||
dropped,
|
||||
listRuns,
|
||||
getRun,
|
||||
cancelRequests,
|
||||
}));
|
||||
return;
|
||||
}
|
||||
@@ -355,7 +365,8 @@ export async function startFixture({ root }) {
|
||||
}
|
||||
if (request.type === 'list_runs') {
|
||||
listRuns++;
|
||||
client.send({ id: request.id, type: 'runs', runs: RUNS, usage: null });
|
||||
client.send({ id: request.id, type: 'runs', runs: RUNS.map((run) =>
|
||||
canceled.has(run.id) ? { ...run, status: 'canceled', executing: false } : run), usage: null });
|
||||
return;
|
||||
}
|
||||
if (request.type === 'get_run') {
|
||||
@@ -377,7 +388,13 @@ export async function startFixture({ root }) {
|
||||
});
|
||||
return;
|
||||
}
|
||||
client.send({ id: request.id, type: 'run', run_detail: detail(id, live) });
|
||||
client.send({ id: request.id, type: 'run', run_detail: detail(id, live, canceled.has(id)) });
|
||||
return;
|
||||
}
|
||||
if (request.type === 'cancel_run' && request.run_id === 4) {
|
||||
cancelRequests.push({ run_id: request.run_id });
|
||||
canceled.add(4);
|
||||
client.send({ id: request.id, type: 'run', run_detail: detail(4, live, true) });
|
||||
return;
|
||||
}
|
||||
client.send({
|
||||
|
||||
Reference in New Issue
Block a user