Merge branch 'main' into flutter/chat-thread
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,195 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../core/transport/connection_state.dart';
|
||||
import 'app_session.dart';
|
||||
import 'server_endpoint.dart';
|
||||
|
||||
/// The full connection screen shown before a destination has ever loaded.
|
||||
///
|
||||
/// A missing native endpoint is a configuration state, not a server failure,
|
||||
/// so it is explained without opening a socket. Otherwise the screen reports
|
||||
/// connecting, then an honest unavailable state with a native Retry action.
|
||||
class ConnectionGate extends StatelessWidget {
|
||||
const ConnectionGate({
|
||||
super.key,
|
||||
required this.session,
|
||||
required this.server,
|
||||
required this.cupertino,
|
||||
});
|
||||
|
||||
final AppSession session;
|
||||
final ServerEndpoint server;
|
||||
final bool cupertino;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final state = session.connection;
|
||||
if (server.requiresConfiguration) {
|
||||
return _status(
|
||||
context,
|
||||
title: 'Server endpoint not configured',
|
||||
detail:
|
||||
'Build the native app with an explicit Pipelines endpoint, for '
|
||||
'example --dart-define=PIPELINES_SERVER_URL=ws://host:port/connect.',
|
||||
);
|
||||
}
|
||||
if (server.error != null) {
|
||||
return _status(context, title: server.error!, detail: '');
|
||||
}
|
||||
// Only the very first attempt is "connecting". A failed attempt keeps the
|
||||
// same honest unavailable state while the client retries behind it, so the
|
||||
// screen no longer flickers between unavailable and connecting.
|
||||
if (state.kind == ConnectionKind.connecting && state.attempt <= 1) {
|
||||
return _status(
|
||||
context,
|
||||
title: 'Connecting to Pipelines…',
|
||||
detail: '',
|
||||
progress: true,
|
||||
);
|
||||
}
|
||||
return _status(
|
||||
context,
|
||||
title: 'Pipelines server unavailable',
|
||||
detail: state.retrying
|
||||
? 'Retrying automatically. Check that the Pipelines server is running.'
|
||||
: 'Check that the Pipelines server is running, then try again.',
|
||||
onRetry: session.retry,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _status(
|
||||
BuildContext context, {
|
||||
required String title,
|
||||
required String detail,
|
||||
bool progress = false,
|
||||
VoidCallback? onRetry,
|
||||
}) {
|
||||
final theme = Theme.of(context);
|
||||
return Center(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (progress)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
child: cupertino
|
||||
? const CupertinoActivityIndicator()
|
||||
: const CircularProgressIndicator(),
|
||||
),
|
||||
Semantics(
|
||||
liveRegion: true,
|
||||
child: Text(
|
||||
title,
|
||||
textAlign: TextAlign.center,
|
||||
style: cupertino
|
||||
? CupertinoTheme.of(context).textTheme.navTitleTextStyle
|
||||
: theme.textTheme.titleMedium,
|
||||
),
|
||||
),
|
||||
if (detail.isNotEmpty) ...[
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
detail,
|
||||
textAlign: TextAlign.center,
|
||||
style: cupertino ? null : theme.textTheme.bodyMedium,
|
||||
),
|
||||
],
|
||||
if (onRetry != null) ...[
|
||||
const SizedBox(height: 16),
|
||||
if (cupertino)
|
||||
CupertinoButton(onPressed: onRetry, child: const Text('Retry'))
|
||||
else
|
||||
FilledButton(onPressed: onRetry, child: const Text('Retry')),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A compact status bar above retained content after the first connection.
|
||||
class ConnectionBanner extends StatelessWidget {
|
||||
const ConnectionBanner({
|
||||
super.key,
|
||||
required this.session,
|
||||
required this.cupertino,
|
||||
});
|
||||
|
||||
final AppSession session;
|
||||
final bool cupertino;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final state = session.connection;
|
||||
final refused = session.subscription == RunSubscriptionState.refused;
|
||||
final reconnecting =
|
||||
!session.connected &&
|
||||
(state.kind == ConnectionKind.connecting || state.retrying);
|
||||
final String title;
|
||||
final String detail;
|
||||
final VoidCallback onRetry;
|
||||
if (session.connected && refused) {
|
||||
title = 'Not live — run updates are unavailable.';
|
||||
detail = session.subscriptionError;
|
||||
onRetry = session.resubscribe;
|
||||
} else if (reconnecting) {
|
||||
title = 'Reconnecting to Pipelines…';
|
||||
detail = '';
|
||||
onRetry = session.retry;
|
||||
} else {
|
||||
title = 'Not live — Pipelines server unavailable.';
|
||||
detail = 'Check that the Pipelines server is running.';
|
||||
onRetry = session.retry;
|
||||
}
|
||||
final textStyle = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyMedium;
|
||||
return ColoredBox(
|
||||
color: cupertino
|
||||
? CupertinoDynamicColor.resolve(CupertinoColors.systemGrey5, context)
|
||||
: Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
if (reconnecting) ...[
|
||||
cupertino
|
||||
? const CupertinoActivityIndicator(radius: 7)
|
||||
: const SizedBox(
|
||||
width: 14,
|
||||
height: 14,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
],
|
||||
Expanded(
|
||||
child: Semantics(
|
||||
liveRegion: true,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(title, style: textStyle),
|
||||
if (detail.isNotEmpty) Text(detail, style: textStyle),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
if (cupertino)
|
||||
CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onRetry,
|
||||
child: const Text('Retry'),
|
||||
)
|
||||
else
|
||||
TextButton(onPressed: onRetry, child: const Text('Retry')),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import 'app.dart';
|
||||
import 'app_route.dart';
|
||||
import 'app_router.dart';
|
||||
import 'app_session.dart';
|
||||
import 'pipelines_destination.dart';
|
||||
import 'runs_destination.dart';
|
||||
import 'server_endpoint.dart';
|
||||
|
||||
@@ -100,6 +101,8 @@ class _PipelinesAppState extends State<PipelinesApp> {
|
||||
onDestinationSelected: (destination) =>
|
||||
_delegate.goTo(_routeOf(destination)),
|
||||
destinationBodies: {
|
||||
AppDestination.pipelines: (_) =>
|
||||
PipelinesDestination(session: _session, server: widget.server),
|
||||
AppDestination.runs: (_) => RunsDestination(
|
||||
session: _session,
|
||||
server: widget.server,
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../features/pipelines/screen.dart';
|
||||
import '../ui/adaptive/host.dart';
|
||||
import 'app_session.dart';
|
||||
import 'connection_status.dart';
|
||||
import 'server_endpoint.dart';
|
||||
|
||||
/// The Pipelines destination: the read-only browser plus honest status.
|
||||
///
|
||||
/// Before the shared socket accepts its first connection nothing is requested,
|
||||
/// so an offline launch cannot look like an empty pipeline list. After that the
|
||||
/// browser stays mounted through drops; a reconnect advances [syncToken] so the
|
||||
/// list and the open detail refresh in place instead of losing the selection.
|
||||
class PipelinesDestination extends StatelessWidget {
|
||||
const PipelinesDestination({
|
||||
super.key,
|
||||
required this.session,
|
||||
required this.server,
|
||||
});
|
||||
|
||||
final AppSession session;
|
||||
final ServerEndpoint server;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => AnimatedBuilder(
|
||||
animation: session,
|
||||
builder: (context, _) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
if ((server.requiresConfiguration || server.error != null) &&
|
||||
session.endpoint == null) {
|
||||
return ConnectionGate(
|
||||
session: session,
|
||||
server: server,
|
||||
cupertino: cupertino,
|
||||
);
|
||||
}
|
||||
if (!session.everConnected) {
|
||||
if (session.connected) return _pipelinesScreen();
|
||||
return ConnectionGate(
|
||||
session: session,
|
||||
server: server,
|
||||
cupertino: cupertino,
|
||||
);
|
||||
}
|
||||
return Column(
|
||||
children: [
|
||||
if (!session.connected)
|
||||
ConnectionBanner(session: session, cupertino: cupertino),
|
||||
Expanded(child: _pipelinesScreen()),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
Widget _pipelinesScreen() => PipelinesScreen(
|
||||
gateway: session.gateway,
|
||||
embedded: true,
|
||||
syncToken: session.connectionEpoch,
|
||||
);
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../core/transport/connection_state.dart';
|
||||
import '../features/runs/screen.dart';
|
||||
import '../ui/adaptive/host.dart';
|
||||
import 'app_session.dart';
|
||||
import 'connection_status.dart';
|
||||
import 'server_endpoint.dart';
|
||||
|
||||
/// The Runs destination: the loaded screen plus an honest connection status.
|
||||
@@ -36,7 +35,7 @@ class RunsDestination extends StatelessWidget {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
if ((server.requiresConfiguration || server.error != null) &&
|
||||
session.endpoint == null) {
|
||||
return _ConnectionScreen(
|
||||
return ConnectionGate(
|
||||
session: session,
|
||||
server: server,
|
||||
cupertino: cupertino,
|
||||
@@ -44,7 +43,7 @@ class RunsDestination extends StatelessWidget {
|
||||
}
|
||||
if (!session.everConnected) {
|
||||
if (session.connected) return _runsScreen();
|
||||
return _ConnectionScreen(
|
||||
return ConnectionGate(
|
||||
session: session,
|
||||
server: server,
|
||||
cupertino: cupertino,
|
||||
@@ -54,7 +53,7 @@ class RunsDestination extends StatelessWidget {
|
||||
children: [
|
||||
if (!session.connected ||
|
||||
session.subscription == RunSubscriptionState.refused)
|
||||
_ConnectionBanner(session: session, cupertino: cupertino),
|
||||
ConnectionBanner(session: session, cupertino: cupertino),
|
||||
Expanded(child: _runsScreen()),
|
||||
],
|
||||
);
|
||||
@@ -69,182 +68,3 @@ class RunsDestination extends StatelessWidget {
|
||||
onBack: onBack,
|
||||
);
|
||||
}
|
||||
|
||||
class _ConnectionScreen extends StatelessWidget {
|
||||
const _ConnectionScreen({
|
||||
required this.session,
|
||||
required this.server,
|
||||
required this.cupertino,
|
||||
});
|
||||
|
||||
final AppSession session;
|
||||
final ServerEndpoint server;
|
||||
final bool cupertino;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final state = session.connection;
|
||||
if (server.requiresConfiguration) {
|
||||
return _status(
|
||||
context,
|
||||
title: 'Server endpoint not configured',
|
||||
detail:
|
||||
'Build the native app with an explicit Pipelines endpoint, for '
|
||||
'example --dart-define=PIPELINES_SERVER_URL=ws://host:port/connect.',
|
||||
);
|
||||
}
|
||||
if (server.error != null) {
|
||||
return _status(context, title: server.error!, detail: '');
|
||||
}
|
||||
// Only the very first attempt is "connecting". A failed attempt keeps the
|
||||
// same honest unavailable state while the client retries behind it, so the
|
||||
// screen no longer flickers between unavailable and connecting.
|
||||
if (state.kind == ConnectionKind.connecting && state.attempt <= 1) {
|
||||
return _status(
|
||||
context,
|
||||
title: 'Connecting to Pipelines…',
|
||||
detail: '',
|
||||
progress: true,
|
||||
);
|
||||
}
|
||||
return _status(
|
||||
context,
|
||||
title: 'Pipelines server unavailable',
|
||||
detail: state.retrying
|
||||
? 'Retrying automatically. Check that the Pipelines server is running.'
|
||||
: 'Check that the Pipelines server is running, then try again.',
|
||||
onRetry: session.retry,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _status(
|
||||
BuildContext context, {
|
||||
required String title,
|
||||
required String detail,
|
||||
bool progress = false,
|
||||
VoidCallback? onRetry,
|
||||
}) {
|
||||
final theme = Theme.of(context);
|
||||
return Center(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (progress)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
child: cupertino
|
||||
? const CupertinoActivityIndicator()
|
||||
: const CircularProgressIndicator(),
|
||||
),
|
||||
Semantics(
|
||||
liveRegion: true,
|
||||
child: Text(
|
||||
title,
|
||||
textAlign: TextAlign.center,
|
||||
style: cupertino
|
||||
? CupertinoTheme.of(context).textTheme.navTitleTextStyle
|
||||
: theme.textTheme.titleMedium,
|
||||
),
|
||||
),
|
||||
if (detail.isNotEmpty) ...[
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
detail,
|
||||
textAlign: TextAlign.center,
|
||||
style: cupertino ? null : theme.textTheme.bodyMedium,
|
||||
),
|
||||
],
|
||||
if (onRetry != null) ...[
|
||||
const SizedBox(height: 16),
|
||||
if (cupertino)
|
||||
CupertinoButton(onPressed: onRetry, child: const Text('Retry'))
|
||||
else
|
||||
FilledButton(onPressed: onRetry, child: const Text('Retry')),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A compact status bar above the retained Runs screen.
|
||||
class _ConnectionBanner extends StatelessWidget {
|
||||
const _ConnectionBanner({required this.session, required this.cupertino});
|
||||
|
||||
final AppSession session;
|
||||
final bool cupertino;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final state = session.connection;
|
||||
final refused = session.subscription == RunSubscriptionState.refused;
|
||||
final reconnecting =
|
||||
!session.connected &&
|
||||
(state.kind == ConnectionKind.connecting || state.retrying);
|
||||
final String title;
|
||||
final String detail;
|
||||
final VoidCallback onRetry;
|
||||
if (session.connected && refused) {
|
||||
title = 'Not live — run updates are unavailable.';
|
||||
detail = session.subscriptionError;
|
||||
onRetry = session.resubscribe;
|
||||
} else if (reconnecting) {
|
||||
title = 'Reconnecting to Pipelines…';
|
||||
detail = '';
|
||||
onRetry = session.retry;
|
||||
} else {
|
||||
title = 'Not live — Pipelines server unavailable.';
|
||||
detail = 'Check that the Pipelines server is running.';
|
||||
onRetry = session.retry;
|
||||
}
|
||||
final textStyle = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyMedium;
|
||||
return ColoredBox(
|
||||
color: cupertino
|
||||
? CupertinoDynamicColor.resolve(CupertinoColors.systemGrey5, context)
|
||||
: Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
if (reconnecting) ...[
|
||||
cupertino
|
||||
? const CupertinoActivityIndicator(radius: 7)
|
||||
: const SizedBox(
|
||||
width: 14,
|
||||
height: 14,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
],
|
||||
Expanded(
|
||||
child: Semantics(
|
||||
liveRegion: true,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(title, style: textStyle),
|
||||
if (detail.isNotEmpty) Text(detail, style: textStyle),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
if (cupertino)
|
||||
CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onRetry,
|
||||
child: const Text('Retry'),
|
||||
)
|
||||
else
|
||||
TextButton(onPressed: onRetry, child: const Text('Retry')),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,18 +21,31 @@ const double kPipelinesWideBreakpoint = 720;
|
||||
///
|
||||
/// [graphBuilder] is the optional integration hook for the later graph item.
|
||||
/// Without it the Graph tab states that graph rendering is pending.
|
||||
///
|
||||
/// Standalone use keeps the screen's own native scaffolding. The application
|
||||
/// shell sets [embedded] because it already owns the one navigation bar, and
|
||||
/// supplies [syncToken] so a reconnect refreshes in place.
|
||||
class PipelinesScreen extends StatefulWidget {
|
||||
const PipelinesScreen({
|
||||
super.key,
|
||||
required this.gateway,
|
||||
this.graphBuilder,
|
||||
this.onStageSelected,
|
||||
this.embedded = false,
|
||||
this.syncToken = 0,
|
||||
});
|
||||
|
||||
final ApiGateway gateway;
|
||||
final PipelineGraphBuilder? graphBuilder;
|
||||
final ValueChanged<PipelineStageRef>? onStageSelected;
|
||||
|
||||
/// True under the application shell, which owns the single navigation bar.
|
||||
final bool embedded;
|
||||
|
||||
/// Advances when the shared socket is replaced. The mounted controller
|
||||
/// reloads the list and the selected detail without losing the selection.
|
||||
final int syncToken;
|
||||
|
||||
@override
|
||||
State<PipelinesScreen> createState() => _PipelinesScreenState();
|
||||
}
|
||||
@@ -54,6 +67,10 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
||||
_controller.dispose();
|
||||
_controller = PipelinesController(PipelinesRepository(widget.gateway))
|
||||
..load();
|
||||
} else if (oldWidget.syncToken != widget.syncToken) {
|
||||
// The socket was replaced; re-read through the existing controller so the
|
||||
// selected pipeline and requested version survive the reconnect.
|
||||
_controller.load();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,6 +119,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
||||
);
|
||||
},
|
||||
);
|
||||
if (widget.embedded) return _embeddedBody(context, body);
|
||||
return useCupertinoControls(context)
|
||||
? _cupertinoShell(context, body)
|
||||
: _materialShell(context, body);
|
||||
@@ -109,6 +127,43 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
/// The shell owns the navigation bar here, so the content keeps a native
|
||||
/// Refresh action without adding a second bar.
|
||||
Widget _embeddedBody(BuildContext context, Widget body) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Align(
|
||||
alignment: AlignmentDirectional.centerEnd,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: _refreshButton(context),
|
||||
),
|
||||
),
|
||||
Expanded(child: body),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _refreshButton(BuildContext context) {
|
||||
if (useCupertinoControls(context)) {
|
||||
return Semantics(
|
||||
button: true,
|
||||
label: 'Refresh',
|
||||
child: CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: _controller.load,
|
||||
child: const Icon(CupertinoIcons.refresh),
|
||||
),
|
||||
);
|
||||
}
|
||||
return IconButton(
|
||||
tooltip: 'Refresh',
|
||||
onPressed: _controller.load,
|
||||
icon: const Icon(Icons.refresh),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _divider(BuildContext context) {
|
||||
if (useCupertinoControls(context)) {
|
||||
return Container(
|
||||
@@ -123,13 +178,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Pipelines'),
|
||||
actions: [
|
||||
IconButton(
|
||||
tooltip: 'Refresh',
|
||||
onPressed: _controller.load,
|
||||
icon: const Icon(Icons.refresh),
|
||||
),
|
||||
],
|
||||
actions: [_refreshButton(context)],
|
||||
),
|
||||
body: SafeArea(child: body),
|
||||
);
|
||||
@@ -139,15 +188,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
middle: const Text('Pipelines'),
|
||||
trailing: Semantics(
|
||||
button: true,
|
||||
label: 'Refresh',
|
||||
child: CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: _controller.load,
|
||||
child: const Icon(CupertinoIcons.refresh),
|
||||
),
|
||||
),
|
||||
trailing: _refreshButton(context),
|
||||
),
|
||||
child: SafeArea(top: false, child: body),
|
||||
);
|
||||
|
||||
@@ -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,174 @@
|
||||
# P1 wire — Pipelines destination on the shared session
|
||||
|
||||
## Implemented
|
||||
|
||||
- `lib/application/pipelines_destination.dart` registers the landed
|
||||
`PipelinesScreen` on the existing `/pipelines` route through `AppSession`.
|
||||
It reuses the session's single socket and gateway; no second connection,
|
||||
fake rows or hidden request path was added.
|
||||
- Before the first accepted connection the destination mounts no screen and
|
||||
sends no `list_pipelines`, `list_runs` or `get_pipeline`. The full gate says
|
||||
`Connecting to Pipelines…` or `Pipelines server unavailable`, with an
|
||||
explicit native `Retry` and the existing missing-endpoint explanation.
|
||||
- After the first connection the screen stays mounted through drops. A
|
||||
status banner reports `Reconnecting to Pipelines…`; a reconnect advances
|
||||
`syncToken`, and `PipelinesScreen.didUpdateWidget` calls the existing
|
||||
`controller.load()` so the list and the selected detail refresh in place.
|
||||
Selection (pipeline id and requested version) is preserved; there is no
|
||||
remount and no return to the empty list.
|
||||
- `PipelinesScreen` gained `embedded` and `syncToken`. Embedded mode skips its
|
||||
own Material `Scaffold`/`AppBar` or Cupertino `CupertinoPageScaffold`/
|
||||
`CupertinoNavigationBar`, because the shell already owns the single bar.
|
||||
A native refresh action stays in the content (`IconButton`/`CupertinoButton`
|
||||
with the same `Refresh` wording), using the real host selection.
|
||||
- The connection gate and banner moved verbatim from `runs_destination.dart`
|
||||
to `lib/application/connection_status.dart`, so Runs and Pipelines share one
|
||||
implementation and one wording. Runs behavior is unchanged.
|
||||
- Registration is a tiny entry in the existing `destinationBodies` map in
|
||||
`lib/application/pipelines_app.dart`.
|
||||
- No graph rendering, actions, templates, schedules, route expansion, native
|
||||
control replacement, fixed component size/font/colour override, server,
|
||||
web, legacy, Android or pubspec change was made. Graph still shows
|
||||
`Graph rendering is pending (P2).`
|
||||
|
||||
## Files
|
||||
|
||||
Production:
|
||||
|
||||
- `lib/application/connection_status.dart` (new, moved shared chrome)
|
||||
- `lib/application/pipelines_destination.dart` (new)
|
||||
- `lib/application/pipelines_app.dart` (registration and import)
|
||||
- `lib/application/runs_destination.dart` (uses the shared chrome)
|
||||
- `lib/features/pipelines/screen.dart` (embedded framing, content refresh,
|
||||
reconnect sync token)
|
||||
|
||||
Tests:
|
||||
|
||||
- `test/application/pipelines_destination_test.dart` (new)
|
||||
- `test/application/pipelines_registration_test.dart` (new)
|
||||
- `test/application/pipelines_replies.dart` (new serialized reply helper)
|
||||
- `test/application/pipelines_app_test.dart` (route now renders the real list)
|
||||
- `test/application/settings_registration_test.dart` (answers the mounted
|
||||
Pipelines reads before visiting Settings)
|
||||
- `test/features/pipelines/pipelines_screen_test.dart` (embedded framing and
|
||||
content refresh)
|
||||
|
||||
Browser tooling (isolated, pure loopback fixtures):
|
||||
|
||||
- `tool/pipelines_wiring_probe_entry.dart` — exact `runPipelinesApp()`
|
||||
composition
|
||||
- `tool/pipelines_wiring_probe_server.mjs` — static bundle plus loopback
|
||||
websocket fixture with drop/refuse/accept/state endpoints
|
||||
- `tool/pipelines_wiring_probe.mjs` — real Chrome DevTools probe
|
||||
|
||||
## Checks actually run
|
||||
|
||||
| Check | Result |
|
||||
| --- | --- |
|
||||
| `flutter analyze` | `No issues found!` |
|
||||
| `flutter test` | **595 passed** |
|
||||
| `flutter test test/application` | **33 passed** |
|
||||
| `flutter test test/features/pipelines` | **49 passed** |
|
||||
| `flutter test test/features/pipelines/pipelines_screen_test.dart` | **6 passed** |
|
||||
| `dart format --output=none --set-exit-if-changed lib test tool/pipelines_wiring_probe_entry.dart` | 273 files, 0 changed |
|
||||
| `node --check` on both probe scripts | passed |
|
||||
| `flutter build web` (default `lib/main.dart`) | `✓ Built build/web` |
|
||||
| `flutter build web -t tool/pipelines_wiring_probe_entry.dart` | `✓ Built` |
|
||||
| `node tool/pipelines_wiring_probe.mjs <build> <captures>` | exit 0, 25 checks, 9 captures, `probe.json` has no error |
|
||||
|
||||
Coverage added:
|
||||
|
||||
- missing native endpoint never opens a socket;
|
||||
- connecting gate sends no list request; the screen mounts only after the
|
||||
shared socket accepts;
|
||||
- refused first connection is friendly, names no transport exception and
|
||||
offers Retry;
|
||||
- a drop retains the loaded rows and detail, then reconnect re-reads list and
|
||||
the open detail without losing the selected row;
|
||||
- the registered `/pipelines` route renders real rows, detail content hash and
|
||||
source with exactly one Material or Cupertino bar, one socket;
|
||||
- Cupertino host builds no `Material` widget;
|
||||
- embedded framing adds no second bar and keeps a working content Refresh.
|
||||
|
||||
## Browser evidence (real Chrome, normal composition)
|
||||
|
||||
Directory: `/Users/alan/.local/share/pipelines/data/artifacts/69/public/p1-wire-captures`
|
||||
|
||||
- `01-gate-refused-material.png` — first connection refused: honest gate,
|
||||
`Retry`, shell nav present, zero list requests recorded by the fixture.
|
||||
- `02-list-material.png` — Material shell below its single bar with the real
|
||||
`Release verification` / `Nightly documentation` rows.
|
||||
- `03-detail-material.png` — selected pipeline Summary with
|
||||
`sha256:fixture-3-v3`, versions and metadata.
|
||||
- `04-source-material.png` — Source tab with the real fixture source text.
|
||||
- `05-drop-detail-retained-material.png` — socket dropped: `Reconnecting to
|
||||
Pipelines…` banner while the open detail stays visible at `/pipelines`.
|
||||
- `06-reconnect-detail-refreshed-material.png` — after Retry: banner gone,
|
||||
list and open detail re-read (fixture counters advanced for `list_pipelines`
|
||||
and `get_pipeline`), same selection.
|
||||
- `07-list-cupertino-dark.png` — macOS/dark host: Cupertino global bar and tab
|
||||
bar, inset grouped rows, `Release verification` present.
|
||||
- `08-detail-cupertino-dark.png` — Cupertino dark detail with content hash,
|
||||
versions and native segmented tabs.
|
||||
- `09-source-cupertino-dark.png` — Cupertino dark Source with source text.
|
||||
- `probe.json` — fixture URL, 25 checks, captures and final counters.
|
||||
|
||||
The probe starts the fixture with websocket upgrades refused, asserts the gate
|
||||
and that `listPipelines`, `listRuns` and `getPipeline` are all 0, then accepts
|
||||
and drives the normal app. Hosts are selected through the browser platform
|
||||
user agent (Linux for Material, macOS for Cupertino), which is what the normal
|
||||
composition reads. OCR asserts the real row, content hash and source; the
|
||||
captures were inspected to confirm one bar and Cupertino dark styling.
|
||||
|
||||
Reproduce:
|
||||
|
||||
```sh
|
||||
flutter build web -t tool/pipelines_wiring_probe_entry.dart -o <build>
|
||||
node tool/pipelines_wiring_probe.mjs <build> <capture-dir>
|
||||
```
|
||||
|
||||
## Explicitly not done / unverified
|
||||
|
||||
- Graph rendering and graph nodes/edges remain P2; the existing pending notice
|
||||
is unchanged.
|
||||
- No action, template, schedule, route expansion or navigation redesign.
|
||||
- No production server, real operator chat/run or authenticated preview was
|
||||
touched; all browser data comes from the isolated loopback fixture.
|
||||
- Android and iOS were not built, installed or run; mobile remains unverified.
|
||||
- No push, deployment or preview-service change was made. The Land stage
|
||||
committed the reviewed candidate on `flutter/p1-wire` and merged `main`
|
||||
into it (see Landing below).
|
||||
- No Material/Cupertino fixed sizes, palette or font overrides were added.
|
||||
The only fixed breakpoint remains the existing `kPipelinesWideBreakpoint`.
|
||||
|
||||
## Diff
|
||||
|
||||
Tracked changes (`git diff --numstat`):
|
||||
|
||||
```
|
||||
3 0 app/lib/application/pipelines_app.dart
|
||||
4 184 app/lib/application/runs_destination.dart
|
||||
57 16 app/lib/features/pipelines/screen.dart
|
||||
26 5 app/test/application/pipelines_app_test.dart
|
||||
3 0 app/test/application/settings_registration_test.dart
|
||||
26 0 app/test/features/pipelines/pipelines_screen_test.dart
|
||||
```
|
||||
|
||||
New files: `connection_status.dart` (195), `pipelines_destination.dart` (61),
|
||||
three test files and three probe files. Net production change is ~120 added
|
||||
lines after moving the shared chrome out of `runs_destination.dart`.
|
||||
|
||||
## Landing
|
||||
|
||||
- Committed the reviewed work as `8476cfd7 feat(app): wire the native
|
||||
pipelines browser on the shared session` (15 paths, no unrelated files).
|
||||
- Merged local `main` (`7be4456f`) into `flutter/p1-wire` with no conflicts;
|
||||
the merge brought in the native run rename work only (`app/WORK.md`,
|
||||
`lib/features/runs/**`, `notes/R2-title-wire.md`, its tests and probe).
|
||||
- Post-merge checks on the merged candidate: `flutter analyze` clean,
|
||||
`flutter test` **599 passed**, `dart format` 274 files 0 changed,
|
||||
`node --check` on both probe scripts, `flutter build web` built, and the
|
||||
Chrome wiring probe again reported **25 checks, 9 captures**, no error,
|
||||
final `{subscribed:3, listPipelines:3, listRuns:3, getPipeline:3,
|
||||
dropped:1, connections:1}`. The 595 in the table above is the pre-merge
|
||||
branch count; the extra 4 tests are the merged rename coverage.
|
||||
@@ -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.
|
||||
@@ -5,8 +5,11 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/application/pipelines_app.dart';
|
||||
import 'package:pipelines_app/application/server_endpoint.dart';
|
||||
import 'package:pipelines_app/core/transport/pipelines_client.dart';
|
||||
import 'package:pipelines_app/features/pipelines/screen.dart';
|
||||
|
||||
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
||||
import '../features/pipelines/fixtures.dart';
|
||||
import 'pipelines_replies.dart';
|
||||
|
||||
ServerEndpoint webServer() => ServerEndpoint.resolve(
|
||||
base: Uri.parse('http://127.0.0.1:8096/'),
|
||||
@@ -125,18 +128,32 @@ void main() {
|
||||
|
||||
await pumpApp(tester, channel: channel, client: client, provider: provider);
|
||||
expect(provider.value.uri.path, '/pipelines');
|
||||
final fixture = PipelineFixture();
|
||||
await replyPipelines(tester, channel, fixture);
|
||||
final pipelinesRunsId =
|
||||
pipelineRequest(channel, 'list_runs')!['id'] as String;
|
||||
|
||||
await tester.tap(find.text('Runs').last);
|
||||
await tester.pump();
|
||||
expect(provider.value.uri.path, '/runs');
|
||||
|
||||
await replyList(
|
||||
final runsRequest = await waitForLaterRequest(
|
||||
tester,
|
||||
channel,
|
||||
runs: [
|
||||
{'id': 2, 'name': 'Beta run', 'status': 'failed'},
|
||||
],
|
||||
'list_runs',
|
||||
pipelinesRunsId,
|
||||
);
|
||||
channel.incoming.add(
|
||||
jsonEncode({
|
||||
'id': runsRequest['id'],
|
||||
'type': 'runs',
|
||||
'runs': [
|
||||
{'id': 2, 'name': 'Beta run', 'status': 'failed'},
|
||||
],
|
||||
}),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
await tester.tap(find.text('Beta run'));
|
||||
await tester.pump();
|
||||
expect(provider.value.uri.path, '/runs/2');
|
||||
@@ -172,6 +189,10 @@ void main() {
|
||||
|
||||
await pumpApp(tester, channel: channel, client: client, provider: provider);
|
||||
expect(provider.value.uri.path, '/pipelines');
|
||||
expect(find.text('Pipelines — Not implemented'), findsOneWidget);
|
||||
await replyPipelines(tester, channel, PipelineFixture());
|
||||
expect(find.byType(PipelinesScreen), findsOneWidget);
|
||||
expect(find.text('Pipelines — Not implemented'), findsNothing);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
await tester.pump();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,237 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/application/app_session.dart';
|
||||
import 'package:pipelines_app/application/pipelines_destination.dart';
|
||||
import 'package:pipelines_app/application/server_endpoint.dart';
|
||||
import 'package:pipelines_app/core/transport/pipelines_client.dart';
|
||||
import 'package:pipelines_app/features/pipelines/screen.dart';
|
||||
|
||||
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
||||
import '../features/pipelines/fixtures.dart';
|
||||
|
||||
ServerEndpoint webServer() => ServerEndpoint.resolve(
|
||||
base: Uri.parse('http://127.0.0.1:8096/'),
|
||||
web: true,
|
||||
);
|
||||
|
||||
Map<String, dynamic>? requestOf(FakeChannel channel, String type) => channel
|
||||
.outgoing
|
||||
.map((frame) => jsonDecode(frame as String) as Map<String, dynamic>)
|
||||
.where((frame) => frame['type'] == type)
|
||||
.firstOrNull;
|
||||
|
||||
Widget materialApp(AppSession session, ServerEndpoint server) => MaterialApp(
|
||||
home: Scaffold(
|
||||
body: PipelinesDestination(session: session, server: server),
|
||||
),
|
||||
);
|
||||
|
||||
Future<void> waitFor(
|
||||
WidgetTester tester,
|
||||
bool Function() check,
|
||||
String label,
|
||||
) async {
|
||||
for (var attempt = 0; attempt < 60 && !check(); attempt++) {
|
||||
await tester.pump(const Duration(milliseconds: 10));
|
||||
}
|
||||
expect(check(), isTrue, reason: 'Timed out waiting for $label');
|
||||
}
|
||||
|
||||
Future<void> replyList(
|
||||
WidgetTester tester,
|
||||
FakeChannel channel,
|
||||
PipelineFixture fixture,
|
||||
) async {
|
||||
await waitFor(
|
||||
tester,
|
||||
() => requestOf(channel, 'list_pipelines') != null,
|
||||
'list_pipelines',
|
||||
);
|
||||
final pipelines = requestOf(channel, 'list_pipelines')!;
|
||||
channel.incoming.add(
|
||||
jsonEncode({
|
||||
'id': pipelines['id'],
|
||||
'type': 'pipelines',
|
||||
'pipelines': fixture.summaries,
|
||||
}),
|
||||
);
|
||||
await tester.pump();
|
||||
await waitFor(
|
||||
tester,
|
||||
() => requestOf(channel, 'list_runs') != null,
|
||||
'list_runs',
|
||||
);
|
||||
final runs = requestOf(channel, 'list_runs')!;
|
||||
channel.incoming.add(
|
||||
jsonEncode({'id': runs['id'], 'type': 'runs', 'runs': fixture.runs}),
|
||||
);
|
||||
await tester.pump();
|
||||
}
|
||||
|
||||
Future<void> replyDetail(
|
||||
WidgetTester tester,
|
||||
FakeChannel channel,
|
||||
PipelineFixture fixture,
|
||||
int id,
|
||||
) async {
|
||||
await waitFor(
|
||||
tester,
|
||||
() => requestOf(channel, 'get_pipeline') != null,
|
||||
'get_pipeline',
|
||||
);
|
||||
final request = requestOf(channel, 'get_pipeline')!;
|
||||
final detail = fixture.detailFor(
|
||||
request['pipeline_id'] as int,
|
||||
request['version'] as int,
|
||||
)!;
|
||||
channel.incoming.add(
|
||||
jsonEncode({'id': request['id'], 'type': 'pipeline', 'detail': detail}),
|
||||
);
|
||||
await tester.pump();
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('missing native configuration never opens a socket', (
|
||||
tester,
|
||||
) async {
|
||||
final channel = FakeChannel();
|
||||
final client = PipelinesClient(channelFactory: (_) => channel);
|
||||
final server = ServerEndpoint.resolve(
|
||||
base: Uri.parse('http://127.0.0.1:8096/'),
|
||||
web: false,
|
||||
);
|
||||
final session = AppSession(endpoint: server.uri, client: client);
|
||||
addTearDown(session.dispose);
|
||||
|
||||
await tester.pumpWidget(materialApp(session, server));
|
||||
expect(find.text('Server endpoint not configured'), findsOneWidget);
|
||||
expect(find.textContaining('PIPELINES_SERVER_URL'), findsOneWidget);
|
||||
expect(find.byType(PipelinesScreen), findsNothing);
|
||||
expect(channel.outgoing, isEmpty);
|
||||
});
|
||||
|
||||
testWidgets('the list is only requested after the first connection', (
|
||||
tester,
|
||||
) async {
|
||||
final fixture = PipelineFixture();
|
||||
final channel = FakeChannel();
|
||||
final client = PipelinesClient(channelFactory: (_) => channel);
|
||||
final server = webServer();
|
||||
final session = AppSession(endpoint: server.uri, client: client);
|
||||
addTearDown(session.dispose);
|
||||
|
||||
final starting = session.start();
|
||||
await tester.pumpWidget(materialApp(session, server));
|
||||
await tester.pump();
|
||||
expect(find.text('Connecting to Pipelines…'), findsOneWidget);
|
||||
expect(find.byType(PipelinesScreen), findsNothing);
|
||||
expect(requestOf(channel, 'list_pipelines'), isNull);
|
||||
expect(channel.outgoing, isEmpty);
|
||||
|
||||
channel.readyCompleter.complete();
|
||||
await starting;
|
||||
await tester.pump();
|
||||
await replyList(tester, channel, fixture);
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(PipelinesScreen), findsOneWidget);
|
||||
expect(find.text('Alpha review'), findsOneWidget);
|
||||
expect(requestOf(channel, 'list_pipelines'), isNotNull);
|
||||
});
|
||||
|
||||
testWidgets('an unavailable first connection is honest and retryable', (
|
||||
tester,
|
||||
) async {
|
||||
final channel = FakeChannel();
|
||||
final client = PipelinesClient(
|
||||
channelFactory: (_) => channel,
|
||||
backoffBase: const Duration(hours: 1),
|
||||
backoffMax: const Duration(hours: 1),
|
||||
);
|
||||
final server = webServer();
|
||||
final session = AppSession(endpoint: server.uri, client: client);
|
||||
addTearDown(session.dispose);
|
||||
|
||||
final starting = session.start();
|
||||
channel.readyCompleter.completeError(StateError('Failed to connect'));
|
||||
await starting;
|
||||
await tester.pumpWidget(materialApp(session, server));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('Pipelines server unavailable'), findsOneWidget);
|
||||
expect(find.textContaining('Failed to connect'), findsNothing);
|
||||
expect(find.widgetWithText(FilledButton, 'Retry'), findsOneWidget);
|
||||
expect(find.byType(PipelinesScreen), findsNothing);
|
||||
expect(channel.outgoing, isEmpty);
|
||||
// The client keeps retrying by design; end its backoff timer explicitly.
|
||||
session.dispose();
|
||||
});
|
||||
|
||||
testWidgets('reconnect refreshes the list and the open detail in place', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(1100, 900);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
|
||||
final fixture = PipelineFixture();
|
||||
final first = FakeChannel()..readyCompleter.complete();
|
||||
final second = FakeChannel()..readyCompleter.complete();
|
||||
var sockets = 0;
|
||||
final client = PipelinesClient(
|
||||
channelFactory: (_) => sockets++ == 0 ? first : second,
|
||||
backoffBase: const Duration(milliseconds: 10),
|
||||
);
|
||||
final server = webServer();
|
||||
final session = AppSession(endpoint: server.uri, client: client);
|
||||
addTearDown(session.dispose);
|
||||
|
||||
await session.start();
|
||||
await tester.pumpWidget(materialApp(session, server));
|
||||
await tester.pump();
|
||||
await replyList(tester, first, fixture);
|
||||
await tester.pump();
|
||||
expect(find.text('Alpha review'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('pipeline-row-1')));
|
||||
await tester.pump();
|
||||
await replyDetail(tester, first, fixture, 1);
|
||||
await tester.pump();
|
||||
expect(find.text('hash-alpha'), findsOneWidget);
|
||||
expect(
|
||||
tester.widget<ListTile>(find.byKey(const Key('pipeline-row-1'))).selected,
|
||||
isTrue,
|
||||
);
|
||||
|
||||
first.incoming.addError(StateError('network drop'));
|
||||
await tester.pump();
|
||||
expect(find.byType(PipelinesScreen), findsOneWidget);
|
||||
expect(find.text('Reconnecting to Pipelines…'), findsOneWidget);
|
||||
expect(find.text('hash-alpha'), findsOneWidget);
|
||||
|
||||
await waitFor(
|
||||
tester,
|
||||
() => requestOf(second, 'list_pipelines') != null,
|
||||
'reconnected list request',
|
||||
);
|
||||
await replyList(tester, second, fixture);
|
||||
await waitFor(
|
||||
tester,
|
||||
() => requestOf(second, 'get_pipeline') != null,
|
||||
'reconnected detail request',
|
||||
);
|
||||
await replyDetail(tester, second, fixture, 1);
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('Reconnecting to Pipelines…'), findsNothing);
|
||||
expect(find.text('hash-alpha'), findsOneWidget);
|
||||
expect(
|
||||
tester.widget<ListTile>(find.byKey(const Key('pipeline-row-1'))).selected,
|
||||
isTrue,
|
||||
reason: 'A reconnect must not remount the screen or drop the selection.',
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/application/pipelines_app.dart';
|
||||
import 'package:pipelines_app/core/transport/pipelines_client.dart';
|
||||
|
||||
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
||||
import '../features/pipelines/fixtures.dart';
|
||||
import '../features/pipelines/test_helpers.dart' show selectableText;
|
||||
import 'pipelines_app_test.dart' show webServer;
|
||||
import 'pipelines_replies.dart';
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets(
|
||||
'the /pipelines route renders real rows, detail and source ($cupertino)',
|
||||
(tester) async {
|
||||
tester.view.physicalSize = const Size(1100, 900);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
if (cupertino) {
|
||||
tester.platformDispatcher.platformBrightnessTestValue =
|
||||
Brightness.dark;
|
||||
addTearDown(
|
||||
tester.platformDispatcher.clearPlatformBrightnessTestValue,
|
||||
);
|
||||
}
|
||||
|
||||
final fixture = PipelineFixture();
|
||||
final channel = FakeChannel()..readyCompleter.complete();
|
||||
var sockets = 0;
|
||||
final client = PipelinesClient(
|
||||
channelFactory: (_) {
|
||||
sockets++;
|
||||
return channel;
|
||||
},
|
||||
);
|
||||
final provider = PlatformRouteInformationProvider(
|
||||
initialRouteInformation: RouteInformation(
|
||||
uri: Uri.parse('/pipelines'),
|
||||
),
|
||||
);
|
||||
addTearDown(provider.dispose);
|
||||
|
||||
await tester.pumpWidget(
|
||||
PipelinesApp(
|
||||
server: webServer(),
|
||||
client: client,
|
||||
cupertino: cupertino,
|
||||
routeInformationProvider: provider,
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
await replyPipelines(tester, channel, fixture);
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('Alpha review'), findsOneWidget);
|
||||
expect(find.text('id 1 · v2 · 2 stages'), findsOneWidget);
|
||||
expect(find.text('Pipelines — Not implemented'), findsNothing);
|
||||
expect(sockets, 1);
|
||||
|
||||
// The shell owns the only navigation bar; the embedded screen adds no
|
||||
// second AppBar or CupertinoNavigationBar.
|
||||
if (cupertino) {
|
||||
expect(find.byType(CupertinoNavigationBar), findsOneWidget);
|
||||
expect(find.byType(CupertinoPageScaffold), findsOneWidget);
|
||||
expect(find.byType(Material), findsNothing);
|
||||
} else {
|
||||
expect(find.byType(AppBar), findsOneWidget);
|
||||
expect(find.byType(Scaffold), findsOneWidget);
|
||||
}
|
||||
|
||||
await tester.tap(find.byKey(const Key('pipeline-row-1')));
|
||||
await tester.pump();
|
||||
await replyPipelineDetail(tester, channel, fixture);
|
||||
await tester.pump();
|
||||
expect(find.text('hash-alpha'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.text('Source'));
|
||||
await tester.pump();
|
||||
expect(
|
||||
selectableText(
|
||||
'name: Alpha review\nstages:\n review:\n type: model',
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
await tester.pump();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
||||
import '../features/pipelines/fixtures.dart';
|
||||
|
||||
Map<String, dynamic>? pipelineRequest(FakeChannel channel, String type) =>
|
||||
channel.outgoing
|
||||
.map((frame) => jsonDecode(frame as String) as Map<String, dynamic>)
|
||||
.where((frame) => frame['type'] == type)
|
||||
.firstOrNull;
|
||||
|
||||
Future<void> waitForRequest(
|
||||
WidgetTester tester,
|
||||
FakeChannel channel,
|
||||
String type,
|
||||
) async {
|
||||
for (
|
||||
var attempt = 0;
|
||||
attempt < 60 && pipelineRequest(channel, type) == null;
|
||||
attempt++
|
||||
) {
|
||||
await tester.pump(const Duration(milliseconds: 10));
|
||||
}
|
||||
expect(
|
||||
pipelineRequest(channel, type),
|
||||
isNotNull,
|
||||
reason: 'Timed out waiting for $type',
|
||||
);
|
||||
}
|
||||
|
||||
/// Waits for a later request of [type] than [afterId]. The transport serializes
|
||||
/// requests, so a destination that mounts later issues its read only after the
|
||||
/// previous reply arrives.
|
||||
Future<Map<String, dynamic>> waitForLaterRequest(
|
||||
WidgetTester tester,
|
||||
FakeChannel channel,
|
||||
String type,
|
||||
String afterId,
|
||||
) async {
|
||||
Map<String, dynamic>? later() => channel.outgoing
|
||||
.map((frame) => jsonDecode(frame as String) as Map<String, dynamic>)
|
||||
.where((frame) => frame['type'] == type && frame['id'] != afterId)
|
||||
.firstOrNull;
|
||||
for (var attempt = 0; attempt < 60 && later() == null; attempt++) {
|
||||
await tester.pump(const Duration(milliseconds: 10));
|
||||
}
|
||||
expect(later(), isNotNull, reason: 'Timed out waiting for later $type');
|
||||
return later()!;
|
||||
}
|
||||
|
||||
Future<void> replyPipelines(
|
||||
WidgetTester tester,
|
||||
FakeChannel channel,
|
||||
PipelineFixture fixture,
|
||||
) async {
|
||||
await waitForRequest(tester, channel, 'list_pipelines');
|
||||
final pipelines = pipelineRequest(channel, 'list_pipelines')!;
|
||||
channel.incoming.add(
|
||||
jsonEncode({
|
||||
'id': pipelines['id'],
|
||||
'type': 'pipelines',
|
||||
'pipelines': fixture.summaries,
|
||||
}),
|
||||
);
|
||||
await tester.pump();
|
||||
await waitForRequest(tester, channel, 'list_runs');
|
||||
final runs = pipelineRequest(channel, 'list_runs')!;
|
||||
channel.incoming.add(
|
||||
jsonEncode({'id': runs['id'], 'type': 'runs', 'runs': fixture.runs}),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
}
|
||||
|
||||
Future<void> replyPipelineDetail(
|
||||
WidgetTester tester,
|
||||
FakeChannel channel,
|
||||
PipelineFixture fixture,
|
||||
) async {
|
||||
await waitForRequest(tester, channel, 'get_pipeline');
|
||||
final request = pipelineRequest(channel, 'get_pipeline')!;
|
||||
final detail = fixture.detailFor(
|
||||
request['pipeline_id'] as int,
|
||||
request['version'] as int,
|
||||
)!;
|
||||
channel.incoming.add(
|
||||
jsonEncode({'id': request['id'], 'type': 'pipeline', 'detail': detail}),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
}
|
||||
@@ -8,7 +8,9 @@ import 'package:pipelines_app/core/transport/pipelines_client.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
||||
import '../features/pipelines/fixtures.dart';
|
||||
import 'pipelines_app_test.dart' show webServer, requestOf;
|
||||
import 'pipelines_replies.dart';
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
@@ -46,6 +48,7 @@ void main() {
|
||||
isNull,
|
||||
reason: 'Unvisited settings must not issue hidden requests',
|
||||
);
|
||||
await replyPipelines(tester, channel, PipelineFixture());
|
||||
|
||||
await tester.tap(find.text('Settings').last);
|
||||
await tester.pump();
|
||||
|
||||
@@ -128,6 +128,32 @@ void main() {
|
||||
expect(find.text('Alpha review'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('embedded framing adds no bar and keeps a content refresh', (
|
||||
tester,
|
||||
) async {
|
||||
final fixture = PipelineFixture();
|
||||
final gateway = gatewayFor(fixture);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text('Host bar')),
|
||||
body: PipelinesScreen(gateway: gateway, embedded: true),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(AppBar), findsOneWidget);
|
||||
expect(find.text('Host bar'), findsOneWidget);
|
||||
expect(find.text('Pipelines'), findsNothing);
|
||||
expect(find.text('Alpha review'), findsOneWidget);
|
||||
|
||||
final lists = gateway.callsOf('list_pipelines').length;
|
||||
await tester.tap(find.byTooltip('Refresh'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(gateway.callsOf('list_pipelines').length, lists + 1);
|
||||
});
|
||||
|
||||
testWidgets('graph tab states it is pending without a hook', (tester) async {
|
||||
final fixture = PipelineFixture();
|
||||
await pumpWide(tester, gatewayFor(fixture));
|
||||
|
||||
@@ -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());
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
// Real-Chrome acceptance for the Pipelines destination in the normal app.
|
||||
//
|
||||
// The bundle is `tool/pipelines_wiring_probe_entry.dart`, i.e. the same
|
||||
// composition as main; the isolated loopback fixture answers the protocol.
|
||||
// Both native hosts are exercised by changing the browser platform user agent.
|
||||
//
|
||||
// Usage: node tool/pipelines_wiring_probe.mjs <build-dir> <capture-dir>
|
||||
import { execFile } from 'node:child_process';
|
||||
import { mkdir, writeFile } from 'node:fs/promises';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join, resolve } from 'node:path';
|
||||
import { promisify } from 'node:util';
|
||||
|
||||
import {
|
||||
connect,
|
||||
launchChrome,
|
||||
sleep,
|
||||
waitForPage,
|
||||
waitForPort,
|
||||
} from './pipelines_probe_cdp_lib.mjs';
|
||||
import {
|
||||
assertName,
|
||||
axNodes,
|
||||
capture,
|
||||
click,
|
||||
enableSemantics,
|
||||
waitFor,
|
||||
} from './pipelines_probe_cdp_input.mjs';
|
||||
import { startWiringFixture } from './pipelines_wiring_probe_server.mjs';
|
||||
|
||||
const CHROME =
|
||||
process.env.CHROME_PATH ??
|
||||
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
|
||||
const buildDir = resolve(process.argv[2] ?? 'build/wiring_web');
|
||||
const captureDir = resolve(process.argv[3] ?? 'p1-wire-captures');
|
||||
const fixture = await startWiringFixture({ root: buildDir, refuse: true });
|
||||
await mkdir(captureDir, { recursive: true });
|
||||
const profile = join(tmpdir(), `pipelines-wiring-chrome-${process.pid}`);
|
||||
const chrome = launchChrome(CHROME, profile, 'about:blank');
|
||||
let connection;
|
||||
const log = { url: fixture.url, captures: [], checks: [], states: [] };
|
||||
|
||||
const semanticText = () =>
|
||||
connection.evaluate(`(() => {
|
||||
const chunks = [];
|
||||
for (const el of document.querySelectorAll('flt-semantics')) {
|
||||
const label = el.getAttribute('aria-label');
|
||||
if (label) chunks.push(label);
|
||||
if (!el.children.length && el.innerText) chunks.push(el.innerText);
|
||||
}
|
||||
if (document.body?.innerText) chunks.push(document.body.innerText);
|
||||
return [...new Set(chunks)].join('\\n');
|
||||
})()`);
|
||||
|
||||
const assertBody = async (text) => {
|
||||
const ok = await waitFor(
|
||||
async () => (await semanticText()).includes(text),
|
||||
12000,
|
||||
);
|
||||
if (!ok) {
|
||||
throw new Error(`Missing text ${JSON.stringify(text)}:\n${(await semanticText()).slice(0, 3000)}`);
|
||||
}
|
||||
log.checks.push(`text: ${text}`);
|
||||
};
|
||||
|
||||
const noBody = async (text) => {
|
||||
if ((await semanticText()).includes(text)) {
|
||||
throw new Error(`Unexpected text ${JSON.stringify(text)}`);
|
||||
}
|
||||
log.checks.push(`absent: ${text}`);
|
||||
};
|
||||
|
||||
const state = async () => fixture.state();
|
||||
|
||||
const waitForState = async (check, label) => {
|
||||
const value = await waitFor(async () => {
|
||||
const current = await state();
|
||||
return check(current) ? current : false;
|
||||
}, 12000);
|
||||
if (!value) throw new Error(`Timed out waiting for ${label}: ${JSON.stringify(await state())}`);
|
||||
log.states.push({ label, ...value });
|
||||
return value;
|
||||
};
|
||||
|
||||
const ocr = async (path) => {
|
||||
const { stdout } = await promisify(execFile)('tesseract', [path, 'stdout']);
|
||||
return stdout;
|
||||
};
|
||||
|
||||
const assertOcr = async (name, text) => {
|
||||
const read = await ocr(join(captureDir, `${name}.png`));
|
||||
if (!read.toLowerCase().includes(text.toLowerCase())) {
|
||||
throw new Error(`OCR of ${name} lacks ${JSON.stringify(text)}:\n${read.slice(0, 3000)}`);
|
||||
}
|
||||
log.checks.push(`ocr ${name}: ${text}`);
|
||||
};
|
||||
|
||||
const navigate = async (url) => {
|
||||
await connection.send('Page.navigate', { url });
|
||||
await waitFor(
|
||||
() => connection.evaluate("document.querySelector('flutter-view') !== null"),
|
||||
20000,
|
||||
);
|
||||
await sleep(1200);
|
||||
await enableSemantics(connection);
|
||||
};
|
||||
|
||||
try {
|
||||
const devtoolsPort = await waitForPort(join(profile, 'DevToolsActivePort'));
|
||||
const target = await waitForPage(devtoolsPort);
|
||||
connection = await connect(target.webSocketDebuggerUrl);
|
||||
await connection.send('Page.enable');
|
||||
await connection.send('Runtime.enable');
|
||||
await connection.send('DOM.enable');
|
||||
await connection.send('Accessibility.enable');
|
||||
await connection.send('Emulation.setDeviceMetricsOverride', {
|
||||
width: 1200,
|
||||
height: 900,
|
||||
deviceScaleFactor: 1,
|
||||
mobile: false,
|
||||
});
|
||||
|
||||
// Material host: Linux platform, light mode.
|
||||
await connection.send('Emulation.setUserAgentOverride', {
|
||||
userAgent:
|
||||
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 ' +
|
||||
'(KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36',
|
||||
platform: 'Linux x86_64',
|
||||
});
|
||||
await navigate(`${fixture.url}/pipelines`);
|
||||
|
||||
// The first connection is refused: the honest gate must appear and nothing
|
||||
// may be requested while there is no socket.
|
||||
await assertBody('Pipelines server unavailable');
|
||||
const initial = await state();
|
||||
if (initial.listPipelines !== 0 || initial.listRuns !== 0 || initial.getPipeline !== 0) {
|
||||
throw new Error(`Premature requests before connection: ${JSON.stringify(initial)}`);
|
||||
}
|
||||
log.checks.push('no requests before first connection');
|
||||
await capture(connection, captureDir, log, '01-gate-refused-material');
|
||||
await assertOcr('01-gate-refused-material', 'Pipelines server unavailable');
|
||||
|
||||
await fetch(`${fixture.url}/fixture/accept`, { method: 'POST' });
|
||||
await click(connection, 'Retry');
|
||||
await assertName(connection, 'Release verification', 'real pipeline row', log);
|
||||
await assertName(connection, 'Nightly documentation', 'second real row', log);
|
||||
await noBody('Pipelines — Not implemented');
|
||||
const loaded = await waitForState(
|
||||
(value) => value.listPipelines >= 1 && value.listRuns >= 1,
|
||||
'pipeline list after retry',
|
||||
);
|
||||
log.checks.push('shell lists real rows');
|
||||
await capture(connection, captureDir, log, '02-list-material');
|
||||
await assertOcr('02-list-material', 'Release verification');
|
||||
|
||||
await click(connection, 'Release verification');
|
||||
await assertName(connection, 'Content hash', 'real pipeline detail', log);
|
||||
await capture(connection, captureDir, log, '03-detail-material');
|
||||
await assertOcr('03-detail-material', 'sha256:fixture-3-v3');
|
||||
|
||||
await click(connection, 'Source');
|
||||
await capture(connection, captureDir, log, '04-source-material');
|
||||
await assertOcr('04-source-material', 'name: Release verification');
|
||||
await assertOcr('04-source-material', 'type: model');
|
||||
await click(connection, 'Summary');
|
||||
await assertName(connection, 'Content hash', 'summary restored', log);
|
||||
|
||||
// A drop keeps the open detail visible and, once the socket returns, the
|
||||
// same list and detail are re-read without remounting or losing selection.
|
||||
await fetch(`${fixture.url}/fixture/refuse`, { method: 'POST' });
|
||||
await assertBody('Reconnecting to Pipelines…');
|
||||
await assertName(connection, 'Content hash', 'detail retained after drop', log);
|
||||
if ((await connection.evaluate('location.pathname')) !== '/pipelines') {
|
||||
throw new Error(`Drop moved the route to ${await connection.evaluate('location.pathname')}`);
|
||||
}
|
||||
await capture(connection, captureDir, log, '05-drop-detail-retained-material');
|
||||
|
||||
await fetch(`${fixture.url}/fixture/accept`, { method: 'POST' });
|
||||
await click(connection, 'Retry');
|
||||
await waitForState(
|
||||
(value) =>
|
||||
value.listPipelines > loaded.listPipelines &&
|
||||
value.getPipeline > loaded.getPipeline,
|
||||
'reconnect reload of list and open detail',
|
||||
);
|
||||
await assertName(connection, 'Content hash', 'detail refreshed in place', log);
|
||||
await noBody('Pipelines server unavailable');
|
||||
await capture(connection, captureDir, log, '06-reconnect-detail-refreshed-material');
|
||||
|
||||
// Cupertino host: macOS platform, dark appearance.
|
||||
await connection.send('Emulation.setUserAgentOverride', {
|
||||
userAgent:
|
||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 ' +
|
||||
'(KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36',
|
||||
platform: 'MacIntel',
|
||||
});
|
||||
await connection.send('Emulation.setEmulatedMedia', {
|
||||
features: [{ name: 'prefers-color-scheme', value: 'dark' }],
|
||||
});
|
||||
await navigate(`${fixture.url}/pipelines`);
|
||||
await assertName(connection, 'Release verification', 'cupertino dark row', log);
|
||||
await noBody('Pipelines — Not implemented');
|
||||
await capture(connection, captureDir, log, '07-list-cupertino-dark');
|
||||
await assertOcr('07-list-cupertino-dark', 'Release verification');
|
||||
|
||||
await click(connection, 'Release verification');
|
||||
await assertName(connection, 'Content hash', 'cupertino dark detail', log);
|
||||
await capture(connection, captureDir, log, '08-detail-cupertino-dark');
|
||||
await assertOcr('08-detail-cupertino-dark', 'Content hash');
|
||||
|
||||
await click(connection, 'Source');
|
||||
await capture(connection, captureDir, log, '09-source-cupertino-dark');
|
||||
await assertOcr('09-source-cupertino-dark', 'name: Release verification');
|
||||
await assertOcr('09-source-cupertino-dark', 'type: model');
|
||||
|
||||
const final = await state();
|
||||
if (final.connections < 1) throw new Error('No shared socket');
|
||||
log.checks.push('both native hosts rendered real rows, detail and source');
|
||||
log.final = final;
|
||||
} catch (error) {
|
||||
log.error = String(error?.stack ?? error);
|
||||
try {
|
||||
log.failureAx = (await axNodes(connection))
|
||||
.filter((node) => node.name?.value)
|
||||
.map((node) => `${node.role?.value}: ${node.name.value}`)
|
||||
.slice(0, 120);
|
||||
} catch {
|
||||
// The browser may already be gone; the error itself is still recorded.
|
||||
}
|
||||
process.exitCode = 1;
|
||||
} finally {
|
||||
await writeFile(join(captureDir, 'probe.json'), JSON.stringify(log, null, 2));
|
||||
connection?.close();
|
||||
chrome.kill('SIGTERM');
|
||||
await fixture.close();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import 'package:pipelines_app/application/bootstrap.dart';
|
||||
|
||||
/// Browser acceptance entrypoint for the Pipelines destination wiring.
|
||||
///
|
||||
/// It is exactly the normal application composition; every reply comes from the
|
||||
/// isolated loopback fixture in `tool/pipelines_wiring_probe_server.mjs`, not
|
||||
/// from app-side fake data and not from a production server.
|
||||
void main() => runPipelinesApp();
|
||||
@@ -0,0 +1,394 @@
|
||||
import { createHash } from 'node:crypto';
|
||||
import { createServer } from 'node:http';
|
||||
import { readFile, realpath, stat } from 'node:fs/promises';
|
||||
import { extname, join, resolve, sep } from 'node:path';
|
||||
import { once } from 'node:events';
|
||||
|
||||
// Isolated loopback fixture for the Pipelines wiring probe. It serves the
|
||||
// normal application composition and answers the read-only protocol with
|
||||
// deterministic data. No production server, database or operator data.
|
||||
|
||||
const MIME = {
|
||||
'.html': 'text/html; charset=utf-8',
|
||||
'.js': 'text/javascript; charset=utf-8',
|
||||
'.mjs': 'text/javascript; charset=utf-8',
|
||||
'.json': 'application/json; charset=utf-8',
|
||||
'.wasm': 'application/wasm',
|
||||
'.css': 'text/css; charset=utf-8',
|
||||
'.png': 'image/png',
|
||||
'.svg': 'image/svg+xml',
|
||||
'.ico': 'image/x-icon',
|
||||
'.ttf': 'font/ttf',
|
||||
'.otf': 'font/otf',
|
||||
'.woff': 'font/woff',
|
||||
'.woff2': 'font/woff2',
|
||||
};
|
||||
|
||||
const PIPELINES = [
|
||||
{
|
||||
id: 3,
|
||||
name: 'Release verification',
|
||||
version: 3,
|
||||
stages: 4,
|
||||
created_at: '2026-09-28T10:12:00',
|
||||
updated_at: '2026-10-21T09:40:00',
|
||||
scheduled: true,
|
||||
schedule_count: 2,
|
||||
enabled_schedule_count: 1,
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
name: 'Nightly documentation',
|
||||
version: 1,
|
||||
stages: 2,
|
||||
created_at: '2026-10-02T18:20:00',
|
||||
updated_at: '2026-10-20T22:05:00',
|
||||
scheduled: true,
|
||||
schedule_count: 1,
|
||||
enabled_schedule_count: 1,
|
||||
},
|
||||
];
|
||||
|
||||
const RUNS = [
|
||||
{
|
||||
id: 488,
|
||||
pipeline_id: 3,
|
||||
status: 'succeeded',
|
||||
created_at: '2026-10-21T09:30:00',
|
||||
finished_at: '2026-10-21T09:34:12',
|
||||
executing: false,
|
||||
},
|
||||
{
|
||||
id: 487,
|
||||
pipeline_id: 7,
|
||||
status: 'running',
|
||||
created_at: '2026-10-21T09:20:00',
|
||||
finished_at: '',
|
||||
executing: true,
|
||||
},
|
||||
];
|
||||
|
||||
const VERSIONS = [
|
||||
{ version: 1, stages: 2, created_at: '2026-09-28T10:12:00' },
|
||||
{ version: 2, stages: 3, created_at: '2026-10-08T15:44:00' },
|
||||
{ version: 3, stages: 4, created_at: '2026-10-21T09:12:00' },
|
||||
];
|
||||
|
||||
const SOURCE = `name: Release verification
|
||||
stages:
|
||||
inspect:
|
||||
type: model
|
||||
output: report
|
||||
verify:
|
||||
type: model
|
||||
output: verdict
|
||||
`;
|
||||
|
||||
const SOURCE_V2 = `${SOURCE} # selected version 2
|
||||
`;
|
||||
|
||||
function detail(id, requestedVersion) {
|
||||
const summary = PIPELINES.find((pipeline) => pipeline.id === id) ?? PIPELINES[0];
|
||||
const versions = id === 3 ? VERSIONS : VERSIONS.slice(0, 1);
|
||||
const latest = versions[versions.length - 1].version;
|
||||
const version = requestedVersion > 0 ? requestedVersion : latest;
|
||||
return {
|
||||
...summary,
|
||||
version,
|
||||
stages: versions.find((row) => row.version === version)?.stages ?? summary.stages,
|
||||
latest_version: id === 3 ? latest : 1,
|
||||
version_created_at:
|
||||
versions.find((row) => row.version === version)?.created_at ?? summary.created_at,
|
||||
content_hash: `sha256:fixture-${id}-v${version}`,
|
||||
source: id === 3 && version === 2 ? SOURCE_V2 : SOURCE,
|
||||
versions,
|
||||
};
|
||||
}
|
||||
|
||||
function accept(key) {
|
||||
return createHash('sha1')
|
||||
.update(`${key}258EAFA5-E914-47DA-95CA-C5AB0DC85B11`)
|
||||
.digest('base64');
|
||||
}
|
||||
|
||||
function frame(opcode, payload) {
|
||||
const length = payload.length;
|
||||
let header;
|
||||
if (length < 126) {
|
||||
header = Buffer.from([0x80 | opcode, length]);
|
||||
} else if (length < 65536) {
|
||||
header = Buffer.alloc(4);
|
||||
header[0] = 0x80 | opcode;
|
||||
header[1] = 126;
|
||||
header.writeUInt16BE(length, 2);
|
||||
} else {
|
||||
header = Buffer.alloc(10);
|
||||
header[0] = 0x80 | opcode;
|
||||
header[1] = 127;
|
||||
header.writeBigUInt64BE(BigInt(length), 2);
|
||||
}
|
||||
return Buffer.concat([header, payload]);
|
||||
}
|
||||
|
||||
class Connection {
|
||||
constructor(socket, owner) {
|
||||
this.socket = socket;
|
||||
this.owner = owner;
|
||||
this.buffer = Buffer.alloc(0);
|
||||
this.fragments = [];
|
||||
this.fragmentOpcode = 0;
|
||||
}
|
||||
|
||||
push(chunk) {
|
||||
if (chunk?.length) this.buffer = Buffer.concat([this.buffer, chunk]);
|
||||
this.parse();
|
||||
}
|
||||
|
||||
parse() {
|
||||
while (this.buffer.length >= 2) {
|
||||
const first = this.buffer[0];
|
||||
const second = this.buffer[1];
|
||||
const fin = (first & 0x80) !== 0;
|
||||
const opcode = first & 0x0f;
|
||||
const masked = (second & 0x80) !== 0;
|
||||
let length = second & 0x7f;
|
||||
let offset = 2;
|
||||
if (length === 126) {
|
||||
if (this.buffer.length < 4) return;
|
||||
length = this.buffer.readUInt16BE(2);
|
||||
offset = 4;
|
||||
} else if (length === 127) {
|
||||
if (this.buffer.length < 10) return;
|
||||
length = Number(this.buffer.readBigUInt64BE(2));
|
||||
offset = 10;
|
||||
}
|
||||
const maskOffset = offset;
|
||||
if (masked) {
|
||||
if (this.buffer.length < offset + 4) return;
|
||||
offset += 4;
|
||||
}
|
||||
if (this.buffer.length < offset + length) return;
|
||||
let payload = Buffer.from(this.buffer.subarray(offset, offset + length));
|
||||
if (masked) {
|
||||
const mask = this.buffer.subarray(maskOffset, maskOffset + 4);
|
||||
for (let index = 0; index < payload.length; index++) {
|
||||
payload[index] ^= mask[index % 4];
|
||||
}
|
||||
}
|
||||
this.buffer = this.buffer.subarray(offset + length);
|
||||
this.handleFrame(fin, opcode, payload);
|
||||
}
|
||||
}
|
||||
|
||||
handleFrame(fin, opcode, payload) {
|
||||
if (opcode === 0x8) return this.close();
|
||||
if (opcode === 0x9) return void this.socket.write(frame(0x0a, payload));
|
||||
if (opcode === 0x0a) return;
|
||||
if (opcode === 0x0) {
|
||||
this.fragments.push(payload);
|
||||
if (fin) {
|
||||
const data = Buffer.concat(this.fragments);
|
||||
this.fragments = [];
|
||||
this.message(this.fragmentOpcode, data);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (opcode !== 0x1) return;
|
||||
if (!fin) {
|
||||
this.fragmentOpcode = opcode;
|
||||
this.fragments = [payload];
|
||||
return;
|
||||
}
|
||||
this.message(opcode, payload);
|
||||
}
|
||||
|
||||
message(_opcode, payload) {
|
||||
let request;
|
||||
try {
|
||||
request = JSON.parse(payload.toString('utf8'));
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
this.owner.onMessage(this, request);
|
||||
}
|
||||
|
||||
send(value) {
|
||||
if (!this.socket.destroyed) {
|
||||
this.socket.write(frame(0x1, Buffer.from(JSON.stringify(value))));
|
||||
}
|
||||
}
|
||||
|
||||
close() {
|
||||
if (!this.socket.destroyed) this.socket.end();
|
||||
}
|
||||
}
|
||||
|
||||
async function staticFile(base, pathname, req, res) {
|
||||
let file = resolve(base, `.${pathname}`);
|
||||
if (file !== base && !file.startsWith(base + sep)) {
|
||||
res.writeHead(403).end();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if ((await stat(file)).isDirectory()) file = join(file, 'index.html');
|
||||
} catch {
|
||||
if (extname(pathname)) {
|
||||
res.writeHead(404).end('not found');
|
||||
return;
|
||||
}
|
||||
file = join(base, 'index.html');
|
||||
}
|
||||
try {
|
||||
const body = await readFile(file);
|
||||
res
|
||||
.writeHead(200, {
|
||||
'content-type': MIME[extname(file)] ?? 'application/octet-stream',
|
||||
'cache-control': 'no-store',
|
||||
})
|
||||
.end(req.method === 'HEAD' ? undefined : body);
|
||||
} catch {
|
||||
res.writeHead(404).end('not found');
|
||||
}
|
||||
}
|
||||
|
||||
export async function startWiringFixture({ root, refuse = false }) {
|
||||
const base = await realpath(root);
|
||||
const connections = new Set();
|
||||
const sockets = new Set();
|
||||
const counts = { subscribed: 0, listPipelines: 0, listRuns: 0, getPipeline: 0, dropped: 0 };
|
||||
let refusing = refuse;
|
||||
|
||||
const dropConnections = () => {
|
||||
for (const connection of connections) connection.close();
|
||||
connections.clear();
|
||||
counts.dropped++;
|
||||
};
|
||||
|
||||
const server = createServer(async (req, res) => {
|
||||
const pathname = new URL(req.url, 'http://fixture').pathname;
|
||||
if (pathname === '/fixture/drop' && req.method === 'POST') {
|
||||
dropConnections();
|
||||
res.writeHead(200).end('{"ok":true}');
|
||||
return;
|
||||
}
|
||||
if (pathname === '/fixture/refuse' && req.method === 'POST') {
|
||||
refusing = true;
|
||||
dropConnections();
|
||||
res.writeHead(200).end('{"ok":true}');
|
||||
return;
|
||||
}
|
||||
if (pathname === '/fixture/accept' && req.method === 'POST') {
|
||||
refusing = false;
|
||||
res.writeHead(200).end('{"ok":true}');
|
||||
return;
|
||||
}
|
||||
if (pathname === '/fixture/state') {
|
||||
res
|
||||
.writeHead(200, { 'content-type': 'application/json' })
|
||||
.end(JSON.stringify({ ...counts, connections: connections.size, refusing }));
|
||||
return;
|
||||
}
|
||||
if (req.method !== 'GET' && req.method !== 'HEAD') {
|
||||
res.writeHead(405).end();
|
||||
return;
|
||||
}
|
||||
await staticFile(base, pathname, req, res);
|
||||
});
|
||||
|
||||
server.on('upgrade', (req, socket, head) => {
|
||||
if (refusing) {
|
||||
socket.end('HTTP/1.1 503 Service Unavailable\r\nConnection: close\r\n\r\n');
|
||||
return;
|
||||
}
|
||||
const url = new URL(req.url, 'http://fixture');
|
||||
if (
|
||||
url.pathname !== '/connect' ||
|
||||
req.headers.upgrade?.toLowerCase() !== 'websocket' ||
|
||||
!req.headers['sec-websocket-key']
|
||||
) {
|
||||
socket.end('HTTP/1.1 400 Bad Request\r\nConnection: close\r\n\r\n');
|
||||
return;
|
||||
}
|
||||
socket.write(
|
||||
'HTTP/1.1 101 Switching Protocols\r\n' +
|
||||
'Upgrade: websocket\r\n' +
|
||||
'Connection: Upgrade\r\n' +
|
||||
`Sec-WebSocket-Accept: ${accept(req.headers['sec-websocket-key'])}\r\n\r\n`,
|
||||
);
|
||||
const connection = new Connection(socket, {
|
||||
onMessage: (client, request) => {
|
||||
switch (request.type) {
|
||||
case 'subscribe':
|
||||
counts.subscribed++;
|
||||
return;
|
||||
case 'unsubscribe':
|
||||
return;
|
||||
case 'list_pipelines':
|
||||
counts.listPipelines++;
|
||||
client.send({ id: request.id, type: 'pipelines', pipelines: PIPELINES });
|
||||
return;
|
||||
case 'list_runs':
|
||||
counts.listRuns++;
|
||||
client.send({ id: request.id, type: 'runs', runs: RUNS });
|
||||
return;
|
||||
case 'get_pipeline': {
|
||||
counts.getPipeline++;
|
||||
const id = request.pipeline_id;
|
||||
if (!PIPELINES.some((pipeline) => pipeline.id === id)) {
|
||||
client.send({
|
||||
id: request.id,
|
||||
type: 'error',
|
||||
error: `Fixture pipeline ${id} is unavailable`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
client.send({
|
||||
id: request.id,
|
||||
type: 'pipeline',
|
||||
detail: detail(id, request.version),
|
||||
});
|
||||
return;
|
||||
}
|
||||
case 'ping':
|
||||
client.send({
|
||||
id: request.id,
|
||||
type: 'pong',
|
||||
build: { version: 'Fixture wiring build' },
|
||||
time: '2026-10-21T12:00:00Z',
|
||||
});
|
||||
return;
|
||||
default:
|
||||
client.send({
|
||||
id: request.id,
|
||||
type: 'error',
|
||||
error: `Fixture does not implement ${request.type}`,
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
connections.add(connection);
|
||||
socket.on('data', (chunk) => connection.push(chunk));
|
||||
socket.on('close', () => connections.delete(connection));
|
||||
socket.on('error', () => connections.delete(connection));
|
||||
connection.push(head);
|
||||
});
|
||||
|
||||
server.listen(0, '127.0.0.1');
|
||||
await once(server, 'listening');
|
||||
server.on('connection', (socket) => {
|
||||
sockets.add(socket);
|
||||
socket.on('close', () => sockets.delete(socket));
|
||||
});
|
||||
|
||||
return {
|
||||
server,
|
||||
url: `http://127.0.0.1:${server.address().port}`,
|
||||
state: async () => (await fetch(`http://127.0.0.1:${server.address().port}/fixture/state`)).json(),
|
||||
close: () =>
|
||||
new Promise((resolveClose) => {
|
||||
for (const connection of connections) connection.close();
|
||||
server.close(() => resolveClose());
|
||||
for (const socket of sockets) socket.destroy();
|
||||
}),
|
||||
};
|
||||
}
|
||||
@@ -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