First run: empty states with a next step, harness setup instead of errors
- One shared EmptyState (icon on a tonal disc, title, one line, primary action) that follows the design tokens; used by Runs (Start your first run), Pipelines (Browse templates), Schedules and the chat list (Start a chat). - Chat on a server without an agent harness showed "Bad state: No saved machine is connected.": the federated list now keeps the server's own refusal, treats an omitted empty list as no chats, and the list shows a "Set up an agent" state with the harness setup command and Refresh. New chat shows the same step instead of a form that can only be refused. - A run that fails because no harness CLI exists names the setup command beside the raw reason; error advice gains a noHarness kind. - Templates opened before the app connected stayed on "Not connected"; it now reads again when the connection arrives. The Pipelines empty state links to Templates, which had no entry point in the UI. - The first-launch walkthrough waits briefly for the connection, so a connected web app is no longer told to connect; the empty-server check treats omitted lists and no chat harness as empty. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1215,6 +1215,7 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
onViewPipelineRuns: (id) =>
|
||||
_delegate.goTo(AppRoute.runsForPipeline(id)),
|
||||
onOpenSchedules: _delegate.openSchedules,
|
||||
onOpenTemplates: _delegate.openTemplates,
|
||||
onOpenSettings: () => _delegate.goTo(AppRoute.settings),
|
||||
onOpenInChat: (context, detail, run) =>
|
||||
_openPipelineInChat(context, detail, run),
|
||||
|
||||
@@ -24,6 +24,7 @@ class PipelinesDestination extends StatelessWidget {
|
||||
this.onRunStarted,
|
||||
this.onViewPipelineRuns,
|
||||
this.onOpenSchedules,
|
||||
this.onOpenTemplates,
|
||||
this.onOpenSettings,
|
||||
this.onSelectionChanged,
|
||||
this.initialPipelineId,
|
||||
@@ -50,6 +51,9 @@ class PipelinesDestination extends StatelessWidget {
|
||||
final ValueChanged<int>? onViewPipelineRuns;
|
||||
final VoidCallback? onOpenSchedules;
|
||||
|
||||
/// Opens the Templates gallery, offered by an empty pipeline list.
|
||||
final VoidCallback? onOpenTemplates;
|
||||
|
||||
/// Opens Settings as a page from the Pipelines bar's gear.
|
||||
final VoidCallback? onOpenSettings;
|
||||
final ValueChanged<int?>? onSelectionChanged;
|
||||
@@ -96,6 +100,7 @@ class PipelinesDestination extends StatelessWidget {
|
||||
onRunStarted: onRunStarted,
|
||||
onViewPipelineRuns: onViewPipelineRuns,
|
||||
onOpenSchedules: onOpenSchedules,
|
||||
onOpenTemplates: onOpenTemplates,
|
||||
onOpenSettings: onOpenSettings,
|
||||
onSelectionChanged: onSelectionChanged,
|
||||
onOpenInChat: onOpenInChat,
|
||||
|
||||
@@ -119,6 +119,7 @@ class _TemplatesDestinationState extends State<TemplatesDestination> {
|
||||
embedded: true,
|
||||
onCreated: widget.onCreated,
|
||||
initialKey: widget.initialKey,
|
||||
reloadToken: session.connectionEpoch,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,16 @@ import 'error_reason.dart';
|
||||
import 'transport/connection_state.dart';
|
||||
|
||||
/// The common kinds of failure an operator can act on.
|
||||
enum ErrorAdviceKind { notConnected, serverTooOld, permission, timeout }
|
||||
enum ErrorAdviceKind {
|
||||
notConnected,
|
||||
serverTooOld,
|
||||
permission,
|
||||
timeout,
|
||||
|
||||
/// The server has no agent harness to run a chat or a stage with: a setup
|
||||
/// step on the server, not a failure of this app.
|
||||
noHarness,
|
||||
}
|
||||
|
||||
/// What to do about a failure, as one sentence, and the raw detail it came
|
||||
/// from (kept available behind the sentence, never replaced by it).
|
||||
@@ -29,6 +38,7 @@ ErrorAdviceKind? errorAdviceKind(Object error) {
|
||||
return ErrorAdviceKind.permission;
|
||||
}
|
||||
final text = '$error'.toLowerCase();
|
||||
if (needsHarnessSetup(text)) return ErrorAdviceKind.noHarness;
|
||||
if (_tooOld.hasMatch(text)) return ErrorAdviceKind.serverTooOld;
|
||||
if (_permission.hasMatch(text)) return ErrorAdviceKind.permission;
|
||||
if (_timeout.hasMatch(text)) return ErrorAdviceKind.timeout;
|
||||
@@ -49,8 +59,23 @@ String errorAdviceSentence(ErrorAdviceKind kind) => switch (kind) {
|
||||
ErrorAdviceKind.timeout =>
|
||||
'The server did not answer in time. Check the connection, then try '
|
||||
'again.',
|
||||
ErrorAdviceKind.noHarness =>
|
||||
'No agent harness is set up on the server yet. In a terminal on the '
|
||||
'server, run `pipelines harness setup <agent>` (claude, codex, '
|
||||
'opencode or pi), then try again.',
|
||||
};
|
||||
|
||||
/// Whether [error] says the server has no usable agent harness: chat is not
|
||||
/// configured, or a stage could not start its harness's CLI. Such a server is
|
||||
/// new, not broken, so callers show the setup step instead of an error.
|
||||
bool needsHarnessSetup(Object? error) =>
|
||||
error != null && _noHarness.hasMatch('$error'.toLowerCase());
|
||||
|
||||
final _noHarness = RegExp(
|
||||
r'chat is not configured|harness unreachable|'
|
||||
r'cannot run the selected \w+ cli',
|
||||
);
|
||||
|
||||
final _tooOld = RegExp(
|
||||
r'unknown (command|message|request)|unsupported (command|message|request)',
|
||||
);
|
||||
|
||||
@@ -91,11 +91,18 @@ class FederatedChatGateway implements ApiGateway {
|
||||
if (type == 'chat_sessions') {
|
||||
final current = Map.of(sources());
|
||||
_cached.removeWhere((id, _) => !serverIds.contains(id));
|
||||
// The first machine's own refusal, kept so a list that no machine
|
||||
// could read says why (chat not set up there, say) instead of
|
||||
// claiming that nothing is connected.
|
||||
Object? firstFailure;
|
||||
final results = await Future.wait(
|
||||
current.entries.map((entry) async {
|
||||
try {
|
||||
final reply = await entry.value.call(type, fields);
|
||||
final list = reply['chat_sessions'];
|
||||
// A server with no chats leaves the empty list out of its reply.
|
||||
final list =
|
||||
reply['chat_sessions'] ??
|
||||
(reply['type'] == 'chat_sessions' ? const <Object?>[] : null);
|
||||
if (list is! List) {
|
||||
throw StateError(
|
||||
'Invalid chat list from ${entry.value.server.name}.',
|
||||
@@ -110,13 +117,15 @@ class FederatedChatGateway implements ApiGateway {
|
||||
.map((v) => Map<String, dynamic>.from(v))
|
||||
.toList();
|
||||
return true;
|
||||
} catch (_) {
|
||||
} catch (error) {
|
||||
firstFailure ??= error;
|
||||
return false;
|
||||
}
|
||||
}),
|
||||
);
|
||||
_cached.removeWhere((id, _) => !serverIds.contains(id));
|
||||
if (!results.contains(true) && _cached.isEmpty) {
|
||||
if (firstFailure case final failure?) throw failure;
|
||||
throw StateError('No saved machine is connected.');
|
||||
}
|
||||
return {
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../ui/status/empty_state.dart';
|
||||
import '../../../walkthrough/walkthrough_harness_command.dart';
|
||||
|
||||
/// The chat list's state on a server without an agent harness: chat is not
|
||||
/// configured there yet, which is a setup step rather than an error. It names
|
||||
/// the step (the setup command for the agent the operator picks, ready to
|
||||
/// copy) and offers Refresh for after the command has run.
|
||||
const chatHarnessSetupKey = ValueKey<String>('chat-harness-setup');
|
||||
|
||||
class ChatHarnessSetupState extends StatelessWidget {
|
||||
const ChatHarnessSetupState({super.key, this.onRefresh});
|
||||
|
||||
/// Reads the chat list again once the harness is set up.
|
||||
final VoidCallback? onRefresh;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final refresh = onRefresh;
|
||||
return EmptyState(
|
||||
key: chatHarnessSetupKey,
|
||||
dense: true,
|
||||
icon: Icons.build_circle_outlined,
|
||||
title: 'Set up an agent to start chatting',
|
||||
message:
|
||||
'Chats run on a coding agent on your server, and none is set up '
|
||||
'yet. Run the setup command for the agent you use in a terminal on '
|
||||
'the server, then refresh.',
|
||||
action: refresh == null
|
||||
? null
|
||||
: emptyStateAction('Refresh', refresh, icon: Icons.refresh),
|
||||
child: const WalkthroughHarnessCommand(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,18 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../core/api_gateway.dart';
|
||||
import '../../../../core/error_advice.dart';
|
||||
import '../../../../ui/status/empty_state.dart';
|
||||
import '../../domain/chat_sessions.dart';
|
||||
import 'chat_adaptive.dart';
|
||||
import 'chat_harness_setup_state.dart';
|
||||
import 'session_list_material.dart';
|
||||
import 'session_pane_menu.dart';
|
||||
import 'session_row_style.dart';
|
||||
|
||||
/// The chat list's state when the server has no chats yet.
|
||||
const chatListEmptyKey = ValueKey<String>('chat-list-empty');
|
||||
|
||||
typedef ChatSessionSection = ({String title, List<JsonMap> sessions});
|
||||
|
||||
/// Which list sections are folded away, kept by the list's screen so the
|
||||
@@ -52,8 +58,16 @@ class ChatSessionsBody extends StatelessWidget {
|
||||
this.onDismissError,
|
||||
this.selectionOnly = false,
|
||||
this.emptyMessageOverride,
|
||||
this.onNewChat,
|
||||
this.onRefresh,
|
||||
});
|
||||
|
||||
/// Starts a chat; an empty list offers it as its next step.
|
||||
final VoidCallback? onNewChat;
|
||||
|
||||
/// Reads the list again; the harness setup state offers it.
|
||||
final VoidCallback? onRefresh;
|
||||
|
||||
/// Reuse list presentation for a picker without mutation menus or gestures.
|
||||
final bool selectionOnly;
|
||||
final String? emptyMessageOverride;
|
||||
@@ -94,6 +108,35 @@ class ChatSessionsBody extends StatelessWidget {
|
||||
: 'No chats match "${query.trim()}".');
|
||||
|
||||
if (loading && sessions.isEmpty) return const ChatLoadingIndicator();
|
||||
// The list's own first-run states. A picker (selectionOnly or an
|
||||
// override) keeps its one-line message.
|
||||
final firstRun =
|
||||
!selectionOnly &&
|
||||
emptyMessageOverride == null &&
|
||||
sessions.isEmpty &&
|
||||
query.trim().isEmpty;
|
||||
if (firstRun && needsHarnessSetup(error)) {
|
||||
return ChatHarnessSetupState(onRefresh: onRefresh);
|
||||
}
|
||||
if (firstRun && error == null) {
|
||||
final start = onNewChat;
|
||||
return EmptyState(
|
||||
key: chatListEmptyKey,
|
||||
dense: true,
|
||||
icon: Icons.forum_outlined,
|
||||
title: 'No chats yet',
|
||||
message:
|
||||
'Talk with a coding agent on your server. Each chat works in a '
|
||||
'folder you choose and keeps its history here.',
|
||||
action: start == null
|
||||
? null
|
||||
: emptyStateAction(
|
||||
'Start a chat',
|
||||
start,
|
||||
icon: Icons.add_comment_outlined,
|
||||
),
|
||||
);
|
||||
}
|
||||
final clearSearch = query.trim().isEmpty ? null : onClearSearch;
|
||||
final duplicateTitles = duplicateChatTitles(visible);
|
||||
return MaterialSessionList(
|
||||
|
||||
@@ -9,6 +9,7 @@ import 'package:flutter/material.dart';
|
||||
import '../../../../ui/layout/content_width.dart';
|
||||
|
||||
import '../../../../core/api_gateway.dart';
|
||||
import '../../../../core/error_advice.dart';
|
||||
import '../../../../shell/shell_bar.dart';
|
||||
import '../../../../shell/shell_list_shortcuts.dart';
|
||||
import '../../../terminal/terminal_open_action.dart';
|
||||
@@ -16,7 +17,9 @@ import '../../data/chat_repository.dart';
|
||||
import '../../domain/chat_colors.dart';
|
||||
import '../../domain/chat_cycle.dart';
|
||||
import '../../domain/chat_sessions.dart';
|
||||
import '../../../../ui/adaptive/app_popups.dart';
|
||||
import 'chat_adaptive.dart';
|
||||
import 'chat_harness_setup_state.dart';
|
||||
import 'chat_color_picker.dart';
|
||||
import 'chat_session_local.dart';
|
||||
import 'chat_sessions_body.dart';
|
||||
@@ -194,6 +197,20 @@ class ChatSessionsScreenState extends State<ChatSessionsScreen> {
|
||||
}
|
||||
|
||||
Future<void> _newChat({bool chooseMachine = true}) async {
|
||||
// Without an agent harness the create form could only be refused: show
|
||||
// the setup step instead, with Refresh to read the list once it is done.
|
||||
if (needsHarnessSetup(_controller.error)) {
|
||||
await showAppDetails<void>(
|
||||
context,
|
||||
builder: (sheet) => ChatHarnessSetupState(
|
||||
onRefresh: () {
|
||||
Navigator.of(sheet).pop();
|
||||
unawaited(_controller.refresh());
|
||||
},
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
final scope = ServerContext.maybeOf(context);
|
||||
var repository = _controller.repository;
|
||||
if (chooseMachine && scope != null) {
|
||||
@@ -241,6 +258,13 @@ class ChatSessionsScreenState extends State<ChatSessionsScreen> {
|
||||
if (session != null && mounted) widget.onOpen(session);
|
||||
}
|
||||
|
||||
/// The list failure shown above the list. A server without an agent
|
||||
/// harness is not a failure: the list itself shows that setup step.
|
||||
String? get _listError {
|
||||
final error = _controller.error;
|
||||
return error == null || needsHarnessSetup(error) ? null : error;
|
||||
}
|
||||
|
||||
/// Starts the same machine picker and create dialog used by the list action.
|
||||
Future<void> newChat() => _newChat();
|
||||
|
||||
@@ -316,20 +340,20 @@ class ChatSessionsScreenState extends State<ChatSessionsScreen> {
|
||||
children: [
|
||||
// A notice above the list starts below the floating bar; the list
|
||||
// under it then needs no inset of its own.
|
||||
if (_controller.error != null)
|
||||
if (_listError != null)
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: MediaQuery.paddingOf(context).top,
|
||||
),
|
||||
child: ChatErrorNotice(
|
||||
message: _controller.error!,
|
||||
message: _listError!,
|
||||
onRetry: _controller.refresh,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: MediaQuery.removePadding(
|
||||
context: context,
|
||||
removeTop: _controller.error != null,
|
||||
removeTop: _listError != null,
|
||||
child: Stack(
|
||||
children: [
|
||||
ContentWidth(
|
||||
@@ -340,6 +364,8 @@ class ChatSessionsScreenState extends State<ChatSessionsScreen> {
|
||||
query: _search.text,
|
||||
loading: _controller.loading,
|
||||
error: _controller.error,
|
||||
onNewChat: _newChat,
|
||||
onRefresh: _controller.refresh,
|
||||
onOpen: _open,
|
||||
onOpenBeside: widget.onOpenBeside == null
|
||||
? null
|
||||
|
||||
@@ -157,8 +157,11 @@ PipelineEmptyState? pipelineListEmptyState(
|
||||
if (items.isNotEmpty) return null;
|
||||
if (all.isEmpty) {
|
||||
return const PipelineEmptyState(
|
||||
'No pipelines yet.',
|
||||
detail: 'Create one from a template in Templates.',
|
||||
'No pipelines yet',
|
||||
detail:
|
||||
'A pipeline is a workflow you define once and run on many tasks. '
|
||||
'Start from a template, or create one with `pipelines new` on the '
|
||||
'server.',
|
||||
);
|
||||
}
|
||||
final name = filters.name;
|
||||
|
||||
@@ -40,6 +40,7 @@ class PipelinesScreen extends StatefulWidget {
|
||||
this.onViewPipelineRuns,
|
||||
this.onSelectionChanged,
|
||||
this.onOpenSchedules,
|
||||
this.onOpenTemplates,
|
||||
this.onOpenSettings,
|
||||
this.initialPipelineId,
|
||||
this.initialVersion = 0,
|
||||
@@ -77,6 +78,9 @@ class PipelinesScreen extends StatefulWidget {
|
||||
/// Opens every schedule; shown in the bar while the list is visible.
|
||||
final VoidCallback? onOpenSchedules;
|
||||
|
||||
/// Opens the Templates gallery from the empty list.
|
||||
final VoidCallback? onOpenTemplates;
|
||||
|
||||
/// Opens Settings as a page; a gear in the bar while the list is visible.
|
||||
final VoidCallback? onOpenSettings;
|
||||
|
||||
@@ -278,6 +282,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
||||
controller: _controller,
|
||||
onOpenInChat: widget.onOpenPipelineInChat,
|
||||
onRun: _runFromList,
|
||||
onOpenTemplates: widget.onOpenTemplates,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -287,6 +292,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
||||
controller: _controller,
|
||||
onOpenInChat: widget.onOpenPipelineInChat,
|
||||
onRun: _runFromList,
|
||||
onOpenTemplates: widget.onOpenTemplates,
|
||||
),
|
||||
),
|
||||
detailIdentity: _controller.selectedId,
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
|
||||
import '../../../shell/shell_list_shortcuts.dart';
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import '../../../ui/adaptive/segmented_bar_overflow.dart';
|
||||
import '../../../ui/status/empty_state.dart';
|
||||
import '../../../ui/status/run_status_icon.dart';
|
||||
import '../pipeline_format.dart';
|
||||
import '../pipeline_models.dart';
|
||||
@@ -22,14 +23,21 @@ import 'pipeline_row_actions.dart';
|
||||
const double kPipelineListInset = 12;
|
||||
|
||||
/// The left/top pane: filter and sort controls, then the truthful list states.
|
||||
/// The state a server without any pipeline shows.
|
||||
const pipelinesEmptyKey = ValueKey<String>('pipelines-empty');
|
||||
|
||||
class PipelineListPanel extends StatelessWidget {
|
||||
const PipelineListPanel({
|
||||
super.key,
|
||||
required this.controller,
|
||||
this.onOpenInChat,
|
||||
this.onRun,
|
||||
this.onOpenTemplates,
|
||||
});
|
||||
|
||||
/// Opens the Templates gallery; an empty server offers it as the next step.
|
||||
final VoidCallback? onOpenTemplates;
|
||||
|
||||
final PipelinesController controller;
|
||||
final Future<void> Function(BuildContext, PipelineSummary, PipelineRun?)?
|
||||
onOpenInChat;
|
||||
@@ -194,34 +202,31 @@ class PipelineListPanel extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _empty(BuildContext context, PipelineEmptyState empty) {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
empty.message,
|
||||
textAlign: TextAlign.center,
|
||||
style: _mutedStyle(context),
|
||||
// A filter that hides every row is not an empty server: name it and
|
||||
// offer the way back.
|
||||
if (empty.clearAction case final clear?) {
|
||||
return EmptyState(
|
||||
dense: true,
|
||||
icon: Icons.filter_alt_off_outlined,
|
||||
title: empty.message,
|
||||
message: empty.detail,
|
||||
action: emptyStateAction(clear, controller.clearFilters),
|
||||
);
|
||||
}
|
||||
final templates = onOpenTemplates;
|
||||
return EmptyState(
|
||||
key: pipelinesEmptyKey,
|
||||
dense: true,
|
||||
icon: Icons.account_tree_outlined,
|
||||
title: empty.message,
|
||||
message: empty.detail,
|
||||
action: templates == null
|
||||
? null
|
||||
: emptyStateAction(
|
||||
'Browse templates',
|
||||
templates,
|
||||
icon: Icons.library_add_outlined,
|
||||
),
|
||||
if (empty.detail != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: Text(
|
||||
empty.detail!,
|
||||
textAlign: TextAlign.center,
|
||||
style: _mutedStyle(context),
|
||||
),
|
||||
),
|
||||
if (empty.clearAction != null)
|
||||
PipelineTextButton(
|
||||
label: empty.clearAction!,
|
||||
onPressed: controller.clearFilters,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -339,13 +344,6 @@ class PipelineListPanel extends StatelessWidget {
|
||||
].join(' · ');
|
||||
}
|
||||
|
||||
TextStyle? _mutedStyle(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return theme.textTheme.bodySmall?.copyWith(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
);
|
||||
}
|
||||
|
||||
/// The pipeline's initial on a tint picked from its id, so neighbouring
|
||||
/// pipelines are told apart at a glance.
|
||||
Widget _pipelineIdentityIcon(BuildContext context, PipelineSummary pipeline) {
|
||||
|
||||
@@ -377,6 +377,7 @@ class _RunsScreenState extends State<RunsScreen> {
|
||||
attention: widget.attention,
|
||||
onOpenInChat: widget.onOpenInChat,
|
||||
onRunAgain: _runAgain,
|
||||
onNewRun: _startNewRun,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../core/error_advice.dart';
|
||||
import '../domain/run_outcome_line.dart';
|
||||
import '../../../ui/theme/app_design_tokens.dart';
|
||||
|
||||
/// The setup step a run that failed for want of an agent harness shows.
|
||||
const runFailureHarnessHintKey = ValueKey<String>('run-failure-harness-hint');
|
||||
|
||||
/// The run Summary's prominent "Why it failed" note: a failed run's recorded
|
||||
/// failure reason (else its diagnostic), selectable, at the top of the
|
||||
/// Summary so the reason is read before the facts. Nothing for other runs.
|
||||
@@ -61,6 +65,19 @@ class RunFailureBanner extends StatelessWidget {
|
||||
color: scheme.onErrorContainer,
|
||||
),
|
||||
),
|
||||
// A server without an agent harness is a setup step:
|
||||
// say which, beside the raw reason.
|
||||
if (needsHarnessSetup(outcome.full)) ...[
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
errorAdviceSentence(ErrorAdviceKind.noHarness),
|
||||
key: runFailureHarnessHintKey,
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
color: scheme.onErrorContainer,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
if (actions case final actions?) ...[
|
||||
const SizedBox(height: 8),
|
||||
actions,
|
||||
|
||||
@@ -18,10 +18,14 @@ import 'runs_filter_options.dart';
|
||||
import 'runs_selection_bar.dart';
|
||||
import 'runs_stats_page.dart';
|
||||
import 'runs_filters.dart';
|
||||
import '../../../ui/status/empty_state.dart';
|
||||
import '../../../ui/status/error_notice.dart';
|
||||
|
||||
export 'run_list_row.dart';
|
||||
|
||||
/// The state a server with no runs at all shows.
|
||||
const runsEmptyKey = ValueKey<String>('runs-empty');
|
||||
|
||||
class RunsList extends StatelessWidget {
|
||||
const RunsList({
|
||||
super.key,
|
||||
@@ -35,8 +39,12 @@ class RunsList extends StatelessWidget {
|
||||
this.active = true,
|
||||
this.onOpenInChat,
|
||||
this.onRunAgain,
|
||||
this.onNewRun,
|
||||
});
|
||||
|
||||
/// Starts a new run; the empty list offers it as its next step.
|
||||
final VoidCallback? onNewRun;
|
||||
|
||||
/// False while a run detail covers the list; the bar is then the run's.
|
||||
final bool active;
|
||||
final Future<void> Function(BuildContext, JsonMap)? onOpenInChat;
|
||||
@@ -184,12 +192,21 @@ class RunsList extends StatelessWidget {
|
||||
...header,
|
||||
Expanded(
|
||||
child: noRunsAtAll
|
||||
? _state(
|
||||
context,
|
||||
icon: const Icon(Icons.inbox_outlined),
|
||||
title: 'No runs yet.',
|
||||
subtitle:
|
||||
'Start one from Pipelines and its runs appear here.',
|
||||
? EmptyState(
|
||||
key: runsEmptyKey,
|
||||
dense: true,
|
||||
icon: Icons.play_circle_outline,
|
||||
title: 'No runs yet',
|
||||
message:
|
||||
'A run is a pipeline working on one task. Start one '
|
||||
'and follow its progress and results here.',
|
||||
action: onNewRun == null
|
||||
? null
|
||||
: emptyStateAction(
|
||||
'Start your first run',
|
||||
onNewRun!,
|
||||
icon: Icons.add,
|
||||
),
|
||||
)
|
||||
: _state(
|
||||
context,
|
||||
|
||||
@@ -7,9 +7,13 @@ import '../../domain/saved_schedule.dart';
|
||||
import 'schedule_list_controller.dart';
|
||||
import 'schedule_list_row.dart';
|
||||
import 'schedule_list_toolbar.dart';
|
||||
import '../../../../ui/status/empty_state.dart';
|
||||
import '../../../../ui/status/error_notice.dart';
|
||||
|
||||
const scheduleListKey = ValueKey<String>('schedule-list');
|
||||
|
||||
/// The state a server without any saved schedule shows.
|
||||
const schedulesEmptyKey = ValueKey<String>('schedules-empty');
|
||||
const scheduleRetryKey = ValueKey<String>('schedule-retry');
|
||||
const scheduleToolbarKey = ValueKey<String>('schedule-toolbar');
|
||||
|
||||
@@ -75,9 +79,13 @@ class SchedulesListView extends StatelessWidget {
|
||||
}
|
||||
if (controller.schedules.isEmpty) {
|
||||
return BelowTopBar(
|
||||
child: _emptyState(
|
||||
'No schedules yet.',
|
||||
detail: 'Saved run configurations, not pipeline definitions.',
|
||||
child: const EmptyState(
|
||||
key: schedulesEmptyKey,
|
||||
icon: Icons.event_repeat_outlined,
|
||||
title: 'No schedules yet',
|
||||
message:
|
||||
'A schedule runs a pipeline for you on a timetable. Open a '
|
||||
"pipeline's Run form and choose Schedule… to add one.",
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -140,29 +148,8 @@ class SchedulesListView extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _emptyState(String message, {String? detail}) {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(message, textAlign: TextAlign.center),
|
||||
if (detail != null)
|
||||
Builder(
|
||||
builder: (context) => Text(
|
||||
detail,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
Widget _emptyState(String message) =>
|
||||
EmptyState(icon: Icons.search_off_outlined, title: message, dense: true);
|
||||
|
||||
Widget _failureState(BuildContext context, ScheduleListFailure failure) {
|
||||
return Center(
|
||||
|
||||
@@ -52,9 +52,15 @@ class TemplatesScreen extends StatefulWidget {
|
||||
this.embedded = false,
|
||||
this.onCreated,
|
||||
this.initialKey,
|
||||
this.reloadToken = 0,
|
||||
});
|
||||
|
||||
final ApiGateway gateway;
|
||||
|
||||
/// Advances when the shared connection is (re)established. A gallery that
|
||||
/// could not be read (opened before the app had connected, or while it was
|
||||
/// offline) reads again then, instead of keeping the failure until Retry.
|
||||
final int reloadToken;
|
||||
final bool embedded;
|
||||
final ValueChanged<JsonMap>? onCreated;
|
||||
|
||||
@@ -88,7 +94,13 @@ class _TemplatesScreenState extends State<TemplatesScreen> {
|
||||
if (oldWidget.initialKey != widget.initialKey) {
|
||||
_selectedKey = widget.initialKey;
|
||||
}
|
||||
if (oldWidget.gateway == widget.gateway) return;
|
||||
if (oldWidget.gateway == widget.gateway) {
|
||||
if (oldWidget.reloadToken != widget.reloadToken &&
|
||||
(_error != null || !_loaded)) {
|
||||
unawaited(_load());
|
||||
}
|
||||
return;
|
||||
}
|
||||
// A different gateway is a different server: never keep this one's rows or
|
||||
// selection while the replacement is read.
|
||||
_repository = TemplateRepository(widget.gateway);
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:async';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../../core/api_gateway.dart';
|
||||
import '../../core/error_advice.dart';
|
||||
import 'first_run_walkthrough.dart';
|
||||
import 'walkthrough_store.dart';
|
||||
|
||||
@@ -11,19 +12,31 @@ import 'walkthrough_store.dart';
|
||||
/// triggers the walkthrough.
|
||||
Future<bool?> serverHasNoWorkYet(ApiGateway? gateway) async {
|
||||
if (gateway == null) return null;
|
||||
// A server leaves an empty list out of its reply.
|
||||
Future<List<Object?>?> list(String type, String key, [JsonMap? fields]) =>
|
||||
gateway.call(type, fields ?? const {}).then((reply) {
|
||||
final value = reply[key] ?? const <Object?>[];
|
||||
return value is List ? List<Object?>.from(value) : null;
|
||||
});
|
||||
Future<List<Object?>?> chats() async {
|
||||
try {
|
||||
return await list('chat_sessions', 'chat_sessions');
|
||||
} catch (error) {
|
||||
// A server without a chat harness has no chats yet; that is the newest
|
||||
// server of all, not an unreadable one.
|
||||
if (needsHarnessSetup(error)) return const <Object?>[];
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
final replies = await Future.wait(<Future<JsonMap>>[
|
||||
gateway.call('list_pipelines', {'include_archived': true}),
|
||||
gateway.call('list_runs'),
|
||||
gateway.call('chat_sessions'),
|
||||
final lists = await Future.wait(<Future<List<Object?>?>>[
|
||||
list('list_pipelines', 'pipelines', {'include_archived': true}),
|
||||
list('list_runs', 'runs'),
|
||||
chats(),
|
||||
]);
|
||||
final lists = <Object?>[
|
||||
replies[0]['pipelines'],
|
||||
replies[1]['runs'],
|
||||
replies[2]['chat_sessions'],
|
||||
];
|
||||
if (lists.any((list) => list is! List)) return null;
|
||||
return lists.every((list) => (list as List).isEmpty);
|
||||
if (lists.any((list) => list == null)) return null;
|
||||
return lists.every((list) => list!.isEmpty);
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
@@ -55,8 +68,13 @@ class FirstRunWalkthroughGate extends StatefulWidget {
|
||||
required this.connected,
|
||||
this.gateway,
|
||||
this.onOpenConnection,
|
||||
this.connectWait = const Duration(seconds: 3),
|
||||
});
|
||||
|
||||
/// How long the first offer waits for a connection before it shows the
|
||||
/// walkthrough with its connect page.
|
||||
final Duration connectWait;
|
||||
|
||||
/// Opens Settings' Connection from the walkthrough's connect page.
|
||||
final VoidCallback? onOpenConnection;
|
||||
|
||||
@@ -115,6 +133,7 @@ class _FirstRunWalkthroughGateState extends State<FirstRunWalkthroughGate> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_endConnectionWait();
|
||||
widget.connection.removeListener(_onConnectionChanged);
|
||||
super.dispose();
|
||||
}
|
||||
@@ -170,6 +189,10 @@ class _FirstRunWalkthroughGateState extends State<FirstRunWalkthroughGate> {
|
||||
if (!_active) return;
|
||||
if (!seen) {
|
||||
_decided = true;
|
||||
// The app usually connects within a moment of its first frame (always
|
||||
// on the web, which is served by the server). Wait briefly so a
|
||||
// connected app is not told to connect.
|
||||
if (!widget.connected()) await _connection(widget.connectWait);
|
||||
await _showIfActive();
|
||||
return;
|
||||
}
|
||||
@@ -190,6 +213,31 @@ class _FirstRunWalkthroughGateState extends State<FirstRunWalkthroughGate> {
|
||||
await _showIfActive();
|
||||
}
|
||||
|
||||
/// The first offer's wait for a connection; ended early by [dispose].
|
||||
Timer? _connectTimer;
|
||||
Completer<void>? _connectWaiting;
|
||||
|
||||
/// Completes when the session connects or after [limit], whichever is
|
||||
/// first, or as soon as the gate is disposed.
|
||||
Future<void> _connection(Duration limit) {
|
||||
final done = _connectWaiting = Completer<void>();
|
||||
void check() {
|
||||
if (widget.connected()) _endConnectionWait();
|
||||
}
|
||||
|
||||
final listenable = widget.connection..addListener(check);
|
||||
_connectTimer = Timer(limit, _endConnectionWait);
|
||||
return done.future.whenComplete(() => listenable.removeListener(check));
|
||||
}
|
||||
|
||||
void _endConnectionWait() {
|
||||
_connectTimer?.cancel();
|
||||
_connectTimer = null;
|
||||
final waiting = _connectWaiting;
|
||||
_connectWaiting = null;
|
||||
if (waiting != null && !waiting.isCompleted) waiting.complete();
|
||||
}
|
||||
|
||||
Future<void> _showIfActive() async {
|
||||
if (!_active) return;
|
||||
await _show();
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../theme/app_design_tokens.dart';
|
||||
|
||||
/// One button of an [EmptyState]: a label, an optional icon and its action.
|
||||
typedef EmptyStateAction = ({
|
||||
String label,
|
||||
IconData? icon,
|
||||
VoidCallback onPressed,
|
||||
});
|
||||
|
||||
/// Builds an [EmptyStateAction]; a named constructor reads better at call
|
||||
/// sites than a record literal.
|
||||
EmptyStateAction emptyStateAction(
|
||||
String label,
|
||||
VoidCallback onPressed, {
|
||||
IconData? icon,
|
||||
}) => (label: label, icon: icon, onPressed: onPressed);
|
||||
|
||||
/// What a list shows when it has nothing yet: never an error, always a next
|
||||
/// step. One look on every screen: a large icon on a tonal disc, a short
|
||||
/// title, one muted line of explanation and up to two actions (the primary
|
||||
/// one filled). [child] adds content under the message, such as a command to
|
||||
/// copy. The whole state scrolls in a short pane instead of overflowing.
|
||||
///
|
||||
/// Shapes follow the active design: the disc takes the design's corner
|
||||
/// radius (square under Terminal, round under Classic and Paper).
|
||||
class EmptyState extends StatelessWidget {
|
||||
const EmptyState({
|
||||
super.key,
|
||||
required this.icon,
|
||||
required this.title,
|
||||
this.message,
|
||||
this.action,
|
||||
this.secondaryAction,
|
||||
this.child,
|
||||
this.dense = false,
|
||||
});
|
||||
|
||||
final IconData icon;
|
||||
final String title;
|
||||
final String? message;
|
||||
final EmptyStateAction? action;
|
||||
final EmptyStateAction? secondaryAction;
|
||||
final Widget? child;
|
||||
|
||||
/// A smaller icon and tighter spacing, for narrow list panes.
|
||||
final bool dense;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final scheme = theme.colorScheme;
|
||||
final tokens = AppDesignTokens.of(context);
|
||||
final disc = dense ? 56.0 : 72.0;
|
||||
final primary = action;
|
||||
final secondary = secondaryAction;
|
||||
return Center(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 420),
|
||||
child: Semantics(
|
||||
container: true,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: scheme.secondaryContainer,
|
||||
borderRadius: tokens.corners(
|
||||
BorderRadius.circular(disc / 2),
|
||||
),
|
||||
),
|
||||
child: SizedBox.square(
|
||||
dimension: disc,
|
||||
child: Icon(
|
||||
icon,
|
||||
size: disc / 2,
|
||||
color: scheme.onSecondaryContainer,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: dense ? 12 : 16),
|
||||
Text(
|
||||
title,
|
||||
textAlign: TextAlign.center,
|
||||
style: theme.textTheme.titleMedium,
|
||||
),
|
||||
if (message case final message?) ...[
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
message,
|
||||
textAlign: TextAlign.center,
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
if (child case final child?) ...[
|
||||
const SizedBox(height: 16),
|
||||
child,
|
||||
],
|
||||
if (primary != null || secondary != null) ...[
|
||||
SizedBox(height: dense ? 16 : 20),
|
||||
Wrap(
|
||||
alignment: WrapAlignment.center,
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: [
|
||||
if (primary != null)
|
||||
primary.icon == null
|
||||
? FilledButton(
|
||||
onPressed: primary.onPressed,
|
||||
child: Text(primary.label),
|
||||
)
|
||||
: FilledButton.icon(
|
||||
onPressed: primary.onPressed,
|
||||
icon: Icon(primary.icon),
|
||||
label: Text(primary.label),
|
||||
),
|
||||
if (secondary != null)
|
||||
secondary.icon == null
|
||||
? TextButton(
|
||||
onPressed: secondary.onPressed,
|
||||
child: Text(secondary.label),
|
||||
)
|
||||
: TextButton.icon(
|
||||
onPressed: secondary.onPressed,
|
||||
icon: Icon(secondary.icon),
|
||||
label: Text(secondary.label),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user