545291e04a
- Run rows show a failed run's reason (else its diagnostic's first line, full text in a tooltip) or a short result preview; the Summary leads with "Why it failed". - Run again for succeeded/canceled/interrupted runs opens the New run form pre-filled (prompt, workspace, report format) at the latest version with the original offered. - Run detail and stage tabs show their names; touch shows captions on the Runs header and artifact viewer actions (desktop keeps tooltips). - ErrorNotice maps not connected / server too old / permission / timeout to what to do, raw detail behind Details (Schedules, create chat, Runs, Pipelines banners). - Settings has no Back arrow; Schedules keeps the rail on wide windows; phone Settings leads with Connection and Notifications and has a Jump to topic menu. - Walkthrough: Open Connection (skipped when connected), labelled Copy. - Pluralised counts; no duplicate status/rail names for screen readers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
181 lines
5.9 KiB
Dart
181 lines
5.9 KiB
Dart
import '../ui/adaptive/segmented_bar.dart';
|
|
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../features/schedules/data/schedules_repository.dart';
|
|
import '../features/schedules/ui/list/schedule_list_controller.dart';
|
|
import '../features/schedules/ui/list/schedule_list_toolbar.dart'
|
|
show ScheduleRefreshAction;
|
|
import '../features/schedules/ui/list/schedule_list_view.dart';
|
|
import '../shell/destination.dart';
|
|
import '../shell/navigation_rail.dart';
|
|
import 'app_session.dart';
|
|
import 'server_endpoint.dart';
|
|
|
|
/// The Back control of the app-level Schedules page.
|
|
const schedulesPageBackKey = ValueKey<String>('schedules-page-back');
|
|
|
|
/// The saved-schedule list above Settings.
|
|
///
|
|
/// It is read-only: opening a row asks the composition to show the owning
|
|
/// pipeline's Summary, where the landed section owns create/edit/pause/delete.
|
|
/// The list never saves, pauses or deletes anything itself.
|
|
class SchedulesDestination extends StatefulWidget {
|
|
const SchedulesDestination({
|
|
super.key,
|
|
required this.session,
|
|
required this.server,
|
|
required this.onBack,
|
|
required this.onOpenPipeline,
|
|
this.onSelectDestination,
|
|
});
|
|
|
|
/// Selects a destination from the rail this page keeps on a wide window,
|
|
/// so Schedules does not hide the app's navigation. Null draws no rail.
|
|
final ValueChanged<AppDestination>? onSelectDestination;
|
|
|
|
final AppSession session;
|
|
final ServerEndpoint server;
|
|
final VoidCallback onBack;
|
|
final ValueChanged<int> onOpenPipeline;
|
|
|
|
@override
|
|
State<SchedulesDestination> createState() => _SchedulesDestinationState();
|
|
}
|
|
|
|
class _SchedulesDestinationState extends State<SchedulesDestination> {
|
|
late final SchedulesController _controller;
|
|
final TextEditingController _search = TextEditingController();
|
|
final ScrollController _scroll = ScrollController();
|
|
|
|
int _epoch = 0;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_controller = SchedulesController(
|
|
repository: SchedulesRepository(widget.session.gateway),
|
|
);
|
|
_epoch = widget.session.connectionEpoch;
|
|
widget.session.addListener(_sessionChanged);
|
|
unawaited(_controller.refresh());
|
|
}
|
|
|
|
/// A reconnect re-reads the list once. A read still in flight (the first
|
|
/// one, queued until the socket opened) already covers the new connection.
|
|
void _sessionChanged() {
|
|
final epoch = widget.session.connectionEpoch;
|
|
if (epoch == _epoch) return;
|
|
_epoch = epoch;
|
|
if (widget.session.connected && !_controller.isLoading) {
|
|
unawaited(_controller.refresh());
|
|
}
|
|
}
|
|
|
|
@override
|
|
void didUpdateWidget(SchedulesDestination oldWidget) {
|
|
super.didUpdateWidget(oldWidget);
|
|
if (oldWidget.session != widget.session) {
|
|
oldWidget.session.removeListener(_sessionChanged);
|
|
widget.session.addListener(_sessionChanged);
|
|
_epoch = widget.session.connectionEpoch;
|
|
}
|
|
if (oldWidget.session.gateway != widget.session.gateway) {
|
|
// A different server lists different schedules; re-read through the same
|
|
// controller so the screen is never shown with the old server's rows.
|
|
unawaited(_controller.refresh());
|
|
}
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
widget.session.removeListener(_sessionChanged);
|
|
_controller.dispose();
|
|
_search.dispose();
|
|
_scroll.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// The page is built inside the builder from the session's connection and
|
|
// the list controller's state; the list view itself does not listen, so a
|
|
// finished read would otherwise stay on `Loading schedules…`.
|
|
return AnimatedBuilder(
|
|
animation: Listenable.merge([widget.session, _controller]),
|
|
builder: (context, _) => _withRail(context, _page()),
|
|
);
|
|
}
|
|
|
|
/// On a window wide enough for the rail, the page keeps it at its leading
|
|
/// edge (Settings selected, since Schedules sits under it).
|
|
Widget _withRail(BuildContext context, Widget page) {
|
|
final select = widget.onSelectDestination;
|
|
if (select == null || !showsNavigationRail(context)) return page;
|
|
final padding = MediaQuery.paddingOf(context);
|
|
return Row(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
Material(
|
|
child: ShellNavigationRail(
|
|
selected: AppDestination.settings,
|
|
icon: (destination) => Icon(destinationDetails(destination).icon),
|
|
onSelected: select,
|
|
padding: EdgeInsets.only(top: padding.top, bottom: padding.bottom),
|
|
),
|
|
),
|
|
const VerticalDivider(width: 1, thickness: 1),
|
|
Expanded(
|
|
child: MediaQuery.removePadding(
|
|
context: context,
|
|
removeLeft: true,
|
|
child: page,
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _page() {
|
|
final body = _body();
|
|
// The round Back closes the page; Refresh sits in the actions pill.
|
|
final bar = SegmentedBar(
|
|
leading: SegmentedBackButton(
|
|
key: schedulesPageBackKey,
|
|
onPressed: widget.onBack,
|
|
),
|
|
title: 'Schedules',
|
|
actions: [
|
|
if (widget.session.everConnected)
|
|
ScheduleRefreshAction(
|
|
controller: _controller,
|
|
onRefresh: () => unawaited(_controller.refresh()),
|
|
),
|
|
],
|
|
);
|
|
// The page reaches its top edge: the search strip floats under the bar
|
|
// and the list scrolls behind both.
|
|
return Scaffold(extendBodyBehindAppBar: true, appBar: bar, body: body);
|
|
}
|
|
|
|
Widget _body() {
|
|
if (!widget.session.everConnected) {
|
|
return const Center(
|
|
child: Text('Connect to the server to see schedules.'),
|
|
);
|
|
}
|
|
return SchedulesListView(
|
|
controller: _controller,
|
|
searchController: _search,
|
|
scrollController: _scroll,
|
|
onOpen: (schedule) {
|
|
final id = schedule.pipelineId;
|
|
if (id != null) widget.onOpenPipeline(id);
|
|
},
|
|
onRefresh: () => _controller.refresh(),
|
|
refreshInToolbar: false,
|
|
);
|
|
}
|
|
}
|