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 {
|
||||
|
||||
Reference in New Issue
Block a user