From 286506310cccd47b5e181069df548dc89561bcd1 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Tue, 10 Nov 2026 22:21:15 +0000 Subject: [PATCH] Show chat details and file details as dialogs on desktop Phase 2b.4 of docs/plans/floating-windows.md: both use showAppDetails (a dialog on a wide app, a bottom sheet on a phone). Implemented by pipeline run 305; landed by hand after its UI review found the dialog clipped, which the helper now scrolls. --- .../chat/conversation/chat_thread_view.dart | 25 ++------ .../features/chat/files/files_details.dart | 48 +++------------ app/notes/chat-details-file-details-popups.md | 14 +++++ .../conversation/chat_info_sheet_test.dart | 49 ++++++--------- .../chat/files/files_details_test.dart | 61 +++++++++++++++++++ 5 files changed, 107 insertions(+), 90 deletions(-) create mode 100644 app/notes/chat-details-file-details-popups.md create mode 100644 app/test/features/chat/files/files_details_test.dart diff --git a/app/lib/features/chat/conversation/chat_thread_view.dart b/app/lib/features/chat/conversation/chat_thread_view.dart index c6a03f99..6f050df0 100644 --- a/app/lib/features/chat/conversation/chat_thread_view.dart +++ b/app/lib/features/chat/conversation/chat_thread_view.dart @@ -56,6 +56,7 @@ import 'chat_sent_entrance.dart'; import 'chat_server_queue.dart'; import 'chat_thread_controller.dart'; import '../../../ui/adaptive/floating_bar_layout.dart'; +import '../../../ui/adaptive/app_popups.dart'; import '../../../ui/adaptive/segmented_bar_overlay.dart'; import '../../../ui/layout/app_sheet_header.dart'; import '../../../ui/layout/wheel_scroll_forwarding.dart'; @@ -511,21 +512,19 @@ class _ChatThreadViewState extends State { /// Reports the harness's recorded usage. The standard sheet is dismissed the /// platform's way (drag/barrier/Back, or a popup tap) and closes explicitly. Future _openInfo() async { - final cupertino = - chatControlsStyleOf(context) == ChatControlsStyle.cupertino; final exporter = ChatExportController( repository: ChatRepository(widget.gateway), sessionId: widget.sessionId, bridge: widget.fileBridge, ); try { - await _showInfo(cupertino, exporter); + await _showInfo(exporter); } finally { exporter.dispose(); } } - Future _showInfo(bool cupertino, ChatExportController exporter) async { + Future _showInfo(ChatExportController exporter) async { final handoff = ChatSessionHandoff.from(widget.sessionId, widget.session); Widget sheet() => _ChatInfoSheet( controller: _controller, @@ -534,23 +533,7 @@ class _ChatThreadViewState extends State { color: chatSessionColor(widget.session), onColorSelected: widget.onColorSelected, ); - if (cupertino) { - await showCupertinoModalPopup( - context: context, - builder: (sheetContext) => Align( - alignment: Alignment.bottomCenter, - child: SafeArea(child: CupertinoPopupSurface(child: sheet())), - ), - ); - return; - } - await showModalBottomSheet( - context: context, - showDragHandle: true, - isScrollControlled: true, - useSafeArea: true, - builder: (sheetContext) => sheet(), - ); + await showAppDetails(context, builder: (_) => sheet()); } /// The transcript in recorded order; a sent turn is part of it from the diff --git a/app/lib/features/chat/files/files_details.dart b/app/lib/features/chat/files/files_details.dart index e5068ad0..b4a2c416 100644 --- a/app/lib/features/chat/files/files_details.dart +++ b/app/lib/features/chat/files/files_details.dart @@ -1,6 +1,5 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import '../../../ui/adaptive/host.dart'; +import '../../../ui/adaptive/app_popups.dart'; import '../../artifacts/actions/artifact_transfer.dart'; import '../../artifacts/domain/artifact_kind.dart'; import '../../artifacts/ui/artifact_external_open.dart'; @@ -18,7 +17,6 @@ void showFileDetails( required Future Function()? download, required ArtifactExternalOpen openExternal, }) { - final cupertino = usesCupertinoHost(context); Widget content(BuildContext sheet) { Future open() async { var opened = false; @@ -37,12 +35,7 @@ void showFileDetails( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - entry.name, - style: cupertino - ? CupertinoTheme.of(sheet).textTheme.navTitleTextStyle - : Theme.of(sheet).textTheme.titleLarge, - ), + Text(entry.name, style: Theme.of(sheet).textTheme.titleLarge), const SizedBox(height: 12), Text( '${artifactKindLabel(artifactKind(fileContentType(entry.name), entry.name))} · ${fileSizeLabel(entry.size)}', @@ -57,42 +50,17 @@ void showFileDetails( const SizedBox(height: 16), if (download != null) FileDownloadButton(download: download), if (urls != null) - cupertino - ? CupertinoButton( - onPressed: open, - child: const Text('Open externally'), - ) - : TextButton.icon( - onPressed: open, - icon: const Icon(Icons.open_in_new), - label: const Text('Open externally'), - ), - if (cupertino) - CupertinoButton( - onPressed: () => Navigator.pop(sheet), - child: const Text('Close'), + TextButton.icon( + onPressed: open, + icon: const Icon(Icons.open_in_new), + label: const Text('Open externally'), ), ], ), ), ); - return cupertino - ? CupertinoPopupSurface( - child: DefaultTextStyle( - style: CupertinoTheme.of(sheet).textTheme.textStyle, - child: body, - ), - ) - : body; + return body; } - if (cupertino) { - showCupertinoModalPopup(context: context, builder: content); - } else { - showModalBottomSheet( - context: context, - showDragHandle: true, - builder: content, - ); - } + showAppDetails(context, builder: content); } diff --git a/app/notes/chat-details-file-details-popups.md b/app/notes/chat-details-file-details-popups.md new file mode 100644 index 00000000..229b3a4e --- /dev/null +++ b/app/notes/chat-details-file-details-popups.md @@ -0,0 +1,14 @@ +# Chat and file details popups + +- Chat information and file details now use `showAppDetails`, producing dialogs + on wide app layouts and bottom sheets on phone layouts. +- Removed the Cupertino-only branches from the two rewritten surfaces while + preserving their existing content, loading/action behavior, and keys. +- Added wide and phone regression coverage in + `chat_info_sheet_test.dart` and `files_details_test.dart`. +- Focused check: `tool/memwatch/full.sh + 'test/features/chat/conversation/chat_info_sheet_test.dart + test/features/chat/files/files_details_test.dart'` — 7 passed. +- `tool/analyze.sh` — clean. +- Browser build and UI capture/review were not run; those belong to the UI + review stage. diff --git a/app/test/features/chat/conversation/chat_info_sheet_test.dart b/app/test/features/chat/conversation/chat_info_sheet_test.dart index 3aac9ee8..236308d3 100644 --- a/app/test/features/chat/conversation/chat_info_sheet_test.dart +++ b/app/test/features/chat/conversation/chat_info_sheet_test.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/core/api_gateway.dart'; @@ -11,11 +10,6 @@ Widget _host(Widget child) => MaterialApp( home: Scaffold(body: child), ); -Widget _cupertinoHost(Widget child) => CupertinoApp( - theme: const CupertinoThemeData(brightness: Brightness.dark), - home: CupertinoPageScaffold(child: child), -); - JsonMap _usageFrame(JsonMap usage) => { 'session_id': 's', 'kind': 'usage', @@ -24,7 +18,7 @@ JsonMap _usageFrame(JsonMap usage) => { Future _thread( WidgetTester tester, { - bool cupertino = false, + Size size = const Size(800, 600), }) async { final gateway = FakeChatGateway(); addTearDown(gateway.close); @@ -34,7 +28,10 @@ Future _thread( sessionId: 's', onBack: () {}, ); - await tester.pumpWidget(cupertino ? _cupertinoHost(thread) : _host(thread)); + tester.view.physicalSize = size; + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + await tester.pumpWidget(_host(thread)); await tester.pumpAndSettle(); return gateway; } @@ -146,9 +143,21 @@ void main() { expect(find.text('\$0.0000'), findsOneWidget); }); - testWidgets('the native sheet dismisses from Done and the barrier', ( - tester, - ) async { + testWidgets('wide details use a dialog', (tester) async { + await _thread(tester, size: const Size(1280, 800)); + await _openInfo(tester); + expect(find.byType(Dialog), findsOneWidget); + expect(find.byType(BottomSheet), findsNothing); + }); + + testWidgets('phone details use a bottom sheet', (tester) async { + await _thread(tester, size: const Size(430, 900)); + await _openInfo(tester); + expect(find.byType(BottomSheet), findsOneWidget); + expect(find.byType(Dialog), findsNothing); + }); + + testWidgets('details dismiss from Done and the barrier', (tester) async { final gateway = await _thread(tester); gateway.emitEvent(_usageFrame({'scope': 'session', 'total_tokens': 5})); await tester.pump(); @@ -170,22 +179,4 @@ void main() { expect(find.byKey(const Key('chat-info-sheet')), findsNothing); expect(find.byKey(const Key('chat-info')), findsOneWidget); }); - - testWidgets('the Cupertino host opens and closes the native popup', ( - tester, - ) async { - final gateway = await _thread(tester, cupertino: true); - gateway.emitEvent(_usageFrame({'scope': 'session', 'total_tokens': 42})); - await tester.pump(); - - await _openInfo(tester); - expect(find.text('Chat information'), findsOneWidget); - expect(find.text('Done'), findsOneWidget); - expect(find.text('42'), findsOneWidget); - - await tester.tap(find.byKey(const Key('chat-info-close'))); - await tester.pumpAndSettle(); - expect(find.byKey(const Key('chat-info-sheet')), findsNothing); - expect(find.byKey(const Key('chat-info')), findsOneWidget); - }); } diff --git a/app/test/features/chat/files/files_details_test.dart b/app/test/features/chat/files/files_details_test.dart new file mode 100644 index 00000000..a1b2ac15 --- /dev/null +++ b/app/test/features/chat/files/files_details_test.dart @@ -0,0 +1,61 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/features/artifacts/ui/artifact_external_open.dart'; +import 'package:pipelines_app/features/chat/data/directory_listing.dart'; +import 'package:pipelines_app/features/chat/files/files_details.dart'; + +const _entry = DirectoryEntry( + name: 'report.txt', + path: '/home/report.txt', + isDir: false, + isGitRepo: false, + hidden: false, + size: 1024, + modified: '2026-01-02T03:04:05Z', +); + +Widget _app() { + return MaterialApp( + home: Scaffold( + body: Builder( + builder: (context) => TextButton( + onPressed: () => showFileDetails( + context, + entry: _entry, + urls: null, + download: null, + openExternal: ((_) async => false) as ArtifactExternalOpen, + ), + child: const Text('Details'), + ), + ), + ), + ); +} + +void _size(WidgetTester tester, Size size) { + tester.view.physicalSize = size; + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); +} + +void main() { + testWidgets('wide file details use a dialog', (tester) async { + _size(tester, const Size(1280, 800)); + await tester.pumpWidget(_app()); + await tester.tap(find.text('Details')); + await tester.pumpAndSettle(); + expect(find.byType(Dialog), findsOneWidget); + expect(find.byType(BottomSheet), findsNothing); + expect(find.text('report.txt'), findsOneWidget); + }); + + testWidgets('phone file details use a bottom sheet', (tester) async { + _size(tester, const Size(430, 900)); + await tester.pumpWidget(_app()); + await tester.tap(find.text('Details')); + await tester.pumpAndSettle(); + expect(find.byType(BottomSheet), findsOneWidget); + expect(find.byType(Dialog), findsNothing); + }); +}