merge(app): land viewer icons, native file actions, full-screen details and stepwise Back

This commit is contained in:
2026-10-23 22:50:44 +01:00
21 changed files with 580 additions and 205 deletions
@@ -56,5 +56,14 @@
<action android:name="android.intent.action.PROCESS_TEXT"/>
<data android:mimeType="text/plain"/>
</intent>
<!-- Artifact links open in the browser. -->
<intent>
<action android:name="android.intent.action.VIEW"/>
<data android:scheme="https"/>
</intent>
<intent>
<action android:name="android.intent.action.VIEW"/>
<data android:scheme="http"/>
</intent>
</queries>
</manifest>
+20 -1
View File
@@ -213,8 +213,13 @@ class AppRouterDelegate extends RouterDelegate<AppRoute> with ChangeNotifier {
notifyListeners();
}
/// Back (Android's button, the browser's): close whatever page sits on top
/// first, then step up one level — a stage to its run or pipeline, a run,
/// pipeline or chat to its list — and only leave the app from a list.
@override
Future<bool> popRoute() async {
final navigator = _navigatorKey.currentState;
if (navigator != null && await navigator.maybePop()) return true;
if (searchOpen) {
closeSearch();
return true;
@@ -227,10 +232,24 @@ class AppRouterDelegate extends RouterDelegate<AppRoute> with ChangeNotifier {
closeTemplates();
return true;
}
if (_route.runId != null) {
final runId = _route.runId;
if (runId != null && _route.stageKey != null) {
goTo(AppRoute.run(runId));
return true;
}
if (runId != null) {
onPopToRuns();
return true;
}
final pipelineId = _route.pipelineId;
if (_route.kind == AppRouteKind.pipelines && pipelineId != null) {
goTo(
_route.stageKey != null
? AppRoute.pipeline(pipelineId, version: _route.version)
: AppRoute.pipelines,
);
return true;
}
if (_route.chatSessionId != null) {
onPopToChat();
return true;
+4
View File
@@ -410,6 +410,10 @@ class _PipelinesAppState extends State<PipelinesApp>
final chatRoute = tab(AppDestination.chat);
return AdaptiveShell(
attentionCount: attentionCount,
detailOpen:
route.runId != null ||
route.chatSessionId != null ||
(route.kind == AppRouteKind.pipelines && route.pipelineId != null),
cupertino: _cupertino,
destination: _destinationOf(route.kind),
onDestinationSelected: _selectDestination,
@@ -23,8 +23,12 @@ class ArtifactFileActions extends StatefulWidget {
required this.resolved,
this.fetch = fetchArtifact,
this.bridge = const ArtifactFileBridge(),
this.compact = false,
});
/// Icon buttons only (a viewer's bottom bar): no labels and no notices.
final bool compact;
final ArtifactRecord artifact;
final ResolvedArtifactUrl resolved;
final ArtifactFetch fetch;
@@ -74,10 +78,12 @@ class _ArtifactFileActionsState extends State<ArtifactFileActions> {
Widget build(BuildContext context) {
return ListenableBuilder(
listenable: _controller,
builder: (context, _) => _ActionBar(
controller: _controller,
cupertino: usesCupertinoHost(context),
),
builder: (context, _) => widget.compact
? _IconActions(controller: _controller)
: _ActionBar(
controller: _controller,
cupertino: usesCupertinoHost(context),
),
);
}
}
@@ -185,3 +191,85 @@ class _ActionBar extends StatelessWidget {
);
}
}
/// Download and Share as icon buttons; a spinner stands in for the one in
/// progress. A host that cannot download or share simply has no button.
class _IconActions extends StatelessWidget {
const _IconActions({required this.controller});
final ArtifactFileActionsController controller;
@override
Widget build(BuildContext context) {
final busy = controller.busy;
return Row(
mainAxisSize: MainAxisSize.min,
children: [
if (controller.canDownload)
ArtifactIconAction(
key: const Key('artifact-download'),
label: 'Download',
icon: Icons.download_outlined,
cupertinoIcon: CupertinoIcons.arrow_down_to_line,
busy: busy,
onPressed: busy ? null : controller.download,
),
if (controller.canShare)
ArtifactIconAction(
key: const Key('artifact-share'),
label: 'Share',
icon: Icons.share_outlined,
cupertinoIcon: CupertinoIcons.share,
onPressed: busy ? null : controller.share,
),
],
);
}
}
/// One icon-only viewer action with its name as tooltip and accessible label.
class ArtifactIconAction extends StatelessWidget {
const ArtifactIconAction({
super.key,
required this.label,
required this.icon,
required this.cupertinoIcon,
required this.onPressed,
this.busy = false,
});
final String label;
final IconData icon;
final IconData cupertinoIcon;
final VoidCallback? onPressed;
final bool busy;
@override
Widget build(BuildContext context) {
if (usesCupertinoHost(context)) {
return Semantics(
button: true,
label: label,
child: CupertinoButton(
padding: const EdgeInsets.all(8),
onPressed: onPressed,
child: busy
? const CupertinoActivityIndicator(radius: 9)
: Icon(cupertinoIcon),
),
);
}
return IconButton(
tooltip: label,
visualDensity: VisualDensity.compact,
onPressed: onPressed,
icon: busy
? const SizedBox(
width: 18,
height: 18,
child: CircularProgressIndicator(strokeWidth: 2),
)
: Icon(icon),
);
}
}
@@ -1,6 +1,7 @@
import 'artifact_file.dart';
import 'artifact_transfer_stub.dart'
if (dart.library.js_interop) 'artifact_transfer_web.dart'
if (dart.library.io) 'artifact_transfer_io.dart'
as impl;
/// The outcome of a host file transfer.
@@ -0,0 +1,56 @@
import 'package:file_picker/file_picker.dart';
import 'package:share_plus/share_plus.dart';
import 'artifact_file.dart';
import 'artifact_transfer.dart';
/// Phones and desktops: Download asks where to save the exact bytes (the
/// system "Save as"), Share hands the named file to the share sheet.
bool get artifactDownloadSupported => true;
bool get artifactShareSupported => true;
String get artifactDownloadUnsupportedMessage => '';
String get artifactShareUnsupportedMessage => '';
Future<ArtifactTransferResult> saveArtifactFile(ArtifactFile file) async {
try {
final saved = await FilePicker.saveFile(
fileName: file.name,
bytes: file.bytes,
mimeType: file.mimeType,
);
if (saved == null) {
return const ArtifactTransferResult(ArtifactTransferState.canceled, '');
}
return ArtifactTransferResult(
ArtifactTransferState.saved,
'Saved ${file.name}.',
);
} catch (error) {
return ArtifactTransferResult(
ArtifactTransferState.failed,
'Could not save ${file.name}: $error',
);
}
}
Future<ArtifactTransferResult> shareArtifactFile(ArtifactFile file) async {
try {
final result = await SharePlus.instance.share(
ShareParams(
files: [XFile.fromData(file.bytes, mimeType: file.mimeType)],
fileNameOverrides: [file.name],
),
);
return result.status == ShareResultStatus.dismissed
? const ArtifactTransferResult(ArtifactTransferState.canceled, '')
: const ArtifactTransferResult(ArtifactTransferState.shared, '');
} catch (error) {
return ArtifactTransferResult(
ArtifactTransferState.failed,
'Could not share ${file.name}: $error',
);
}
}
@@ -1,6 +1,7 @@
import '../domain/artifact_url.dart';
import 'artifact_external_open_stub.dart'
if (dart.library.js_interop) 'artifact_external_open_web.dart'
if (dart.library.io) 'artifact_external_open_io.dart'
as impl;
/// Opens an already validated artifact url with the host's external handler.
@@ -0,0 +1,11 @@
import 'package:url_launcher/url_launcher.dart';
/// Phones and desktops: the link opens in the system browser, which renders
/// what it can and offers to download the rest.
Future<bool> openArtifactExternally(Uri uri) async {
try {
return await launchUrl(uri, mode: LaunchMode.externalApplication);
} catch (_) {
return false;
}
}
@@ -62,27 +62,10 @@ class ArtifactViewerBody extends StatelessWidget {
@override
Widget build(BuildContext context) {
final resolved = plan.resolved;
final controls = <Widget>[
if (resolved != null && !resolved.external)
ArtifactFileActions(
key: ValueKey<String>(
'viewer-files-${page.group.stageKey}\u0000'
'${page.group.visit}\u0000${page.artifact.url}',
),
artifact: page.artifact,
resolved: resolved,
fetch: fetch,
bridge: fileBridge,
),
if (resolved != null)
_Actions(resolved: resolved, onOpen: onOpen, onCopy: onCopy),
];
final content = SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Room for the controls bar, so it never covers the first line.
if (controls.isNotEmpty) const SizedBox(height: 56),
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(16, 12, 16, 4),
child: ArtifactSelectionFacts(
@@ -102,11 +85,6 @@ class ArtifactViewerBody extends StatelessWidget {
),
),
),
if (status != null)
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(16, 0, 16, 4),
child: Semantics(liveRegion: true, child: Text(status!)),
),
ArtifactPreviewBody(
plan: plan,
loading: loading,
@@ -118,23 +96,60 @@ class ArtifactViewerBody extends StatelessWidget {
],
),
);
final hasPrevious = pagedIndex(index, -1, count) != index;
final hasNext = pagedIndex(index, 1, count) != index;
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
child: controls.isEmpty
? content
: ArtifactControlsOverlay(
key: ValueKey<String>('viewer-overlay-${page.artifact.url}'),
controls: controls,
child: content,
),
// A horizontal swipe moves to the previous or next artifact.
child: GestureDetector(
key: const Key('artifact-viewer-swipe'),
behavior: HitTestBehavior.translucent,
onHorizontalDragEnd: (details) {
final velocity = details.primaryVelocity ?? 0;
if (velocity < -250 && hasNext) onNext();
if (velocity > 250 && hasPrevious) onPrevious();
},
child: content,
),
),
_Pager(
index: index,
count: count,
onPrevious: onPrevious,
onNext: onNext,
// Every action as an icon at the bottom, beside the pager.
SafeArea(
top: false,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: Row(
key: const Key('artifact-viewer-actions'),
children: [
if (resolved != null && !resolved.external)
ArtifactFileActions(
key: ValueKey<String>(
'viewer-files-${page.group.stageKey}\u0000'
'${page.group.visit}\u0000${page.artifact.url}',
),
artifact: page.artifact,
resolved: resolved,
fetch: fetch,
bridge: fileBridge,
compact: true,
),
if (resolved != null)
_Actions(resolved: resolved, onOpen: onOpen, onCopy: onCopy),
Expanded(
child: Align(
alignment: AlignmentDirectional.centerEnd,
child: _Pager(
index: index,
count: count,
onPrevious: onPrevious,
onNext: onNext,
),
),
),
],
),
),
),
],
);
@@ -263,40 +278,25 @@ class _Actions extends StatelessWidget {
final VoidCallback onCopy;
@override
Widget build(BuildContext context) {
if (usesCupertinoHost(context)) {
return SafeArea(
top: false,
child: Wrap(
alignment: WrapAlignment.center,
spacing: 8,
children: [
CupertinoButton(onPressed: onOpen, child: const Text('Open')),
CupertinoButton(onPressed: onCopy, child: const Text('Copy link')),
],
),
);
}
return SafeArea(
top: false,
child: Wrap(
alignment: WrapAlignment.center,
spacing: 8,
children: [
TextButton.icon(
onPressed: onOpen,
icon: const Icon(Icons.open_in_new),
label: const Text('Open'),
),
TextButton.icon(
onPressed: onCopy,
icon: const Icon(Icons.content_copy),
label: const Text('Copy link'),
),
],
Widget build(BuildContext context) => Row(
mainAxisSize: MainAxisSize.min,
children: [
ArtifactIconAction(
key: const Key('artifact-open'),
label: 'Open',
icon: Icons.open_in_new,
cupertinoIcon: CupertinoIcons.arrow_up_right_square,
onPressed: onOpen,
),
);
}
ArtifactIconAction(
key: const Key('artifact-copy-link'),
label: 'Copy link',
icon: Icons.link,
cupertinoIcon: CupertinoIcons.link,
onPressed: onCopy,
),
],
);
}
const artifactPreviousKey = ValueKey<String>('artifact-previous');
@@ -320,18 +320,15 @@ class _Pager extends StatelessWidget {
if (count <= 1) return const SizedBox.shrink();
final hasPrevious = pagedIndex(index, -1, count) != index;
final hasNext = pagedIndex(index, 1, count) != index;
return SafeArea(
top: false,
child: ChevronPager(
index: index,
count: count,
previousLabel: 'Previous artifact',
nextLabel: 'Next artifact',
previousKey: artifactPreviousKey,
nextKey: artifactNextKey,
onPrevious: hasPrevious ? onPrevious : null,
onNext: hasNext ? onNext : null,
),
return ChevronPager(
index: index,
count: count,
previousLabel: 'Previous artifact',
nextLabel: 'Next artifact',
previousKey: artifactPreviousKey,
nextKey: artifactNextKey,
onPrevious: hasPrevious ? onPrevious : null,
onNext: hasNext ? onNext : null,
);
}
}
@@ -128,18 +128,19 @@ class RunVisitSectionStrip extends StatelessWidget {
}
/// The stage page's tabs: Summary (Input and Output), Artifacts, Changes and
/// More (Session and Definition). The finer sections stay addressable.
/// Session. The finer sections stay addressable.
const shownVisitSections = [
RunVisitSection.summary,
RunVisitSection.artifacts,
RunVisitSection.changes,
RunVisitSection.more,
RunVisitSection.session,
];
/// The tab that shows [section].
RunVisitSection visitTabFor(RunVisitSection section) => switch (section) {
RunVisitSection.input || RunVisitSection.output => RunVisitSection.summary,
RunVisitSection.session || RunVisitSection.definition => RunVisitSection.more,
// The stage's definition lives on the pipeline, not on a run's visit.
RunVisitSection.more || RunVisitSection.definition => RunVisitSection.session,
_ => section,
};
@@ -178,10 +179,7 @@ Widget runVisitSectionBody({
cupertino: cupertino,
);
case RunVisitSection.more:
return _MoreSection(
session: body(RunVisitSection.session),
definition: body(RunVisitSection.definition),
);
return body(RunVisitSection.session);
case RunVisitSection.input:
return runDetailFieldTab(
tabKey: 'visit-input',
@@ -230,57 +228,6 @@ Widget runVisitSectionBody({
}
}
/// Session and Definition behind one tab, with a small switch between them.
class _MoreSection extends StatefulWidget {
const _MoreSection({required this.session, required this.definition});
final Widget session;
final Widget definition;
@override
State<_MoreSection> createState() => _MoreSectionState();
}
class _MoreSectionState extends State<_MoreSection> {
var _definition = false;
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
final control = cupertino
? CupertinoSlidingSegmentedControl<bool>(
key: const Key('run-visit-more-switch'),
groupValue: _definition,
onValueChanged: (value) =>
setState(() => _definition = value ?? false),
children: const {false: Text('Session'), true: Text('Definition')},
)
: SegmentedButton<bool>(
key: const Key('run-visit-more-switch'),
showSelectedIcon: false,
segments: const [
ButtonSegment(value: false, label: Text('Session')),
ButtonSegment(value: true, label: Text('Definition')),
],
selected: {_definition},
onSelectionChanged: (value) =>
setState(() => _definition = value.single),
);
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
child: control,
),
Expanded(child: _definition ? widget.definition : widget.session),
],
);
}
}
/// The stage's Input and Output as sticky collapsibles, each with a copy
/// button for its recorded text.
class _VisitSummary extends StatefulWidget {
const _VisitSummary({
super.key,
+19 -13
View File
@@ -15,6 +15,7 @@ class AdaptiveShell extends StatefulWidget {
this.onDestinationSelected,
this.onSearch,
this.attentionCount = 0,
this.detailOpen = false,
});
final Map<AppDestination, WidgetBuilder> destinationBodies;
@@ -33,6 +34,10 @@ class AdaptiveShell extends StatefulWidget {
/// so it stays visible from any destination. Zero shows no badge.
final int attentionCount;
/// A pipeline, run or chat is open: on a phone it takes the whole screen,
/// like its own page, and the destination bar steps aside until Back.
final bool detailOpen;
@override
State<AdaptiveShell> createState() => _AdaptiveShellState();
}
@@ -183,18 +188,19 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
: Column(
children: [
Expanded(child: _destinationStack(contents, index)),
CupertinoTabBar(
currentIndex: index,
onTap: (value) =>
_select(AppDestination.values[value]),
items: _items((destination) {
final item = destinationDetails(destination);
return BottomNavigationBarItem(
icon: _icon(destination, item.cupertinoIcon),
label: item.label,
);
}),
),
if (!widget.detailOpen)
CupertinoTabBar(
currentIndex: index,
onTap: (value) =>
_select(AppDestination.values[value]),
items: _items((destination) {
final item = destinationDetails(destination);
return BottomNavigationBarItem(
icon: _icon(destination, item.cupertinoIcon),
label: item.label,
);
}),
),
],
),
),
@@ -250,7 +256,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
Expanded(child: _destinationStack(contents, index)),
],
),
bottomNavigationBar: wide
bottomNavigationBar: wide || widget.detailOpen
? null
: NavigationBar(
selectedIndex: index,
+168
View File
@@ -1,6 +1,14 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
android_file_picker:
dependency: transitive
description:
name: android_file_picker
sha256: e94229cc41c4bb5fb6a2254146340a8b650664c99b5c93b9001f66c3375d0060
url: "https://pub.dev"
source: hosted
version: "2.1.1"
args:
dependency: transitive
description:
@@ -57,6 +65,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.19.1"
cross_file:
dependency: transitive
description:
name: cross_file
sha256: f141ea4f277af142a0356955707f6556f37b03947d39d55585981a06ca437bd6
url: "https://pub.dev"
source: hosted
version: "0.3.5+5"
crypto:
dependency: transitive
description:
@@ -121,6 +137,54 @@ packages:
url: "https://pub.dev"
source: hosted
version: "7.0.1"
file_picker:
dependency: "direct main"
description:
name: file_picker
sha256: "98c0b156b6380ba55bc767a14e2e6b3feb246e713ad40092424596fa79005bea"
url: "https://pub.dev"
source: hosted
version: "13.1.0"
file_picker_darwin:
dependency: transitive
description:
name: file_picker_darwin
sha256: ca2918264c453400c80ef0d69ca3f8b816f894db6144bebac73064ad64927e0e
url: "https://pub.dev"
source: hosted
version: "2.3.3"
file_picker_linux:
dependency: transitive
description:
name: file_picker_linux
sha256: c6562fc7d426db2fb85ea66fe2627953d2709932df5584ceaacf0aa5e39cf4da
url: "https://pub.dev"
source: hosted
version: "2.0.2"
file_picker_platform_interface:
dependency: transitive
description:
name: file_picker_platform_interface
sha256: "336e7168306834a2b68e6168ed768e00d3fabeac23154d5793e277ca9f97cf20"
url: "https://pub.dev"
source: hosted
version: "4.2.0"
file_picker_web:
dependency: transitive
description:
name: file_picker_web
sha256: a2288008280aabe371aff029466b3405e60838e0a1d714767488c59b926c8b8c
url: "https://pub.dev"
source: hosted
version: "4.2.0"
fixnum:
dependency: transitive
description:
name: fixnum
sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be
url: "https://pub.dev"
source: hosted
version: "1.1.1"
flutter:
dependency: "direct main"
description: flutter
@@ -304,6 +368,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.18.0"
mime:
dependency: transitive
description:
name: mime
sha256: bd47de35f07e27267e69c8c8b22edf9473bfee170a60d60fcc93730c5144b7f6
url: "https://pub.dev"
source: hosted
version: "2.1.0"
objective_c:
dependency: transitive
description:
@@ -440,6 +512,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.6.0"
share_plus:
dependency: "direct main"
description:
name: share_plus
sha256: db40767f130189d53f3ae8a6393c217ff4a492da1baff718a9873679c0c00224
url: "https://pub.dev"
source: hosted
version: "13.3.1"
share_plus_platform_interface:
dependency: transitive
description:
name: share_plus_platform_interface
sha256: "365ef7379fc22507256adda3385152942ffce08935452bc972c2e52a0bebae41"
url: "https://pub.dev"
source: hosted
version: "7.2.0"
shared_preferences:
dependency: "direct main"
description:
@@ -565,6 +653,78 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.4.0"
url_launcher:
dependency: "direct main"
description:
name: url_launcher
sha256: e8cc955c97e06df9879140a1fe301f3d493f01b7c62dec7f46834be31d7e9fda
url: "https://pub.dev"
source: hosted
version: "6.3.3"
url_launcher_android:
dependency: transitive
description:
name: url_launcher_android
sha256: "611e87fb320b70d1dd721dc46af89c98aceccea9b31fde49e084591414e0c610"
url: "https://pub.dev"
source: hosted
version: "6.3.33"
url_launcher_ios:
dependency: transitive
description:
name: url_launcher_ios
sha256: "8faa1aab294f1ab4040b43660c887b0418d5fa4f0cffef76a484e6aa1092eb4a"
url: "https://pub.dev"
source: hosted
version: "6.4.2"
url_launcher_linux:
dependency: transitive
description:
name: url_launcher_linux
sha256: "10f86fef4c2c43563fa6c211ff9cf757adf4d3ab762c56bd430664a947d70cd0"
url: "https://pub.dev"
source: hosted
version: "3.2.3"
url_launcher_macos:
dependency: transitive
description:
name: url_launcher_macos
sha256: "5e835a3b869c2d70325349c81c5a45c28e20791265b67b2669da6b08c5cd5201"
url: "https://pub.dev"
source: hosted
version: "3.2.6"
url_launcher_platform_interface:
dependency: transitive
description:
name: url_launcher_platform_interface
sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029"
url: "https://pub.dev"
source: hosted
version: "2.3.2"
url_launcher_web:
dependency: transitive
description:
name: url_launcher_web
sha256: "85c81589622fbc87c1c683aaea164d3604a7777495a79d91e39ffcdec39ddb34"
url: "https://pub.dev"
source: hosted
version: "2.4.3"
url_launcher_windows:
dependency: transitive
description:
name: url_launcher_windows
sha256: "6c5ad3f22cd4c38e089b81963b3cd7bb83b111b2df5dce008bb066162f42e429"
url: "https://pub.dev"
source: hosted
version: "3.1.6"
uuid:
dependency: transitive
description:
name: uuid
sha256: "9b129329f58692f6e6578329498a8fe9fbe98f090beb764ffbb8ee2eadd01dcd"
url: "https://pub.dev"
source: hosted
version: "4.6.0"
vector_math:
dependency: transitive
description:
@@ -685,6 +845,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "6.4.0"
windows_file_picker:
dependency: transitive
description:
name: windows_file_picker
sha256: "18452aa293de3b6961c6d05b0e71b4be7bb90c67635abdd3aa5c4e75dd875072"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
xdg_directories:
dependency: transitive
description:
+3
View File
@@ -45,6 +45,9 @@ dependencies:
package_info_plus: ^10.2.2
path_provider: ^2.1.6
open_filex: ^5.0.0
share_plus: ^13.3.1
file_picker: ^13.1.0
url_launcher: ^6.3.3
dev_dependencies:
flutter_test:
+28
View File
@@ -13,6 +13,7 @@ AppRouterDelegate delegate(AppRoute initial, {void Function()? onChat}) =>
);
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
test('system Back leaves one chat session for the chat list', () async {
var left = 0;
final router = delegate(AppRoute.chatSession('s1'), onChat: () => left++);
@@ -22,6 +23,33 @@ void main() {
expect(left, 1);
});
test('system Back steps up one level at a time', () async {
var runs = 0;
final router = AppRouterDelegate(
builder: (context, route) => const SizedBox.shrink(),
onPopToRuns: () => runs++,
onPopToChat: () {},
cupertino: false,
initial: AppRoute.run.stage(77, 'plan', visit: 0),
);
addTearDown(router.dispose);
// A stage returns to its run, then the run to the Runs list.
expect(await router.popRoute(), isTrue);
expect(router.route, AppRoute.run(77));
expect(await router.popRoute(), isTrue);
expect(runs, 1);
// A pipeline stage returns to its pipeline, then to the list, and the
// list leaves Back to the platform.
router.goTo(AppRoute.pipelineStage(4, 'plan', version: 2));
expect(await router.popRoute(), isTrue);
expect(router.route, AppRoute.pipeline(4, version: 2));
expect(await router.popRoute(), isTrue);
expect(router.route, AppRoute.pipelines);
expect(await router.popRoute(), isFalse);
});
test('system Back on a list destination stays with the platform', () async {
final router = delegate(AppRoute.chat);
addTearDown(router.dispose);
+4 -3
View File
@@ -268,7 +268,7 @@ void main() {
testWidgets(
'the Search tab opens focused and the Runs tab keeps the open run',
(tester) async {
tester.view.physicalSize = const Size(390, 844);
tester.view.physicalSize = const Size(900, 1000);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
@@ -295,7 +295,8 @@ void main() {
);
await replyRunList(tester, channel);
await replyRunDetail(tester, channel, 2);
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
// On a phone an open run fills the screen and the tabs step aside, so
// switching tabs with a run open is a wide-window move.
// Search is the fifth tab.
await tapTab(tester, 'Search');
@@ -337,7 +338,7 @@ void main() {
testWidgets('a result opens through the existing run route over one socket', (
tester,
) async {
tester.view.physicalSize = const Size(390, 844);
tester.view.physicalSize = const Size(900, 1000);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
@@ -223,7 +223,11 @@ void main() {
stage: 'review',
visit: 1,
artifacts: <JsonMap>[
artifact('report.zip', contentType: 'application/zip', sizeBytes: 3),
artifact(
'report.zip',
contentType: 'application/zip',
sizeBytes: 3,
),
],
),
],
@@ -262,6 +266,14 @@ void main() {
artifact: _record,
resolved: resolveArtifactUrl(_endpoint, _record.url)!,
fetch: _fetch,
bridge: const ArtifactFileBridge(
downloadSupported: false,
shareSupported: false,
downloadUnsupportedMessage:
'Downloading files is not supported on this platform yet.',
shareUnsupportedMessage:
'File sharing is not supported on this platform yet.',
),
),
),
),
@@ -374,8 +386,8 @@ void main() {
);
await tester.pumpAndSettle();
expect(find.text('Download'), findsOneWidget);
expect(find.text('Share'), findsOneWidget);
expect(find.byKey(const Key('artifact-download')), findsOneWidget);
expect(find.byKey(const Key('artifact-share')), findsOneWidget);
final externalGroup = visitGroup(artifacts: <ArtifactRecord>[external]);
await tester.pumpWidget(
@@ -395,9 +407,9 @@ void main() {
);
await tester.pumpAndSettle();
expect(find.text('Download'), findsNothing);
expect(find.text('Share'), findsNothing);
expect(find.text('Open'), findsOneWidget);
expect(find.byKey(const Key('artifact-download')), findsNothing);
expect(find.byKey(const Key('artifact-share')), findsNothing);
expect(find.byKey(const Key('artifact-open')), findsOneWidget);
},
);
}
@@ -466,7 +466,10 @@ void main() {
);
expect(tester.takeException(), isNull);
expect(tester.getSize(find.byType(CustomScrollView)).height, greaterThan(0));
expect(
tester.getSize(find.byType(CustomScrollView)).height,
greaterThan(0),
);
expect(
find.text('12 files excluded from artifact capture.'),
findsOneWidget,
@@ -150,10 +150,9 @@ void main() {
expect(find.byType(ArtifactViewerPage), findsOneWidget);
// The gallery's thumbnail and the viewer read the same recorded file.
expect(fetched, isNotEmpty);
expect(
fetched.toSet(),
{Uri.parse('http://127.0.0.1:8081/artifacts/1/1/shot.png')},
);
expect(fetched.toSet(), {
Uri.parse('http://127.0.0.1:8081/artifacts/1/1/shot.png'),
});
expect(find.byType(Image), findsOneWidget);
expect(find.text('1 of 1 · image/png'), findsOneWidget);
expect(find.text('image/png · 1.0\u00a0KiB'), findsOneWidget);
@@ -247,7 +246,7 @@ void main() {
);
expect(fetched, isEmpty);
expect(find.byType(Image), findsNothing);
await tester.tap(find.text('Open'));
await tester.tap(find.byKey(const Key('artifact-open')));
await tester.pumpAndSettle();
expect(opened, [Uri.parse('https://elsewhere.test/shot.png')]);
});
@@ -320,8 +319,8 @@ void main() {
// The player streams the url itself; the viewer never fetches its bytes.
expect(find.byType(ArtifactVideoPlayer), findsOneWidget);
expect(find.text('This file type cannot be previewed here.'), findsNothing);
expect(find.text('Open'), findsOneWidget);
expect(find.text('Copy link'), findsOneWidget);
expect(find.byKey(const Key('artifact-open')), findsOneWidget);
expect(find.byKey(const Key('artifact-copy-link')), findsOneWidget);
expect(fetches, 0);
});
@@ -523,6 +522,37 @@ void main() {
expect(find.byType(Material), findsNothing);
});
testWidgets('a swipe moves to the next and previous artifact', (
tester,
) async {
final first = recordedArtifact(
'a.png',
url: '/artifacts/1/1/a.png',
contentType: 'image/png',
);
final second = recordedArtifact(
'b.png',
url: '/artifacts/1/2/b.png',
contentType: 'image/png',
);
final groups = [
_group([first], visit: 1),
_group([second], visit: 2),
];
await _pumpViewer(
tester,
groups: groups,
selected: artifactVisitIdentity(groups[0], first),
);
final swipe = find.byKey(const Key('artifact-viewer-swipe'));
await tester.fling(swipe, const Offset(-300, 0), 1000);
await tester.pumpAndSettle();
expect(find.textContaining('2 of 2'), findsWidgets);
await tester.fling(swipe, const Offset(300, 0), 1000);
await tester.pumpAndSettle();
expect(find.textContaining('1 of 2'), findsWidgets);
});
testWidgets('Material paging stays inside 320px at 2x text', (tester) async {
tester.view.physicalSize = const Size(640, 1200);
tester.view.devicePixelRatio = 2;
@@ -21,12 +21,12 @@ void main() {
expect(find.text('Back'), findsNothing);
// The page bar's own Back is the only one.
expect(find.byKey(const Key('run-visit-back')), findsOneWidget);
// Four tabs: Summary, Artifacts, Changes, More.
// Four tabs: Summary, Artifacts, Changes, Session.
expect(shownVisitSections, [
RunVisitSection.summary,
RunVisitSection.artifacts,
RunVisitSection.changes,
RunVisitSection.more,
RunVisitSection.session,
]);
// Summary holds both Input and Output.
expect(find.text('Input'), findsOneWidget);
@@ -73,9 +73,8 @@ void main() {
expect(find.text('sess-1'), findsOneWidget);
expect(find.text('Open session.html'), findsOneWidget);
await openVisitTab(tester, RunVisitSection.definition);
expect(find.byType(StageDefinitionView), findsOneWidget);
expect(find.text('Draft the plan.'), findsOneWidget);
// The stage's definition belongs to the pipeline, not to a visit.
expect(find.byType(StageDefinitionView), findsNothing);
});
testWidgets('${platform.name} artifacts tab reports the capture state', (
@@ -178,21 +177,6 @@ void main() {
expect(find.byType(ArtifactGalleryPage), findsOneWidget);
});
testWidgets('${platform.name} missing definition uses exact wording', (
tester,
) async {
await openVisit(
tester,
platform,
run: visitRunFixture(declareStage: false),
);
await openVisitTab(tester, RunVisitSection.definition);
expect(find.byType(StageDefinitionView), findsNothing);
expect(find.text(unknownStageDefinition), findsOneWidget);
expect(find.text('Draft the plan.'), findsNothing);
});
testWidgets('${platform.name} visit sections at 320 with 2x dark text', (
tester,
) async {
@@ -115,8 +115,7 @@ Future<void> openVisit(
await tester.pumpAndSettle();
}
/// Opens the tab showing [section]: Input and Output are on Summary, Session
/// and Definition behind More's switch.
/// Opens the tab showing [section]: Input and Output are on Summary.
Future<void> openVisitTab(WidgetTester tester, RunVisitSection section) async {
final shown = visitTabFor(section);
final tab = find.byKey(ValueKey('run-visit-tab-${shown.name}'));
@@ -124,15 +123,4 @@ Future<void> openVisitTab(WidgetTester tester, RunVisitSection section) async {
await tester.pumpAndSettle();
await tester.tap(tab);
await tester.pumpAndSettle();
if (section == RunVisitSection.session ||
section == RunVisitSection.definition) {
final choice = find.descendant(
of: find.byKey(const Key('run-visit-more-switch')),
matching: find.text(
section == RunVisitSection.session ? 'Session' : 'Definition',
),
);
await tester.tap(choice);
await tester.pumpAndSettle();
}
}
+19
View File
@@ -99,4 +99,23 @@ void main() {
findsNothing,
);
});
testWidgets('an open detail fills a phone screen without the tab bar', (
tester,
) async {
tester.view.physicalSize = const Size(390, 844);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
Widget shell({required bool detail}) => MaterialApp(
home: AdaptiveShell(
destination: AppDestination.runs,
detailOpen: detail,
destinationBodies: {AppDestination.runs: (_) => const Text('runs')},
),
);
await tester.pumpWidget(shell(detail: false));
expect(find.byType(NavigationBar), findsOneWidget);
await tester.pumpWidget(shell(detail: true));
expect(find.byType(NavigationBar), findsNothing);
});
}