From afd1943b734dd37217599108d7749a4e40fa0a94 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Fri, 23 Oct 2026 12:36:26 +0100 Subject: [PATCH] fix(app): chat conversation bar leads, outside the transcript scroller --- .../chat/conversation/chat_thread_view.dart | 164 +++++++++--------- .../conversation/chat_activity_line_test.dart | 14 +- .../chat_background_tasks_test.dart | 21 +++ 3 files changed, 116 insertions(+), 83 deletions(-) diff --git a/app/lib/features/chat/conversation/chat_thread_view.dart b/app/lib/features/chat/conversation/chat_thread_view.dart index 9cc482b1..caee95d3 100644 --- a/app/lib/features/chat/conversation/chat_thread_view.dart +++ b/app/lib/features/chat/conversation/chat_thread_view.dart @@ -291,7 +291,8 @@ class _ChatThreadViewState extends State { /// The runner for this session's `/new`, `/close` and `/rename`, rebuilt per /// build so an adopted row's directory and title are the current ones. ChatCommandActions _commandActions() { - final session = widget.session ?? {'id': widget.sessionId, 'title': widget.title}; + final session = + widget.session ?? {'id': widget.sessionId, 'title': widget.title}; final onCreated = widget.onCreatedSession; return ChatCommandActions( repository: ChatRepository(widget.gateway), @@ -299,8 +300,8 @@ class _ChatThreadViewState extends State { directory: '${session['directory'] ?? ''}'.trim(), showNotice: _showCommandNotice, confirmClose: () => confirmCloseChat(context, session), - openCreatedSession: onCreated ?? - (created, notice) => _showCommandNotice(notice), + openCreatedSession: + onCreated ?? (created, notice) => _showCommandNotice(notice), onRenamed: widget.onSessionRenamed, onClosed: widget.onSessionClosed, newOperationId: widget.newOperationId, @@ -552,8 +553,7 @@ class _ChatThreadViewState extends State { /// table's horizontal scroll bubbles through this listener too and must not /// release the conversation's follow intent. bool _onScrollNotification(ScrollNotification notification) { - if (notification.depth != 0 || - notification.metrics.axis != Axis.vertical) { + if (notification.depth != 0 || notification.metrics.axis != Axis.vertical) { return false; } if (notification is UserScrollNotification) { @@ -662,6 +662,70 @@ class _ChatThreadViewState extends State { _scheduleFollow(); return 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, + ), + child: ChatModelControl( + key: ValueKey( + 'chat-model-${widget.sessionId}', + ), + gateway: widget.gateway, + sessionId: widget.sessionId, + session: session, + onChanged: widget.onModelChanged, + ), + ), + 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. @@ -683,72 +747,6 @@ class _ChatThreadViewState extends State { controller: _scroll, padding: const EdgeInsets.symmetric(vertical: 8), children: [ - Padding( - key: const Key('chat-thread-header'), - padding: const EdgeInsetsDirectional.fromSTEB(4, 0, 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, - ), - child: ChatModelControl( - key: ValueKey( - 'chat-model-${widget.sessionId}', - ), - gateway: widget.gateway, - sessionId: widget.sessionId, - session: session, - onChanged: widget.onModelChanged, - ), - ), - ChatBarAction( - key: const Key('chat-info'), - label: 'Chat information', - onPressed: _openInfo, - materialIcon: Icons.info_outline, - cupertinoIcon: CupertinoIcons.info, - ), - ], - ); - }, - ), - ), if (initialLoad) Padding( key: const Key('chat-thread-loading'), @@ -813,7 +811,9 @@ class _ChatThreadViewState extends State { rows[index], onDismissCompaction: compactionNotice != null && - chatNoticeActivityCondition(rows[index]) == + chatNoticeActivityCondition( + rows[index], + ) == compactionNotice.condition ? () => _dismiss(compactionNotice) : null, @@ -840,17 +840,17 @@ class _ChatThreadViewState extends State { ), ], ), - if (showJump) - PositionedDirectional( - end: 16, - bottom: 16, - child: _ChatJumpToLatest( - key: const Key('chat-jump-to-latest'), - label: chatJumpToLatestLabel(newMessages), - cupertino: cupertino, - onPressed: _followLatest, + if (showJump) + PositionedDirectional( + end: 16, + bottom: 16, + child: _ChatJumpToLatest( + key: const Key('chat-jump-to-latest'), + label: chatJumpToLatestLabel(newMessages), + cupertino: cupertino, + onPressed: _followLatest, + ), ), - ), ], ), ), diff --git a/app/test/features/chat/conversation/chat_activity_line_test.dart b/app/test/features/chat/conversation/chat_activity_line_test.dart index d21782a6..0ba64f20 100644 --- a/app/test/features/chat/conversation/chat_activity_line_test.dart +++ b/app/test/features/chat/conversation/chat_activity_line_test.dart @@ -278,7 +278,19 @@ void main() { final control = find.byKey( const ValueKey('chat-activity-toggle'), ); - await tester.ensureVisible(control); + // Drag like an operator: a programmatic scroll is undone by the + // view's follow-to-latest, while a user drag stops following. + final list = find.byKey(const ValueKey('chat-thread-s')); + final viewport = tester.getRect(list); + for (var i = 0; i < 10; i++) { + final rect = tester.getRect(control); + if (rect.top >= viewport.top && rect.bottom <= viewport.bottom) break; + await tester.drag( + list, + Offset(0, rect.top < viewport.top ? 200 : -200), + ); + await tester.pumpAndSettle(); + } await tester.tap(control); await tester.pumpAndSettle(); } diff --git a/app/test/features/chat/conversation/chat_background_tasks_test.dart b/app/test/features/chat/conversation/chat_background_tasks_test.dart index 44884133..b0df80ff 100644 --- a/app/test/features/chat/conversation/chat_background_tasks_test.dart +++ b/app/test/features/chat/conversation/chat_background_tasks_test.dart @@ -579,4 +579,25 @@ void main() { expect(find.text('Background tasks'), findsOneWidget); expect(find.text('1 running'), findsOneWidget); }); + + testWidgets('the conversation bar leads, above the task bar', (tester) async { + final gateway = _TasksGateway(); + gateway.shells = () async => _snapshot([_running('sh1')]); + addTearDown(gateway.close); + + await tester.pumpWidget(_thread(gateway)); + await tester.pumpAndSettle(); + + final header = tester.getRect(find.byKey(const Key('chat-thread-header'))); + final tasks = tester.getRect( + find.byKey(const Key('chat-background-tasks')), + ); + final list = tester.getRect( + find.byKey(const ValueKey('chat-thread-s')), + ); + expect(header.top, 0); + expect(tasks.top, greaterThanOrEqualTo(header.bottom)); + // The bar sits outside the transcript's scroller, as the web's chat-bar. + expect(list.top, greaterThanOrEqualTo(tasks.bottom)); + }); }