feat(app): start a pipeline from the detail view
Native Run action opens the web's prompt/workspace/notify dialog, sends the exact run_pipeline body against the pinned resolved version with one request key per confirmed attempt, keeps refusals in the dialog, reconciles a lost reply by key, and opens only the server-named run through the existing run route with one fresh Runs list read. Adds a shared failure-reason helper so operators never see Dart runtime prefixes, and records the slice boundary in notes/P3-run.md.
This commit is contained in:
@@ -0,0 +1,174 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
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 '../widgets/pipeline_controls.dart';
|
||||
import 'run_pipeline_dialog.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.
|
||||
class RunPipelineAction extends StatefulWidget {
|
||||
const RunPipelineAction({
|
||||
super.key,
|
||||
required this.controller,
|
||||
required this.detail,
|
||||
required this.gateway,
|
||||
this.onRunStarted,
|
||||
});
|
||||
|
||||
final PipelinesController controller;
|
||||
final PipelineDetail detail;
|
||||
final ApiGateway gateway;
|
||||
|
||||
/// Receives the id from an accepted server reply. It is never called for a
|
||||
/// guessed or malformed response.
|
||||
final ValueChanged<int>? onRunStarted;
|
||||
|
||||
@override
|
||||
State<RunPipelineAction> createState() => _RunPipelineActionState();
|
||||
}
|
||||
|
||||
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 {
|
||||
await showRunPipelineDialog(
|
||||
context: context,
|
||||
detail: widget.detail,
|
||||
pending: widget.controller.pendingRunFor(_pipelineId, _version),
|
||||
onSubmit: _submit,
|
||||
onPendingChanged: (intent) {
|
||||
if (intent == null) {
|
||||
widget.controller.clearPendingRun(_pipelineId, _version);
|
||||
} else {
|
||||
widget.controller.rememberPendingRun(intent);
|
||||
}
|
||||
},
|
||||
onAccepted: _accepted,
|
||||
);
|
||||
} 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,
|
||||
);
|
||||
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 (useCupertinoControls(context)) {
|
||||
return CupertinoButton.filled(
|
||||
key: runPipelineActionKey,
|
||||
onPressed: _open,
|
||||
child: label,
|
||||
);
|
||||
}
|
||||
return FilledButton(
|
||||
key: runPipelineActionKey,
|
||||
onPressed: _open,
|
||||
child: label,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../pipeline_models.dart';
|
||||
import '../run_pipeline_intent.dart';
|
||||
import 'run_pipeline_fields.dart';
|
||||
import 'run_pipeline_wording.dart';
|
||||
|
||||
/// Opens the native start-a-run prompt; resolves when it closes.
|
||||
///
|
||||
/// Opening, typing and Cancel send nothing. Only the confirm action validates
|
||||
/// and submits. [pending] restores an intent whose admission is still unknown,
|
||||
/// so its fields are locked and the same request key is offered for check/retry.
|
||||
Future<void> showRunPipelineDialog({
|
||||
required BuildContext context,
|
||||
required PipelineDetail detail,
|
||||
required RunPipelineIntent? pending,
|
||||
required Future<RunPipelineOutcome> Function(RunPipelineIntent intent)
|
||||
onSubmit,
|
||||
required ValueChanged<RunPipelineIntent?> onPendingChanged,
|
||||
required ValueChanged<JsonMap> onAccepted,
|
||||
}) {
|
||||
final dialog = _RunPipelineDialog(
|
||||
detail: detail,
|
||||
pending: pending,
|
||||
cupertino: usesCupertinoHost(context),
|
||||
onSubmit: onSubmit,
|
||||
onPendingChanged: onPendingChanged,
|
||||
onAccepted: onAccepted,
|
||||
);
|
||||
return dialog.cupertino
|
||||
? showCupertinoDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (_) => dialog,
|
||||
)
|
||||
: showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (_) => dialog,
|
||||
);
|
||||
}
|
||||
|
||||
class _RunPipelineDialog extends StatefulWidget {
|
||||
const _RunPipelineDialog({
|
||||
required this.detail,
|
||||
required this.pending,
|
||||
required this.cupertino,
|
||||
required this.onSubmit,
|
||||
required this.onPendingChanged,
|
||||
required this.onAccepted,
|
||||
});
|
||||
|
||||
final PipelineDetail detail;
|
||||
final RunPipelineIntent? pending;
|
||||
final bool cupertino;
|
||||
final Future<RunPipelineOutcome> Function(RunPipelineIntent intent) onSubmit;
|
||||
final ValueChanged<RunPipelineIntent?> onPendingChanged;
|
||||
final ValueChanged<JsonMap> onAccepted;
|
||||
|
||||
@override
|
||||
State<_RunPipelineDialog> createState() => _RunPipelineDialogState();
|
||||
}
|
||||
|
||||
class _RunPipelineDialogState extends State<_RunPipelineDialog> {
|
||||
late final TextEditingController _prompt;
|
||||
late final TextEditingController _workspace;
|
||||
late RunNotifyMode _notify;
|
||||
late RunPipelineIntent? _intent;
|
||||
bool _sending = false;
|
||||
String? _error;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final pending = widget.pending;
|
||||
final restored =
|
||||
pending != null &&
|
||||
pending.matches(widget.detail.id, widget.detail.resolvedVersion)
|
||||
? pending
|
||||
: null;
|
||||
_intent = restored;
|
||||
_notify = restored?.notifyMode ?? RunNotifyMode.pipelineDefault;
|
||||
_prompt = TextEditingController(text: restored?.prompt ?? '');
|
||||
_workspace = TextEditingController(text: restored?.workspace ?? '');
|
||||
_error = restored == null ? null : runPipelineUnknownAdmission;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_prompt.dispose();
|
||||
_workspace.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
bool get _locked => _intent != null || _sending;
|
||||
|
||||
void _cancel() {
|
||||
if (!_sending) Navigator.of(context).pop();
|
||||
}
|
||||
|
||||
Future<void> _confirm() async {
|
||||
if (_sending) return;
|
||||
final prompt = _prompt.text.trim();
|
||||
if (prompt.isEmpty) {
|
||||
setState(() => _error = runPipelinePromptRequired);
|
||||
return;
|
||||
}
|
||||
// The browser checks the field as typed; only the sent value is trimmed.
|
||||
final workspace = _workspace.text;
|
||||
if (!workspace.startsWith('/')) {
|
||||
setState(() => _error = runPipelineWorkspaceAbsolute);
|
||||
return;
|
||||
}
|
||||
final intent =
|
||||
_intent ??
|
||||
RunPipelineIntent(
|
||||
pipelineId: widget.detail.id,
|
||||
version: widget.detail.resolvedVersion,
|
||||
prompt: prompt,
|
||||
workspace: workspace.trim(),
|
||||
notifyMode: _notify,
|
||||
requestKey: newRunPipelineRequestKey(
|
||||
widget.detail.id,
|
||||
widget.detail.resolvedVersion,
|
||||
),
|
||||
);
|
||||
setState(() {
|
||||
_sending = true;
|
||||
_error = null;
|
||||
});
|
||||
final outcome = await widget.onSubmit(intent);
|
||||
if (!mounted) return;
|
||||
switch (outcome) {
|
||||
case RunPipelineAccepted(:final run):
|
||||
widget.onPendingChanged(null);
|
||||
widget.onAccepted(run);
|
||||
Navigator.of(context).pop();
|
||||
case RunPipelineRefused(:final message, :final admissionUnknown):
|
||||
final keep = admissionUnknown ? intent : null;
|
||||
widget.onPendingChanged(keep);
|
||||
setState(() {
|
||||
_intent = keep;
|
||||
_sending = false;
|
||||
_error = message;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final dialog = widget.cupertino ? _cupertino(context) : _material(context);
|
||||
return PopScope(canPop: !_sending, child: dialog);
|
||||
}
|
||||
|
||||
Widget _material(BuildContext context) {
|
||||
return AlertDialog(
|
||||
scrollable: true,
|
||||
title: Text(runPipelineDialogTitle(widget.detail.name)),
|
||||
content: _content(context),
|
||||
actions: [
|
||||
TextButton(
|
||||
key: runPipelineCancelKey,
|
||||
onPressed: _sending ? null : _cancel,
|
||||
child: const Text(runPipelineCancelLabel),
|
||||
),
|
||||
FilledButton(
|
||||
key: runPipelineConfirmKey,
|
||||
onPressed: _sending ? null : _confirm,
|
||||
child: Text(_confirmLabel),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cupertino(BuildContext context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: Text(runPipelineDialogTitle(widget.detail.name)),
|
||||
content: _content(context),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
key: runPipelineCancelKey,
|
||||
onPressed: _sending ? null : _cancel,
|
||||
child: const Text(runPipelineCancelLabel),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
key: runPipelineConfirmKey,
|
||||
isDefaultAction: true,
|
||||
onPressed: _sending ? null : _confirm,
|
||||
child: Text(_confirmLabel),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
String get _confirmLabel {
|
||||
if (_sending) return runPipelineSendingLabel;
|
||||
return _intent == null
|
||||
? runPipelineConfirmLabel
|
||||
: runPipelineCheckRetryLabel;
|
||||
}
|
||||
|
||||
Widget _content(BuildContext context) {
|
||||
final errorStyle = widget.cupertino
|
||||
? TextStyle(color: CupertinoColors.systemRed.resolveFrom(context))
|
||||
: TextStyle(color: Theme.of(context).colorScheme.error);
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
RunPipelineFields(
|
||||
prompt: _prompt,
|
||||
workspace: _workspace,
|
||||
notifyMode: _notify,
|
||||
locked: _locked,
|
||||
onNotifyChanged: (mode) => setState(() => _notify = mode),
|
||||
),
|
||||
if (_error case final error?)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 12),
|
||||
child: Semantics(
|
||||
liveRegion: true,
|
||||
child: Text(error, key: runPipelineErrorKey, style: errorStyle),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../run_pipeline_intent.dart';
|
||||
import 'run_pipeline_wording.dart';
|
||||
|
||||
/// The dialog's three web fields, in the host's native controls.
|
||||
///
|
||||
/// A confirmed launch locks every field: the request is immutable until its
|
||||
/// admission is known, exactly like the browser's disabled inputs.
|
||||
class RunPipelineFields extends StatelessWidget {
|
||||
const RunPipelineFields({
|
||||
super.key,
|
||||
required this.prompt,
|
||||
required this.workspace,
|
||||
required this.notifyMode,
|
||||
required this.locked,
|
||||
required this.onNotifyChanged,
|
||||
});
|
||||
|
||||
final TextEditingController prompt;
|
||||
final TextEditingController workspace;
|
||||
final RunNotifyMode notifyMode;
|
||||
final bool locked;
|
||||
final ValueChanged<RunNotifyMode> onNotifyChanged;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
_FieldLabel(runPipelinePromptLabel, cupertino: cupertino),
|
||||
_promptField(context, cupertino),
|
||||
const SizedBox(height: 12),
|
||||
_FieldLabel(runPipelineWorkspaceLabel, cupertino: cupertino),
|
||||
_workspaceField(context, cupertino),
|
||||
_helper(context, runPipelineWorkspaceHelper, cupertino),
|
||||
const SizedBox(height: 12),
|
||||
_FieldLabel(runPipelineNotifyLabel, cupertino: cupertino),
|
||||
_notifyField(context, cupertino),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _promptField(BuildContext context, bool cupertino) {
|
||||
if (cupertino) {
|
||||
return CupertinoTextField(
|
||||
key: runPipelinePromptKey,
|
||||
controller: prompt,
|
||||
placeholder: runPipelinePromptPlaceholder,
|
||||
placeholderStyle: _cupertinoPlaceholder(context),
|
||||
style: CupertinoTheme.of(context).textTheme.textStyle,
|
||||
minLines: 3,
|
||||
maxLines: 5,
|
||||
enabled: !locked,
|
||||
autofocus: !locked,
|
||||
padding: const EdgeInsets.all(8),
|
||||
textCapitalization: TextCapitalization.sentences,
|
||||
);
|
||||
}
|
||||
return TextField(
|
||||
key: runPipelinePromptKey,
|
||||
controller: prompt,
|
||||
enabled: !locked,
|
||||
autofocus: !locked,
|
||||
minLines: 3,
|
||||
maxLines: 5,
|
||||
textCapitalization: TextCapitalization.sentences,
|
||||
decoration: const InputDecoration(
|
||||
hintText: runPipelinePromptPlaceholder,
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _workspaceField(BuildContext context, bool cupertino) {
|
||||
if (cupertino) {
|
||||
return CupertinoTextField(
|
||||
key: runPipelineWorkspaceKey,
|
||||
controller: workspace,
|
||||
placeholder: runPipelineWorkspacePlaceholder,
|
||||
placeholderStyle: _cupertinoPlaceholder(context),
|
||||
style: CupertinoTheme.of(context).textTheme.textStyle,
|
||||
enabled: !locked,
|
||||
autocorrect: false,
|
||||
padding: const EdgeInsets.all(8),
|
||||
);
|
||||
}
|
||||
return TextField(
|
||||
key: runPipelineWorkspaceKey,
|
||||
controller: workspace,
|
||||
enabled: !locked,
|
||||
autocorrect: false,
|
||||
decoration: const InputDecoration(
|
||||
hintText: runPipelineWorkspacePlaceholder,
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _notifyField(BuildContext context, bool cupertino) {
|
||||
if (cupertino) {
|
||||
return CupertinoButton(
|
||||
key: runPipelineNotifyKey,
|
||||
padding: EdgeInsets.zero,
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
onPressed: locked ? null : () => _chooseNotify(context),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Flexible(child: Text(notifyMode.label)),
|
||||
const SizedBox(width: 4),
|
||||
const Icon(CupertinoIcons.chevron_down, size: 14),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
return DropdownButtonFormField<RunNotifyMode>(
|
||||
key: runPipelineNotifyKey,
|
||||
initialValue: notifyMode,
|
||||
decoration: const InputDecoration(border: OutlineInputBorder()),
|
||||
items: [
|
||||
for (final mode in RunNotifyMode.values)
|
||||
DropdownMenuItem(value: mode, child: Text(mode.label)),
|
||||
],
|
||||
onChanged: locked
|
||||
? null
|
||||
: (mode) {
|
||||
if (mode != null) onNotifyChanged(mode);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _chooseNotify(BuildContext context) async {
|
||||
final chosen = await showCupertinoModalPopup<RunNotifyMode>(
|
||||
context: context,
|
||||
builder: (sheetContext) => CupertinoActionSheet(
|
||||
title: const Text(runPipelineNotifyLabel),
|
||||
actions: [
|
||||
for (final mode in RunNotifyMode.values)
|
||||
CupertinoActionSheetAction(
|
||||
onPressed: () => Navigator.of(sheetContext).pop(mode),
|
||||
child: Text(mode.label),
|
||||
),
|
||||
],
|
||||
cancelButton: CupertinoActionSheetAction(
|
||||
isDefaultAction: true,
|
||||
onPressed: () => Navigator.of(sheetContext).pop(),
|
||||
child: const Text(runPipelineCancelLabel),
|
||||
),
|
||||
),
|
||||
);
|
||||
if (chosen != null) onNotifyChanged(chosen);
|
||||
}
|
||||
|
||||
TextStyle _cupertinoPlaceholder(BuildContext context) {
|
||||
// The host's own dynamic placeholder colour (light and dark), resolved for
|
||||
// the dialog's inherited Cupertino brightness.
|
||||
return TextStyle(color: CupertinoColors.placeholderText.resolveFrom(context));
|
||||
}
|
||||
|
||||
Widget _helper(BuildContext context, String text, bool cupertino) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: Text(text, style: _secondaryStyle(context, cupertino)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Secondary copy under a field: the host's own secondary role, never a
|
||||
/// borrowed palette or invented point size.
|
||||
TextStyle _secondaryStyle(BuildContext context, bool cupertino) {
|
||||
if (cupertino) {
|
||||
return CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
);
|
||||
}
|
||||
final theme = Theme.of(context);
|
||||
return (theme.textTheme.bodySmall ?? const TextStyle()).copyWith(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
);
|
||||
}
|
||||
|
||||
/// The label above each native field, using the web's exact words.
|
||||
class _FieldLabel extends StatelessWidget {
|
||||
const _FieldLabel(this.text, {required this.cupertino});
|
||||
|
||||
final String text;
|
||||
final bool cupertino;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// A theme label role with the primary label colour, matching the app's
|
||||
// Cupertino form pattern; secondaryLabel is for helper copy only.
|
||||
final style = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.labelLarge;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 4),
|
||||
child: Text(text, style: style),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../../../core/error_reason.dart';
|
||||
|
||||
/// The browser client's start-a-run wording, kept verbatim.
|
||||
String runPipelineDialogTitle(String name) =>
|
||||
'Run ${name.isEmpty ? 'pipeline' : name}';
|
||||
const runPipelineActionLabel = 'Run';
|
||||
const runPipelinePromptLabel = 'Prompt';
|
||||
const runPipelinePromptPlaceholder = 'What should this run do?';
|
||||
const runPipelineWorkspaceLabel = 'Working directory (on the server)';
|
||||
const runPipelineWorkspaceHelper =
|
||||
'Choose a recent directory or type an absolute path.';
|
||||
const runPipelineWorkspacePlaceholder = '/absolute/path/on/the/server';
|
||||
const runPipelineNotifyLabel = 'Notifications for this run';
|
||||
const runPipelineCancelLabel = 'Cancel';
|
||||
const runPipelineConfirmLabel = 'Run';
|
||||
const runPipelineSendingLabel = 'Starting…';
|
||||
const runPipelineCheckRetryLabel = 'Check / retry';
|
||||
|
||||
/// Local validation, exactly the browser's two states.
|
||||
const runPipelinePromptRequired = 'Enter a prompt for this run.';
|
||||
const runPipelineWorkspaceAbsolute =
|
||||
'Choose an absolute working directory on the server.';
|
||||
|
||||
/// Shown when a stored launch already has an unknown result.
|
||||
const runPipelineUnknownAdmission =
|
||||
'A previous launch has an unknown result. Check/retry reconciles that '
|
||||
'same request; it will not start a duplicate.';
|
||||
|
||||
/// Appended to a transport failure whose admission cannot be proven either way.
|
||||
const runPipelineUnknownSuffix =
|
||||
'. Admission may be unknown. Check/retry uses the same request key.';
|
||||
|
||||
/// Stable test/semantics keys shared by the action and its prompt.
|
||||
const runPipelineActionKey = ValueKey<String>('run-pipeline-action');
|
||||
const runPipelinePromptKey = ValueKey<String>('run-pipeline-prompt');
|
||||
const runPipelineWorkspaceKey = ValueKey<String>('run-pipeline-workspace');
|
||||
const runPipelineNotifyKey = ValueKey<String>('run-pipeline-notify');
|
||||
const runPipelineCancelKey = ValueKey<String>('run-pipeline-cancel');
|
||||
const runPipelineConfirmKey = ValueKey<String>('run-pipeline-confirm');
|
||||
const runPipelineErrorKey = ValueKey<String>('run-pipeline-error');
|
||||
|
||||
/// The server's refusal, verbatim. Only a blank error gets a sentence so the
|
||||
/// prompt never claims a run that was not admitted.
|
||||
String describeRunPipelineError(Object error) => describeErrorReason(
|
||||
error,
|
||||
fallback: 'The server did not start the run.',
|
||||
);
|
||||
Reference in New Issue
Block a user