From 0defe42ac1988e965400bcf75c68a6513e637820 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Fri, 23 Oct 2026 22:33:13 +0100 Subject: [PATCH 1/3] feat(app): section bodies sit on their own surface; the whole title strip toggles; no seam above a pinned title --- app/lib/ui/layout/section_heading.dart | 16 +- app/lib/ui/layout/sticky_section.dart | 167 ++++++++++++++------ app/test/ui/layout/sticky_section_test.dart | 15 ++ 3 files changed, 143 insertions(+), 55 deletions(-) diff --git a/app/lib/ui/layout/section_heading.dart b/app/lib/ui/layout/section_heading.dart index 87c855c6..834f83c5 100644 --- a/app/lib/ui/layout/section_heading.dart +++ b/app/lib/ui/layout/section_heading.dart @@ -9,12 +9,17 @@ import '../adaptive/host.dart'; class SectionHeadingStyle { const SectionHeadingStyle({ required this.background, + required this.body, required this.accent, required this.title, required this.line, }); final Color background; + + /// The surface under a section's content: between the page and the title, + /// so the content reads as belonging to its section. + final Color body; final Color accent; final TextStyle title; final Color line; @@ -23,8 +28,12 @@ class SectionHeadingStyle { if (usesCupertinoHost(context)) { final base = CupertinoTheme.of(context).textTheme.textStyle; return SectionHeadingStyle( - background: CupertinoColors.secondarySystemGroupedBackground - .resolveFrom(context), + background: CupertinoColors.tertiarySystemGroupedBackground.resolveFrom( + context, + ), + body: CupertinoColors.secondarySystemGroupedBackground.resolveFrom( + context, + ), accent: CupertinoTheme.of(context).primaryColor, title: base.copyWith( fontWeight: FontWeight.w700, @@ -35,7 +44,8 @@ class SectionHeadingStyle { } final scheme = Theme.of(context).colorScheme; return SectionHeadingStyle( - background: scheme.surfaceContainerHigh, + background: scheme.surfaceContainerHighest, + body: scheme.surfaceContainerLow, accent: scheme.primary, title: (Theme.of(context).textTheme.titleSmall ?? const TextStyle()) .copyWith(fontWeight: FontWeight.w700, color: scheme.onSurface), diff --git a/app/lib/ui/layout/sticky_section.dart b/app/lib/ui/layout/sticky_section.dart index f5d58761..6ae68190 100644 --- a/app/lib/ui/layout/sticky_section.dart +++ b/app/lib/ui/layout/sticky_section.dart @@ -52,14 +52,17 @@ class StickySection extends StatelessWidget { ), ), ), - // The content grows and shrinks under the pinned title. + // The content grows and shrinks under the pinned title, on its own + // surface with the title's accent continuing down its edge. SliverToBoxAdapter( child: ClipRect( child: AnimatedSize( duration: Motion.of(context, Motion.standard), curve: Motion.curve, alignment: Alignment.topCenter, - child: open ? body : const SizedBox(width: double.infinity), + child: open + ? _SectionBody(child: body) + : const SizedBox(width: double.infinity), ), ), ), @@ -96,61 +99,121 @@ class StickySectionTitle extends StatelessWidget { final style = color == null ? heading.title : heading.title.copyWith(color: color); - return DecoratedBox( - decoration: BoxDecoration( - color: heading.background, - border: Border( - left: BorderSide(color: heading.accent, width: 3), - bottom: BorderSide(color: heading.line, width: 0.5), - ), + final chevron = AnimatedRotation( + turns: open ? 0.5 : 0, + duration: Motion.of(context, Motion.standard), + curve: Motion.curve, + child: Icon( + cupertino ? CupertinoIcons.chevron_down : Icons.expand_more, + color: muted, ), - child: Padding( - padding: const EdgeInsetsDirectional.only(start: 13, end: 8), - child: Row( - children: [ - Expanded( - child: Semantics( - container: true, - header: true, - button: true, - expanded: open, - label: title, - excludeSemantics: true, - onTap: onToggle, - child: GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: onToggle, - child: Row( - children: [ - Expanded( - child: Text( - title, - style: style, - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - ), - AnimatedRotation( - turns: open ? 0.5 : 0, - duration: Motion.of(context, Motion.standard), - curve: Motion.curve, - child: Icon( - cupertino - ? CupertinoIcons.chevron_down - : Icons.expand_more, - color: muted, - ), - ), - ], - ), - ), + ); + final row = Padding( + padding: const EdgeInsetsDirectional.only(start: 13, end: 8), + child: Row( + children: [ + Expanded( + // The title is the section's heading and its toggle for + // assistive tech; the strip's own tap target is not announced. + child: Semantics( + container: true, + header: true, + button: true, + expanded: open, + label: title, + excludeSemantics: true, + onTap: onToggle, + child: Text( + title, + style: style, + maxLines: 1, + overflow: TextOverflow.ellipsis, ), ), - ...trailing, - ], - ), + ), + ...trailing, + ExcludeSemantics(child: chevron), + ], ), ); + final decoration = BoxDecoration( + color: heading.background, + border: Border( + left: BorderSide(color: heading.accent, width: 3), + bottom: BorderSide(color: heading.line, width: 0.5), + ), + ); + // The whole strip opens and closes the section; its own buttons (copy) + // still take their taps first. + final Widget strip = cupertino + ? GestureDetector( + behavior: HitTestBehavior.opaque, + excludeFromSemantics: true, + onTap: onToggle, + child: DecoratedBox(decoration: decoration, child: row), + ) + : Material( + color: heading.background, + child: Ink( + decoration: decoration, + child: InkWell( + onTap: onToggle, + excludeFromSemantics: true, + child: row, + ), + ), + ); + return Stack( + clipBehavior: Clip.none, + fit: StackFit.expand, + children: [ + // A few pixels of the title's colour above it: at fractional pixel + // ratios content scrolling under a pinned title could peek through. + Positioned( + left: 0, + right: 0, + top: -3, + height: 4, + child: ColoredBox(color: heading.background), + ), + MouseRegion(cursor: SystemMouseCursors.click, child: strip), + ], + ); + } +} + +/// A section's open content: its own surface, a faint continuation of the +/// title's accent, and room between the title and the first line. +class _SectionBody extends StatelessWidget { + const _SectionBody({required this.child}); + + final Widget child; + + @override + Widget build(BuildContext context) { + final heading = SectionHeadingStyle.of(context); + final decoration = BoxDecoration( + color: heading.body, + border: Border( + left: BorderSide( + color: heading.accent.withValues(alpha: 0.35), + width: 3, + ), + bottom: BorderSide(color: heading.line, width: 0.5), + ), + ); + final content = Padding( + padding: const EdgeInsets.only(top: 12, bottom: 4), + child: child, + ); + if (usesCupertinoHost(context)) { + return DecoratedBox(decoration: decoration, child: content); + } + // Rows inside paint their ripples on this surface. + return Material( + color: heading.body, + child: Ink(decoration: decoration, child: content), + ); } } diff --git a/app/test/ui/layout/sticky_section_test.dart b/app/test/ui/layout/sticky_section_test.dart index 17ed2e52..073b88cd 100644 --- a/app/test/ui/layout/sticky_section_test.dart +++ b/app/test/ui/layout/sticky_section_test.dart @@ -46,4 +46,19 @@ void main() { expect(find.text('line 40'), findsNothing); }, ); + + testWidgets('a tap anywhere on the title strip toggles the section', ( + tester, + ) async { + tester.view.physicalSize = const Size(390, 600); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + await tester.pumpWidget(const MaterialApp(home: Scaffold(body: _Host()))); + expect(find.text('line 0'), findsOneWidget); + // Empty space well right of the short title, left of the chevron. + final strip = tester.getRect(find.byType(StickySectionTitle)); + await tester.tapAt(Offset(strip.center.dx + 60, strip.center.dy)); + await tester.pumpAndSettle(); + expect(find.text('line 0'), findsNothing); + }); } From f81957cd730cb5f5c4af3c4cb095a8bb4cc1f98d Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Fri, 23 Oct 2026 22:34:11 +0100 Subject: [PATCH 2/3] feat(app): left/right arrows step through artifacts and changed files --- .../artifacts/ui/artifact_viewer_page.dart | 9 ++++- .../changes/widgets/file_diff_viewer.dart | 18 ++++++--- app/lib/ui/input/arrow_key_pager.dart | 32 +++++++++++++++ app/test/ui/input/arrow_key_pager_test.dart | 40 +++++++++++++++++++ 4 files changed, 92 insertions(+), 7 deletions(-) create mode 100644 app/lib/ui/input/arrow_key_pager.dart create mode 100644 app/test/ui/input/arrow_key_pager_test.dart diff --git a/app/lib/features/artifacts/ui/artifact_viewer_page.dart b/app/lib/features/artifacts/ui/artifact_viewer_page.dart index cbb9a189..5fd4c5f3 100644 --- a/app/lib/features/artifacts/ui/artifact_viewer_page.dart +++ b/app/lib/features/artifacts/ui/artifact_viewer_page.dart @@ -1,3 +1,4 @@ +import '../../../ui/input/arrow_key_pager.dart'; import 'dart:convert'; import 'package:flutter/cupertino.dart'; @@ -219,7 +220,7 @@ class _ArtifactViewerPageState extends State { final title = page == null ? artifactViewerTitle : artifactDisplayName(page.artifact); - final body = page == null || plan == null + Widget body = page == null || plan == null ? const Center(child: Text('No previewable artifacts recorded.')) : ArtifactViewerBody( page: page, @@ -239,6 +240,12 @@ class _ArtifactViewerPageState extends State { onOpen: plan.resolved == null ? () {} : () => _open(plan.resolved!), onCopy: plan.resolved == null ? () {} : () => _copy(plan.resolved!), ); + // Left/right arrows walk the same list as the Previous/Next buttons. + body = ArrowKeyPager( + onPrevious: () => _step(-1), + onNext: () => _step(1), + child: body, + ); if (usesCupertinoHost(context)) { return CupertinoPageScaffold( backgroundColor: CupertinoColors.systemGroupedBackground, diff --git a/app/lib/features/changes/widgets/file_diff_viewer.dart b/app/lib/features/changes/widgets/file_diff_viewer.dart index bfbfdd51..b145c693 100644 --- a/app/lib/features/changes/widgets/file_diff_viewer.dart +++ b/app/lib/features/changes/widgets/file_diff_viewer.dart @@ -1,3 +1,4 @@ +import '../../../ui/input/arrow_key_pager.dart'; import 'dart:async'; import 'package:flutter/cupertino.dart'; @@ -287,12 +288,17 @@ class _FileDiffPageState extends State { onPrevious: _index > 0 ? () => _step(-1) : null, onNext: _index < count - 1 ? () => _step(1) : null, ); - final body = Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Expanded(child: viewer), - ?pager, - ], + // Left/right arrows step between changed files, like the chevrons. + final body = ArrowKeyPager( + onPrevious: _index > 0 ? () => _step(-1) : null, + onNext: _index < count - 1 ? () => _step(1) : null, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Expanded(child: viewer), + ?pager, + ], + ), ); if (cupertino) { return CupertinoPageScaffold( diff --git a/app/lib/ui/input/arrow_key_pager.dart b/app/lib/ui/input/arrow_key_pager.dart new file mode 100644 index 00000000..0986c430 --- /dev/null +++ b/app/lib/ui/input/arrow_key_pager.dart @@ -0,0 +1,32 @@ +import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; + +/// Left and right arrow keys step to the previous and next item (an +/// artifact, a changed file) wherever a keyboard is attached. A field that +/// takes the arrows itself (a text box) keeps them while it has focus. +class ArrowKeyPager extends StatelessWidget { + const ArrowKeyPager({ + super.key, + required this.onPrevious, + required this.onNext, + required this.child, + }); + + /// Null at the first item. + final VoidCallback? onPrevious; + + /// Null at the last item. + final VoidCallback? onNext; + final Widget child; + + @override + Widget build(BuildContext context) => CallbackShortcuts( + bindings: { + const SingleActivator(LogicalKeyboardKey.arrowLeft): () => + onPrevious?.call(), + const SingleActivator(LogicalKeyboardKey.arrowRight): () => + onNext?.call(), + }, + child: Focus(autofocus: true, child: child), + ); +} diff --git a/app/test/ui/input/arrow_key_pager_test.dart b/app/test/ui/input/arrow_key_pager_test.dart new file mode 100644 index 00000000..a8bb003e --- /dev/null +++ b/app/test/ui/input/arrow_key_pager_test.dart @@ -0,0 +1,40 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/features/changes/domain/change_kind.dart'; +import 'package:pipelines_app/features/changes/domain/file_change.dart'; +import 'package:pipelines_app/features/changes/widgets/file_diff_viewer.dart'; + +FileChange _file(String path) => FileChange( + path: path, + kind: ChangeKind.modified, + patch: '--- a/$path\n+++ b/$path\n@@ -1 +1 @@\n-a\n+b\n', +); + +void main() { + testWidgets('left and right arrows step between changed files', ( + tester, + ) async { + await tester.pumpWidget( + MaterialApp( + home: FileDiffPage( + files: [_file('lib/one.dart'), _file('lib/two.dart')], + ), + ), + ); + await tester.pumpAndSettle(); + expect(find.text('one.dart'), findsWidgets); + + await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight); + await tester.pumpAndSettle(); + expect(find.text('two.dart'), findsWidgets); + + // The last file stays put; left goes back. + await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight); + await tester.pumpAndSettle(); + expect(find.text('two.dart'), findsWidgets); + await tester.sendKeyEvent(LogicalKeyboardKey.arrowLeft); + await tester.pumpAndSettle(); + expect(find.text('one.dart'), findsWidgets); + }); +} From c200ecdaa17f014b7d1da220475977ffc89946eb Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Fri, 23 Oct 2026 22:36:42 +0100 Subject: [PATCH 3/3] feat(app): an open chat takes over the app bar instead of adding its own --- .../chat/conversation/chat_thread_view.dart | 154 +++++++++++------- .../application/chat_registration_test.dart | 9 +- 2 files changed, 101 insertions(+), 62 deletions(-) diff --git a/app/lib/features/chat/conversation/chat_thread_view.dart b/app/lib/features/chat/conversation/chat_thread_view.dart index 5d64db58..9e6a70cc 100644 --- a/app/lib/features/chat/conversation/chat_thread_view.dart +++ b/app/lib/features/chat/conversation/chat_thread_view.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import '../../../core/api_gateway.dart'; +import '../../../shell/shell_bar.dart'; import '../data/chat_repository.dart'; import '../domain/chat_activity_detail.dart'; import '../domain/chat_notice.dart'; @@ -631,73 +632,77 @@ class _ChatThreadViewState extends State { // Place the first loaded transcript and keep a following view at the end. // Scheduling after the build means the new extent is already laid out. _scheduleFollow(); - return Column( + // Under the app shell the conversation takes over the app's bar (title, + // Back, model, information) instead of drawing a second bar below it. + final inShellBar = ShellBar.available(context); + final column = Column( children: [ // The conversation's own bar first, outside the transcript's scroller, // as on the web (chat-bar, then background tasks, then transcript). - Padding( - key: const Key('chat-thread-header'), - padding: const EdgeInsetsDirectional.fromSTEB(4, 8, 4, 4), - child: LayoutBuilder( - builder: (context, constraints) { - final title = widget.title.trim(); - final session = widget.session; - final hasModel = - session != null && - supportsChatModels('${session['backend'] ?? ''}'); - // One compact row, as on the web: back, the conversation's - // name, its model and the information action. The title - // takes the remaining width and ellipsises; the model keeps - // a bounded share so neither control is pushed off a narrow - // 2x phone and the header never wraps onto a second line. - return Row( - children: [ - _backButton(cupertino), - Expanded( - child: Padding( - padding: const EdgeInsetsDirectional.only(start: 4), - child: title.isEmpty - ? const SizedBox.shrink() - : Text( - title, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: cupertino - ? CupertinoTheme.of( - context, - ).textTheme.navTitleTextStyle - : Theme.of(context).textTheme.titleLarge, - ), - ), - ), - if (hasModel) - ConstrainedBox( - constraints: BoxConstraints( - maxWidth: constraints.maxWidth * 0.4, + if (!inShellBar) + Padding( + key: const Key('chat-thread-header'), + padding: const EdgeInsetsDirectional.fromSTEB(4, 8, 4, 4), + child: LayoutBuilder( + builder: (context, constraints) { + final title = widget.title.trim(); + final session = widget.session; + final hasModel = + session != null && + supportsChatModels('${session['backend'] ?? ''}'); + // One compact row, as on the web: back, the conversation's + // name, its model and the information action. The title + // takes the remaining width and ellipsises; the model keeps + // a bounded share so neither control is pushed off a narrow + // 2x phone and the header never wraps onto a second line. + return Row( + children: [ + _backButton(cupertino), + Expanded( + child: Padding( + padding: const EdgeInsetsDirectional.only(start: 4), + child: title.isEmpty + ? const SizedBox.shrink() + : Text( + title, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: cupertino + ? CupertinoTheme.of( + context, + ).textTheme.navTitleTextStyle + : Theme.of(context).textTheme.titleLarge, + ), ), - child: ChatModelControl( - key: ValueKey( - 'chat-model-${widget.sessionId}', + ), + if (hasModel) + ConstrainedBox( + constraints: BoxConstraints( + maxWidth: constraints.maxWidth * 0.4, + ), + child: ChatModelControl( + key: ValueKey( + 'chat-model-${widget.sessionId}', + ), + gateway: widget.gateway, + sessionId: widget.sessionId, + session: session, + onChanged: widget.onModelChanged, + answeredBy: latestReplyModel(_controller.messages), ), - gateway: widget.gateway, - sessionId: widget.sessionId, - session: session, - onChanged: widget.onModelChanged, - answeredBy: latestReplyModel(_controller.messages), ), + ChatBarAction( + key: const Key('chat-info'), + label: 'Chat information', + onPressed: _openInfo, + materialIcon: Icons.info_outline, + cupertinoIcon: CupertinoIcons.info, ), - ChatBarAction( - key: const Key('chat-info'), - label: 'Chat information', - onPressed: _openInfo, - materialIcon: Icons.info_outline, - cupertinoIcon: CupertinoIcons.info, - ), - ], - ); - }, + ], + ); + }, + ), ), - ), // The session's still-running background tasks, above the transcript // and outside its scroller (web C11). It removes itself when the last // task exits and never draws a finished task. @@ -829,6 +834,37 @@ class _ChatThreadViewState extends State { ), ], ); + if (!inShellBar) return column; + final session = widget.session; + final hasModel = + session != null && supportsChatModels('${session['backend'] ?? ''}'); + final title = widget.title.trim(); + return ShellBar( + title: title.isEmpty ? null : title, + onBack: widget.onBack, + actions: [ + if (hasModel) + ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 180), + child: ChatModelControl( + key: ValueKey('chat-model-${widget.sessionId}'), + gateway: widget.gateway, + sessionId: widget.sessionId, + session: session, + onChanged: widget.onModelChanged, + answeredBy: latestReplyModel(_controller.messages), + ), + ), + ChatBarAction( + key: const Key('chat-info'), + label: 'Chat information', + onPressed: _openInfo, + materialIcon: Icons.info_outline, + cupertinoIcon: CupertinoIcons.info, + ), + ], + child: column, + ); }, ); diff --git a/app/test/application/chat_registration_test.dart b/app/test/application/chat_registration_test.dart index 81afc495..48d3d879 100644 --- a/app/test/application/chat_registration_test.dart +++ b/app/test/application/chat_registration_test.dart @@ -231,9 +231,12 @@ void main() { await tester.pump(); expect(find.text('A live line arrived.'), findsOneWidget); - // One compact icon-only Back control in the thread header; its - // accessible name is the destination, and both hosts share the key. - await tester.tap(find.byKey(const Key('chat-back'))); + // The open chat takes over the app bar: one Back there, and no + // second header row under it. + expect(find.byKey(const Key('chat-thread-header')), findsNothing); + await tester.tap(find.byKey(const ValueKey('shell.back'))); + await tester.pump(); + // The bar hands back to the list on the next frame. await tester.pump(); expect(provider.value.uri.path, '/chat'); expect(find.byType(ChatThreadView), findsNothing);