merge(app): land section bodies, arrow keys and chat bar

This commit is contained in:
2026-10-23 22:37:56 +01:00
9 changed files with 336 additions and 124 deletions
@@ -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<ArtifactViewerPage> {
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<ArtifactViewerPage> {
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,
@@ -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<FileDiffPage> {
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(
@@ -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<ChatThreadView> {
// 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<String>(
'chat-model-${widget.sessionId}',
),
if (hasModel)
ConstrainedBox(
constraints: BoxConstraints(
maxWidth: constraints.maxWidth * 0.4,
),
child: ChatModelControl(
key: ValueKey<String>(
'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<ChatThreadView> {
),
],
);
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<String>('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,
);
},
);
+32
View File
@@ -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),
);
}
+13 -3
View File
@@ -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),
+115 -52
View File
@@ -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),
);
}
}
@@ -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);
@@ -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);
});
}
@@ -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);
});
}