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:
@@ -5,6 +5,7 @@ import 'package:pipelines_app/core/servers/chat/chat_identity.dart';
|
||||
import 'package:pipelines_app/core/servers/chat/chat_server_gateway.dart';
|
||||
import 'package:pipelines_app/core/servers/chat/federated_chat_gateway.dart';
|
||||
import 'package:pipelines_app/core/servers/server_catalog.dart';
|
||||
import 'package:pipelines_app/core/transport/connection_state.dart';
|
||||
import 'package:pipelines_app/core/transport/server_url.dart';
|
||||
import 'package:pipelines_app/features/chat/files/files_urls.dart';
|
||||
|
||||
@@ -12,6 +13,8 @@ class Machine implements ApiGateway {
|
||||
final events = StreamController<JsonMap>.broadcast();
|
||||
final calls = <(String, JsonMap)>[];
|
||||
bool fail = false;
|
||||
Object? failure;
|
||||
JsonMap? sessionsReply;
|
||||
Completer<JsonMap>? pendingSessions;
|
||||
@override
|
||||
Stream<JsonMap> get frames => events.stream;
|
||||
@@ -19,6 +22,8 @@ class Machine implements ApiGateway {
|
||||
Future<JsonMap> call(String type, [JsonMap fields = const {}]) async {
|
||||
calls.add((type, fields));
|
||||
if (fail) throw StateError('offline');
|
||||
if (failure case final failure?) throw failure;
|
||||
if (type == 'chat_sessions' && sessionsReply != null) return sessionsReply!;
|
||||
if (type == 'chat_sessions') {
|
||||
if (pendingSessions != null) return pendingSessions!.future;
|
||||
return {
|
||||
@@ -57,6 +62,40 @@ SavedServer server(String id) => SavedServer.validated(
|
||||
endpoints: ['ws://$id.test/connect'],
|
||||
);
|
||||
void main() {
|
||||
group('a server with no chats or no chat harness', () {
|
||||
FederatedChatGateway federated(Machine machine) {
|
||||
final sources = {'a': ChatServerGateway(server('a'), machine)};
|
||||
return FederatedChatGateway(
|
||||
() => sources,
|
||||
() => 'a',
|
||||
const Stream.empty(),
|
||||
);
|
||||
}
|
||||
|
||||
test('an omitted empty list reads as no chats, not a failure', () async {
|
||||
final machine = Machine()..sessionsReply = {'type': 'chat_sessions'};
|
||||
final reply = await federated(machine).call('chat_sessions');
|
||||
expect(reply['chat_sessions'], isEmpty);
|
||||
});
|
||||
|
||||
test('the server\'s own refusal is kept when no machine answers', () {
|
||||
final machine = Machine()
|
||||
..failure = const ProtocolError(
|
||||
'chat is not configured on this server',
|
||||
);
|
||||
expect(
|
||||
federated(machine).call('chat_sessions'),
|
||||
throwsA(
|
||||
isA<ProtocolError>().having(
|
||||
(error) => error.message,
|
||||
'message',
|
||||
'chat is not configured on this server',
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test(
|
||||
'colliding native IDs remain distinct, mutations and replies stay on source',
|
||||
() async {
|
||||
|
||||
@@ -17,7 +17,7 @@ void main() {
|
||||
|
||||
expect(find.byType(Scaffold), findsWidgets);
|
||||
|
||||
const message = 'No chats yet. Use New chat to start one.';
|
||||
const message = 'No chats yet';
|
||||
expect(find.text(message), findsOneWidget);
|
||||
expectNormalTextStyle(tester, message);
|
||||
});
|
||||
@@ -39,7 +39,7 @@ void main() {
|
||||
'for this operator';
|
||||
expect(find.text(message), findsOneWidget);
|
||||
expectNormalTextStyle(tester, message);
|
||||
expect(find.text('No chats yet. Use New chat to start one.'), findsNothing);
|
||||
expect(find.text('No chats yet'), findsNothing);
|
||||
expect(
|
||||
find.ancestor(
|
||||
of: find.text('Retry'),
|
||||
|
||||
@@ -3,6 +3,8 @@ 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/chat/ui/sessions/chat_harness_setup_state.dart';
|
||||
|
||||
import 'chat_test_harness.dart';
|
||||
import 'fake_chat_gateway.dart';
|
||||
@@ -91,13 +93,29 @@ void main() {
|
||||
) async {
|
||||
final gateway = FakeChatGateway();
|
||||
await pumpMaterialChat(tester, gateway);
|
||||
expect(
|
||||
find.text('No chats yet. Use New chat to start one.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('No chats yet'), findsOneWidget);
|
||||
expect(find.text('Start a chat'), findsOneWidget);
|
||||
expect(find.textContaining('No chats match'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('a server without a chat harness shows the setup step', (
|
||||
tester,
|
||||
) async {
|
||||
usePhoneSurface(tester);
|
||||
final gateway = FakeChatGateway()
|
||||
..sessionsHandler = () => Future.error(
|
||||
const ProtocolError('chat is not configured on this server'),
|
||||
);
|
||||
await pumpMaterialChat(tester, gateway);
|
||||
|
||||
expect(find.byKey(chatHarnessSetupKey), findsOneWidget);
|
||||
expect(find.text('pipelines harness setup claude'), findsOneWidget);
|
||||
// Not a failure: no error notice, no raw server text.
|
||||
expect(find.textContaining('not configured'), findsNothing);
|
||||
expect(find.text('No chats yet'), findsNothing);
|
||||
expect(find.text('Refresh'), findsWidgets);
|
||||
});
|
||||
|
||||
testWidgets('load failure wraps the reason and hides the empty message', (
|
||||
tester,
|
||||
) async {
|
||||
@@ -114,7 +132,7 @@ void main() {
|
||||
'Bad state: server unavailable while listing chat sessions '
|
||||
'for this operator';
|
||||
expect(find.text(message), findsOneWidget);
|
||||
expect(find.text('No chats yet. Use New chat to start one.'), findsNothing);
|
||||
expect(find.text('No chats yet'), findsNothing);
|
||||
final messageBox = tester.renderObject<RenderBox>(find.text(message));
|
||||
expect(
|
||||
messageBox.size.height,
|
||||
|
||||
@@ -132,7 +132,7 @@ void main() {
|
||||
const [],
|
||||
const PipelineFilters(),
|
||||
)?.message,
|
||||
'No pipelines yet.',
|
||||
'No pipelines yet',
|
||||
);
|
||||
expect(pipelineListEmptyState(all, all, const PipelineFilters()), isNull);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:pipelines_app/features/pipelines/screen.dart';
|
||||
import 'package:pipelines_app/features/pipelines/widgets/pipeline_list_panel.dart';
|
||||
|
||||
import 'fixtures.dart';
|
||||
import 'test_helpers.dart';
|
||||
|
||||
@@ -20,11 +23,8 @@ void main() {
|
||||
(tester) async {
|
||||
await pumpWide(tester, emptyServerGateway());
|
||||
|
||||
expect(find.text('No pipelines yet.'), findsOneWidget);
|
||||
expect(
|
||||
find.text('Create one from a template in Templates.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('No pipelines yet'), findsOneWidget);
|
||||
expect(find.textContaining('Start from a template'), findsOneWidget);
|
||||
expect(find.text('Loading pipelines…'), findsNothing);
|
||||
expect(find.byKey(const Key('pipeline-list')), findsNothing);
|
||||
expect(find.textContaining('not defined'), findsNothing);
|
||||
@@ -33,6 +33,28 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('the empty state opens Templates as its next step', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(1100, 900);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
var opened = 0;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: PipelinesScreen(
|
||||
gateway: emptyServerGateway(),
|
||||
onOpenTemplates: () => opened++,
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(pipelinesEmptyKey), findsOneWidget);
|
||||
await tester.tap(find.text('Browse templates'));
|
||||
expect(opened, 1);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'a failed list stays an error and never reads as an empty server',
|
||||
(tester) async {
|
||||
@@ -42,7 +64,7 @@ void main() {
|
||||
);
|
||||
|
||||
expect(find.textContaining('server offline'), findsOneWidget);
|
||||
expect(find.text('No pipelines yet.'), findsNothing);
|
||||
expect(find.text('No pipelines yet'), findsNothing);
|
||||
expect(find.text('Loading pipelines…'), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
|
||||
@@ -104,11 +104,8 @@ void main() {
|
||||
MaterialApp(home: PipelinesScreen(gateway: emptyGateway)),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('No pipelines yet.'), findsOneWidget);
|
||||
expect(
|
||||
find.text('Create one from a template in Templates.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('No pipelines yet'), findsOneWidget);
|
||||
expect(find.textContaining('Start from a template'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('a detail refusal keeps the selection and offers retry', (
|
||||
|
||||
@@ -146,4 +146,34 @@ void main() {
|
||||
);
|
||||
expect(find.text('Why it failed'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('a run that found no agent harness names the setup step', (
|
||||
tester,
|
||||
) async {
|
||||
const reason =
|
||||
'environment problem: model stage research: HARNESS TRANSPORT: '
|
||||
'harness unreachable: cannot run the selected OpenCode CLI: exec: '
|
||||
'"opencode": executable file not found in \$PATH';
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: RunFailureBanner(
|
||||
run: _run('failed', {'failure_reason': reason}),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(find.byKey(runFailureHarnessHintKey), findsOneWidget);
|
||||
expect(find.textContaining('pipelines harness setup'), findsOneWidget);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: RunFailureBanner(
|
||||
run: _run('failed', {'diagnostic': 'exit status 2'}),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(find.byKey(runFailureHarnessHintKey), findsNothing);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import 'package:pipelines_app/features/runs/ui/runs_controller.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/runs_filters.dart';
|
||||
import 'package:pipelines_app/ui/status/run_status_icon.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/runs_list.dart';
|
||||
import 'package:pipelines_app/ui/status/error_notice.dart';
|
||||
|
||||
class _Gateway implements ApiGateway {
|
||||
final framesController = StreamController<JsonMap>.broadcast();
|
||||
@@ -162,8 +163,10 @@ void main() {
|
||||
gateway.reply = {'runs': []};
|
||||
await controller.load();
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('No runs yet.'), findsOneWidget);
|
||||
expect(find.textContaining('Start one from Pipelines'), findsOneWidget);
|
||||
expect(find.text('No runs yet'), findsOneWidget);
|
||||
expect(find.textContaining('A run is a pipeline'), findsOneWidget);
|
||||
// No New run seam in this fixture: the state offers no dead button.
|
||||
expect(find.text('Start your first run'), findsNothing);
|
||||
expect(find.text('No runs found.'), findsNothing);
|
||||
expect(find.textContaining('offline'), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
@@ -173,7 +176,7 @@ void main() {
|
||||
controller.setStatus('failed');
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('No runs found.'), findsOneWidget);
|
||||
expect(find.text('No runs yet.'), findsNothing);
|
||||
expect(find.text('No runs yet'), findsNothing);
|
||||
expect(
|
||||
find.text('Try changing or clearing the filters.'),
|
||||
findsOneWidget,
|
||||
@@ -183,6 +186,32 @@ void main() {
|
||||
variant: TargetPlatformVariant.only(TargetPlatform.android),
|
||||
);
|
||||
|
||||
testWidgets('an empty server offers the first run as the next step', (
|
||||
tester,
|
||||
) async {
|
||||
gateway.failure = null;
|
||||
gateway.gate = null;
|
||||
gateway.reply = {'runs': []};
|
||||
await controller.load();
|
||||
var started = 0;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: RunsList(
|
||||
controller: controller,
|
||||
onSelected: (_) {},
|
||||
onNewRun: () => started++,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(runsEmptyKey), findsOneWidget);
|
||||
expect(find.byType(ErrorNotice), findsNothing);
|
||||
await tester.tap(find.text('Start your first run'));
|
||||
expect(started, 1);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'an empty server with a search query reads as no match, not no runs',
|
||||
(tester) async {
|
||||
@@ -200,7 +229,7 @@ void main() {
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('No runs found.'), findsOneWidget);
|
||||
expect(find.text('No runs yet.'), findsNothing);
|
||||
expect(find.text('No runs yet'), findsNothing);
|
||||
expect(
|
||||
find.text('Try changing or clearing the filters.'),
|
||||
findsOneWidget,
|
||||
|
||||
@@ -88,7 +88,7 @@ void main() {
|
||||
(type, fields) async => {'type': 'schedules'},
|
||||
);
|
||||
await pumpSchedules(tester, gateway: empty);
|
||||
expect(find.text('No schedules yet.'), findsOneWidget);
|
||||
expect(find.text('No schedules yet'), findsOneWidget);
|
||||
expect(find.byKey(scheduleRetryKey), findsNothing);
|
||||
|
||||
final unsupported = FakeSchedulesGateway(
|
||||
@@ -100,7 +100,7 @@ void main() {
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byKey(scheduleRetryKey), findsOneWidget);
|
||||
expect(find.text('No schedules yet.'), findsNothing);
|
||||
expect(find.text('No schedules yet'), findsNothing);
|
||||
|
||||
final failed = FakeSchedulesGateway(
|
||||
(type, fields) async => throw StateError('socket closed'),
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -108,6 +108,37 @@ Future<void> _finishWalkthrough(WidgetTester tester) async {
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'first launch waits briefly for the connection before welcoming',
|
||||
(tester) async {
|
||||
final store = MemoryWalkthroughStore();
|
||||
final link = ValueNotifier<bool>(false);
|
||||
await tester.pumpWidget(_host(store: store, link: link));
|
||||
await tester.pump();
|
||||
expect(find.text(_welcome), findsNothing);
|
||||
|
||||
// The app connects a moment later: the welcome is the connected one,
|
||||
// with no connect directions.
|
||||
link.value = true;
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(_welcome), findsOneWidget);
|
||||
expect(find.textContaining('start by connecting'), findsNothing);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'first launch without a connection still offers the connect page',
|
||||
(tester) async {
|
||||
final store = MemoryWalkthroughStore();
|
||||
final link = ValueNotifier<bool>(false);
|
||||
await tester.pumpWidget(_host(store: store, link: link));
|
||||
await tester.pump(const Duration(seconds: 3));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(_welcome), findsOneWidget);
|
||||
expect(find.textContaining('start by connecting'), findsOneWidget);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('first launch shows the walkthrough once per device', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
@@ -35,6 +35,23 @@ void main() {
|
||||
errorAdviceKind(TimeoutException('request timed out after 30000ms')),
|
||||
ErrorAdviceKind.timeout,
|
||||
);
|
||||
expect(
|
||||
errorAdviceKind(
|
||||
const ProtocolError('chat is not configured on this server'),
|
||||
),
|
||||
ErrorAdviceKind.noHarness,
|
||||
);
|
||||
expect(
|
||||
errorAdviceKind(
|
||||
'HARNESS TRANSPORT: harness unreachable: cannot run the selected '
|
||||
'OpenCode CLI',
|
||||
),
|
||||
ErrorAdviceKind.noHarness,
|
||||
);
|
||||
expect(
|
||||
errorAdviceSentence(ErrorAdviceKind.noHarness),
|
||||
contains('pipelines harness setup'),
|
||||
);
|
||||
expect(errorAdviceKind('pipeline 4 has no stage review'), isNull);
|
||||
final advice = errorAdvice(StateError('Connection closed'));
|
||||
expect(advice?.detail, 'Connection closed');
|
||||
|
||||
Reference in New Issue
Block a user