Files
pipelines/app/lib/application/pipelines_destination.dart
T
alan e72bee3faa 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>
2026-12-03 23:29:23 +00:00

116 lines
4.1 KiB
Dart

import 'package:flutter/material.dart';
import '../features/pipelines/screen.dart';
import '../features/pipelines/pipeline_models.dart';
import '../ui/adaptive/top_bar_notices.dart';
import 'app_session.dart';
import 'connection_status.dart';
import 'pending_run_scope.dart';
import 'server_endpoint.dart';
/// The Pipelines destination: the read-only browser plus honest status.
///
/// Before the shared socket accepts its first connection nothing is requested,
/// so an offline launch cannot look like an empty pipeline list. After that the
/// browser stays mounted through drops; a reconnect advances [syncToken] so the
/// list and the open detail refresh in place instead of losing the selection.
class PipelinesDestination extends StatelessWidget {
const PipelinesDestination({
super.key,
required this.session,
required this.server,
this.refreshToken = 0,
this.active = true,
this.onRunStarted,
this.onViewPipelineRuns,
this.onOpenSchedules,
this.onOpenTemplates,
this.onOpenSettings,
this.onSelectionChanged,
this.initialPipelineId,
this.initialVersion = 0,
this.initialStageKey,
this.legacyPendingEndpoints = const [],
this.onOpenInChat,
this.onOpenPipelineInChat,
});
final AppSession session;
final ServerEndpoint server;
/// Requests a fresh list/detail read without remounting the screen or losing
/// the open pipeline. The shell advances it when a template create was
/// accepted; the rows still come only from the server's next reply.
final int refreshToken;
/// Keeps a pushed pipeline detail from covering another selected tab.
final bool active;
/// Receives the run id an accepted launch named; the shell opens that route.
final ValueChanged<int>? onRunStarted;
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;
/// The pipeline and pinned version a deep link names.
final int? initialPipelineId;
final int initialVersion;
/// The definition stage a deep link names, or null for no stage request.
final String? initialStageKey;
final List<String> legacyPendingEndpoints;
final Future<void> Function(BuildContext, PipelineDetail, PipelineRun?)?
onOpenInChat;
final Future<void> Function(BuildContext, PipelineSummary, PipelineRun?)?
onOpenPipelineInChat;
@override
Widget build(BuildContext context) => AnimatedBuilder(
animation: session,
builder: (context, _) {
if ((server.requiresConfiguration || server.error != null) &&
session.endpoint == null) {
return ConnectionGate(session: session, server: server);
}
if (!session.everConnected) {
if (session.connected) return _pipelinesScreen();
return ConnectionGate(session: session, server: server);
}
// The banner stays below the top bar; without it the pipelines reach
// the top edge and scroll behind the bar.
return TopBarNotices(
notices: [if (!session.connected) ConnectionBanner(session: session)],
child: _pipelinesScreen(),
);
},
);
Widget _pipelinesScreen() => PipelinesScreen(
gateway: session.gateway,
endpoint: pendingRunScope(session.gateway, server),
legacyEndpoints: legacyPendingEndpoints,
embedded: true,
active: active,
onRunStarted: onRunStarted,
onViewPipelineRuns: onViewPipelineRuns,
onOpenSchedules: onOpenSchedules,
onOpenTemplates: onOpenTemplates,
onOpenSettings: onOpenSettings,
onSelectionChanged: onSelectionChanged,
onOpenInChat: onOpenInChat,
onOpenPipelineInChat: onOpenPipelineInChat,
initialPipelineId: initialPipelineId,
initialVersion: initialVersion,
initialStageKey: initialStageKey,
// A reconnect or an accepted template create both advance this counter;
// either change re-reads through the mounted controller.
syncToken: session.connectionEpoch + refreshToken,
);
}