From f201b834d4719cc22994508c6250ac01283ba7f0 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Mon, 26 Oct 2026 00:02:50 +0000 Subject: [PATCH] Place chat recency and actions beside row metadata --- .../chat/ui/sessions/session_row_content.dart | 115 ++++++++++++------ app/notes/compact-chat-rows.md | 26 ++++ .../chat_session_compact_row_test.dart | 69 +++++++++++ 3 files changed, 172 insertions(+), 38 deletions(-) create mode 100644 app/notes/compact-chat-rows.md create mode 100644 app/test/features/chat/ui/sessions/chat_session_compact_row_test.dart diff --git a/app/lib/features/chat/ui/sessions/session_row_content.dart b/app/lib/features/chat/ui/sessions/session_row_content.dart index 137e1379..8c6316e9 100644 --- a/app/lib/features/chat/ui/sessions/session_row_content.dart +++ b/app/lib/features/chat/ui/sessions/session_row_content.dart @@ -1,8 +1,13 @@ +import 'dart:math' as math; + +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'chat_adaptive.dart'; + /// Hierarchical row copy shared by the Material and Cupertino list variants. -/// Each server-recorded fact keeps its own line; recency is visually anchored -/// at the end of its own line rather than competing with the other metadata. +/// Metadata stays on the left; recency and native actions share its vertical +/// space on the right instead of adding full-width rows below it. class ChatSessionRowContent extends StatelessWidget { const ChatSessionRowContent({ super.key, @@ -39,42 +44,76 @@ class ChatSessionRowContent extends StatelessWidget { overflow: TextOverflow.ellipsis, style: titleStyle, ), - if (status != null || leading != null) ...[ - const SizedBox(height: 2), - Wrap( - crossAxisAlignment: WrapCrossAlignment.center, - spacing: 8, - children: [ - ?leading, - if (status != null) - _StatusLabel(status: status!, style: statusStyle), - ], - ), - ], - for (final line in meta) - Text( - line, - maxLines: 2, - overflow: TextOverflow.ellipsis, - style: metaStyle, - ), - if (recency != null && recency!.isNotEmpty) ...[ - const SizedBox(height: 3), - Align( - alignment: AlignmentDirectional.centerEnd, - child: Text( - recency!, - maxLines: 2, - textAlign: TextAlign.end, - style: metaStyle, - ), - ), - ], - if (actions.isNotEmpty) - Align( - alignment: AlignmentDirectional.centerEnd, - child: Wrap(alignment: WrapAlignment.end, children: actions), - ), + LayoutBuilder( + builder: (context, constraints) { + final hasTrailing = + actions.isNotEmpty || (recency?.isNotEmpty ?? false); + final nativeTarget = + chatControlsStyleOf(context) == ChatControlsStyle.cupertino + ? kMinInteractiveDimensionCupertino + : kMinInteractiveDimension; + final trailingWidth = math.min( + constraints.maxWidth, + math.max( + nativeTarget, + math.min( + constraints.maxWidth * 0.45, + nativeTarget * math.max(1, actions.length), + ), + ), + ); + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + if (status != null || leading != null) + Wrap( + crossAxisAlignment: WrapCrossAlignment.center, + spacing: 8, + children: [ + ?leading, + if (status != null) + _StatusLabel(status: status!, style: statusStyle), + ], + ), + for (final line in meta) + Text( + line, + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: metaStyle, + ), + ], + ), + ), + if (hasTrailing) + SizedBox( + width: trailingWidth, + child: Column( + crossAxisAlignment: CrossAxisAlignment.end, + mainAxisSize: MainAxisSize.min, + children: [ + if (recency?.isNotEmpty ?? false) + Text( + recency!, + maxLines: 2, + overflow: TextOverflow.ellipsis, + textAlign: TextAlign.end, + style: metaStyle, + ), + if (actions.isNotEmpty) + Wrap(alignment: WrapAlignment.end, children: actions), + ], + ), + ), + ], + ); + }, + ), ], ); } diff --git a/app/notes/compact-chat-rows.md b/app/notes/compact-chat-rows.md new file mode 100644 index 00000000..cd922625 --- /dev/null +++ b/app/notes/compact-chat-rows.md @@ -0,0 +1,26 @@ +# Compact chat rows + +- `session_row_content.dart` now keeps the full-width title above a shared row: + recorded metadata/state at the start, timestamp and favorite/more at the end. + Timestamp/actions no longer add full-width lines below metadata. Native action + targets remain unchanged; actions wrap within the right column on narrow panes. +- New `chat_session_compact_row_test.dart` verifies timestamp/actions beside + metadata on both hosts at 120/360 content widths, including horizontal actions + overlapping the metadata's vertical space when there is room. +- Full suite: **1,964 tests pass**, clean analysis. Existing session/shared-pane + tests pass including both hosts, light/dark, narrow/wide and 2x text/actions. +- Installer-built production-entry browser probes passed. Captures inspected in + `build/compact-rows-{material,cupertino,narrow}`: 1280 on both hosts and 640 + Material; native selected rows remain intact and metadata stays separate. +- No backend change, service restart, real-chat mutation or device installation. + +## Publication + +- Existing `./install --web` and `./install --apk --notes …` paths used. No + executing pipeline runs at preparation. Rollbacks of installed web/feed and + public feed: `~/.local/share/pipelines/backups/compact-chat-rows-20261025-235851/`. +- Web is live; public rollback `build/web-before-compact-rows-1792972937/`. + Full authenticated downloads on HTTPS 8443/8096 match installed JS SHA256: + `e68b298475940f25df4efb5caac8bc156e7a8282a44747388790814a62558478`. +- APK build still running; publication verification pending. Public APK remains + the prior 0.1.29882860 until the new build is checked and copied to the feeds. diff --git a/app/test/features/chat/ui/sessions/chat_session_compact_row_test.dart b/app/test/features/chat/ui/sessions/chat_session_compact_row_test.dart new file mode 100644 index 00000000..b64c46b6 --- /dev/null +++ b/app/test/features/chat/ui/sessions/chat_session_compact_row_test.dart @@ -0,0 +1,69 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/features/chat/ui/sessions/session_row_content.dart'; +import 'package:pipelines_app/features/chat/ui/sessions/session_actions.dart'; + +void main() { + for (final cupertino in [false, true]) { + for (final width in [120.0, 360.0]) { + testWidgets( + 'right-side recency/actions, Cupertino=$cupertino width=$width', + (tester) async { + final star = SessionStarButton( + session: const {'id': 's'}, + onPressed: () {}, + ); + final more = SessionActionsButton( + session: const {'id': 's'}, + onSelected: (_) {}, + ); + final row = Center( + child: SizedBox( + width: width, + child: ChatSessionRowContent( + title: 'Chat title', + status: null, + recency: '5 min ago', + meta: const ['opencode', 'model', '/work'], + titleStyle: const TextStyle(fontSize: 17), + metaStyle: const TextStyle(fontSize: 12), + statusStyle: const TextStyle(fontSize: 12), + actions: [ + KeyedSubtree(key: const Key('star'), child: star), + KeyedSubtree(key: const Key('more'), child: more), + ], + ), + ), + ); + await tester.pumpWidget( + cupertino + ? CupertinoApp(home: CupertinoPageScaffold(child: row)) + : MaterialApp(home: Scaffold(body: row)), + ); + await tester.pumpAndSettle(); + final backend = tester.getRect(find.text('opencode')); + final time = tester.getRect(find.text('5 min ago')); + final favorite = tester.getRect(find.byKey(const Key('star'))); + final menu = tester.getRect(find.byKey(const Key('more'))); + expect(time.left, greaterThanOrEqualTo(backend.right)); + expect( + time.top, + closeTo(backend.top, 0.1), + reason: 'Timestamp belongs beside metadata, not below it', + ); + expect(favorite.left, greaterThanOrEqualTo(backend.right)); + expect(menu.left, greaterThanOrEqualTo(backend.right)); + if (width == 360) { + expect( + favorite.top, + lessThan(tester.getRect(find.text('/work')).bottom), + ); + expect(menu.top, closeTo(favorite.top, 0.1)); + } + expect(tester.takeException(), isNull); + }, + ); + } + } +}