Merge main into open in chat
This commit is contained in:
@@ -2,6 +2,8 @@ part of 'screen.dart';
|
|||||||
|
|
||||||
/// Pane layout, focus and route publication for one Chat destination visit.
|
/// Pane layout, focus and route publication for one Chat destination visit.
|
||||||
mixin _ChatScreenWorkspace on State<ChatScreen> {
|
mixin _ChatScreenWorkspace on State<ChatScreen> {
|
||||||
|
final _sessionsKey = GlobalKey<ChatSessionsScreenState>();
|
||||||
|
|
||||||
Map<String, JsonMap> get _openedSessions;
|
Map<String, JsonMap> get _openedSessions;
|
||||||
ChatComposerFocusRequests get _composerFocus;
|
ChatComposerFocusRequests get _composerFocus;
|
||||||
ChatPaneCommands get _paneCommands;
|
ChatPaneCommands get _paneCommands;
|
||||||
@@ -46,6 +48,10 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
|
|||||||
activeSessionId: selected,
|
activeSessionId: selected,
|
||||||
visibleSessionIds: _visibleSidebarSessions,
|
visibleSessionIds: _visibleSidebarSessions,
|
||||||
onOpen: _openSidebarSession,
|
onOpen: _openSidebarSession,
|
||||||
|
onNewChat: () {
|
||||||
|
final state = _sessionsKey.currentState;
|
||||||
|
if (state != null) unawaited(state.newChat());
|
||||||
|
},
|
||||||
onExpand: () => _setSidebarMode(ChatSidebarMode.expanded),
|
onExpand: () => _setSidebarMode(ChatSidebarMode.expanded),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -278,14 +284,12 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
|
|||||||
String? _publishedWorkspaceSession;
|
String? _publishedWorkspaceSession;
|
||||||
String _workspaceSignature = '';
|
String _workspaceSignature = '';
|
||||||
|
|
||||||
/// Ctrl+Tab cycles the floating chat windows while any is shown, from the
|
/// Ctrl+Tab cycles a single tiled pane through the open chats in sidebar
|
||||||
/// tiling as well (see [ChatWindows]). With none shown it cycles the
|
/// order. The pane is replaced in place so its retained view keeps the
|
||||||
/// retained panes, even when the sidebar or toolbar owns focus, and over a
|
/// transcript and draft. With multiple panes it cycles those panes. A
|
||||||
/// single pane it does nothing: it never brings up a chat that is not
|
/// focused floating chat window handles the key itself (see [ChatWindows]).
|
||||||
/// visible in the tiling. Command+Tab stays with the operating system's
|
/// Command+Tab stays with the operating system's application switcher, and
|
||||||
/// application switcher. While the app's terminal is shown, Ctrl+Tab moves
|
/// the terminal keeps Ctrl+Tab for its own tabs.
|
||||||
/// between its tabs instead. A floating window that is not a chat, or any
|
|
||||||
/// other window holding the keyboard, keeps the key.
|
|
||||||
bool _cycleChatKey(KeyEvent event) {
|
bool _cycleChatKey(KeyEvent event) {
|
||||||
final keyboard = HardwareKeyboard.instance;
|
final keyboard = HardwareKeyboard.instance;
|
||||||
if (event is! KeyDownEvent ||
|
if (event is! KeyDownEvent ||
|
||||||
@@ -298,8 +302,48 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
|
|||||||
!_chatOwnsKeyboard()) {
|
!_chatOwnsKeyboard()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (widget.windows?.raiseTopFromTiling() ?? false) return true;
|
if (!_workspaceVisible || _workspace.paneCount == 0) return false;
|
||||||
if (!_workspaceVisible || _workspace.paneCount < 2) return false;
|
if (_workspace.paneCount == 1) {
|
||||||
|
final pane = _workspace.activePane;
|
||||||
|
if (pane == null) return false;
|
||||||
|
final floating = widget.windows?.floatingSessionIds.toSet() ?? const {};
|
||||||
|
final sessions = chatSessionsShown(
|
||||||
|
_sessionsForSidebar.sessions
|
||||||
|
.where(
|
||||||
|
(row) =>
|
||||||
|
row['closed_at'] == null &&
|
||||||
|
row['closed'] != true &&
|
||||||
|
!floating.contains('${row['id'] ?? ''}'),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
query: '',
|
||||||
|
// Cycling is independent of a collapsed section: the sidebar's
|
||||||
|
// ordering is still used, but every open-chat row remains reachable.
|
||||||
|
isOpen: (_) => true,
|
||||||
|
);
|
||||||
|
final active = sessions.indexWhere(
|
||||||
|
(row) => '${row['id'] ?? ''}' == pane.sessionId,
|
||||||
|
);
|
||||||
|
if (sessions.length < 2 || active < 0) return false;
|
||||||
|
final direction = keyboard.isShiftPressed ? -1 : 1;
|
||||||
|
final target = sessions[(active + direction) % sessions.length];
|
||||||
|
final targetId = '${target['id'] ?? ''}';
|
||||||
|
if (targetId.isEmpty) return false;
|
||||||
|
_workspace.replacePaneSession(pane.id, targetId);
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (!mounted ||
|
||||||
|
!_workspaceVisible ||
|
||||||
|
_workspace.activePane?.sessionId != targetId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final destination = ShellBarScope.maybeOf(context)?.registry.focus;
|
||||||
|
if (destination == null || destination == AppDestination.chat) {
|
||||||
|
_composerFocus.request(targetId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
WidgetsBinding.instance.ensureVisualUpdate();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
final panes = _workspace.panes;
|
final panes = _workspace.panes;
|
||||||
final active = panes.indexWhere(
|
final active = panes.indexWhere(
|
||||||
(pane) => pane.id == _workspace.activePaneId,
|
(pane) => pane.id == _workspace.activePaneId,
|
||||||
|
|||||||
@@ -485,6 +485,7 @@ class _ChatScreenState extends State<ChatScreen>
|
|||||||
// The session list pads its first row by the bar's height itself, so it
|
// The session list pads its first row by the bar's height itself, so it
|
||||||
// scrolls behind the shell's floating bar like the other lists.
|
// scrolls behind the shell's floating bar like the other lists.
|
||||||
final sessions = ChatSessionsScreen(
|
final sessions = ChatSessionsScreen(
|
||||||
|
key: _sessionsKey,
|
||||||
gateway: widget.gateway,
|
gateway: widget.gateway,
|
||||||
embedded: true,
|
embedded: true,
|
||||||
syncToken: widget.syncToken,
|
syncToken: widget.syncToken,
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ class ChatCompactSidebar extends StatelessWidget {
|
|||||||
required this.activeSessionId,
|
required this.activeSessionId,
|
||||||
this.visibleSessionIds = const {},
|
this.visibleSessionIds = const {},
|
||||||
required this.onOpen,
|
required this.onOpen,
|
||||||
|
required this.onNewChat,
|
||||||
required this.onExpand,
|
required this.onExpand,
|
||||||
this.navigation,
|
this.navigation,
|
||||||
});
|
});
|
||||||
@@ -31,6 +32,7 @@ class ChatCompactSidebar extends StatelessWidget {
|
|||||||
final String? activeSessionId;
|
final String? activeSessionId;
|
||||||
final Set<String> visibleSessionIds;
|
final Set<String> visibleSessionIds;
|
||||||
final ValueChanged<JsonMap> onOpen;
|
final ValueChanged<JsonMap> onOpen;
|
||||||
|
final VoidCallback onNewChat;
|
||||||
final VoidCallback onExpand;
|
final VoidCallback onExpand;
|
||||||
final Widget? navigation;
|
final Widget? navigation;
|
||||||
static const width = 72.0;
|
static const width = 72.0;
|
||||||
@@ -135,6 +137,7 @@ class ChatCompactSidebar extends StatelessWidget {
|
|||||||
width: width,
|
width: width,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
|
_button(context, 'New chat', const Icon(Icons.add), onNewChat),
|
||||||
_button(
|
_button(
|
||||||
context,
|
context,
|
||||||
'Expand chat list',
|
'Expand chat list',
|
||||||
|
|||||||
@@ -98,10 +98,10 @@ class ChatSessionsScreen extends StatefulWidget {
|
|||||||
final ChatSectionFolds? folds;
|
final ChatSectionFolds? folds;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ChatSessionsScreen> createState() => _ChatSessionsScreenState();
|
ChatSessionsScreenState createState() => ChatSessionsScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
|
class ChatSessionsScreenState extends State<ChatSessionsScreen> {
|
||||||
late final ChatSessionsController _controller =
|
late final ChatSessionsController _controller =
|
||||||
(widget.controller ??
|
(widget.controller ??
|
||||||
ChatSessionsController(
|
ChatSessionsController(
|
||||||
@@ -233,6 +233,9 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
|
|||||||
if (session != null && mounted) widget.onOpen(session);
|
if (session != null && mounted) widget.onOpen(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Starts the same machine picker and create dialog used by the list action.
|
||||||
|
Future<void> newChat() => _newChat();
|
||||||
|
|
||||||
void _markOpened(JsonMap session) =>
|
void _markOpened(JsonMap session) =>
|
||||||
unawaited(_controller.markOpened(session));
|
unawaited(_controller.markOpened(session));
|
||||||
|
|
||||||
|
|||||||
@@ -237,6 +237,23 @@ class ChatWorkspaceController extends ChangeNotifier {
|
|||||||
_changed();
|
_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Replaces a pane after its caller has already validated [newId]. Unlike
|
||||||
|
/// [replaceSession], this does not ask the window host to show a floating
|
||||||
|
/// chat; keyboard cycling filters those chats before calling this method.
|
||||||
|
void replacePaneSession(String paneId, String newId) {
|
||||||
|
if (newId.isEmpty) return;
|
||||||
|
final pane = panes.where((p) => p.id == paneId).firstOrNull;
|
||||||
|
if (pane == null) return;
|
||||||
|
final existing = panes.where((p) => p.sessionId == newId).firstOrNull;
|
||||||
|
if (existing != null) {
|
||||||
|
close(pane.id);
|
||||||
|
activate(existing.id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_root = _replace(_root!, pane.id, ChatWorkspacePane(pane.id, newId));
|
||||||
|
_changed();
|
||||||
|
}
|
||||||
|
|
||||||
ChatWorkspaceNode _replace(
|
ChatWorkspaceNode _replace(
|
||||||
ChatWorkspaceNode node,
|
ChatWorkspaceNode node,
|
||||||
String id,
|
String id,
|
||||||
|
|||||||
@@ -156,10 +156,10 @@ class KeyboardShortcutRegistry {
|
|||||||
if (!web)
|
if (!web)
|
||||||
const KeyboardShortcutEntry(
|
const KeyboardShortcutEntry(
|
||||||
group: KeyboardShortcutGroup.chat,
|
group: KeyboardShortcutGroup.chat,
|
||||||
action: 'Cycle chat panes and floating chats',
|
action: 'Cycle chats and floating chat panes',
|
||||||
keys: 'Ctrl+Tab, Ctrl+Shift+Tab',
|
keys: 'Ctrl+Tab, Ctrl+Shift+Tab',
|
||||||
caveat:
|
caveat:
|
||||||
'While the terminal is shown, Ctrl+Tab moves between its tabs instead.',
|
'With one tiled pane, cycles open sidebar chats (excluding closed, hidden and floating chats); with multiple panes, cycles panes. While the terminal is shown, Ctrl+Tab moves between its tabs instead.',
|
||||||
),
|
),
|
||||||
const KeyboardShortcutEntry(
|
const KeyboardShortcutEntry(
|
||||||
group: KeyboardShortcutGroup.chat,
|
group: KeyboardShortcutGroup.chat,
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
# Compact sidebar New chat
|
||||||
|
|
||||||
|
The compact chat rail now keeps a Material `+` action above its scrolling
|
||||||
|
session list. Its callback reaches the mounted `ChatSessionsScreenState` and
|
||||||
|
invokes the existing `_newChat` flow, so machine selection, harness discovery,
|
||||||
|
and the create dialog remain shared with the expanded list action.
|
||||||
|
|
||||||
|
## Regression coverage
|
||||||
|
|
||||||
|
- `test/features/chat/ui/sessions/chat_visibility_marker_test.dart`: the rail
|
||||||
|
exposes the `New chat` tooltip and invokes its callback.
|
||||||
|
- `test/features/chat/ui/sessions/chat_machine_creation_test.dart`: the
|
||||||
|
existing expanded-list flow still selects a machine before harness discovery.
|
||||||
|
- `test/features/chat/ui/sessions/chat_sessions_floating_bar_test.dart`: the
|
||||||
|
expanded list still has exactly one New chat action in its bar.
|
||||||
|
|
||||||
|
## Verification
|
||||||
|
|
||||||
|
- `tool/memwatch/full.sh 'test/features/chat/ui/sessions/chat_visibility_marker_test.dart test/features/chat/ui/sessions/chat_state_legibility_test.dart test/features/chat/ui/sessions/chat_machine_creation_test.dart test/features/chat/ui/sessions/chat_sessions_floating_bar_test.dart'`: 10 passed.
|
||||||
|
- `tool/analyze.sh`: clean.
|
||||||
|
- Browser captures: desktop 1600x1000 compact rail in light and dark themes,
|
||||||
|
including the New chat tooltip, are in the shared artifact
|
||||||
|
`public/chat-compact-sidebar/`.
|
||||||
@@ -41,10 +41,11 @@ every destination and come back at app start without Chat being opened.
|
|||||||
takes the keyboard. Open order is the order the windows were opened (a
|
takes the keyboard. Open order is the order the windows were opened (a
|
||||||
restored window keeps its saved place), so a raise does not change the
|
restored window keeps its saved place), so a raise does not change the
|
||||||
cycle; the stacking order does change on a raise.
|
cycle; the stacking order does change on a raise.
|
||||||
- **With no chat window shown**, Ctrl+Tab cycles the tiled panes only and
|
- **With no chat window focused**, Ctrl+Tab cycles the tiled panes and the
|
||||||
the keys focus the chosen pane's composer. With one tiled pane it does
|
keys focus the chosen pane's composer. With exactly one tiled pane it
|
||||||
nothing. A chat shown before, or a minimised or floating chat, is never
|
cycles all open chats in sidebar order, replacing that pane while keeping
|
||||||
swapped in.
|
its transcript and draft; closed, hidden-on-this-device and floating
|
||||||
|
chats are skipped. With two or more panes it cycles the panes only.
|
||||||
- Command+Tab stays with the system. While the terminal claims tab keys
|
- Command+Tab stays with the system. While the terminal claims tab keys
|
||||||
(shown) Ctrl+Tab switches terminal tabs. A keyboard held by another window
|
(shown) Ctrl+Tab switches terminal tabs. A keyboard held by another window
|
||||||
(a run, terminal) is left to that window. Alt+` (`windowCycleShortcut`)
|
(a run, terminal) is left to that window. Alt+` (`windowCycleShortcut`)
|
||||||
@@ -80,36 +81,33 @@ every destination and come back at app start without Chat being opened.
|
|||||||
|
|
||||||
## Checks
|
## Checks
|
||||||
|
|
||||||
- Focused, 2026-11-12, `tool/memwatch/full.sh` over
|
- Focused, 2026-11-13, `tool/memwatch/full.sh` over
|
||||||
`test/features/chat/chat_floating_pane_test.dart`,
|
`test/features/chat/chat_floating_pane_test.dart`,
|
||||||
`test/features/chat/chat_keyboard_focus_test.dart`,
|
`test/features/chat/chat_keyboard_focus_test.dart`,
|
||||||
`test/features/chat/chat_control_tab_test.dart`,
|
`test/features/chat/chat_control_tab_test.dart`,
|
||||||
`test/features/chat/windows/chat_windows_test.dart` and
|
`test/features/chat/windows/chat_windows_test.dart`,
|
||||||
`test/features/terminal/terminal_chat_tab_test.dart`: 38 passed, 0 failed.
|
`test/features/terminal/terminal_chat_tab_test.dart`, the keyboard
|
||||||
Related Ctrl+Tab users, `tool/memwatch/full.sh` over
|
shortcuts registry test and related Ctrl+Tab users: 70 passed, 0 failed.
|
||||||
|
This included `tool/memwatch/full.sh` over
|
||||||
`test/shell/destination_shortcuts_test.dart`,
|
`test/shell/destination_shortcuts_test.dart`,
|
||||||
`test/shell/tab_history_back_test.dart`, `test/shell/search_escape_test.dart`
|
`test/shell/tab_history_back_test.dart`, `test/shell/search_escape_test.dart`
|
||||||
and `test/features/chat/shell/chat_shell_terminal_test.dart`: 26 passed,
|
and `test/features/chat/shell/chat_shell_terminal_test.dart`: 26 passed,
|
||||||
0 failed.
|
0 failed.
|
||||||
- New in the first file: Ctrl+Tab and Ctrl+Shift+Tab over three floating chats
|
- Floating-window Ctrl+Tab and Ctrl+Shift+Tab over three floating chats cycle
|
||||||
cycle in open order, not stacking order (order, wrap, composer focus,
|
in open order, not stacking order (order, wrap, composer focus, Command+Tab
|
||||||
Command+Tab ignored). With the tiling focused Ctrl+Tab goes to the top-most
|
ignored). With the tiling focused, a single tiled pane cycles the open,
|
||||||
shown window and leaves the panes alone; with one shown window it does
|
device-visible sidebar chats and skips closed, hidden and floating chats;
|
||||||
nothing; with the window minimised the panes cycle and the window stays
|
multiple tiled panes cycle panes. A terminal that claims tab keys keeps
|
||||||
hidden. With one tiled pane and a minimised chat, Ctrl+Tab does nothing and
|
Ctrl+Tab over a focused chat window.
|
||||||
shows nothing. A terminal that claims tab keys keeps Ctrl+Tab over a focused
|
- Changed: a single tiled pane now cycles the open, device-visible sidebar
|
||||||
chat window.
|
chats in list order, skips closed, hidden-on-this-device and floating chats,
|
||||||
- Removed: the single-pane recent-chat swap (the chat shown before, opened
|
wraps in both directions, and focuses the replacement composer. Multiple
|
||||||
back into the pane), with its tests in `chat_keyboard_focus_test.dart`. A
|
panes and focused floating windows retain their existing cycles.
|
||||||
single pane with no shown window now does nothing on Ctrl+Tab, so
|
|
||||||
`chat_control_tab_test.dart` no longer expects the composer to take focus
|
|
||||||
from the sidebar.
|
|
||||||
- `tool/analyze.sh` on `lib/features/chat` and the three chat test files:
|
- `tool/analyze.sh` on `lib/features/chat` and the three chat test files:
|
||||||
clean.
|
clean.
|
||||||
- Affected states: two or more floating chats; one floating chat shown;
|
- Affected states: a single tiled pane with open chats; shown or minimised
|
||||||
floating chat minimised with one tiled pane; tiling focused with windows
|
floating chats; two or more tiled panes; a focused floating window; the
|
||||||
shown and with none; a window focused; the terminal shown (claimed);
|
terminal shown (claimed); Command+Tab.
|
||||||
Command+Tab.
|
|
||||||
- Not covered: the terminal's own tab switching (the test app has no terminal
|
- Not covered: the terminal's own tab switching (the test app has no terminal
|
||||||
surface), real browser or device keys, and captures (ui-review's).
|
surface), real browser or device keys, and captures (ui-review's).
|
||||||
- Observed, not changed: in the widget harness, floating from a pane's More
|
- Observed, not changed: in the widget harness, floating from a pane's More
|
||||||
|
|||||||
@@ -12,12 +12,17 @@ import 'package:pipelines_app/shell/destination.dart';
|
|||||||
import 'conversation/chat_thread_fixtures.dart';
|
import 'conversation/chat_thread_fixtures.dart';
|
||||||
|
|
||||||
class _Gateway extends FakeChatGateway {
|
class _Gateway extends FakeChatGateway {
|
||||||
|
_Gateway({this.rows = const ['a', 'b', 'c']});
|
||||||
|
|
||||||
|
final List<String> rows;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<JsonMap> call(String type, [JsonMap fields = const {}]) {
|
Future<JsonMap> call(String type, [JsonMap fields = const {}]) {
|
||||||
if (type == 'chat_sessions') {
|
if (type == 'chat_sessions') {
|
||||||
return Future.value({
|
return Future.value({
|
||||||
'chat_sessions': [
|
'chat_sessions': [
|
||||||
for (final id in ['a', 'b', 'c']) {'id': id, 'title': 'Chat $id'},
|
for (final id in rows)
|
||||||
|
{'id': id, 'title': 'Chat $id', if (id == 'closed') 'closed_at': 1},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -57,12 +62,16 @@ Future<void> _chord(
|
|||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _setup(WidgetTester tester, {bool open = true}) async {
|
Future<void> _setup(
|
||||||
|
WidgetTester tester, {
|
||||||
|
bool open = true,
|
||||||
|
List<String> rows = const ['a', 'b', 'c'],
|
||||||
|
}) async {
|
||||||
SharedPreferences.setMockInitialValues({});
|
SharedPreferences.setMockInitialValues({});
|
||||||
tester.view.physicalSize = const Size(1800, 1000);
|
tester.view.physicalSize = const Size(1800, 1000);
|
||||||
tester.view.devicePixelRatio = 1;
|
tester.view.devicePixelRatio = 1;
|
||||||
addTearDown(tester.view.reset);
|
addTearDown(tester.view.reset);
|
||||||
final gateway = _Gateway()..history = (_) async => chatPage([]);
|
final gateway = _Gateway(rows: rows)..history = (_) async => chatPage([]);
|
||||||
addTearDown(gateway.close);
|
addTearDown(gateway.close);
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
@@ -133,20 +142,44 @@ void main() {
|
|||||||
await tester.pumpWidget(const SizedBox.shrink());
|
await tester.pumpWidget(const SizedBox.shrink());
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('single pane with no shown window does nothing; empty workspace '
|
testWidgets(
|
||||||
'does not consume', (tester) async {
|
'single pane cycles list chats; empty workspace does not consume',
|
||||||
await _setup(tester, open: false);
|
(tester) async {
|
||||||
await _chord(tester);
|
await _setup(tester, open: false);
|
||||||
expect(find.byType(ChatWorkspace), findsNothing);
|
await _chord(tester);
|
||||||
|
expect(find.byType(ChatWorkspace), findsNothing);
|
||||||
|
await tester.tap(find.byKey(const Key('chat-row-a')));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
_focusSidebar(tester);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await _chord(tester);
|
||||||
|
expect(find.byType(ChatWorkspace), findsOneWidget);
|
||||||
|
expect(_workspace(tester).paneCount, 1);
|
||||||
|
expect(_workspace(tester).activePane?.sessionId, 'b');
|
||||||
|
expect(_editable(tester, 'b').focusNode.hasPrimaryFocus, isTrue);
|
||||||
|
await tester.pumpWidget(const SizedBox.shrink());
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
testWidgets('single pane skips closed and hidden-on-this-device chats', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
await _setup(tester, open: false, rows: ['a', 'hidden', 'c', 'closed']);
|
||||||
|
await tester.tap(_actions('hidden'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.text('Hide on this device'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
await tester.tap(find.byKey(const Key('chat-row-a')));
|
await tester.tap(find.byKey(const Key('chat-row-a')));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
_focusSidebar(tester);
|
_focusSidebar(tester);
|
||||||
await tester.pumpAndSettle();
|
|
||||||
await _chord(tester);
|
await _chord(tester);
|
||||||
expect(find.byType(ChatWorkspace), findsOneWidget);
|
expect(_workspace(tester).activePane?.sessionId, 'c');
|
||||||
expect(_workspace(tester).paneCount, 1);
|
await _chord(tester);
|
||||||
expect(_editable(tester, 'a').focusNode.hasPrimaryFocus, isFalse);
|
expect(_workspace(tester).activePane?.sessionId, 'a');
|
||||||
expect(_editable(tester, 'a').controller.text, isEmpty);
|
|
||||||
|
await _chord(tester, reverse: true);
|
||||||
|
expect(_workspace(tester).activePane?.sessionId, 'c');
|
||||||
await tester.pumpWidget(const SizedBox.shrink());
|
await tester.pumpWidget(const SizedBox.shrink());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -592,10 +592,8 @@ void main() {
|
|||||||
await app.stop(tester);
|
await app.stop(tester);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('with the tiling focused Ctrl+Tab goes to the top-most shown '
|
testWidgets('with the tiling focused Ctrl+Tab cycles the single pane chat '
|
||||||
'window, and cycles the panes only when no window is shown', (
|
'list and cycles panes when there are multiple panes', (tester) async {
|
||||||
tester,
|
|
||||||
) async {
|
|
||||||
await _saved('a', 'b', 'c');
|
await _saved('a', 'b', 'c');
|
||||||
final app = _App(_Store());
|
final app = _App(_Store());
|
||||||
await app.start(tester);
|
await app.start(tester);
|
||||||
@@ -603,20 +601,20 @@ void main() {
|
|||||||
expect(app.floating, ['c']);
|
expect(app.floating, ['c']);
|
||||||
final controller = _workspace(tester);
|
final controller = _workspace(tester);
|
||||||
|
|
||||||
// A window is shown: from the tiling, Ctrl+Tab takes the keyboard to it
|
// A shown floating chat is skipped while the single tiled pane cycles the
|
||||||
// and the panes stay where they are.
|
// remaining open chats.
|
||||||
await tester.tapAt(tester.getCenter(_input('a')));
|
await tester.tapAt(tester.getCenter(_input('a')));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(controller.activePane?.sessionId, 'a');
|
expect(controller.activePane?.sessionId, 'a');
|
||||||
await _tab(tester);
|
await _tab(tester);
|
||||||
expect(controller.activePane?.sessionId, 'a');
|
expect(controller.activePane?.sessionId, 'b');
|
||||||
expect(_composerFocused(tester, 'c'), isTrue);
|
expect(_composerFocused(tester, 'b'), isTrue);
|
||||||
expect(app.floating, ['c']);
|
expect(app.floating, ['c']);
|
||||||
|
|
||||||
// A single shown window has nothing to cycle to.
|
// It wraps back to the other non-floating chat.
|
||||||
await _tab(tester);
|
await _tab(tester);
|
||||||
expect(controller.activePane?.sessionId, 'a');
|
expect(controller.activePane?.sessionId, 'a');
|
||||||
expect(_composerFocused(tester, 'c'), isTrue);
|
expect(_composerFocused(tester, 'a'), isTrue);
|
||||||
expect(app.floating, ['c']);
|
expect(app.floating, ['c']);
|
||||||
|
|
||||||
// No window shown: the panes cycle and the hidden window stays hidden.
|
// No window shown: the panes cycle and the hidden window stays hidden.
|
||||||
|
|||||||
@@ -150,28 +150,25 @@ void main() {
|
|||||||
await tester.pumpWidget(const SizedBox.shrink());
|
await tester.pumpWidget(const SizedBox.shrink());
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Control Tab over one pane does nothing: it never brings up '
|
testWidgets('Control Tab over one pane cycles the sidebar chats in both '
|
||||||
'another chat', (tester) async {
|
'directions', (tester) async {
|
||||||
await _setup(tester);
|
await _setup(tester);
|
||||||
await _openRow(tester, 'a');
|
await _openRow(tester, 'a');
|
||||||
final workspace = _workspace(tester);
|
final workspace = _workspace(tester);
|
||||||
await _controlTab(tester);
|
|
||||||
expect(workspace.activePane?.sessionId, 'a');
|
|
||||||
expect(_editable(tester, 'a').focusNode.hasPrimaryFocus, isFalse);
|
|
||||||
|
|
||||||
// Opening b replaces the lone pane; a is no longer shown anywhere.
|
|
||||||
await _openRow(tester, 'b');
|
|
||||||
await tester.enterText(_input('b'), 'Draft B');
|
|
||||||
await _focusSidebar(tester);
|
await _focusSidebar(tester);
|
||||||
for (final shift in [false, true]) {
|
for (final id in ['b', 'c', 'a']) {
|
||||||
await _controlTab(tester, shift: shift);
|
await _controlTab(tester);
|
||||||
expect(workspace.paneCount, 1);
|
expect(workspace.activePane?.sessionId, id);
|
||||||
expect(workspace.activePane?.sessionId, 'b');
|
expect(_editable(tester, id).focusNode.hasPrimaryFocus, isTrue);
|
||||||
expect(_editable(tester, 'b').focusNode.hasPrimaryFocus, isFalse);
|
}
|
||||||
expect(_editable(tester, 'b').controller.text, 'Draft B');
|
await _focusSidebar(tester);
|
||||||
|
for (final id in ['c', 'b', 'a']) {
|
||||||
|
await _controlTab(tester, shift: true);
|
||||||
|
expect(workspace.activePane?.sessionId, id);
|
||||||
|
expect(_editable(tester, id).focusNode.hasPrimaryFocus, isTrue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Two panes cycle the panes, not the history.
|
// Two panes still cycle panes, not the chat list.
|
||||||
await _openRow(tester, 'c');
|
await _openRow(tester, 'c');
|
||||||
await tester.tap(_actions('a'));
|
await tester.tap(_actions('a'));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ void main() {
|
|||||||
activeSessionId: null,
|
activeSessionId: null,
|
||||||
visibleSessionIds: const {'a'},
|
visibleSessionIds: const {'a'},
|
||||||
onOpen: (_) {},
|
onOpen: (_) {},
|
||||||
|
onNewChat: () {},
|
||||||
onExpand: () {},
|
onExpand: () {},
|
||||||
navigation: const Text('Destinations'),
|
navigation: const Text('Destinations'),
|
||||||
),
|
),
|
||||||
@@ -139,6 +140,7 @@ void main() {
|
|||||||
activeSessionId: 'a',
|
activeSessionId: 'a',
|
||||||
visibleSessionIds: const {'a', 'b'},
|
visibleSessionIds: const {'a', 'b'},
|
||||||
onOpen: (_) {},
|
onOpen: (_) {},
|
||||||
|
onNewChat: () {},
|
||||||
onExpand: () {},
|
onExpand: () {},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ void main() {
|
|||||||
await controller.refresh();
|
await controller.refresh();
|
||||||
final folds = ChatSectionFolds();
|
final folds = ChatSectionFolds();
|
||||||
addTearDown(folds.dispose);
|
addTearDown(folds.dispose);
|
||||||
|
var newChatPressed = false;
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
home: Scaffold(
|
home: Scaffold(
|
||||||
@@ -116,12 +117,16 @@ void main() {
|
|||||||
activeSessionId: 'a',
|
activeSessionId: 'a',
|
||||||
visibleSessionIds: const {'a', 'b'},
|
visibleSessionIds: const {'a', 'b'},
|
||||||
onOpen: (_) {},
|
onOpen: (_) {},
|
||||||
|
onNewChat: () => newChatPressed = true,
|
||||||
onExpand: () {},
|
onExpand: () {},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.byTooltip('New chat'), findsOneWidget);
|
||||||
|
await tester.tap(find.byTooltip('New chat'));
|
||||||
|
expect(newChatPressed, isTrue);
|
||||||
expect(find.byTooltip('Expand chat list'), findsOneWidget);
|
expect(find.byTooltip('Expand chat list'), findsOneWidget);
|
||||||
expect(edge(tester, 'a').width, 10);
|
expect(edge(tester, 'a').width, 10);
|
||||||
expect(edge(tester, 'b').width, 3);
|
expect(edge(tester, 'b').width, 3);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ const _implemented = [
|
|||||||
'Stop a running chat',
|
'Stop a running chat',
|
||||||
'Focus the neighbouring chat pane',
|
'Focus the neighbouring chat pane',
|
||||||
'Move the active chat pane',
|
'Move the active chat pane',
|
||||||
'Cycle chat panes and floating chats',
|
'Cycle chats and floating chat panes',
|
||||||
'Resize panes with a focused divider',
|
'Resize panes with a focused divider',
|
||||||
'Scroll a wide transcript block',
|
'Scroll a wide transcript block',
|
||||||
'Show or hide floating chats',
|
'Show or hide floating chats',
|
||||||
|
|||||||
Reference in New Issue
Block a user