Keep chat titles readable in narrow headers

Prioritize the conversation title on narrow chat bars, move compact controls and overflow actions into More, and omit the duplicate title in floating windows. Add focused widget coverage for title sizing, icon dimensions, menus, and floating chrome.
This commit is contained in:
2026-11-12 10:42:43 +00:00
parent 24618964ce
commit 7d9b6c1d1b
9 changed files with 431 additions and 85 deletions
@@ -6,6 +6,8 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/conversation/chat_mode_control.dart';
import 'package:pipelines_app/features/chat/screen.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart'
show segmentedMoreKey;
/// A chat destination gateway whose listing can change between reads, as it
/// does when the server learns a row's mode after the row was first opened.
@@ -101,13 +103,33 @@ Future<void> _pump(
await tester.pumpAndSettle();
}
/// The mode the drawn control names, or null when the bar has none. A
/// A narrow phone bar draws only the shield, so read the control itself.
String? _shown(WidgetTester tester) {
if (_modeControl.evaluate().isEmpty) return null;
/// The mode the drawn control names, or null when there is none. A phone bar
/// keeps its selectors in the More menu's settings sheet, so the sheet is
/// opened to read the control and then dismissed again.
Future<String?> _shown(WidgetTester tester) async {
if (_modeControl.evaluate().isNotEmpty) {
final control = find.byType(ChatModeControl);
expect(control, findsOneWidget);
return tester.widget<ChatModeControl>(control).modeName;
}
await tester.tap(find.byKey(segmentedMoreKey).hitTestable());
await tester.pumpAndSettle();
if (find.text('Chat settings').evaluate().isEmpty) {
// No selectors for this chat: nothing to read; close the menu.
await tester.tapAt(const Offset(5, 5));
await tester.pumpAndSettle();
return null;
}
await tester.tap(find.text('Chat settings'));
await tester.pumpAndSettle();
final control = find.byType(ChatModeControl);
expect(control, findsOneWidget);
return tester.widget<ChatModeControl>(control).modeName;
final name = control.evaluate().isEmpty
? null
: tester.widget<ChatModeControl>(control).modeName;
// Dismiss the sheet through its barrier, above the bar.
await tester.tapAt(const Offset(5, 5));
await tester.pumpAndSettle();
return name;
}
void main() {
@@ -123,7 +145,7 @@ void main() {
await tester.tap(find.byKey(const Key('chat-row-s')));
await tester.pumpAndSettle();
expect(_shown(tester), 'Ask for permission');
expect(await _shown(tester), 'Ask for permission');
},
);
@@ -135,7 +157,7 @@ void main() {
await _pump(tester, gateway, platform: platform);
await tester.tap(find.byKey(const Key('chat-row-s')));
await tester.pumpAndSettle();
expect(_shown(tester), isNull);
expect(await _shown(tester), isNull);
// A reconnect re-reads the list; the open chat follows that row
// without being closed and opened again.
@@ -151,7 +173,7 @@ void main() {
_app(gateway, platform: platform, syncToken: 1),
);
await tester.pumpAndSettle();
expect(_shown(tester), 'Ask for permission');
expect(await _shown(tester), 'Ask for permission');
// Another device chose Auto; the next re-read keeps the bar in sync.
gateway.sessions = [
@@ -161,7 +183,7 @@ void main() {
_app(gateway, platform: platform, syncToken: 2),
);
await tester.pumpAndSettle();
expect(_shown(tester), 'Auto');
expect(await _shown(tester), 'Auto');
},
);
@@ -171,7 +193,7 @@ void main() {
final gateway = _ModeScreenGateway();
await _pump(tester, gateway, platform: platform, initialSessionId: 's');
expect(_shown(tester), 'Ask for permission');
expect(await _shown(tester), 'Ask for permission');
});
testWidgets('$style: switching chats shows each chat its own mode', (
@@ -198,19 +220,19 @@ void main() {
await tester.tap(find.byKey(const Key('chat-row-s')));
await tester.pumpAndSettle();
expect(_shown(tester), 'Ask for permission');
expect(await _shown(tester), 'Ask for permission');
await tester.tap(find.byKey(const Key('chat-row-t')));
await tester.pumpAndSettle();
expect(_shown(tester), 'Auto');
expect(await _shown(tester), 'Auto');
await tester.tap(find.byKey(const Key('chat-row-u')));
await tester.pumpAndSettle();
expect(_shown(tester), isNull);
expect(await _shown(tester), isNull);
await tester.tap(find.byKey(const Key('chat-row-s')));
await tester.pumpAndSettle();
expect(_shown(tester), 'Ask for permission');
expect(await _shown(tester), 'Ask for permission');
});
}
@@ -252,7 +274,7 @@ void main() {
await runNew(tester);
expect(find.text('New chat'), findsWidgets);
expect(_shown(tester), 'Plan');
expect(await _shown(tester), 'Plan');
gateway.listGate!.complete();
await tester.pumpAndSettle();
},
@@ -277,11 +299,11 @@ void main() {
await runNew(tester);
// The row is open on the /new reply, which names no mode.
expect(find.text('New chat'), findsWidgets);
expect(_shown(tester), isNull);
expect(await _shown(tester), isNull);
gateway.listGate!.complete();
await tester.pumpAndSettle();
expect(_shown(tester), 'Plan');
expect(await _shown(tester), 'Plan');
},
variant: _desktop,
);