From 73af9d851b5b4dc43b05729e18b5d4a0747fa179 Mon Sep 17 00:00:00 2001 From: Wang Zichong Date: Sun, 22 Nov 2026 12:32:59 +0800 Subject: [PATCH] ui: one row height and one trailing line in the sidebar, and a dsh-Go activity cap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - The project header is a ListTile now, like a session row: both are 72 high (title + subtitle). A Material 3 list tile ends at 24, so the band's 8px inset gets 16 more, putting the project + and the session ⋮ on one line (a widget test asserts both the heights and the x centres). - The running status is a full-width stadium like dsh-Go's activity strip: title and current-step summary on the left, a tabular m:ss clock on the right, translucent surface, 36 minimum height. The spinner inside is gone; the cap's top edge is where the future input-box pet will perch. - 0.3.20 (320). --- PLAN.md | 9 ++ README.md | 2 +- lib/screens/chat_screen.dart | 95 ++++++++++------- lib/screens/sessions_screen.dart | 177 +++++++++++++++---------------- pubspec.yaml | 2 +- test/sidebar_rows_test.dart | 47 ++++++++ 6 files changed, 200 insertions(+), 132 deletions(-) create mode 100644 test/sidebar_rows_test.dart diff --git a/PLAN.md b/PLAN.md index a4e3d79..09a9687 100644 --- a/PLAN.md +++ b/PLAN.md @@ -5,6 +5,15 @@ --- +## 0.3.20 侧栏项目/会话行等高与右对齐、活动条改为 dsh-Go 胶囊(分支 `flutter`) + +| 项 | 结果 | +| --- | --- | +| 侧栏等高 | 项目分组头改用与会话行相同的 `ListTile`(标题 + 副标题),两者高度都是 72;分组的 8px 外边距由 ListTile 的内边距补偿,`+` 与会话的 `⋮` 落在同一竖线上 | +| 活动条 | 改为 dsh-Go 风格的全宽胶囊:左侧「标题 + 步骤摘要」,右侧等宽数字计时 `m:ss`(不足一分钟也显示 `0:03`),半透明 surface 背景,最小高度 36;去掉条内的转圈。胶囊顶边就是之后输入框宠物的栖息位置 | +| 版本 | **0.3.20(code 320)** | +--- + ## 0.3.19 输入框环居中、运行状态条、侧栏项目层级与 Windows 路径(分支 `flutter`) | 项 | 结果 | diff --git a/README.md b/README.md index 0aaec0a..30ea6ac 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Android first. This branch (`flutter`) is a framework evaluation: the same feature set as the earlier Asuka/Go and MyGo attempts, reimplemented in Flutter to compare mobile UI maturity. -Status: 0.3.19 — servers (passwordless / password login, HTTP/HTTPS and +Status: 0.3.20 — servers (passwordless / password login, HTTP/HTTPS and SOCKS5/socks5h proxy, self-signed certificates and pinning), session list with search and live events, chat with streaming Markdown and full history paging, tool steps grouped per turn (icon, one-line summary, foldable run) with image previews, a diff --git a/lib/screens/chat_screen.dart b/lib/screens/chat_screen.dart index 495a051..f202497 100644 --- a/lib/screens/chat_screen.dart +++ b/lib/screens/chat_screen.dart @@ -1380,57 +1380,72 @@ class _ChatScreenState extends State { if (start <= 0) return ''; final secs = ((DateTime.now().millisecondsSinceEpoch - start) / 1000).round(); - if (secs <= 0) return ''; - if (secs < 60) return '$secs 秒'; + if (secs <= 0) return '0:00'; return '${secs ~/ 60}:${(secs % 60).toString().padLeft(2, '0')}'; } - /// dsh-Go's activity strip: the current step and its clock, above the input. + /// dsh-Go's activity cap: a stadium above the input with the current step + /// on the left and its clock on the right. Its top edge is where the + /// input-box pet will later perch. Widget _activityStrip() { final theme = Theme.of(context); final scheme = theme.colorScheme; final act = _activity(); final elapsed = _elapsedSince(_runningStart()); return Padding( - padding: const EdgeInsets.fromLTRB(14, 2, 14, 2), - child: Row( - children: [ - SizedBox( - width: 13, - height: 13, - child: CircularProgressIndicator( - strokeWidth: 1.7, - color: scheme.primary, - ), - ), - const SizedBox(width: 8), - Expanded( - child: Text.rich( - TextSpan(children: [ - TextSpan( - text: act.title, - style: TextStyle( - fontSize: 12.5, - fontWeight: FontWeight.w600, - color: scheme.onSurface, + // The same 8px side margin as the composer, so the two capsules agree. + padding: const EdgeInsets.fromLTRB(8, 4, 8, 4), + child: Container( + constraints: const BoxConstraints(minHeight: 36), + padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 6), + decoration: ShapeDecoration( + color: scheme.surfaceContainerHighest.withValues(alpha: 0.7), + shape: const StadiumBorder(), + ), + child: Row( + children: [ + Expanded( + child: Row( + children: [ + Text( + act.title, + style: theme.textTheme.labelMedium?.copyWith( + fontSize: 13, + fontWeight: FontWeight.w600, + color: scheme.onSurface, + ), ), + if (act.detail.isNotEmpty) ...[ + const SizedBox(width: 6), + Flexible( + child: Text( + act.detail, + maxLines: 1, + softWrap: false, + overflow: TextOverflow.ellipsis, + style: theme.textTheme.bodySmall?.copyWith( + fontSize: 12, + color: scheme.onSurfaceVariant, + ), + ), + ), + ], + ], + ), + ), + if (elapsed.isNotEmpty) ...[ + const SizedBox(width: 8), + Text( + elapsed, + style: TextStyle( + fontSize: 12, + color: theme.hintColor, + fontFeatures: const [FontFeature.tabularFigures()], ), - if (act.detail.isNotEmpty) - TextSpan( - text: ' · ${act.detail}', - style: TextStyle(fontSize: 12, color: theme.hintColor), - ), - if (elapsed.isNotEmpty) - TextSpan( - text: ' · $elapsed', - style: TextStyle(fontSize: 12, color: theme.hintColor), - ), - ]), - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - ), - ], + ), + ], + ], + ), ), ); } diff --git a/lib/screens/sessions_screen.dart b/lib/screens/sessions_screen.dart index c9d49f8..8c4f02b 100644 --- a/lib/screens/sessions_screen.dart +++ b/lib/screens/sessions_screen.dart @@ -298,16 +298,58 @@ class _SessionListPaneState extends State { Widget _groupHeader(_SessionGroup group, {required bool collapsed}) { final theme = Theme.of(context); final scheme = theme.colorScheme; - final radius = BorderRadius.circular(10); - // A tinted band, at least a session row's height: a project reads as a - // section, not as another row. + // A ListTile with a title and a subtitle has the session rows' height and + // trailing slot; only the tinted band and the folder mark it as a project. return Padding( - padding: const EdgeInsets.fromLTRB(8, 10, 8, 2), + padding: const EdgeInsets.fromLTRB(8, 8, 8, 2), child: Material( color: scheme.surfaceContainerHighest.withValues(alpha: 0.5), - borderRadius: radius, + borderRadius: BorderRadius.circular(10), clipBehavior: Clip.antiAlias, - child: InkWell( + child: ListTile( + // The band already insets by 8. A Material 3 list tile ends at 24 + // (start 16), so 16 here makes the + line up with the session + // rows' ⋮. + contentPadding: const EdgeInsets.only(left: 8, right: 16), + leading: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon(collapsed ? Icons.chevron_right : Icons.expand_more, + size: 18, color: scheme.onSurfaceVariant), + const SizedBox(width: 2), + Icon(Icons.folder_outlined, size: 16, color: scheme.primary), + ], + ), + title: Text( + group.label.isEmpty ? '未命名项目' : group.label, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.w700, + color: scheme.onSurface, + ), + ), + subtitle: group.path.isEmpty + ? null + : Text( + group.path, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle(fontSize: 11.5, color: theme.hintColor), + ), + // A fixed 48 slot, like the session rows' menu: both keys then sit + // on the same vertical line. + trailing: SizedBox( + width: 48, + height: 48, + child: IconButton( + icon: const Icon(Icons.add, size: 20), + padding: EdgeInsets.zero, + tooltip: '在此项目新会话', + onPressed: () => _newSession(directory: group.path), + ), + ), onTap: () => setState(() { if (collapsed) { _collapsed.remove(group.key); @@ -315,56 +357,6 @@ class _SessionListPaneState extends State { _collapsed.add(group.key); } }), - child: ConstrainedBox( - constraints: const BoxConstraints(minHeight: 56), - child: Padding( - padding: const EdgeInsets.fromLTRB(10, 10, 4, 10), - child: Row( - children: [ - Icon(collapsed ? Icons.chevron_right : Icons.expand_more, - size: 18, color: scheme.onSurfaceVariant), - const SizedBox(width: 6), - Icon(Icons.folder_outlined, - size: 16, color: scheme.primary), - const SizedBox(width: 6), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text( - group.label.isEmpty ? '未命名项目' : group.label, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 13.5, - fontWeight: FontWeight.w700, - color: scheme.onSurface), - ), - if (group.path.isNotEmpty) - Padding( - padding: const EdgeInsets.only(top: 2), - child: Text( - group.path, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 11, color: theme.hintColor), - ), - ), - ], - ), - ), - IconButton( - icon: const Icon(Icons.add, size: 18), - tooltip: '在此项目新会话', - visualDensity: VisualDensity.compact, - onPressed: () => _newSession(directory: group.path), - ), - ], - ), - ), - ), ), ), ); @@ -565,42 +557,47 @@ class _SessionListPaneState extends State { } Widget _menu(Session session, {required bool archived}) { - return PopupMenuButton( - icon: const Icon(Icons.more_vert, size: 18), - onSelected: (value) { - switch (value) { - case 'rename': - _rename(session); - break; - case 'pin': - _app.togglePin(session); - break; - case 'archive': - _archive(session, archived); - break; - case 'delete': - _confirmDelete(session); - break; - case 'copy': - Clipboard.setData(ClipboardData(text: session.id)); - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar(content: Text('已复制会话 ID'))); - break; - } - }, - itemBuilder: (_) => [ - if (!archived) ...[ - const PopupMenuItem(value: 'rename', child: Text('重命名')), + // The same 48 slot as the project header's +, so the keys line up. + return SizedBox( + width: 48, + height: 48, + child: PopupMenuButton( + icon: const Icon(Icons.more_vert, size: 18), + onSelected: (value) { + switch (value) { + case 'rename': + _rename(session); + break; + case 'pin': + _app.togglePin(session); + break; + case 'archive': + _archive(session, archived); + break; + case 'delete': + _confirmDelete(session); + break; + case 'copy': + Clipboard.setData(ClipboardData(text: session.id)); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('已复制会话 ID'))); + break; + } + }, + itemBuilder: (_) => [ + if (!archived) ...[ + const PopupMenuItem(value: 'rename', child: Text('重命名')), + PopupMenuItem( + value: 'pin', + child: Text(session.isPinned ? '取消置顶' : '置顶')), + ], PopupMenuItem( - value: 'pin', - child: Text(session.isPinned ? '取消置顶' : '置顶')), + value: 'archive', + child: Text(archived ? '取消归档' : '归档')), + const PopupMenuItem(value: 'delete', child: Text('删除')), + const PopupMenuItem(value: 'copy', child: Text('复制会话 ID')), ], - PopupMenuItem( - value: 'archive', - child: Text(archived ? '取消归档' : '归档')), - const PopupMenuItem(value: 'delete', child: Text('删除')), - const PopupMenuItem(value: 'copy', child: Text('复制会话 ID')), - ], + ), ); } diff --git a/pubspec.yaml b/pubspec.yaml index 73bda42..f637ebd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: openchamber description: "A lightweight OpenChamber client for phones." publish_to: 'none' -version: 0.3.19+319 +version: 0.3.20+320 environment: sdk: ^3.14.0 diff --git a/test/sidebar_rows_test.dart b/test/sidebar_rows_test.dart new file mode 100644 index 0000000..0f2a0b0 --- /dev/null +++ b/test/sidebar_rows_test.dart @@ -0,0 +1,47 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:openchamber/api/models.dart'; +import 'package:openchamber/screens/sessions_screen.dart'; +import 'package:openchamber/state.dart'; + +void main() { + testWidgets('the project band matches a session row and keeps the keys in line', + (tester) async { + final app = AppState(); + final now = DateTime.now().millisecondsSinceEpoch; + app.sessions = [ + Session( + id: 's1', + title: '标签页拖拽与分屏', + agent: 'build', + location: Location(r'C:\msys64\home\Gary\Sources\pineapple-notepad'), + created: now, + updated: now, + ), + ]; + addTearDown(app.dispose); + + await tester.pumpWidget(MaterialApp( + home: Scaffold(body: SessionListPane(app: app)), + )); + await tester.pumpAndSettle(); + + // A Windows path names the folder, not the whole path. + expect(find.text('pineapple-notepad'), findsOneWidget); + + final header = find.ancestor( + of: find.text('pineapple-notepad'), + matching: find.byType(ListTile), + ); + final row = find.ancestor( + of: find.text('标签页拖拽与分屏'), + matching: find.byType(ListTile), + ); + expect(tester.getSize(header).height, tester.getSize(row).height); + + // The project's + and the session's ⋮ share one vertical line. + final add = tester.getCenter(find.byTooltip('在此项目新会话')); + final menu = tester.getCenter(find.byIcon(Icons.more_vert)); + expect(add.dx, closeTo(menu.dx, 0.5)); + }); +}