feat(app): chat sections are clear collapsible dividers; closed chats start collapsed

This commit is contained in:
2026-10-24 00:22:18 +01:00
parent d0b1c8e524
commit 1e55b8d2b3
16 changed files with 293 additions and 161 deletions
@@ -5,6 +5,7 @@ import 'package:pipelines_app/core/api_gateway.dart';
import 'chat_test_harness.dart';
import 'fake_chat_gateway.dart';
import 'expand_closed.dart';
void main() {
testWidgets('material row star, rename, close confirm and reopen', (
@@ -53,6 +54,7 @@ void main() {
'chat_query': {'session_id': 's2'},
});
await expandClosedChats(tester);
await tester.ensureVisible(find.byKey(const Key('chat-actions-s4')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('chat-actions-s4')));
@@ -6,6 +6,7 @@ import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_screen.dar
import 'chat_test_harness.dart';
import 'fake_chat_gateway.dart';
import 'expand_closed.dart';
/// Long enough that a single ellipsised line would visibly lose the reason.
const _refusal =
@@ -93,6 +94,7 @@ void main() {
closed = true;
await tester.tap(find.byKey(const Key('chat-refresh')));
await tester.pumpAndSettle();
await expandClosedChats(tester);
expect(find.text('New'), findsNothing);
expect(
@@ -134,6 +136,7 @@ void main() {
),
);
await tester.pumpAndSettle();
await expandClosedChats(tester);
await tester.ensureVisible(find.byKey(const Key('chat-actions-s4')));
await tester.tap(find.byKey(const Key('chat-actions-s4')));
@@ -185,6 +188,7 @@ void main() {
),
);
await tester.pumpAndSettle();
await expandClosedChats(tester);
await tester.ensureVisible(find.byKey(const Key('chat-actions-s4')));
await tester.tap(find.byKey(const Key('chat-actions-s4')));
@@ -3,6 +3,7 @@ import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/ui/sessions/session_list_material.dart';
import 'expand_closed.dart';
/// The Android host: a Material grouped list with its native separators.
Future<void> _pumpRows(
@@ -116,6 +117,7 @@ void main() {
'closed_at': '2026-01-01',
},
], section: 'Closed');
await expandClosedChats(tester);
// The section header also says Closed; the row's trailing word is its own.
expect(
@@ -8,6 +8,7 @@ import 'package:pipelines_app/core/api_gateway.dart';
import 'chat_test_harness.dart';
import 'fake_chat_gateway.dart';
import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_screen.dart';
import 'expand_closed.dart';
void main() {
testWidgets('deep-linked active chat is marked read when its row loads', (
@@ -64,17 +65,13 @@ void main() {
final gateway = FakeChatGateway()
..sessionsReply = {'chat_sessions': sampleSessions()};
await pumpMaterialChat(tester, gateway);
await expandClosedChats(tester);
expect(find.text('Starred'), findsOneWidget);
expect(find.text('Chats'), findsNWidgets(2));
// The Closed section header, and each closed row's trailing word.
expect(
find.byWidgetPredicate(
(widget) =>
widget is ExpansionTile &&
widget.title is Text &&
(widget.title as Text).data == 'Closed',
),
find.byKey(const ValueKey('chat-section-Closed')),
findsOneWidget,
);
expect(
@@ -112,8 +109,10 @@ void main() {
// The list has no search field; New chat and Refresh are the actions.
expect(find.byType(CupertinoSearchTextField), findsNothing);
expect(find.byType(Scaffold), findsNothing);
expect(find.text('Chats · /work'), findsOneWidget);
expect(find.text('Chats · /else'), findsOneWidget);
// Directory groups sit under their section's heading.
expect(find.byKey(const ValueKey('chat-section-Chats')), findsOneWidget);
expect(find.text('/work'), findsWidgets);
expect(find.text('/else'), findsWidgets);
await tester.tap(find.byKey(const Key('chat-star-s2')));
await tester.pumpAndSettle();
@@ -138,6 +137,8 @@ void main() {
'chat_rename': {'session_id': 's2', 'title': 'Renamed on Cupertino'},
});
await expandClosedChats(tester);
await tester.ensureVisible(find.byKey(const Key('chat-actions-s4')));
await tester.tap(find.byKey(const Key('chat-actions-s4')));
await tester.pumpAndSettle();
await tester.tap(find.text('Reopen'));
@@ -198,4 +199,17 @@ void main() {
);
semantics.dispose();
});
testWidgets('closed chats start folded away behind their heading', (
tester,
) async {
final gateway = FakeChatGateway()
..sessionsReply = {'chat_sessions': sampleSessions()};
await pumpMaterialChat(tester, gateway);
expect(find.byKey(const ValueKey('chat-section-Closed')), findsOneWidget);
expect(find.byKey(const Key('chat-row-s4')), findsNothing);
expect(find.text('Open chat'), findsOneWidget);
await expandClosedChats(tester);
expect(find.byKey(const Key('chat-row-s4')), findsOneWidget);
});
}
@@ -0,0 +1,12 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
/// Closed chats start folded away; opens that section when it is shown.
Future<void> expandClosedChats(WidgetTester tester) async {
final section = find.byKey(const ValueKey('chat-section-Closed'));
if (section.evaluate().isEmpty) return;
final heading = find.descendant(of: section, matching: find.text('Closed'));
await tester.ensureVisible(heading.first);
await tester.tap(heading.first);
await tester.pumpAndSettle();
}