Add labelled run entry points

Make starting runs discoverable from pipeline details and the Runs tab. Share the existing launch flow, add an active-pipeline picker, and update walkthrough guidance with focused widget coverage.
This commit is contained in:
2026-11-12 10:53:09 +00:00
parent 24618964ce
commit fc86a8257c
14 changed files with 820 additions and 153 deletions
@@ -0,0 +1,11 @@
import '../core/api_gateway.dart';
import '../core/servers/server_scope.dart';
import 'server_endpoint.dart';
/// The scope that isolates a server's pending launch intents. Pipelines and
/// Runs must compute the same scope, or a lost reply could be retried under a
/// different key from the one the Pipelines tab would check.
String pendingRunScope(ApiGateway gateway, ServerEndpoint server) {
final identity = serverIdentity(gateway);
return identity == null ? server.uri?.toString() ?? '' : 'profile:$identity';
}
@@ -1,10 +1,10 @@
import 'package:flutter/material.dart';
import '../core/servers/server_scope.dart';
import '../features/pipelines/screen.dart';
import '../ui/adaptive/top_bar_notices.dart';
import 'app_session.dart';
import 'connection_status.dart';
import 'pending_run_scope.dart';
import 'server_endpoint.dart';
/// The Pipelines destination: the read-only browser plus honest status.
@@ -82,9 +82,7 @@ class PipelinesDestination extends StatelessWidget {
Widget _pipelinesScreen() => PipelinesScreen(
gateway: session.gateway,
endpoint: serverIdentity(session.gateway) == null
? server.uri?.toString() ?? ''
: 'profile:${serverIdentity(session.gateway)}',
endpoint: pendingRunScope(session.gateway, server),
legacyEndpoints: legacyPendingEndpoints,
embedded: true,
active: active,
@@ -2,11 +2,13 @@ import 'package:flutter/material.dart';
import '../features/attention/notify/notification_controller.dart';
import '../features/attention/runtime/attention_controller.dart';
import '../features/pipelines/pending_run_store.dart';
import '../features/runs/screen.dart';
import '../features/runs/ui/run_pipeline_link.dart';
import '../ui/adaptive/top_bar_notices.dart';
import 'app_session.dart';
import 'connection_status.dart';
import 'pending_run_scope.dart';
import 'server_endpoint.dart';
/// The Runs destination: the loaded screen plus an honest connection status.
@@ -100,6 +102,9 @@ class RunsDestination extends StatelessWidget {
listRefreshToken: listRefreshToken,
notifications: notifications,
attention: attention,
pendingRunStore: SharedPreferencesPendingRunStore(
pendingRunScope(session.gateway, server),
),
onRunSelected: onRunSelected,
onBack: onBack,
onPipelineFilterChanged: onPipelineFilterChanged,
@@ -1,21 +1,16 @@
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../../core/transport/connection_state.dart';
import '../../runs/data/runs_repository.dart';
import '../../../ui/adaptive/segmented_bar_overflow.dart';
import '../pipeline_models.dart';
import '../pipelines_controller.dart';
import '../run_pipeline_intent.dart';
import '../widgets/pipeline_bar_buttons.dart';
import 'run_pipeline_dialog.dart';
import 'run_pipeline_flow.dart';
import 'run_pipeline_wording.dart';
/// The pipeline detail's Run action.
///
/// Nothing is requested until the dialog's confirm. A confirmed attempt sends
/// the web's exact `run_pipeline` body against the pinned resolved version; a
/// lost reply keeps the intent so the next deliberate press checks by the same
/// request key before resending. Only the id the server names is opened.
const _runIcon = Icons.play_arrow_rounded;
/// The pipeline detail's Run action: a labelled button that opens the shared
/// start flow ([openRunPipelineFlow]).
class RunPipelineAction extends StatefulWidget {
const RunPipelineAction({
super.key,
@@ -26,8 +21,8 @@ class RunPipelineAction extends StatefulWidget {
this.inBar = false,
});
/// The compact icon-and-word button of a top bar's actions pill instead
/// of an inline button.
/// The compact button of a top bar's actions pill instead of an inline
/// button. A narrow bar moves it into its More menu, labelled.
final bool inBar;
final PipelinesController controller;
@@ -45,143 +40,38 @@ class RunPipelineAction extends StatefulWidget {
class _RunPipelineActionState extends State<RunPipelineAction> {
bool _dialogOpen = false;
int get _pipelineId => widget.detail.id;
int get _version => widget.detail.resolvedVersion;
Future<void> _open() async {
if (_dialogOpen) return;
_dialogOpen = true;
try {
final pending = await widget.controller.loadPendingRun(
_pipelineId,
_version,
);
if (!mounted) return;
await showRunPipelineDialog(
await openRunPipelineFlow(
context: context,
controller: widget.controller,
detail: widget.detail,
gateway: widget.gateway,
pending: pending,
onSubmit: _submit,
onPendingChanged: (intent) {
if (intent == null) {
widget.controller.clearPendingRun(_pipelineId, _version);
} else {
widget.controller.rememberPendingRun(intent);
}
},
onAccepted: _accepted,
onRunStarted: widget.onRunStarted,
);
} finally {
_dialogOpen = false;
}
}
void _accepted(JsonMap run) {
final id = runPipelineRunId(run);
if (id == null) return;
widget.controller.clearPendingRun(_pipelineId, _version);
widget.onRunStarted?.call(id);
}
Future<RunPipelineOutcome> _submit(RunPipelineIntent intent) async {
final repository = RunsRepository(widget.gateway);
final pending = widget.controller.pendingRunFor(
intent.pipelineId,
intent.version,
);
if (pending?.requestKey == intent.requestKey) {
// A previous send may have been admitted even though its reply was lost.
// Check before resending the same key; the server dedupes either way.
try {
final existing = await repository.runByRequestKey(intent.requestKey);
if (existing != null) return _accept(existing);
} catch (error) {
widget.controller.rememberPendingRun(intent);
return RunPipelineRefused(
'${describeRunPipelineError(error)}$runPipelineUnknownSuffix',
admissionUnknown: true,
);
}
}
try {
final run = await repository.startRun(
pipelineId: intent.pipelineId,
version: intent.version,
prompt: intent.prompt,
workspace: intent.workspace,
requestKey: intent.requestKey,
notifyMode: intent.notifyMode.wireValue,
outputFormat: intent.outputFormat.wireValue,
);
final accepted = _accept(run);
if (accepted is RunPipelineAccepted) return accepted;
// A reply without a usable run id is not navigable: read the admitted run
// by key rather than inventing an id or starting another run.
return _refuse(repository, intent, 'The server returned no run id.');
} on ProtocolError catch (error) {
return _refuse(repository, intent, describeRunPipelineError(error));
} on RunsRepositoryException catch (error) {
return _refuse(repository, intent, describeRunPipelineError(error));
} catch (error) {
widget.controller.rememberPendingRun(intent);
return RunPipelineRefused(
'${describeRunPipelineError(error)}$runPipelineUnknownSuffix',
admissionUnknown: true,
);
}
}
/// A reply is only accepted when it names a usable run id.
RunPipelineOutcome _accept(JsonMap run) {
if (runPipelineRunId(run) == null) {
return const RunPipelineRefused(
'The server returned no run id.',
admissionUnknown: false,
);
}
widget.controller.clearPendingRun(widget.detail.id, _version);
return RunPipelineAccepted(run);
}
/// A confirmed refusal: prove by key that no run was admitted before letting
/// the operator correct the fields and try with a fresh key.
Future<RunPipelineOutcome> _refuse(
RunsRepository repository,
RunPipelineIntent intent,
String message,
) async {
try {
final existing = await repository.runByRequestKey(intent.requestKey);
if (existing != null) return _accept(existing);
widget.controller.clearPendingRun(intent.pipelineId, intent.version);
return RunPipelineRefused(message, admissionUnknown: false);
} catch (_) {
// Admission cannot be proven either way: keep the intent immutable.
widget.controller.rememberPendingRun(intent);
return RunPipelineRefused(
'$message$runPipelineUnknownSuffix',
admissionUnknown: true,
);
}
}
@override
Widget build(BuildContext context) {
final label = const Text(runPipelineActionLabel);
if (widget.inBar) {
return pipelineBarIconButton(
context,
key: runPipelineActionKey,
label: 'Run ${widget.detail.displayName}',
icon: Icons.play_arrow_rounded,
onPressed: _open,
);
}
return FilledButton(
final button = FilledButton.icon(
key: runPipelineActionKey,
onPressed: _open,
child: label,
icon: const Icon(_runIcon),
label: const Text(runPipelineActionLabel),
);
if (!widget.inBar) return button;
return SegmentedOverflowAction(
overflowEntry: SegmentedOverflowEntry(
label: runPipelineActionLabel,
icon: _runIcon,
onPressed: _open,
),
child: button,
);
}
}
@@ -0,0 +1,155 @@
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../../core/transport/connection_state.dart';
import '../../runs/data/runs_repository.dart';
import '../pipeline_models.dart';
import '../pipelines_controller.dart';
import '../run_pipeline_intent.dart';
import 'run_pipeline_dialog.dart';
import 'run_pipeline_wording.dart';
/// The one Run start flow, shared by a pipeline's Run action and the Runs
/// tab's New run picker.
///
/// Nothing is requested until the dialog's confirm. A confirmed attempt sends
/// the web's exact `run_pipeline` body against the pinned resolved version; a
/// lost reply keeps the intent so the next deliberate press checks by the same
/// request key before resending. Only the id the server names is reported.
Future<void> openRunPipelineFlow({
required BuildContext context,
required PipelinesController controller,
required PipelineDetail detail,
required ApiGateway gateway,
ValueChanged<int>? onRunStarted,
}) async {
final pipelineId = detail.id;
final version = detail.resolvedVersion;
final pending = await controller.loadPendingRun(pipelineId, version);
if (!context.mounted) return;
await showRunPipelineDialog(
context: context,
detail: detail,
gateway: gateway,
pending: pending,
onSubmit: (intent) => _submit(controller, gateway, intent),
onPendingChanged: (intent) {
if (intent == null) {
controller.clearPendingRun(pipelineId, version);
} else {
controller.rememberPendingRun(intent);
}
},
onAccepted: (run) {
final id = runPipelineRunId(run);
if (id == null) return;
controller.clearPendingRun(pipelineId, version);
onRunStarted?.call(id);
},
);
}
Future<RunPipelineOutcome> _submit(
PipelinesController controller,
ApiGateway gateway,
RunPipelineIntent intent,
) async {
final repository = RunsRepository(gateway);
final pending = controller.pendingRunFor(intent.pipelineId, intent.version);
if (pending?.requestKey == intent.requestKey) {
// A previous send may have been admitted even though its reply was lost.
// Check before resending the same key; the server dedupes either way.
try {
final existing = await repository.runByRequestKey(intent.requestKey);
if (existing != null) {
return _accept(controller, intent, existing);
}
} catch (error) {
controller.rememberPendingRun(intent);
return RunPipelineRefused(
'${describeRunPipelineError(error)}$runPipelineUnknownSuffix',
admissionUnknown: true,
);
}
}
try {
final run = await repository.startRun(
pipelineId: intent.pipelineId,
version: intent.version,
prompt: intent.prompt,
workspace: intent.workspace,
requestKey: intent.requestKey,
notifyMode: intent.notifyMode.wireValue,
outputFormat: intent.outputFormat.wireValue,
);
final accepted = _accept(controller, intent, run);
if (accepted is RunPipelineAccepted) return accepted;
// A reply without a usable run id is not navigable: read the admitted run
// by key rather than inventing an id or starting another run.
return _refuse(
controller,
repository,
intent,
'The server returned no run id.',
);
} on ProtocolError catch (error) {
return _refuse(
controller,
repository,
intent,
describeRunPipelineError(error),
);
} on RunsRepositoryException catch (error) {
return _refuse(
controller,
repository,
intent,
describeRunPipelineError(error),
);
} catch (error) {
controller.rememberPendingRun(intent);
return RunPipelineRefused(
'${describeRunPipelineError(error)}$runPipelineUnknownSuffix',
admissionUnknown: true,
);
}
}
/// A reply is only accepted when it names a usable run id.
RunPipelineOutcome _accept(
PipelinesController controller,
RunPipelineIntent intent,
JsonMap run,
) {
if (runPipelineRunId(run) == null) {
return const RunPipelineRefused(
'The server returned no run id.',
admissionUnknown: false,
);
}
controller.clearPendingRun(intent.pipelineId, intent.version);
return RunPipelineAccepted(run);
}
/// A confirmed refusal: prove by key that no run was admitted before letting
/// the operator correct the fields and try with a fresh key.
Future<RunPipelineOutcome> _refuse(
PipelinesController controller,
RunsRepository repository,
RunPipelineIntent intent,
String message,
) async {
try {
final existing = await repository.runByRequestKey(intent.requestKey);
if (existing != null) return _accept(controller, intent, existing);
controller.clearPendingRun(intent.pipelineId, intent.version);
return RunPipelineRefused(message, admissionUnknown: false);
} catch (_) {
// Admission cannot be proven either way: keep the intent immutable.
controller.rememberPendingRun(intent);
return RunPipelineRefused(
'$message$runPipelineUnknownSuffix',
admissionUnknown: true,
);
}
}
+88 -13
View File
@@ -11,10 +11,15 @@ import '../attention/notify/notification_controller.dart';
import '../../ui/layout/content_width.dart';
import '../attention/runtime/attention_controller.dart';
import '../attention/runtime/attention_store.dart';
import '../pipelines/pending_run_store.dart';
import '../pipelines/pipeline_repository.dart';
import '../pipelines/pipelines_controller.dart';
import 'actions/decision_action.dart';
import 'data/runs_repository.dart';
import 'data/runs_sort_store.dart';
import 'domain/run_decisions.dart';
import 'ui/new_run_button.dart';
import 'ui/new_run_flow.dart';
import 'ui/run_pipeline_link.dart';
import 'ui/run_detail_view.dart';
import 'ui/run_search_selection.dart';
@@ -47,6 +52,7 @@ class RunsScreen extends StatefulWidget {
this.notifications,
this.attention,
this.sortStore = const SharedPreferencesRunsSortStore(),
this.pendingRunStore = const SharedPreferencesPendingRunStore(''),
});
final ApiGateway gateway;
@@ -94,12 +100,24 @@ class RunsScreen extends StatefulWidget {
/// Where the list's sort choice persists; tests inject a memory store.
final RunsSortStore sortStore;
/// Where a New run's pending launch intent persists, under the same endpoint
/// scope the Pipelines tab uses. Tests inject a memory store.
final PendingRunStore pendingRunStore;
@override
State<RunsScreen> createState() => _RunsScreenState();
}
/// The vertical band the New run button occupies over the list's bottom edge:
/// its margin, the extended button's height and its margin again.
const double _newRunBand = 88;
class _RunsScreenState extends State<RunsScreen> {
late final RunsController controller;
/// Starts a run from the New run picker. Its state is only the pending
/// launch intent; the pipeline itself is read when the operator picks one.
late final PipelinesController _launches;
num? _shownRunId;
int? _reportedPipelineId;
bool _applyingRoutePipeline = false;
@@ -118,6 +136,10 @@ class _RunsScreenState extends State<RunsScreen> {
RunsRepository(widget.gateway),
sortStore: widget.sortStore,
);
_launches = PipelinesController(
PipelinesRepository(widget.gateway),
pendingRunStore: widget.pendingRunStore,
);
// A deleted open run closes its detail; the route returns to the list.
controller.onOpenRunRemoved = () =>
widget.onBack?.call(controller.pipelineId);
@@ -234,6 +256,23 @@ class _RunsScreenState extends State<RunsScreen> {
widget.onBack?.call(controller.pipelineId);
}
/// The New run picker, then the same start flow a pipeline's Run opens.
void _startNewRun() => unawaited(
startNewRunFlow(
context: context,
controller: _launches,
gateway: widget.gateway,
onRunStarted: _newRunStarted,
),
);
/// An accepted launch re-reads the list so its row appears, then opens the
/// run the same way a row tap does.
void _newRunStarted(int id) {
unawaited(controller.resync());
_select(id);
}
@override
void dispose() {
controller.removeListener(_selectionChanged);
@@ -241,6 +280,7 @@ class _RunsScreenState extends State<RunsScreen> {
controller.removeListener(_detailChanged);
_page.dispose();
controller.dispose();
_launches.dispose();
super.dispose();
}
@@ -285,20 +325,55 @@ class _RunsScreenState extends State<RunsScreen> {
onClosed: _back,
builder: (context) => _detail(() => Navigator.of(context).maybePop()),
);
final list = AnimatedBuilder(
animation: controller,
builder: (context, _) => ContentWidth(
child: RunsList(
active: narrow ? !selected : true,
controller: controller,
onSelected: _select,
syncToken: widget.syncToken,
attentionStore: widget.attentionStore,
attentionNow: widget.attentionNow,
notifications: widget.notifications,
attention: widget.attention,
// The New run button floats over the list's bottom-right corner while the
// list is the visible view. The list reserves the button's band in its
// bottom padding, so its last row rests above the button, and the overlay
// lifts clear of the shell's bar like the list's own clearance does.
final list = Stack(
fit: StackFit.expand,
children: [
AnimatedBuilder(
animation: controller,
builder: (context, _) {
final showsButton = !(narrow && selected);
final media = MediaQuery.of(context);
return MediaQuery(
data: media.copyWith(
padding: media.padding.copyWith(
bottom:
media.padding.bottom + (showsButton ? _newRunBand : 0),
),
),
child: ContentWidth(
child: RunsList(
active: narrow ? !selected : true,
controller: controller,
onSelected: _select,
syncToken: widget.syncToken,
attentionStore: widget.attentionStore,
attentionNow: widget.attentionNow,
notifications: widget.notifications,
attention: widget.attention,
),
),
);
},
),
),
AnimatedBuilder(
animation: controller,
builder: (context, _) => narrow && selected
? const SizedBox.shrink()
: Positioned(
left: 16,
right: 16,
bottom: 16 + MediaQuery.paddingOf(context).bottom,
child: Align(
alignment: AlignmentDirectional.bottomEnd,
child: NewRunButton(onPressed: _startNewRun),
),
),
),
],
);
if (narrow) return list;
return ListDetailPanes(
@@ -0,0 +1,17 @@
import 'package:flutter/material.dart';
/// The Runs tab's New run action: an extended floating button that opens the
/// pipeline picker. It is labelled, so it needs no tooltip of its own.
class NewRunButton extends StatelessWidget {
const NewRunButton({super.key, required this.onPressed});
final VoidCallback onPressed;
@override
Widget build(BuildContext context) => FloatingActionButton.extended(
key: const Key('runs-new-run'),
onPressed: onPressed,
icon: const Icon(Icons.add),
label: const Text('New run'),
);
}
@@ -0,0 +1,40 @@
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../pipelines/pipeline_models.dart';
import '../../pipelines/pipeline_repository.dart';
import '../../pipelines/pipelines_controller.dart';
import '../../pipelines/ui/run_pipeline_flow.dart';
import '../../pipelines/ui/run_pipeline_wording.dart';
import 'new_run_picker.dart';
/// The Runs tab's New run: pick an active pipeline, read its latest version,
/// then the same start flow a pipeline's Run action opens.
Future<void> startNewRunFlow({
required BuildContext context,
required PipelinesController controller,
required ApiGateway gateway,
ValueChanged<int>? onRunStarted,
}) async {
final repository = PipelinesRepository(gateway);
final pipelineId = await pickPipelineForNewRun(context, repository);
if (pipelineId == null || !context.mounted) return;
final PipelineDetail detail;
try {
detail = await repository.getPipeline(pipelineId, 0);
} catch (error) {
if (!context.mounted) return;
ScaffoldMessenger.maybeOf(
context,
)?.showSnackBar(SnackBar(content: Text(describeRunPipelineError(error))));
return;
}
if (!context.mounted) return;
await openRunPipelineFlow(
context: context,
controller: controller,
detail: detail,
gateway: gateway,
onRunStarted: onRunStarted,
);
}
@@ -0,0 +1,143 @@
import 'package:flutter/material.dart';
import '../../pipelines/pipeline_models.dart';
import '../../pipelines/pipeline_repository.dart';
import '../../pipelines/ui/run_pipeline_wording.dart';
/// Whether an active pipeline matches a picker search by name. An empty query
/// matches every pipeline.
bool pipelineMatchesQuery(PipelineSummary pipeline, String query) {
final needle = query.trim().toLowerCase();
if (needle.isEmpty) return true;
return pipeline.displayName.toLowerCase().contains(needle);
}
/// Opens the searchable list of active pipelines. Resolves to the chosen
/// pipeline's id, or null when the picker is dismissed.
Future<int?> pickPipelineForNewRun(
BuildContext context,
PipelinesRepository repository,
) => showDialog<int>(
context: context,
builder: (_) => _PipelinePicker(repository: repository),
);
class _PipelinePicker extends StatefulWidget {
const _PipelinePicker({required this.repository});
final PipelinesRepository repository;
@override
State<_PipelinePicker> createState() => _PipelinePickerState();
}
class _PipelinePickerState extends State<_PipelinePicker> {
late Future<List<PipelineSummary>> _pipelines = _loadActive();
String _query = '';
/// Archived pipelines cannot run, so the picker offers only active ones.
Future<List<PipelineSummary>> _loadActive() async {
final all = await widget.repository.listPipelines();
return all.where((pipeline) => !pipeline.archived).toList(growable: false);
}
void _retry() => setState(() => _pipelines = _loadActive());
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Dialog(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 480, maxHeight: 560),
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text('Choose a pipeline', style: theme.textTheme.titleLarge),
const Padding(padding: EdgeInsets.only(top: 12)),
TextField(
key: const Key('new-run-search'),
decoration: const InputDecoration(
hintText: 'Search pipelines',
prefixIcon: Icon(Icons.search),
),
onChanged: (value) => setState(() => _query = value),
),
const Padding(padding: EdgeInsets.only(top: 8)),
Flexible(child: _body(context)),
],
),
),
),
);
}
Widget _body(BuildContext context) {
return FutureBuilder<List<PipelineSummary>>(
future: _pipelines,
builder: (context, snapshot) {
if (snapshot.connectionState != ConnectionState.done) {
return const Padding(
padding: EdgeInsets.all(24),
child: Center(child: CircularProgressIndicator()),
);
}
if (snapshot.hasError) {
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
describeRunPipelineError(snapshot.error!),
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
TextButton(onPressed: _retry, child: const Text('Retry')),
],
);
}
final active = snapshot.data ?? const <PipelineSummary>[];
if (active.isEmpty) {
return const _Notice('No active pipelines.');
}
final matches = active
.where((pipeline) => pipelineMatchesQuery(pipeline, _query))
.toList(growable: false);
if (matches.isEmpty) {
return const _Notice('No pipeline matches the search.');
}
return ListView(
shrinkWrap: true,
children: [
for (final pipeline in matches)
ListTile(
key: ValueKey<String>('new-run-pipeline-${pipeline.id}'),
title: Text(
pipeline.displayName,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
subtitle: Text(
'v${pipeline.version} · ${pipeline.stages} stages',
),
onTap: () => Navigator.of(context).pop(pipeline.id),
),
],
);
},
);
}
}
class _Notice extends StatelessWidget {
const _Notice(this.message);
final String message;
@override
Widget build(BuildContext context) => Padding(
padding: const EdgeInsets.all(16),
child: Text(message, style: TextStyle(color: Theme.of(context).hintColor)),
);
}
@@ -61,7 +61,7 @@ const walkthroughSteps = <WalkthroughStep>[
points: <String>[
'Pipelines tab: open a workflow and fill in its inputs.',
'Runs tab: follow a run as it works, then read what it produced.',
'Choose Run on a workflow to start one.',
'Press Run on a workflow, or New run on the Runs tab, to start one.',
],
),
WalkthroughStep(
+98
View File
@@ -0,0 +1,98 @@
# Starting a run: labelled entry points
## Change
- Pipeline detail: the icon-only play button in the top bar is now a labelled
`FilledButton.icon` "Run" (same key, `runPipelineActionKey`). In a narrow bar
it moves into the More menu with its label, via the existing
`SegmentedOverflowAction`.
- Runs: an extended "New run" button (`runs-new-run`) floats over the list's
bottom-right corner while the list is the visible view (phone list, or the
desktop list pane). It sits above the shell's bottom bar: the button's bottom
is lifted by the body's bottom padding, the same inset the list clears. While
it is shown, the list's bottom padding also reserves its band (`_newRunBand`
in `lib/features/runs/screen.dart`), so the last row should rest above the button (no test covers this; ui-review to confirm).
It opens a searchable picker of active pipelines (archived ones are
withheld), reads the chosen pipeline's latest version, then opens the same
start dialog the Run button opens.
- The start flow moved out of `RunPipelineAction` into
`lib/features/pipelines/ui/run_pipeline_flow.dart` (`openRunPipelineFlow`),
so both entry points share one submit, pending-intent and accept path.
- The pending-intent store on Runs uses the same endpoint scope as Pipelines
(`lib/application/pending_run_scope.dart`).
- Walkthrough step 3 now reads: "Press Run on a workflow, or New run on the
Runs tab, to start one."
## Fix for ui-review rejection (visit 1)
- Defect: on a phone the "New run" button sat beneath the bottom navigation
(semantics rect y=928-984 at 430x900), so it was hidden and a tap reached
Settings.
- Cause: the button was the last child of a column under the list, and the
shell's body extends under the bar (`extendBody`), so the bottom of the
column was under the bar.
- Fix: the button is now an overlay positioned above the body's bottom inset,
and the list reserves the band. Desktop uses the same overlay.
- Tried first and rejected: wrapping the list in a `Column` with the button as
a second child (in both an `Expanded` and an outer form). It fixed the phone
position but broke row selection on desktop (`list_detail_consistency_test`
"selected rows" at 640 wide: row 1 kept its selected flag after row 2 was
opened). The overlay keeps the list as a direct child and passes that test.
## Files
- Source: `lib/features/pipelines/ui/run_pipeline_action.dart`,
`lib/features/pipelines/ui/run_pipeline_flow.dart` (new),
`lib/features/runs/screen.dart`, `lib/features/runs/ui/new_run_button.dart`
(new), `lib/features/runs/ui/new_run_flow.dart` (new),
`lib/features/runs/ui/new_run_picker.dart` (new),
`lib/application/pending_run_scope.dart` (new),
`lib/application/pipelines_destination.dart`,
`lib/application/runs_destination.dart`,
`lib/features/walkthrough/walkthrough_steps.dart`.
- Tests: `test/features/runs/ui/new_run_test.dart` (new),
`test/features/pipelines/ui/run_pipeline_launch_test.dart` (one case added),
`test/features/runs/ui/runs_list_refresh_test.dart` (finder scoped to the list
rows; its expectations are unchanged).
## Regression coverage for the rejection
- `new_run_test.dart` "New run clears the bottom bar and opens the picker on a
phone": the screen sits in a scaffold with `extendBody` and a NavigationBar,
as the shell does. It asserts the button's bottom is at or above the bar's
top, and that a tap on the button opens the picker. Before the fix it failed
(button bottom 884, bar top 820).
## Focused results (visit 2)
Command: `tool/memwatch/full.sh` with 19 test files (the new-run and launch
tests plus every test file that builds RunsScreen, the Pipelines Run action, the
Pipelines screen, Settings, or the walkthrough).
- 119 passed, 1 failed. Verdict named only the intended paths.
- Failing: `test/application/run_start_wiring_test.dart` "an accepted launch
opens the returned run and re-reads the runs list exactly once". It also fails
on untouched `main` (checked in a temporary main worktree, since removed): it
times out waiting for `get_pipeline` after tapping `pipeline-row-1`.
- `list_detail_consistency_test.dart`: passes (it failed with the rejected
`Column` layout; see Fix above).
- `new_run_test.dart`: 5 passed, including the phone bottom-bar case.
- `tool/analyze.sh`: clean (exit 0).
## Affected UI states (for ui-review to re-capture; not captured here)
1. Pipeline detail, wide bar: labelled "Run" next to the list and more icons.
2. Pipeline detail, narrow phone bar: Run should move into More, labelled.
3. Runs list, phone (430x900): "New run" floats above the bottom bar, clear of
the last row at rest. This is the rejected state; it must be re-captured.
4. Runs list, desktop: "New run" floats over the list pane's bottom-right.
5. New run picker: default, searching, no match, no active pipelines, error+retry.
6. Start dialog reached from the picker.
7. Walkthrough step 3 copy.
Before captures: `/tmp/ui-review/pipe-light-430x900/01-pipeline-detail.png`
(play icon unlabelled) and `/tmp/ui-review/base-light-430x900/03-runs.png`
(no New run).
## Limitations
- No UI was built or captured in this stage (per the stage instructions);
rendering is unverified. The phone position is verified only by the widget
test's layout geometry under a scaffold that mirrors the shell.
- `_newRunBand` is a fixed reservation (16 + 56 + 16). If the extended button
grows with text scale, the last row may need more room. Measuring it would
need a size callback; not done.
- The Runs picker reads only the current endpoint scope. Pending intents stored
under legacy endpoints are not offered by New run (Pipelines still offers them).
- Not run on web, a device or the Fold.
@@ -604,4 +604,28 @@ void main() {
expect(find.text('Nightly review'), findsWidgets);
expect(launches, 0);
});
testWidgets('the labelled Run button on the detail starts the flow', (
tester,
) async {
final fixture = PipelineFixture();
final navigated = <int>[];
final gateway = launchGateway(fixture, onLaunch: (_) => acceptedRun(79));
await pumpScreen(tester, gateway, navigated);
await openDetail(tester);
final run = find.byKey(runPipelineActionKey);
expect(
find.descendant(of: run, matching: find.text(runPipelineActionLabel)),
findsOneWidget,
);
await tester.tap(run);
await tester.pumpAndSettle();
await fillFields(tester);
await tester.tap(find.byKey(runPipelineConfirmKey));
await tester.pumpAndSettle();
expect(gateway.callsOf('run_pipeline'), hasLength(1));
expect(navigated, [79]);
});
}
+206
View File
@@ -0,0 +1,206 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/pipelines/ui/run_pipeline_wording.dart';
import 'package:pipelines_app/features/runs/screen.dart';
import '../../pipelines/fixtures.dart';
JsonMap _acceptedRun(int id) => {
'type': 'run',
'run_detail': {'id': id, 'status': 'running', 'title': 'Run $id'},
};
/// Pipelines for the picker: the fixture's three active ones plus one archived
/// pipeline, which must never be offered for a new run.
List<Map<String, dynamic>> _pipelines(PipelineFixture fixture) => [
...fixture.summaries,
{
...pipelineSummary(id: 4, name: 'Retired build'),
'archived_at': '2026-10-01T10:00:00',
},
];
FakeGateway _gateway(PipelineFixture fixture, {required int launchedRunId}) =>
FakeGateway(
(type, fields) => switch (type) {
'list_runs' => runListReply(fixture.runs),
'list_pipelines' => pipelineListReply(_pipelines(fixture)),
'get_pipeline' => pipelineDetailReply(
fixture.detailFor(
fields['pipeline_id'] as int,
fields['version'] as int,
)!,
),
'chat_directories' => {
'type': 'chat_directories',
'chat_directories': ['/work/recent'],
},
'run_pipeline' => _acceptedRun(launchedRunId),
_ => errorReply('unexpected $type'),
},
);
/// Pumps the Runs screen. With [withNavigationBar] the screen sits in a
/// scaffold with `extendBody` and a bottom NavigationBar, as the shell does on
/// a phone, so the body scrolls under the bar.
Future<void> _pumpRuns(
WidgetTester tester,
FakeGateway gateway, {
required Size size,
required List<int> selected,
bool withNavigationBar = false,
}) async {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final screen = RunsScreen(gateway: gateway, onRunSelected: selected.add);
await tester.pumpWidget(
MaterialApp(
home: withNavigationBar
? Scaffold(
extendBody: true,
body: screen,
bottomNavigationBar: NavigationBar(
selectedIndex: 0,
onDestinationSelected: (_) {},
destinations: const [
NavigationDestination(
icon: Icon(Icons.play_arrow),
label: 'Runs',
),
NavigationDestination(
icon: Icon(Icons.settings),
label: 'Settings',
),
],
),
)
: Scaffold(body: screen),
),
);
await tester.pumpAndSettle();
}
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
SharedPreferences.setMockInitialValues({});
for (final size in const [Size(430, 900), Size(1100, 900)]) {
testWidgets('New run is labelled on the Runs list at ${size.width} wide', (
tester,
) async {
final gateway = _gateway(PipelineFixture(), launchedRunId: 91);
await _pumpRuns(tester, gateway, size: size, selected: []);
final button = find.byKey(const Key('runs-new-run'));
expect(button, findsOneWidget);
expect(
find.descendant(of: button, matching: find.text('New run')),
findsOneWidget,
);
});
}
testWidgets('New run clears the bottom bar and opens the picker on a phone', (
tester,
) async {
final gateway = _gateway(PipelineFixture(), launchedRunId: 91);
await _pumpRuns(
tester,
gateway,
size: const Size(430, 900),
selected: [],
withNavigationBar: true,
);
final button = find.byKey(const Key('runs-new-run'));
final bar = find.byType(NavigationBar);
expect(button, findsOneWidget);
// The button sits wholly above the bar, not beneath it.
expect(
tester.getRect(button).bottom,
lessThanOrEqualTo(tester.getRect(bar).top),
);
// A tap at the button reaches the button, not the bar behind it.
await tester.tap(button);
await tester.pumpAndSettle();
expect(find.byKey(const Key('new-run-search')), findsOneWidget);
});
testWidgets(
'New run picks an active pipeline, starts it and opens the new run',
(tester) async {
final fixture = PipelineFixture();
final gateway = _gateway(fixture, launchedRunId: 91);
final selected = <int>[];
await _pumpRuns(
tester,
gateway,
size: const Size(1100, 900),
selected: selected,
);
await tester.tap(find.byKey(const Key('runs-new-run')));
await tester.pumpAndSettle();
// The picker lists active pipelines only; the archived one is withheld.
expect(find.byKey(const ValueKey('new-run-pipeline-1')), findsOneWidget);
expect(find.byKey(const ValueKey('new-run-pipeline-2')), findsOneWidget);
expect(find.byKey(const ValueKey('new-run-pipeline-4')), findsNothing);
// Search narrows the list by name.
await tester.enterText(find.byKey(const Key('new-run-search')), 'beta');
await tester.pump();
expect(find.byKey(const ValueKey('new-run-pipeline-1')), findsNothing);
expect(find.byKey(const ValueKey('new-run-pipeline-2')), findsOneWidget);
await tester.tap(find.byKey(const ValueKey('new-run-pipeline-2')));
await tester.pumpAndSettle();
// The chosen pipeline's latest version is read, then the start dialog
// opens for it: the same flow as the pipeline's own Run action.
expect(gateway.callsOf('get_pipeline').single.fields, {
'pipeline_id': 2,
'version': 0,
});
await tester.enterText(
find.byKey(runPipelinePromptKey),
'Ship the beta.',
);
await tester.enterText(find.byKey(runPipelineWorkspaceKey), '/work/beta');
await tester.pump();
await tester.tap(find.byKey(runPipelineConfirmKey));
await tester.pumpAndSettle();
final launch = gateway.callsOf('run_pipeline').single.fields;
expect(launch['pipeline_id'], 2);
expect(launch['version'], 1);
expect(selected, [91]);
},
);
testWidgets('dismissing the picker starts nothing', (tester) async {
final gateway = _gateway(PipelineFixture(), launchedRunId: 91);
final selected = <int>[];
await _pumpRuns(
tester,
gateway,
size: const Size(430, 900),
selected: selected,
);
await tester.tap(find.byKey(const Key('runs-new-run')));
await tester.pumpAndSettle();
await tester.tapAt(const Offset(4, 4));
await tester.pumpAndSettle();
expect(find.byKey(const Key('new-run-search')), findsNothing);
expect(gateway.callsOf('get_pipeline'), isEmpty);
expect(gateway.callsOf('run_pipeline'), isEmpty);
expect(selected, isEmpty);
});
}
@@ -4,6 +4,11 @@ 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/screen.dart';
import 'package:pipelines_app/features/runs/ui/runs_list.dart';
/// The list's row titles only: the New run button carries the same words.
Finder _rowTitled(String title) =>
find.descendant(of: find.byType(RunsList), matching: find.text(title));
class _Gateway implements ApiGateway {
final listRequests = <Completer<JsonMap>>[];
@@ -53,7 +58,7 @@ void main() {
await tester.pump();
expect(gateway.listRequests, hasLength(2));
// No row is invented while the fresh read is outstanding.
expect(find.text('New run'), findsNothing);
expect(_rowTitled('New run'), findsNothing);
gateway.listRequests[1].complete({
'runs': [
{'id': 2, 'title': 'New run', 'status': 'running'},
@@ -63,7 +68,7 @@ void main() {
await tester.pump();
await tester.pump();
expect(find.text('New run'), findsOneWidget);
expect(_rowTitled('New run'), findsOneWidget);
expect(gateway.listRequests, hasLength(2));
expect(gateway.detailRequests, isEmpty);
});