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:
2026-12-03 23:29:23 +00:00
parent 9436067bf2
commit e72bee3faa
30 changed files with 696 additions and 111 deletions
@@ -3,6 +3,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/core/transport/connection_state.dart';
import 'package:pipelines_app/features/templates/screen.dart';
import 'package:pipelines_app/features/templates/ui/template_detail.dart';
import 'package:pipelines_app/features/templates/ui/template_gallery.dart'
@@ -122,6 +123,29 @@ void main() {
expect(find.text('Release workflow'), findsOneWidget);
});
testWidgets('a gallery opened before the connection reads again on connect', (
tester,
) async {
var connected = false;
final gateway = GalleryGateway((type, fields) async {
if (!connected) throw const NotConnectedError();
if (type == 'list_templates') return templatesReply(galleryTemplates);
throw StateError('unexpected $type');
});
Widget screen(int token) => MaterialApp(
home: TemplatesScreen(gateway: gateway, reloadToken: token),
);
await tester.pumpWidget(screen(0));
await tester.pumpAndSettle();
expect(find.byKey(templatesErrorKey), findsOneWidget);
connected = true;
await tester.pumpWidget(screen(1));
await tester.pumpAndSettle();
expect(find.byKey(templatesErrorKey), findsNothing);
expect(find.text('Release workflow'), findsOneWidget);
});
testWidgets('refresh re-reads the catalogue and keeps the selection', (
tester,
) async {