feat(app): an open pipeline, run or chat fills a phone screen; Back steps up one level; stage tabs end with Session

This commit is contained in:
2026-10-23 22:49:21 +01:00
parent dd324d1f92
commit 0e6db03903
9 changed files with 104 additions and 108 deletions
+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,
@@ -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,
+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);
@@ -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);
});
}