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);