Merge commit '82418d31a76548ef5d5965a4472582740036dbc6' into pipelines/run-20261112-1022-settings-as-a-top-level-destination-5a4e
This commit is contained in:
@@ -52,8 +52,8 @@ class AppTerminals {
|
||||
|
||||
/// [shell] with the terminal panel, window or page around it, and the
|
||||
/// app's floating [windows] above both.
|
||||
/// [onChat]: the phone shortcut that reopens the terminal shows on the
|
||||
/// Chat tab only.
|
||||
/// [onChat]: whether the phone shortcut that reopens the terminal shows on
|
||||
/// this page. Pages whose own bar carries Terminal pass false.
|
||||
Widget surround(Widget shell, {bool onChat = true, Widget? windows}) =>
|
||||
TerminalSurface(
|
||||
hub: hub,
|
||||
|
||||
@@ -828,7 +828,11 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
valueListenable: _attentionCount,
|
||||
builder: (context, count, _) => _terminals.surround(
|
||||
_shellFor(route, count),
|
||||
onChat: route.kind == AppRouteKind.chat,
|
||||
// Every narrow Chat bar carries Terminal itself (the list's top bar
|
||||
// and an open chat's bar, see terminalChatBarAction), so the floating
|
||||
// bubble is off on every route. It otherwise covered the list's
|
||||
// header and duplicated the open chat's Terminal entry.
|
||||
onChat: false,
|
||||
windows: WindowHost(manager: _windows, reservesRail: true),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -11,6 +11,7 @@ import '../../../../ui/layout/content_width.dart';
|
||||
import '../../../../core/api_gateway.dart';
|
||||
import '../../../../shell/shell_bar.dart';
|
||||
import '../../../../shell/shell_list_shortcuts.dart';
|
||||
import '../../../terminal/terminal_open_action.dart';
|
||||
import '../../data/chat_repository.dart';
|
||||
import '../../domain/chat_colors.dart';
|
||||
import '../../domain/chat_cycle.dart';
|
||||
@@ -381,7 +382,7 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
|
||||
if (ShellBar.available(context)) {
|
||||
return ShellBar(
|
||||
active: widget.publishShellBar ?? widget.activeSessionId == null,
|
||||
actions: _actions(),
|
||||
actions: _actions(context),
|
||||
// The Chat tab counts chats with messages not yet seen.
|
||||
child: ShellBadge(
|
||||
kind: ShellBadgeKind.unread,
|
||||
@@ -396,7 +397,7 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
|
||||
alignment: AlignmentDirectional.centerEnd,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: _actions(),
|
||||
children: _actions(context),
|
||||
),
|
||||
),
|
||||
Expanded(child: body),
|
||||
@@ -406,7 +407,7 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
|
||||
|
||||
return Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: SegmentedBar(title: 'Chats', actions: _actions()),
|
||||
appBar: SegmentedBar(title: 'Chats', actions: _actions(context)),
|
||||
// The list scrolls behind the floating bar; New chat is the bar's
|
||||
// own action, so there is no second create button.
|
||||
body: body,
|
||||
@@ -415,18 +416,24 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> _actions() => [
|
||||
ChatBarAction(
|
||||
key: const Key('chat-new-chat'),
|
||||
label: 'New chat',
|
||||
onPressed: _newChat,
|
||||
materialIcon: Icons.add,
|
||||
),
|
||||
ChatBarAction(
|
||||
key: const Key('chat-refresh'),
|
||||
label: 'Refresh',
|
||||
onPressed: _controller.refresh,
|
||||
materialIcon: Icons.refresh,
|
||||
),
|
||||
];
|
||||
/// New chat, Refresh and, on a narrow layout, the terminal toggle (wide
|
||||
/// layouts keep it on the shell bar, so it is null here).
|
||||
List<Widget> _actions(BuildContext context) {
|
||||
final terminal = terminalChatBarAction(context);
|
||||
return [
|
||||
ChatBarAction(
|
||||
key: const Key('chat-new-chat'),
|
||||
label: 'New chat',
|
||||
onPressed: _newChat,
|
||||
materialIcon: Icons.add,
|
||||
),
|
||||
ChatBarAction(
|
||||
key: const Key('chat-refresh'),
|
||||
label: 'Refresh',
|
||||
onPressed: _controller.refresh,
|
||||
materialIcon: Icons.refresh,
|
||||
),
|
||||
?terminal,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
# Phone chat list: terminal button over the Chats header
|
||||
|
||||
## Defect
|
||||
At 430px the floating terminal shortcut (`TerminalShortcutBubble`, end 12,
|
||||
top = safe top + 64) sat on the chat list's `Chats` section header at
|
||||
[370,64,48,48]. It hid the header's count and collapse chevron and left a
|
||||
stray glyph beside it. Evidence: `/tmp/ui-review/base-light-430x900/07-chat.png`,
|
||||
`/tmp/ui-review/chatmenus-light-430x900/01-chatlist-more.png`.
|
||||
|
||||
Run 393 had removed a duplicate terminal icon from the narrow list bar, so the
|
||||
list had only the floating bubble.
|
||||
|
||||
## Change
|
||||
- `lib/features/chat/ui/sessions/chat_sessions_screen.dart`: `_actions(context)`
|
||||
now appends `terminalChatBarAction(context)` after New chat and Refresh. It is
|
||||
null on wide layouts (the shell bar keeps Terminal there) and with no
|
||||
terminal surface, so it appears only on a narrow layout with a surface.
|
||||
- `lib/application/pipelines_app.dart`: the floating bubble's `onChat` is now
|
||||
`false` on every route. On a narrow layout every Chat-tab bar carries Terminal
|
||||
itself (the list's top bar, and an open chat's bar via
|
||||
`chat_thread_view.dart`'s `terminalChatBarAction`), so the bubble has no
|
||||
remaining place. The earlier rule (`kind == chat && chatSessionId != null`)
|
||||
still showed it on an open chat, duplicating that chat's Terminal entry.
|
||||
- `lib/application/app_terminals.dart`: doc comment for `surround(onChat:)`
|
||||
now says pages whose own bar carries Terminal pass false. No behaviour change.
|
||||
|
||||
Result on a phone: exactly one terminal entry on the chat list (top bar) and on
|
||||
an open chat (its bar), and no floating control over any header.
|
||||
|
||||
## Focused tests (memwatch, from app/)
|
||||
- `test/application/phone_chat_terminal_entries_test.dart`: new, 2 tests at
|
||||
430x900 through the app shell. `/chat` and `/chat/abc123` each have no
|
||||
`TerminalShortcutBubble` and exactly one Terminal `ChatBarAction`.
|
||||
Against the previous `onChat` rule the open-chat test FAILS (the bubble is
|
||||
shown), so it guards the reviewer's finding. Restored after that check.
|
||||
- `test/features/chat/ui/sessions/chat_list_terminal_action_test.dart`: 4 tests.
|
||||
Narrow top bar carries Terminal beside New chat and Refresh, and tapping it
|
||||
toggles. The Chats heading sits below the bar. Wide has no list terminal.
|
||||
No terminal surface has no list terminal.
|
||||
- Users of the changed wiring, all in the same run:
|
||||
- `test/application/pipelines_app_test.dart`
|
||||
- `test/features/terminal/terminal_surface_test.dart`
|
||||
- `test/features/chat/ui/sessions/chat_sessions_floating_bar_test.dart`
|
||||
- `test/features/chat/ui/sessions/chat_sessions_screen_test.dart`
|
||||
|
||||
Combined run of these six plus the list test: PASS 28/28 (`memwatch: PASS`,
|
||||
exit 0), run after the final edit.
|
||||
- Not re-run in this pass: `test/features/chat/shell/chat_shell_terminal_test.dart`
|
||||
and `chat_shell_terminal_session_test.dart` (listed as users in an earlier
|
||||
pass). The `onChat` change does not touch the shell's wide path.
|
||||
- `tool/analyze.sh`: clean (0 errors, 0 warnings, 0 infos) after the final edit.
|
||||
|
||||
## Not verified here
|
||||
- No rendered capture. The before/after screenshots at 430x900 are for ui-review.
|
||||
- The open-chat test checks the Terminal action by label, not by semantics
|
||||
identifier. In the open chat's bar the identifier lookup found nothing even
|
||||
though the action is present, so this is a limit of the probe, not evidence
|
||||
of a missing entry. A capture is needed to confirm what is drawn.
|
||||
|
||||
## Open limitations
|
||||
- `TerminalShortcutBubble` is now never shown by the app shell (`onChat` is
|
||||
always false). It and `TerminalSurface`'s shortcut code remain, with their
|
||||
own tests. Removing them is a follow-up if the owner agrees.
|
||||
- A narrow Chat-tab route with no chat bar would now have no terminal entry at
|
||||
all. None was found in the code, but this was not exhaustively checked.
|
||||
- The bubble's old top edge on an open chat was not checked against that chat's
|
||||
bar; with the bubble gone that check is moot.
|
||||
@@ -0,0 +1,57 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/transport/pipelines_client.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/chat_adaptive.dart';
|
||||
import 'package:pipelines_app/features/terminal/terminal_shortcut_bubble.dart';
|
||||
import 'package:pipelines_app/features/terminal/terminal_toggle_button.dart';
|
||||
|
||||
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
||||
import 'pipelines_app_test.dart' show pumpApp;
|
||||
|
||||
/// On a phone the Chat tab has exactly one terminal entry: the bar's own
|
||||
/// Terminal action. The floating shortcut bubble must not appear over the
|
||||
/// chat list's header, nor beside an open chat's bar that already has it.
|
||||
|
||||
Future<void> _pumpAt(WidgetTester tester, String location) async {
|
||||
tester.view.physicalSize = const Size(430, 900);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
final channel = FakeChannel()..readyCompleter.complete();
|
||||
final client = PipelinesClient(channelFactory: (_) => channel);
|
||||
final provider = PlatformRouteInformationProvider(
|
||||
initialRouteInformation: RouteInformation(uri: Uri.parse(location)),
|
||||
);
|
||||
addTearDown(provider.dispose);
|
||||
await pumpApp(tester, channel: channel, client: client, provider: provider);
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
}
|
||||
|
||||
/// The bar's Terminal actions on screen (a [ChatBarAction] carrying the
|
||||
/// terminal toggle's label).
|
||||
Finder _barTerminal() => find.byWidgetPredicate(
|
||||
(w) => w is ChatBarAction && w.label == TerminalToggleButton.label,
|
||||
);
|
||||
|
||||
void main() {
|
||||
testWidgets('phone chat list: one terminal entry, no floating bubble', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpAt(tester, '/chat');
|
||||
|
||||
expect(find.byType(TerminalShortcutBubble), findsNothing);
|
||||
expect(_barTerminal(), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('phone open chat: one terminal entry, no floating bubble', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpAt(tester, '/chat/abc123');
|
||||
|
||||
expect(find.byType(TerminalShortcutBubble), findsNothing);
|
||||
expect(_barTerminal(), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_screen.dart';
|
||||
import 'package:pipelines_app/features/terminal/terminal_scope.dart';
|
||||
import 'package:pipelines_app/features/terminal/terminal_toggle_button.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||
import 'package:pipelines_app/ui/layout/section_heading.dart';
|
||||
|
||||
import 'chat_test_harness.dart';
|
||||
import 'fake_chat_gateway.dart';
|
||||
|
||||
/// The chat list's top bar carries Terminal beside New chat and Refresh on a
|
||||
/// narrow layout, so the phone header below it has no floating terminal
|
||||
/// shortcut over its count and collapse chevron.
|
||||
|
||||
class _Actions implements TerminalActions {
|
||||
int toggles = 0;
|
||||
|
||||
@override
|
||||
void toggle() => toggles++;
|
||||
|
||||
@override
|
||||
bool get claimsTabKeys => false;
|
||||
|
||||
@override
|
||||
Future<String?> openAt(ApiGateway gateway, String cwd) async => null;
|
||||
}
|
||||
|
||||
const _terminalIdentifier = 'chat-terminal-toggle';
|
||||
|
||||
Future<void> _pumpList(
|
||||
WidgetTester tester, {
|
||||
required Size size,
|
||||
TerminalActions? actions,
|
||||
}) async {
|
||||
tester.view.physicalSize = size;
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
final gateway = FakeChatGateway()
|
||||
..sessionsReply = {'chat_sessions': sampleSessions()};
|
||||
final list = ChatSessionsScreen(
|
||||
gateway: gateway,
|
||||
onOpen: (_) {},
|
||||
localStore: MemoryChatSessionLocalStore(),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.android),
|
||||
home: MediaQuery(
|
||||
data: MediaQueryData(size: size),
|
||||
child: actions == null
|
||||
? list
|
||||
: TerminalScope(actions: actions, child: list),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('phone: Terminal sits in the top bar beside New chat and '
|
||||
'Refresh, and is the only terminal entry on the list', (tester) async {
|
||||
final actions = _Actions();
|
||||
await _pumpList(tester, size: const Size(430, 900), actions: actions);
|
||||
|
||||
final bar = find.byType(SegmentedBar);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: bar,
|
||||
matching: find.byKey(const Key('chat-new-chat')),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.descendant(of: bar, matching: find.byKey(const Key('chat-refresh'))),
|
||||
findsOneWidget,
|
||||
);
|
||||
final terminal = find.descendant(
|
||||
of: bar,
|
||||
matching: find.bySemanticsIdentifier(_terminalIdentifier),
|
||||
);
|
||||
expect(terminal, findsOneWidget);
|
||||
expect(find.byTooltip(TerminalToggleButton.label), findsOneWidget);
|
||||
expect(find.byType(FloatingActionButton), findsNothing);
|
||||
|
||||
await tester.tap(terminal);
|
||||
await tester.pump();
|
||||
expect(actions.toggles, 1);
|
||||
});
|
||||
|
||||
testWidgets('phone: the top bar sits above the Chats header, which keeps its '
|
||||
'count and collapse chevron clear of it', (tester) async {
|
||||
await _pumpList(tester, size: const Size(430, 900), actions: _Actions());
|
||||
|
||||
final bar = tester.getRect(find.byType(SegmentedBar));
|
||||
final heading = find.descendant(
|
||||
of: find.byKey(const ValueKey('chat-section-Chats')),
|
||||
matching: find.byType(SectionHeading),
|
||||
);
|
||||
expect(heading, findsOneWidget);
|
||||
final headerRect = tester.getRect(heading);
|
||||
expect(
|
||||
headerRect.top,
|
||||
greaterThanOrEqualTo(bar.bottom),
|
||||
reason: 'no top-bar control may cover the section header',
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('a wide layout keeps Terminal on the shell bar, not the list '
|
||||
'bar', (tester) async {
|
||||
await _pumpList(tester, size: const Size(1200, 800), actions: _Actions());
|
||||
|
||||
expect(find.bySemanticsIdentifier(_terminalIdentifier), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('with no terminal surface the list bar has no terminal entry', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpList(tester, size: const Size(430, 900));
|
||||
|
||||
expect(find.bySemanticsIdentifier(_terminalIdentifier), findsNothing);
|
||||
expect(find.byKey(const Key('chat-new-chat')), findsOneWidget);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user