Expose pane actions in chat list menu
Share the open chat pane menu choices with session rows so list actions use the same handlers and target the selected chat. Add command routing, pane movement support, and focused coverage for wide and narrow layouts.
This commit is contained in:
@@ -7,6 +7,7 @@ import '../../shell/detail_page.dart';
|
||||
import 'chat_runtime.dart';
|
||||
import 'conversation/chat_thread_view.dart';
|
||||
import 'conversation/composer_focus_request.dart';
|
||||
import 'workspace/chat_pane_commands.dart';
|
||||
|
||||
/// Where an open chat is shown and what that place alone decides: its Back,
|
||||
/// its pane menu, whether it takes pastes, and what follows `/new` and
|
||||
@@ -22,6 +23,7 @@ class ChatPanePlacement {
|
||||
this.pasteTarget = false,
|
||||
this.ownsPasteWhenFocused = false,
|
||||
this.paneControls,
|
||||
this.paneCommands,
|
||||
this.onNextChat,
|
||||
});
|
||||
|
||||
@@ -49,6 +51,9 @@ class ChatPanePlacement {
|
||||
|
||||
/// The pane menu's choices, built in the pane's own context.
|
||||
final List<Widget> Function(BuildContext paneContext)? paneControls;
|
||||
|
||||
/// Choices the chat list hands to this chat's conversation to run.
|
||||
final ChatPaneCommands? paneCommands;
|
||||
final VoidCallback? onNextChat;
|
||||
}
|
||||
|
||||
@@ -103,6 +108,7 @@ Widget buildChatPaneContent({
|
||||
ownsPasteWhenFocused: placement.ownsPasteWhenFocused,
|
||||
showBackButton: placement.showBackButton,
|
||||
paneControls: placement.paneControls?.call(context) ?? const [],
|
||||
paneCommands: placement.paneCommands,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
part of 'screen.dart';
|
||||
|
||||
/// The move choices in the pane menu's order, with their pane label.
|
||||
const _paneMoveChoices = [
|
||||
(direction: ChatPaneDirection.up, action: SessionPaneAction.moveUp),
|
||||
(direction: ChatPaneDirection.down, action: SessionPaneAction.moveDown),
|
||||
(direction: ChatPaneDirection.left, action: SessionPaneAction.moveLeft),
|
||||
(direction: ChatPaneDirection.right, action: SessionPaneAction.moveRight),
|
||||
];
|
||||
|
||||
String _paneMoveLabel(ChatPaneDirection direction) => switch (direction) {
|
||||
ChatPaneDirection.up => 'Move up',
|
||||
ChatPaneDirection.down => 'Move down',
|
||||
ChatPaneDirection.left => 'Move left',
|
||||
ChatPaneDirection.right => 'Move right',
|
||||
};
|
||||
|
||||
/// The chat list's row menu reaches the open panes' More choices. Each choice
|
||||
/// is offered with the pane's own label and visibility, and runs the pane's
|
||||
/// own handler for the row's chat, which is opened first.
|
||||
mixin _ChatScreenPaneMenu on State<ChatScreen>, _ChatScreenWorkspace
|
||||
implements SessionPaneMenu {
|
||||
ChatPaneCommands get _paneCommands;
|
||||
void _openBySelection(JsonMap session);
|
||||
|
||||
/// The open pane showing [id]'s chat, or null when it is not open.
|
||||
ChatWorkspacePane? _paneShowing(String id) {
|
||||
for (final pane in _workspace.panes) {
|
||||
if (pane.sessionId == id) return pane;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
List<SessionPaneChoice> choicesFor(BuildContext context, JsonMap session) {
|
||||
final id = '${session['id'] ?? ''}';
|
||||
final panes = _workspace.paneCount;
|
||||
final tiled = panes > 1;
|
||||
final pane = _paneShowing(id);
|
||||
// Moves exist only while the panes are tiled (the pane's own rule); the
|
||||
// targets are absent otherwise.
|
||||
final moves = pane == null ? null : _paneMoveTargets[pane.id];
|
||||
final directory = '${session['directory'] ?? ''}'.trim();
|
||||
return [
|
||||
(
|
||||
action: SessionPaneAction.addPane,
|
||||
label: 'Add chat pane',
|
||||
enabled: true,
|
||||
),
|
||||
if (tiled)
|
||||
(
|
||||
action: SessionPaneAction.openChats,
|
||||
label: 'Open chats ($panes)',
|
||||
enabled: true,
|
||||
),
|
||||
if (tiled && showsListBesideDetail(context))
|
||||
(
|
||||
action: SessionPaneAction.centerStage,
|
||||
label: chatCenterStageLabel(ChatCenterStageController.instance),
|
||||
enabled: true,
|
||||
),
|
||||
if (moves != null)
|
||||
for (final move in _paneMoveChoices)
|
||||
(
|
||||
action: move.action,
|
||||
label:
|
||||
'${_paneMoveLabel(move.direction)} '
|
||||
'(${chatPaneMoveShortcutLabel(move.direction)})',
|
||||
enabled: moves[move.direction] != null,
|
||||
),
|
||||
if (pane != null && tiled)
|
||||
(
|
||||
action: SessionPaneAction.closePane,
|
||||
label: 'Close pane',
|
||||
enabled: true,
|
||||
),
|
||||
if (WindowScope.maybeOf(context) != null)
|
||||
(
|
||||
action: SessionPaneAction.chatDetails,
|
||||
label: 'Chat details',
|
||||
enabled: true,
|
||||
),
|
||||
(action: SessionPaneAction.files, label: 'Files', enabled: true),
|
||||
(
|
||||
action: SessionPaneAction.runCommand,
|
||||
label: chatShellRunActionLabel,
|
||||
enabled: true,
|
||||
),
|
||||
if (_paneCommands.hasFinished(id))
|
||||
(
|
||||
action: SessionPaneAction.dismissFinished,
|
||||
label: chatShellDismissAllLabel,
|
||||
enabled: true,
|
||||
),
|
||||
if (TerminalScope.maybeOf(context) != null && directory.isNotEmpty)
|
||||
(
|
||||
action: SessionPaneAction.openTerminal,
|
||||
label: terminalOpenActionLabel,
|
||||
enabled: true,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
@override
|
||||
void run(BuildContext context, JsonMap session, SessionPaneAction action) {
|
||||
final id = '${session['id'] ?? ''}';
|
||||
if (id.isEmpty) return;
|
||||
switch (action) {
|
||||
case SessionPaneAction.addPane:
|
||||
_openBySelection(session);
|
||||
_addPane(context);
|
||||
case SessionPaneAction.openChats:
|
||||
_openBySelection(session);
|
||||
_pickPane(context);
|
||||
case SessionPaneAction.centerStage:
|
||||
_openBySelection(session);
|
||||
ChatCenterStageController.instance.toggle();
|
||||
case SessionPaneAction.moveUp:
|
||||
_moveRowPane(session, ChatPaneDirection.up);
|
||||
case SessionPaneAction.moveDown:
|
||||
_moveRowPane(session, ChatPaneDirection.down);
|
||||
case SessionPaneAction.moveLeft:
|
||||
_moveRowPane(session, ChatPaneDirection.left);
|
||||
case SessionPaneAction.moveRight:
|
||||
_moveRowPane(session, ChatPaneDirection.right);
|
||||
case SessionPaneAction.closePane:
|
||||
for (final pane
|
||||
in _workspace.panes
|
||||
.where((pane) => pane.sessionId == id)
|
||||
.toList()) {
|
||||
_closePane(pane.id);
|
||||
}
|
||||
case SessionPaneAction.chatDetails:
|
||||
_requestInOpenChat(session, ChatPaneCommand.details);
|
||||
case SessionPaneAction.files:
|
||||
_requestInOpenChat(session, ChatPaneCommand.files);
|
||||
case SessionPaneAction.runCommand:
|
||||
_requestInOpenChat(session, ChatPaneCommand.runCommand);
|
||||
case SessionPaneAction.openTerminal:
|
||||
_requestInOpenChat(session, ChatPaneCommand.openTerminal);
|
||||
case SessionPaneAction.dismissFinished:
|
||||
_requestInOpenChat(session, ChatPaneCommand.dismissFinished);
|
||||
}
|
||||
}
|
||||
|
||||
/// Swaps the pane showing [session]'s chat with its neighbour across
|
||||
/// [direction], as that pane's own move does. The chat is already open here,
|
||||
/// so nothing is opened first.
|
||||
void _moveRowPane(JsonMap session, ChatPaneDirection direction) {
|
||||
final pane = _paneShowing('${session['id'] ?? ''}');
|
||||
if (pane == null) return;
|
||||
final target = _paneMoveTargets[pane.id]?[direction];
|
||||
if (target == null) return;
|
||||
_movePane(pane.id, target);
|
||||
}
|
||||
|
||||
/// Opens [session] and hands [command] to its conversation, which runs it
|
||||
/// once built.
|
||||
void _requestInOpenChat(JsonMap session, ChatPaneCommand command) {
|
||||
_openBySelection(session);
|
||||
_paneCommands.request('${session['id'] ?? ''}', command);
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,15 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
|
||||
|
||||
Set<String> _visibleWorkspaceSessions = const {};
|
||||
|
||||
/// Each pane's move targets as the workspace last laid them out. Read when
|
||||
/// the chat list's row menu opens; it needs no rebuild of its own.
|
||||
Map<String, Map<ChatPaneDirection, String>> _paneMoveTargets = const {};
|
||||
void _paneMoveTargetsChanged(
|
||||
Map<String, Map<ChatPaneDirection, String>> targets,
|
||||
) {
|
||||
_paneMoveTargets = targets;
|
||||
}
|
||||
|
||||
void _workspaceVisibilityChanged(Set<String> sessions) {
|
||||
if (!mounted || setEquals(_visibleWorkspaceSessions, sessions)) return;
|
||||
setState(() => _visibleWorkspaceSessions = Set.unmodifiable(sessions));
|
||||
@@ -318,6 +327,7 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
|
||||
chatColorShade(context, chatSessionColor(_rowFor(pane.sessionId))),
|
||||
controller: _workspace,
|
||||
onVisibleSessionIdsChanged: _workspaceVisibilityChanged,
|
||||
onMoveTargetsChanged: _paneMoveTargetsChanged,
|
||||
shortcutsEnabled: _workspaceVisible,
|
||||
singlePane: !showsListBesideDetail(context),
|
||||
mobilePeeks: true,
|
||||
|
||||
@@ -20,6 +20,7 @@ import '../../../core/transport/pipelines_client.dart'
|
||||
import '../domain/chat_shown_items.dart';
|
||||
import '../domain/chat_transcript.dart';
|
||||
import '../domain/chat_turn_diffs.dart';
|
||||
import '../workspace/chat_pane_commands.dart';
|
||||
import '../ui/sessions/chat_color_picker.dart';
|
||||
import '../ui/sessions/session_actions.dart';
|
||||
import '../ui/sessions/session_row_content.dart';
|
||||
@@ -118,6 +119,7 @@ class ChatThreadView extends StatefulWidget {
|
||||
this.onColorSelected,
|
||||
this.onNextChat,
|
||||
this.paneControls = const [],
|
||||
this.paneCommands,
|
||||
this.sidebarControl,
|
||||
this.showBackButton,
|
||||
this.useNativeBack = false,
|
||||
@@ -130,6 +132,9 @@ class ChatThreadView extends StatefulWidget {
|
||||
/// Retained for existing callers; Next chat is no longer shown in the header.
|
||||
final VoidCallback? onNextChat;
|
||||
final List<Widget> paneControls;
|
||||
|
||||
/// The chat list's requests for this chat, run as the More menu runs them.
|
||||
final ChatPaneCommands? paneCommands;
|
||||
final Widget? sidebarControl;
|
||||
final bool? showBackButton;
|
||||
final bool useNativeBack;
|
||||
@@ -214,7 +219,8 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
/// The operator's own shell commands in this chat (see `../shell/`).
|
||||
late ChatShellRunsController _shellRuns = _attachShellRuns();
|
||||
ChatShellRunsController _attachShellRuns() =>
|
||||
ChatShellRunsController(widget.gateway, widget.sessionId);
|
||||
ChatShellRunsController(widget.gateway, widget.sessionId)
|
||||
..addListener(_reportFinishedRuns);
|
||||
late ChatRowKeys _rowKeys = ChatRowKeys();
|
||||
final _sentEntrances = ChatSentEntrances();
|
||||
final _rowWidgets = ChatRowWidgets();
|
||||
@@ -284,8 +290,51 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
if (mounted) _openFilesSheet();
|
||||
});
|
||||
}
|
||||
_takeCommands();
|
||||
}
|
||||
|
||||
/// Runs each request the chat list made for this chat, as the More menu does.
|
||||
/// Waits until the saved Files state has loaded: Files is a toggle, and a
|
||||
/// toggle taken before that load would be overwritten by it.
|
||||
void _takeCommands() {
|
||||
final commands = widget.paneCommands;
|
||||
if (commands == null || !mounted || !_filesPrefsLoaded) return;
|
||||
for (
|
||||
var command = commands.take(widget.sessionId);
|
||||
command != null;
|
||||
command = commands.take(widget.sessionId)
|
||||
) {
|
||||
switch (command) {
|
||||
case ChatPaneCommand.details:
|
||||
unawaited(_openInfo());
|
||||
case ChatPaneCommand.files:
|
||||
_toggleFiles();
|
||||
case ChatPaneCommand.runCommand:
|
||||
_runShellFromMenu();
|
||||
case ChatPaneCommand.openTerminal:
|
||||
_openTerminalFromMenu();
|
||||
case ChatPaneCommand.dismissFinished:
|
||||
_dismissFinishedShellRuns();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Tells the chat list whether this chat holds finished command runs.
|
||||
void _reportFinishedRuns() => widget.paneCommands?.setFinished(
|
||||
widget.sessionId,
|
||||
_shellRuns.finishedIds.isNotEmpty,
|
||||
);
|
||||
|
||||
void _openTerminalFromMenu() => openInTerminal(
|
||||
context,
|
||||
widget.gateway,
|
||||
'${widget.session?['directory'] ?? ''}'.trim(),
|
||||
onRefused: _terminalRefused,
|
||||
);
|
||||
|
||||
void _terminalRefused(String refusal) =>
|
||||
_showCommandNotice("Couldn't open a terminal: $refusal", failed: true);
|
||||
|
||||
void _toggleFiles() {
|
||||
final next = !_filesVisible;
|
||||
if (!mounted) return;
|
||||
@@ -585,11 +634,21 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
_savedPosition = widget.scrollPositions?.read(widget.sessionId);
|
||||
_adoptCachedTranscript();
|
||||
_seedCommandNotice();
|
||||
widget.paneCommands?.addListener(_takeCommands);
|
||||
_reportFinishedRuns();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) _takeCommands();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant ChatThreadView oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (!identical(oldWidget.paneCommands, widget.paneCommands)) {
|
||||
oldWidget.paneCommands?.removeListener(_takeCommands);
|
||||
oldWidget.paneCommands?.setFinished(oldWidget.sessionId, false);
|
||||
widget.paneCommands?.addListener(_takeCommands);
|
||||
}
|
||||
if (oldWidget.gateway != widget.gateway ||
|
||||
oldWidget.sessionId != widget.sessionId) {
|
||||
// The conversation being left keeps the position the operator chose.
|
||||
@@ -604,12 +663,19 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
_composer.dispose();
|
||||
_shellRuns.dispose();
|
||||
_shellRuns = _attachShellRuns();
|
||||
oldWidget.paneCommands?.setFinished(oldWidget.sessionId, false);
|
||||
_reportFinishedRuns();
|
||||
_files.removeListener(_persistFilesPreferences);
|
||||
_files.dispose();
|
||||
_files = _newFilesController()..addListener(_persistFilesPreferences);
|
||||
_filesVisible = false;
|
||||
_filesPrefsLoaded = false;
|
||||
_reportedCenterStageFilesWidth = null;
|
||||
unawaited(_loadFilesPreferences());
|
||||
// A request the list made for this chat before the pane showed it.
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) _takeCommands();
|
||||
});
|
||||
_closed = false;
|
||||
_controller = _attach();
|
||||
_composer = _attachComposer();
|
||||
@@ -676,6 +742,8 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
void dispose() {
|
||||
_persistPosition();
|
||||
_saveTranscript(widget.transcripts, widget.sessionId);
|
||||
widget.paneCommands?.removeListener(_takeCommands);
|
||||
widget.paneCommands?.setFinished(widget.sessionId, false);
|
||||
_scroll.dispose();
|
||||
_composer.dispose();
|
||||
_controller.dispose();
|
||||
@@ -1427,10 +1495,7 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
||||
context,
|
||||
gateway: widget.gateway,
|
||||
directory: directory,
|
||||
onRefused: (refusal) => _showCommandNotice(
|
||||
"Couldn't open a terminal: $refusal",
|
||||
failed: true,
|
||||
),
|
||||
onRefused: _terminalRefused,
|
||||
),
|
||||
],
|
||||
controls: [
|
||||
|
||||
@@ -20,6 +20,12 @@ import 'package:flutter/services.dart';
|
||||
|
||||
import '../../core/api_gateway.dart';
|
||||
import '../../core/servers/server_scope.dart';
|
||||
import '../../shell/windows/window_scope.dart';
|
||||
import 'shell/chat_shell_command.dart';
|
||||
import 'shell/chat_shell_dismiss.dart';
|
||||
import '../terminal/terminal_open_action.dart';
|
||||
import 'ui/sessions/session_pane_menu.dart';
|
||||
import 'workspace/chat_pane_commands.dart';
|
||||
import 'workspace/chat_float_shortcut.dart';
|
||||
import 'workspace/chat_workspace_binding.dart';
|
||||
import 'workspace/chat_workspace_snapshot.dart';
|
||||
@@ -34,6 +40,7 @@ import 'workspace/chat_center_stage_action.dart';
|
||||
import 'workspace/chat_center_stage_controller.dart';
|
||||
import 'workspace/chat_center_stage_keys.dart';
|
||||
import 'workspace/chat_pane_move_actions.dart';
|
||||
import 'workspace/chat_pane_move_shortcuts.dart';
|
||||
import 'workspace/chat_workspace_entrance.dart';
|
||||
import 'ui/sessions/chat_adaptive.dart';
|
||||
import 'conversation/composer_focus_request.dart';
|
||||
@@ -49,6 +56,7 @@ import 'ui/sessions/chat_sessions_screen.dart';
|
||||
import '../../ui/input/keyboard_owner.dart';
|
||||
|
||||
part 'chat_screen_float.dart';
|
||||
part 'chat_screen_pane_menu.dart';
|
||||
part 'chat_screen_keys.dart';
|
||||
part 'chat_screen_workspace.dart';
|
||||
|
||||
@@ -103,7 +111,11 @@ class ChatScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ChatScreenState extends State<ChatScreen>
|
||||
with _ChatScreenWorkspace, _ChatScreenKeys, _ChatScreenFloat {
|
||||
with
|
||||
_ChatScreenWorkspace,
|
||||
_ChatScreenKeys,
|
||||
_ChatScreenFloat,
|
||||
_ChatScreenPaneMenu {
|
||||
/// The chats' shared state: the list, opened rows, accepted models,
|
||||
/// transcript positions and caches (see [ChatRuntime]).
|
||||
late final ChatRuntime _runtime =
|
||||
@@ -221,6 +233,7 @@ class _ChatScreenState extends State<ChatScreen>
|
||||
/// Opens [session] chosen by a tap, click or Next chat: its composer takes
|
||||
/// focus on a desktop host or after a mouse click, not from a finger on a
|
||||
/// phone or tablet (see [chatSelectionFocusesComposer]).
|
||||
@override
|
||||
void _openBySelection(JsonMap session) =>
|
||||
_open(session, focusComposer: chatSelectionFocusesComposer(session));
|
||||
|
||||
@@ -368,6 +381,7 @@ class _ChatScreenState extends State<ChatScreen>
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_paneCommands.dispose();
|
||||
HardwareKeyboard.instance.removeHandler(_cycleChatKey);
|
||||
HardwareKeyboard.instance.removeHandler(_slashFocusKey);
|
||||
_page.dispose();
|
||||
@@ -384,6 +398,10 @@ class _ChatScreenState extends State<ChatScreen>
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/// Requests the chat list hands to an open chat (see [_ChatScreenPaneMenu]).
|
||||
@override
|
||||
final _paneCommands = ChatPaneCommands();
|
||||
|
||||
@override
|
||||
Widget _thread(ChatWorkspacePane pane) {
|
||||
final selected = pane.sessionId;
|
||||
@@ -401,6 +419,7 @@ class _ChatScreenState extends State<ChatScreen>
|
||||
useNativeBack: _page.open,
|
||||
pasteTarget: _workspaceVisible && pane.id == _workspace.activePaneId,
|
||||
showBackButton: _page.open || !showsListBesideDetail(context),
|
||||
paneCommands: _paneCommands,
|
||||
paneControls: (paneContext) => [
|
||||
ChatBarAction(
|
||||
label: 'Add chat pane',
|
||||
@@ -467,6 +486,7 @@ class _ChatScreenState extends State<ChatScreen>
|
||||
onOpenBeside: beside ? _openBeside : null,
|
||||
onOpenBelow: _openBelow,
|
||||
onFloat: _floatsHere ? _floatSession : null,
|
||||
paneMenu: this,
|
||||
onShortcutOpen: _openByShortcut,
|
||||
onSessions: _adoptRows,
|
||||
activeSessionId: selected,
|
||||
|
||||
@@ -4,6 +4,7 @@ import '../../../../core/api_gateway.dart';
|
||||
import '../../domain/chat_sessions.dart';
|
||||
import 'chat_adaptive.dart';
|
||||
import 'session_list_material.dart';
|
||||
import 'session_pane_menu.dart';
|
||||
import 'session_row_style.dart';
|
||||
|
||||
typedef ChatSessionSection = ({String title, List<JsonMap> sessions});
|
||||
@@ -34,6 +35,7 @@ class ChatSessionsBody extends StatelessWidget {
|
||||
this.onOpenBeside,
|
||||
this.onOpenBelow,
|
||||
this.onFloat,
|
||||
this.paneMenu,
|
||||
required this.onRename,
|
||||
required this.onClose,
|
||||
required this.onReopen,
|
||||
@@ -65,6 +67,7 @@ class ChatSessionsBody extends StatelessWidget {
|
||||
final ValueChanged<JsonMap>? onOpenBeside;
|
||||
final ValueChanged<JsonMap>? onOpenBelow;
|
||||
final ValueChanged<JsonMap>? onFloat;
|
||||
final SessionPaneMenu? paneMenu;
|
||||
final ValueChanged<JsonMap> onRename;
|
||||
final ValueChanged<JsonMap> onClose;
|
||||
final ValueChanged<JsonMap> onReopen;
|
||||
@@ -103,6 +106,7 @@ class ChatSessionsBody extends StatelessWidget {
|
||||
onOpenBeside: onOpenBeside,
|
||||
onOpenBelow: onOpenBelow,
|
||||
onFloat: onFloat,
|
||||
paneMenu: paneMenu,
|
||||
onRename: onRename,
|
||||
onClose: onClose,
|
||||
onReopen: onReopen,
|
||||
|
||||
@@ -23,6 +23,7 @@ import 'chat_sessions_controller.dart';
|
||||
import 'create_chat_dialog.dart';
|
||||
import 'rename_chat_dialog.dart';
|
||||
import 'session_actions.dart';
|
||||
import 'session_pane_menu.dart';
|
||||
|
||||
/// Browses server-owned sessions. Opening a row is read-only at this layer.
|
||||
class ChatSessionsScreen extends StatefulWidget {
|
||||
@@ -33,6 +34,7 @@ class ChatSessionsScreen extends StatefulWidget {
|
||||
this.onOpenBeside,
|
||||
this.onOpenBelow,
|
||||
this.onFloat,
|
||||
this.paneMenu,
|
||||
this.onShortcutOpen,
|
||||
this.embedded = false,
|
||||
this.syncToken = 0,
|
||||
@@ -54,6 +56,9 @@ class ChatSessionsScreen extends StatefulWidget {
|
||||
/// Floats the chat in a window over the app; absent when it cannot.
|
||||
final ValueChanged<JsonMap>? onFloat;
|
||||
|
||||
/// The open panes' More choices for each row's menu, when the list has panes.
|
||||
final SessionPaneMenu? paneMenu;
|
||||
|
||||
/// Opens a row the shell's Ctrl+1…Ctrl+9 named, so the destination can put
|
||||
/// the keyboard in its composer; null opens it like a tap ([onOpen]).
|
||||
final void Function(JsonMap session)? onShortcutOpen;
|
||||
@@ -353,6 +358,7 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
|
||||
? null
|
||||
: _openBelow,
|
||||
onFloat: widget.onFloat,
|
||||
paneMenu: widget.paneMenu,
|
||||
onRename: _rename,
|
||||
onClose: _close,
|
||||
onReopen: _reopen,
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import '../../../../core/api_gateway.dart';
|
||||
import '../../domain/chat_sessions.dart';
|
||||
import '../../workspace/chat_float_shortcut.dart';
|
||||
import 'session_pane_menu.dart';
|
||||
import 'session_row_style.dart';
|
||||
import '../../../../ui/layout/app_overflow_menu.dart';
|
||||
|
||||
@@ -34,6 +35,7 @@ class SessionActionsButton extends StatelessWidget {
|
||||
this.allowOpenBeside = false,
|
||||
this.allowOpenBelow = false,
|
||||
this.allowFloat = false,
|
||||
this.paneMenu,
|
||||
});
|
||||
|
||||
final JsonMap session;
|
||||
@@ -43,31 +45,48 @@ class SessionActionsButton extends StatelessWidget {
|
||||
final bool allowOpenBelow;
|
||||
final bool allowFloat;
|
||||
|
||||
/// The open panes' choices, offered after the list's split and float items.
|
||||
final SessionPaneMenu? paneMenu;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppOverflowMenu<SessionAction>(
|
||||
return AppOverflowMenu<Object>(
|
||||
label: sessionActionsLabel(session, duplicateTitles),
|
||||
sheetTitle: chatSessionTitle(session),
|
||||
actions: [
|
||||
actionsBuilder: () => [
|
||||
if (allowOpenBeside)
|
||||
const AppMenuAction(
|
||||
const AppMenuAction<Object>(
|
||||
value: SessionAction.openBeside,
|
||||
label: 'Open to the right',
|
||||
),
|
||||
if (allowOpenBelow)
|
||||
const AppMenuAction(
|
||||
const AppMenuAction<Object>(
|
||||
value: SessionAction.openBelow,
|
||||
label: 'Open below',
|
||||
),
|
||||
if (allowFloat)
|
||||
AppMenuAction(
|
||||
AppMenuAction<Object>(
|
||||
value: SessionAction.float,
|
||||
label: 'Float (${chatFloatShortcutLabel()})',
|
||||
),
|
||||
for (final choice
|
||||
in paneMenu?.choicesFor(context, session) ??
|
||||
const <SessionPaneChoice>[])
|
||||
AppMenuAction<Object>(
|
||||
value: choice.action,
|
||||
label: choice.label,
|
||||
enabled: choice.enabled,
|
||||
),
|
||||
for (final item in _items(session))
|
||||
AppMenuAction(value: item.action, label: item.label),
|
||||
AppMenuAction<Object>(value: item.action, label: item.label),
|
||||
],
|
||||
onSelected: (_, action) => onSelected(action),
|
||||
onSelected: (context, value) {
|
||||
if (value is SessionAction) {
|
||||
onSelected(value);
|
||||
} else if (value is SessionPaneAction) {
|
||||
paneMenu?.run(context, session, value);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import '../../../../ui/layout/collapsible_list_section.dart';
|
||||
import '../../domain/chat_sessions.dart';
|
||||
import 'chat_adaptive.dart';
|
||||
import 'chat_sessions_body.dart';
|
||||
import 'session_pane_menu.dart';
|
||||
import 'session_row_memo.dart';
|
||||
|
||||
/// One entry of a chat section's lazy list: a directory header, a row or a
|
||||
@@ -90,6 +91,7 @@ SessionListItem chatSessionRowItem(
|
||||
ValueChanged<JsonMap>? onOpenBeside,
|
||||
ValueChanged<JsonMap>? onOpenBelow,
|
||||
ValueChanged<JsonMap>? onFloat,
|
||||
SessionPaneMenu? paneMenu,
|
||||
required ValueChanged<JsonMap> onStar,
|
||||
required ValueChanged<JsonMap>? onColor,
|
||||
required ValueChanged<JsonMap> onRename,
|
||||
@@ -113,6 +115,7 @@ SessionListItem chatSessionRowItem(
|
||||
onOpenBeside: onOpenBeside,
|
||||
onOpenBelow: onOpenBelow,
|
||||
onFloat: onFloat,
|
||||
paneMenu: paneMenu,
|
||||
onStar: onStar,
|
||||
onColor: onColor,
|
||||
onRename: onRename,
|
||||
|
||||
@@ -5,6 +5,7 @@ import '../../../../core/api_gateway.dart';
|
||||
import 'chat_sessions_body.dart';
|
||||
import 'chat_list_viewport.dart';
|
||||
import 'session_list_items.dart';
|
||||
import 'session_pane_menu.dart';
|
||||
|
||||
class MaterialSessionList extends StatelessWidget {
|
||||
const MaterialSessionList({
|
||||
@@ -16,6 +17,7 @@ class MaterialSessionList extends StatelessWidget {
|
||||
this.onOpenBeside,
|
||||
this.onOpenBelow,
|
||||
this.onFloat,
|
||||
this.paneMenu,
|
||||
required this.onRename,
|
||||
required this.onClose,
|
||||
required this.onReopen,
|
||||
@@ -43,6 +45,7 @@ class MaterialSessionList extends StatelessWidget {
|
||||
final ValueChanged<JsonMap>? onOpenBeside;
|
||||
final ValueChanged<JsonMap>? onOpenBelow;
|
||||
final ValueChanged<JsonMap>? onFloat;
|
||||
final SessionPaneMenu? paneMenu;
|
||||
final ValueChanged<JsonMap> onRename;
|
||||
final ValueChanged<JsonMap> onClose;
|
||||
final ValueChanged<JsonMap> onReopen;
|
||||
@@ -117,6 +120,7 @@ class MaterialSessionList extends StatelessWidget {
|
||||
onOpenBeside: onOpenBeside,
|
||||
onOpenBelow: onOpenBelow,
|
||||
onFloat: onFloat,
|
||||
paneMenu: paneMenu,
|
||||
onStar: onStar,
|
||||
onColor: onColor,
|
||||
onRename: onRename,
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../../../../core/api_gateway.dart';
|
||||
|
||||
/// The pane More menu's choices that a chat row's menu also offers.
|
||||
enum SessionPaneAction {
|
||||
addPane,
|
||||
openChats,
|
||||
centerStage,
|
||||
moveUp,
|
||||
moveDown,
|
||||
moveLeft,
|
||||
moveRight,
|
||||
closePane,
|
||||
chatDetails,
|
||||
files,
|
||||
runCommand,
|
||||
openTerminal,
|
||||
dismissFinished,
|
||||
}
|
||||
|
||||
/// One pane choice as the row's menu shows it: the pane's own label. A
|
||||
/// disabled choice stays listed, as the pane lists it (a move with no pane
|
||||
/// across that edge).
|
||||
typedef SessionPaneChoice = ({
|
||||
SessionPaneAction action,
|
||||
String label,
|
||||
bool enabled,
|
||||
});
|
||||
|
||||
/// The open chat panes, as a chat row's menu reaches them. The offers are read
|
||||
/// when the menu opens, so they follow the panes as they are then.
|
||||
abstract interface class SessionPaneMenu {
|
||||
/// The pane More menu's choices for [session] now, in the pane's order and
|
||||
/// with its visibility (narrow layouts, one pane, no window or terminal).
|
||||
List<SessionPaneChoice> choicesFor(BuildContext context, JsonMap session);
|
||||
|
||||
/// Runs [action] for [session], opening the chat first where the pane's
|
||||
/// handler acts on an open chat.
|
||||
void run(BuildContext context, JsonMap session, SessionPaneAction action);
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import 'chat_session_state.dart';
|
||||
import 'session_actions.dart';
|
||||
import 'session_activity_badge.dart';
|
||||
import 'session_harness_icon.dart';
|
||||
import 'session_pane_menu.dart';
|
||||
import 'session_row_style.dart';
|
||||
|
||||
/// One chat in the list, in the app's shared row on both hosts: the harness
|
||||
@@ -34,6 +35,7 @@ class ChatSessionRow extends StatelessWidget {
|
||||
this.onOpenBeside,
|
||||
this.onOpenBelow,
|
||||
this.onFloat,
|
||||
this.paneMenu,
|
||||
required this.onAction,
|
||||
this.selected = false,
|
||||
this.visible = false,
|
||||
@@ -52,6 +54,7 @@ class ChatSessionRow extends StatelessWidget {
|
||||
final ValueChanged<JsonMap>? onOpenBeside;
|
||||
final ValueChanged<JsonMap>? onOpenBelow;
|
||||
final ValueChanged<JsonMap>? onFloat;
|
||||
final SessionPaneMenu? paneMenu;
|
||||
final VoidCallback? onLongPress;
|
||||
final ValueChanged<SessionAction> onAction;
|
||||
final bool selected;
|
||||
@@ -167,6 +170,7 @@ class ChatSessionRow extends StatelessWidget {
|
||||
allowOpenBeside: onOpenBeside != null,
|
||||
allowOpenBelow: onOpenBelow != null,
|
||||
allowFloat: onFloat != null,
|
||||
paneMenu: paneMenu,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -4,6 +4,7 @@ import '../../../../core/api_gateway.dart';
|
||||
import '../../../../ui/layout/memo_subtree.dart';
|
||||
import '../../domain/chat_sessions.dart';
|
||||
import 'session_actions.dart';
|
||||
import 'session_pane_menu.dart';
|
||||
import 'session_row_content.dart';
|
||||
|
||||
/// A chat row that rebuilds only when its own session or state changes, so a
|
||||
@@ -23,6 +24,7 @@ Widget memoChatSessionRow({
|
||||
ValueChanged<JsonMap>? onOpenBeside,
|
||||
ValueChanged<JsonMap>? onOpenBelow,
|
||||
ValueChanged<JsonMap>? onFloat,
|
||||
SessionPaneMenu? paneMenu,
|
||||
required ValueChanged<JsonMap> onStar,
|
||||
required ValueChanged<JsonMap>? onColor,
|
||||
required ValueChanged<JsonMap> onRename,
|
||||
@@ -44,6 +46,7 @@ Widget memoChatSessionRow({
|
||||
onOpenBeside,
|
||||
onOpenBelow,
|
||||
onFloat,
|
||||
paneMenu,
|
||||
onStar,
|
||||
onColor,
|
||||
onRename,
|
||||
@@ -63,6 +66,7 @@ Widget memoChatSessionRow({
|
||||
onOpenBeside: onOpenBeside,
|
||||
onOpenBelow: onOpenBelow,
|
||||
onFloat: onFloat,
|
||||
paneMenu: paneMenu,
|
||||
// A long-press is the touch way to the colour, the row's quick mark.
|
||||
onLongPress: selectionOnly || onColor == null
|
||||
? null
|
||||
|
||||
@@ -3,14 +3,19 @@ import 'package:flutter/material.dart';
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
import 'chat_center_stage_controller.dart';
|
||||
|
||||
/// The center-stage toggle's label, naming its keyboard shortcut.
|
||||
String chatCenterStageLabel(ChatCenterStageController controller) {
|
||||
final shortcut = chatCenterStageShortcutLabel();
|
||||
return controller.value
|
||||
? 'Leave center stage ($shortcut)'
|
||||
: 'Center stage ($shortcut)';
|
||||
}
|
||||
|
||||
/// The pane menu's center-stage toggle, naming its keyboard shortcut.
|
||||
ChatBarAction chatCenterStageAction(ChatCenterStageController controller) {
|
||||
final shortcut = chatCenterStageShortcutLabel();
|
||||
return ChatBarAction(
|
||||
identifier: 'chat-center-stage-toggle',
|
||||
label: controller.value
|
||||
? 'Leave center stage ($shortcut)'
|
||||
: 'Center stage ($shortcut)',
|
||||
label: chatCenterStageLabel(controller),
|
||||
onPressed: controller.toggle,
|
||||
materialIcon: controller.value
|
||||
? Icons.view_quilt_outlined
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
/// A pane menu action that lives in the conversation itself (its own state),
|
||||
/// so a chat list choice asks the open conversation to run it.
|
||||
enum ChatPaneCommand {
|
||||
details,
|
||||
files,
|
||||
runCommand,
|
||||
openTerminal,
|
||||
dismissFinished,
|
||||
}
|
||||
|
||||
/// Hands a chat list choice to the open conversation of one chat. The list
|
||||
/// opens the chat first; its conversation takes the request once it is built
|
||||
/// and runs the same handler its own More menu runs.
|
||||
///
|
||||
/// It also records which chats have finished command runs, so the list offers
|
||||
/// Dismiss all finished commands where the pane would.
|
||||
class ChatPaneCommands extends ChangeNotifier {
|
||||
final List<(String, ChatPaneCommand)> _pending = [];
|
||||
final Set<String> _finished = {};
|
||||
|
||||
/// Asks [sessionId]'s conversation to run [command].
|
||||
void request(String sessionId, ChatPaneCommand command) {
|
||||
_pending.add((sessionId, command));
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// Takes the oldest request for [sessionId], or null when there is none.
|
||||
ChatPaneCommand? take(String sessionId) {
|
||||
final index = _pending.indexWhere((entry) => entry.$1 == sessionId);
|
||||
if (index < 0) return null;
|
||||
return _pending.removeAt(index).$2;
|
||||
}
|
||||
|
||||
/// Whether [sessionId]'s conversation holds finished command runs.
|
||||
bool hasFinished(String sessionId) => _finished.contains(sessionId);
|
||||
|
||||
/// Called by a conversation as its finished runs change.
|
||||
void setFinished(String sessionId, bool finished) {
|
||||
if (finished) {
|
||||
_finished.add(sessionId);
|
||||
} else {
|
||||
_finished.remove(sessionId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,22 @@ enum ChatPaneChord { focus, move }
|
||||
);
|
||||
}
|
||||
|
||||
/// The move chord as text, for a menu item that cannot show it beside the
|
||||
/// label: "Command+Option+Shift+Up" on macOS, "Ctrl+Alt+Shift+Up" elsewhere.
|
||||
String chatPaneMoveShortcutLabel(
|
||||
ChatPaneDirection direction, {
|
||||
TargetPlatform? platform,
|
||||
}) {
|
||||
final mac = (platform ?? defaultTargetPlatform) == TargetPlatform.macOS;
|
||||
final key = switch (direction) {
|
||||
ChatPaneDirection.left => 'Left',
|
||||
ChatPaneDirection.right => 'Right',
|
||||
ChatPaneDirection.up => 'Up',
|
||||
ChatPaneDirection.down => 'Down',
|
||||
};
|
||||
return mac ? 'Command+Option+Shift+$key' : 'Ctrl+Alt+Shift+$key';
|
||||
}
|
||||
|
||||
/// The move chord as a menu shows it: Command on macOS, Ctrl elsewhere.
|
||||
SingleActivator chatPaneMoveActivator(
|
||||
ChatPaneDirection direction, {
|
||||
|
||||
@@ -40,6 +40,7 @@ class ChatWorkspace extends StatefulWidget {
|
||||
this.animationStyle,
|
||||
this.paneTitle,
|
||||
this.onVisibleSessionIdsChanged,
|
||||
this.onMoveTargetsChanged,
|
||||
this.centerStage,
|
||||
this.paneColor,
|
||||
});
|
||||
@@ -54,6 +55,11 @@ class ChatWorkspace extends StatefulWidget {
|
||||
final String Function(ChatWorkspacePane)? paneTitle;
|
||||
final ValueChanged<Set<String>>? onVisibleSessionIdsChanged;
|
||||
|
||||
/// Reports each pane's move targets (see [ChatWorkspacePaneScope.moveTargets])
|
||||
/// after a layout that changed them. Empty while the panes are not tiled.
|
||||
final ValueChanged<Map<String, Map<ChatPaneDirection, String>>>?
|
||||
onMoveTargetsChanged;
|
||||
|
||||
/// While true on a wide window, the active chat takes center stage and the
|
||||
/// others line up beside it (see [ChatCenterStageLayout]).
|
||||
final ValueListenable<bool>? centerStage;
|
||||
@@ -110,6 +116,30 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
|
||||
});
|
||||
}
|
||||
|
||||
Map<String, Map<ChatPaneDirection, String>> _reportedMoveTargets = const {};
|
||||
|
||||
void _reportMoveTargets(Map<String, Map<ChatPaneDirection, String>> targets) {
|
||||
if (_sameMoveTargets(targets, _reportedMoveTargets)) return;
|
||||
_reportedMoveTargets = targets;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted && identical(targets, _reportedMoveTargets)) {
|
||||
widget.onMoveTargetsChanged?.call(targets);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static bool _sameMoveTargets(
|
||||
Map<String, Map<ChatPaneDirection, String>> a,
|
||||
Map<String, Map<ChatPaneDirection, String>> b,
|
||||
) {
|
||||
if (a.length != b.length) return false;
|
||||
for (final MapEntry(key: id, value: targets) in a.entries) {
|
||||
final other = b[id];
|
||||
if (other == null || !mapEquals(targets, other)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void _reportPaneExtraWidth(String paneId, double width) {
|
||||
if ((_paneExtraWidths[paneId] ?? 0) == width) return;
|
||||
if (width == 0) {
|
||||
@@ -234,6 +264,7 @@ class _ChatWorkspaceState extends State<ChatWorkspace>
|
||||
direction: ?geometry.adjacent(pane.id, direction),
|
||||
},
|
||||
};
|
||||
_reportMoveTargets(moveTargets);
|
||||
// Finish one joined loop before taking the latest requested role.
|
||||
// Repeated taps/chords never tear the tape or duplicate a live chat.
|
||||
final activeId =
|
||||
|
||||
@@ -7,6 +7,7 @@ class AppMenuAction<T> {
|
||||
required this.label,
|
||||
this.key,
|
||||
this.destructive = false,
|
||||
this.enabled = true,
|
||||
});
|
||||
|
||||
final T value;
|
||||
@@ -15,6 +16,9 @@ class AppMenuAction<T> {
|
||||
/// Placed on the menu item so tests can find the same item.
|
||||
final Key? key;
|
||||
|
||||
/// A disabled item stays listed but cannot be chosen.
|
||||
final bool enabled;
|
||||
|
||||
// Kept for callers that distinguish destructive actions in their data model;
|
||||
// Material PopupMenuItem does not apply a separate action-sheet treatment.
|
||||
final bool destructive;
|
||||
@@ -28,7 +32,8 @@ class AppMenuAction<T> {
|
||||
class AppOverflowMenu<T> extends StatelessWidget {
|
||||
const AppOverflowMenu({
|
||||
super.key,
|
||||
required this.actions,
|
||||
this.actions = const [],
|
||||
this.actionsBuilder,
|
||||
required this.onSelected,
|
||||
this.label = 'More actions',
|
||||
this.sheetTitle,
|
||||
@@ -38,6 +43,10 @@ class AppOverflowMenu<T> extends StatelessWidget {
|
||||
|
||||
final List<AppMenuAction<T>> actions;
|
||||
|
||||
/// When given, supplies the choices each time the menu opens, instead of
|
||||
/// [actions]; for choices that depend on state read at that moment.
|
||||
final List<AppMenuAction<T>> Function()? actionsBuilder;
|
||||
|
||||
/// Called with the picked value once the menu has closed.
|
||||
final void Function(BuildContext context, T value) onSelected;
|
||||
|
||||
@@ -55,7 +64,9 @@ class AppOverflowMenu<T> extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (actions.isEmpty) return const SizedBox.shrink();
|
||||
if (actionsBuilder == null && actions.isEmpty) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return Localizations.override(
|
||||
context: context,
|
||||
delegates: const [DefaultMaterialLocalizations.delegate],
|
||||
@@ -67,10 +78,11 @@ class AppOverflowMenu<T> extends StatelessWidget {
|
||||
enabled: enabled,
|
||||
onSelected: (value) => onSelected(context, value),
|
||||
itemBuilder: (_) => [
|
||||
for (final action in actions)
|
||||
for (final action in actionsBuilder?.call() ?? actions)
|
||||
PopupMenuItem<T>(
|
||||
key: action.key,
|
||||
value: action.value,
|
||||
enabled: action.enabled,
|
||||
child: Text(action.label),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
# Chat list row menu offers the open pane's More choices
|
||||
|
||||
Run 385, stage 01-implement. Source only; nothing committed, no UI captured.
|
||||
|
||||
## What changed
|
||||
|
||||
The chat list row's More menu now also offers the choices of the open chat
|
||||
pane's More menu, under the same labels and visibility, after its split and
|
||||
Float items and before the list's own Star, Colour, Rename, Close and Hide.
|
||||
|
||||
Offered choices and what each runs for the row's chat:
|
||||
|
||||
| Choice | Shown when (as the pane shows it) | Runs |
|
||||
| --- | --- | --- |
|
||||
| Add chat pane | always | opens the row's chat, then `_addPane` |
|
||||
| Open chats (n) | more than one pane | opens the row's chat, then `_pickPane` |
|
||||
| Center stage (shortcut) / Leave center stage | more than one pane, wide layout | opens the row's chat, then toggles center stage |
|
||||
| Move up / Move down / Move left / Move right (shortcut as text) | the row's chat is in a tiled pane (the pane's own rule); a direction with no neighbour is listed disabled | `_movePane` with the pane's move target for that direction; the chat is already open, so nothing is opened |
|
||||
| Close pane | the row's chat is in a pane and more than one pane | `_closePane` for that pane |
|
||||
| Chat details | inside a window only | opens the chat, then the conversation's info |
|
||||
| Files | always | opens the chat, then the conversation's Files toggle |
|
||||
| Run command… | always | opens the chat, then the conversation's run dialog |
|
||||
| Dismiss all finished commands | the chat's conversation holds finished runs | opens the chat, then the conversation's dismiss |
|
||||
| Open in terminal | a terminal surface and a folder | opens the chat, then the conversation's terminal open |
|
||||
|
||||
Float keeps its existing list behaviour. Open to the right and Open below are
|
||||
offered only where the pane offers them (wide layout), as before.
|
||||
|
||||
Choices are read when the menu opens, so they follow the panes as they are then.
|
||||
|
||||
## How it is wired
|
||||
|
||||
- `ui/sessions/session_pane_menu.dart`: `SessionPaneMenu` (choices and run) and
|
||||
`SessionPaneAction`. `ChatSessionsScreen` takes it as `paneMenu` and passes it
|
||||
down the row chain as one stable object, so no memo key changes.
|
||||
- `ui/layout/app_overflow_menu.dart`: optional `actionsBuilder`, called when the
|
||||
menu opens, and `AppMenuAction.enabled` (default true) for disabled items.
|
||||
Existing callers are unchanged.
|
||||
- Move targets: `ChatWorkspace` reports each pane's move targets (the same map
|
||||
its pane scope uses) through the new `onMoveTargetsChanged` callback after a
|
||||
layout that changed them. `chat_screen_workspace.dart` stores them; the list
|
||||
reads them when its menu opens, and `_movePane` runs the chosen swap.
|
||||
- `chat_screen_pane_menu.dart` (mixin on `ChatScreen`): builds the choices with
|
||||
the pane's own conditions and runs them. Pane-level handlers are the same
|
||||
methods the pane's menu calls.
|
||||
- `workspace/chat_pane_commands.dart`: `ChatPaneCommands`, a small bus. The list
|
||||
opens the chat and requests a command; the chat's `ChatThreadView` takes it
|
||||
once built (initState post-frame, or on notify) and runs the same handler its
|
||||
own menu uses. It also records which chats hold finished runs.
|
||||
- `conversation/chat_thread_view.dart`: takes requests, reports finished runs,
|
||||
and shares the terminal refusal notice with its header.
|
||||
- `workspace/chat_center_stage_action.dart`: label extracted to
|
||||
`chatCenterStageLabel`, used by both menus.
|
||||
|
||||
## Focused results
|
||||
|
||||
Command: `tool/memwatch/full.sh 'test/features/chat/ui/sessions test/features/chat/chat_floating_pane_test.dart'`
|
||||
|
||||
- PASS: 127 passed, 0 failed, 0 skipped; peak 1674 MB; 31s; exit 0.
|
||||
- Verdict named only the two intended paths.
|
||||
- An earlier run had one failure in the new narrow-layout test (the phone's open
|
||||
chat covers the list). The test now taps `chat-back` first. No expectation
|
||||
was changed.
|
||||
|
||||
New tests:
|
||||
|
||||
- `ui/sessions/chat_session_actions_test.dart`
|
||||
- The row menu shows pane choices in order before Star, and choosing one runs
|
||||
`run` for that row only (no gateway calls beyond the list's read).
|
||||
- A disabled pane choice is listed disabled and running it does nothing; an
|
||||
enabled move runs.
|
||||
- The choices are read at each open (an emptied list drops the item).
|
||||
- Command requests reach a chat once, in order; finished-run flags set and clear.
|
||||
- `chat_floating_pane_test.dart`
|
||||
- Wide: the list menu for chat b offers the pane choices and omits Chat
|
||||
details and Open in terminal.
|
||||
- Wide, side by side: Move up/down/right are listed disabled, Move left is
|
||||
enabled, and choosing it swaps b with a (panes now `b`, `a`).
|
||||
- Close pane from the list closes that pane only.
|
||||
- Files from the list opens a chat that was not open (it becomes a pane).
|
||||
- Run command… from the list shows the run dialog and leaves panes unchanged.
|
||||
- Narrow: Add chat pane and Open chats (2) show; Center stage, Float, Open
|
||||
to the right and every Move do not.
|
||||
|
||||
Analyzer: `tool/analyze.sh lib/features/chat lib/ui/layout/app_overflow_menu.dart
|
||||
test/features/chat/ui/sessions test/features/chat/chat_floating_pane_test.dart`
|
||||
reports clean (0 errors, 0 warnings, 0 infos).
|
||||
|
||||
## Affected UI states (not captured, not verified in a browser or on a device)
|
||||
|
||||
- Wide list row menu, with one pane and with two or more panes.
|
||||
- Narrow list row menu (Add chat pane, Open chats, no Float or Open to the right).
|
||||
- Row menu for a chat not open (Files, Run command… open it into a pane).
|
||||
- Row menu with a window (Chat details appears only for a window's own pane, so
|
||||
it is not shown from the main list).
|
||||
- Dismiss all finished commands, Open in terminal, Center stage, Close pane
|
||||
with terminal and finished-run states: code paths only, no test asserts them.
|
||||
|
||||
## Limitations
|
||||
|
||||
- **Move shortcut hints are text.** The pane shows the move chord beside the
|
||||
label through Material's menu shortcut; a list item has only a label, so the
|
||||
list writes it into the label, e.g. `Move up (Ctrl+Alt+Shift+Up)` (Command+
|
||||
Option+Shift on macOS). Same chord, different presentation.
|
||||
- **Move targets are one layout behind at most.** They are reported after a
|
||||
frame, so a menu opened during the very first layout after a change may read
|
||||
the previous targets.
|
||||
- **Dismiss all finished commands** appears only after the chat's conversation
|
||||
has reported finished runs in this visit. A chat never opened this visit will
|
||||
not show it, even if the server has finished runs for it.
|
||||
- **Open in terminal** and **Run command…** from the list open the chat first,
|
||||
as the rule for this change requires; the pane itself does not need the chat
|
||||
opened for them.
|
||||
- **Add chat pane**, Open chats and Center stage from the list are not asserted
|
||||
by tests beyond the menu labels and the run/close paths above.
|
||||
- Changed shared code that other suites use: `chatCenterStageLabel` extraction,
|
||||
the header's terminal refusal (now `_terminalRefused`), and `AppOverflowMenu`
|
||||
(new optional `actionsBuilder`). Suites beyond the two named files were not
|
||||
run here; the land gate covers them.
|
||||
- No Cupertino code, tests or captures were added.
|
||||
|
||||
## Re-entry after ui-review: list Files did not open the panel
|
||||
|
||||
Defect: choosing Files from an unopened chat's list menu opened and selected
|
||||
the chat, but the Files panel stayed hidden. Cause: the list's request was
|
||||
taken in the thread view's first post-frame callback, which toggled Files on.
|
||||
The saved Files state then loaded asynchronously and wrote the stored value
|
||||
(hidden) over it.
|
||||
|
||||
Fix (`conversation/chat_thread_view.dart`):
|
||||
|
||||
- `_takeCommands` waits until the saved Files state has loaded
|
||||
(`_filesPrefsLoaded`), so the Files toggle always acts on the loaded state.
|
||||
- `_loadFilesPreferences` runs pending commands once the state is set.
|
||||
- A session switch resets `_filesPrefsLoaded` and retries pending commands
|
||||
after the frame, so a request made before the pane showed the chat is not
|
||||
stranded.
|
||||
|
||||
Test (`chat_floating_pane_test.dart`, "a list choice opens a chat that is not
|
||||
open first"): now also asserts that the `FilesPanel` is shown. It failed before
|
||||
the fix (0 `FilesPanel` widgets) and passes after.
|
||||
|
||||
Focused results after the fix:
|
||||
`tool/memwatch/full.sh 'test/features/chat/chat_floating_pane_test.dart test/features/chat/ui/sessions test/features/chat/conversation/chat_floating_chrome_test.dart test/features/chat/conversation/chat_thread_view_test.dart test/features/chat/files/files_directory_metadata_test.dart'`
|
||||
- PASS: 142 passed, 0 failed, 0 skipped; peak 1890 MB; 30s; exit 0.
|
||||
- Verdict named only those paths.
|
||||
|
||||
Analyzer (`tool/analyze.sh lib/features/chat lib/ui/layout/app_overflow_menu.dart test/features/chat/ui/sessions test/features/chat/chat_floating_pane_test.dart`): clean.
|
||||
|
||||
Limitations: the wider conversation suites (about 40 files that use
|
||||
`ChatThreadView`) were not run here; the land gate covers them. Narrow-width
|
||||
Files (bottom sheet) from the list is not asserted by a test.
|
||||
@@ -6,10 +6,12 @@ import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/core/servers/server_scope.dart';
|
||||
import 'package:pipelines_app/features/chat/chat_runtime.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
|
||||
import 'package:pipelines_app/features/chat/files/files_panel.dart';
|
||||
import 'package:pipelines_app/features/chat/screen.dart';
|
||||
import 'package:pipelines_app/features/chat/windows/chat_windows.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_float_store.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_workspace.dart';
|
||||
import 'package:pipelines_app/features/chat/shell/chat_shell_command.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_workspace_store.dart';
|
||||
import 'package:pipelines_app/shell/windows/window_frame.dart';
|
||||
import 'package:pipelines_app/shell/windows/window_host.dart';
|
||||
@@ -199,6 +201,29 @@ Future<void> _menu(WidgetTester tester, String session, String label) async {
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
/// Opens the chat list's More menu for chat [id] and returns its labels.
|
||||
Future<List<String>> _listMenu(WidgetTester tester, String id) async {
|
||||
// Windows sit over the list, so the list's menu is reached with them hidden.
|
||||
await tester.tap(find.byTooltip('Chat actions for Chat $id').first);
|
||||
await tester.pumpAndSettle();
|
||||
return [
|
||||
for (final text in tester.widgetList<Text>(
|
||||
find.descendant(
|
||||
of: find.byType(PopupMenuItem<Object>),
|
||||
matching: find.byType(Text),
|
||||
),
|
||||
))
|
||||
text.data!,
|
||||
];
|
||||
}
|
||||
|
||||
/// Chooses [label] in chat [id]'s list menu.
|
||||
Future<void> _listChoice(WidgetTester tester, String id, String label) async {
|
||||
await _listMenu(tester, id);
|
||||
await tester.tap(find.text(label).last);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
Future<void> _saved(String a, String b, [String? c]) async {
|
||||
final layout = ChatWorkspaceController()
|
||||
..open(a)
|
||||
@@ -566,4 +591,152 @@ void main() {
|
||||
expect(find.text('Open chats (2)'), findsOneWidget);
|
||||
await app.stop(tester);
|
||||
});
|
||||
|
||||
testWidgets('the chat list More menu offers the pane choices, as the pane '
|
||||
'does', (tester) async {
|
||||
await _saved('a', 'b');
|
||||
final app = _App(_Store());
|
||||
await app.start(tester);
|
||||
app.manager.setGroupShown(chatWindowKind, false);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final labels = await _listMenu(tester, 'b');
|
||||
expect(
|
||||
labels,
|
||||
containsAllInOrder([
|
||||
'Open to the right',
|
||||
'Open below',
|
||||
'Float (Alt+Y)',
|
||||
'Add chat pane',
|
||||
'Open chats (2)',
|
||||
'Close pane',
|
||||
'Files',
|
||||
'Run command…',
|
||||
'Star',
|
||||
]),
|
||||
);
|
||||
expect(labels.any((label) => label.startsWith('Center stage')), isTrue);
|
||||
// Only a window's own pane offers Chat details, and no terminal is wired.
|
||||
expect(labels, isNot(contains('Chat details')));
|
||||
expect(labels, isNot(contains('Open in terminal')));
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull);
|
||||
await app.stop(tester);
|
||||
});
|
||||
|
||||
testWidgets('a list choice closes the row chat pane it names', (
|
||||
tester,
|
||||
) async {
|
||||
await _saved('a', 'b');
|
||||
final app = _App(_Store());
|
||||
await app.start(tester);
|
||||
app.manager.setGroupShown(chatWindowKind, false);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await _listChoice(tester, 'b', 'Close pane');
|
||||
expect(_workspace(tester).panes.map((p) => p.sessionId), ['a']);
|
||||
expect(app.floating, isEmpty);
|
||||
expect(tester.takeException(), isNull);
|
||||
await app.stop(tester);
|
||||
});
|
||||
|
||||
testWidgets('a list choice moves the row chat pane across its edge', (
|
||||
tester,
|
||||
) async {
|
||||
await _saved('a', 'b');
|
||||
final app = _App(_Store());
|
||||
await app.start(tester);
|
||||
app.manager.setGroupShown(chatWindowKind, false);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Side by side: b has a pane to its left only, so its Move right is
|
||||
// listed but disabled, and nothing is above or below it.
|
||||
final labels = await _listMenu(tester, 'b');
|
||||
expect(
|
||||
labels,
|
||||
containsAllInOrder([
|
||||
'Move up (Ctrl+Alt+Shift+Up)',
|
||||
'Move down (Ctrl+Alt+Shift+Down)',
|
||||
'Move left (Ctrl+Alt+Shift+Left)',
|
||||
'Move right (Ctrl+Alt+Shift+Right)',
|
||||
'Close pane',
|
||||
]),
|
||||
);
|
||||
PopupMenuItem<Object> item(String label) =>
|
||||
tester.widget(find.widgetWithText(PopupMenuItem<Object>, label));
|
||||
expect(item('Move left (Ctrl+Alt+Shift+Left)').enabled, isTrue);
|
||||
expect(item('Move right (Ctrl+Alt+Shift+Right)').enabled, isFalse);
|
||||
expect(item('Move up (Ctrl+Alt+Shift+Up)').enabled, isFalse);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await _listChoice(tester, 'b', 'Move left (Ctrl+Alt+Shift+Left)');
|
||||
expect(_workspace(tester).panes.map((p) => p.sessionId), ['b', 'a']);
|
||||
expect(app.floating, isEmpty);
|
||||
expect(tester.takeException(), isNull);
|
||||
await app.stop(tester);
|
||||
});
|
||||
|
||||
testWidgets('a list choice opens a chat that is not open first', (
|
||||
tester,
|
||||
) async {
|
||||
await _saved('a', 'b');
|
||||
final app = _App(_Store());
|
||||
await app.start(tester);
|
||||
app.manager.setGroupShown(chatWindowKind, false);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Chat c is not open, so it has no pane choices beyond the list's own.
|
||||
expect((await _listMenu(tester, 'c')).contains('Close pane'), isFalse);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await _listChoice(tester, 'c', 'Files');
|
||||
expect(_workspace(tester).panes.map((p) => p.sessionId), contains('c'));
|
||||
// The chat opens with its Files panel shown, as the pane's Files does.
|
||||
expect(find.byType(FilesPanel), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
await app.stop(tester);
|
||||
});
|
||||
|
||||
testWidgets('a list choice runs the command dialog for its chat', (
|
||||
tester,
|
||||
) async {
|
||||
await _saved('a', 'b');
|
||||
final app = _App(_Store());
|
||||
await app.start(tester);
|
||||
app.manager.setGroupShown(chatWindowKind, false);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await _listChoice(tester, 'b', 'Run command…');
|
||||
expect(find.text(chatShellRunDialogTitle), findsOneWidget);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
|
||||
await tester.pumpAndSettle();
|
||||
expect(_workspace(tester).panes.map((p) => p.sessionId), ['a', 'b']);
|
||||
expect(tester.takeException(), isNull);
|
||||
await app.stop(tester);
|
||||
});
|
||||
|
||||
testWidgets('narrow layouts offer the list the panes it can reach', (
|
||||
tester,
|
||||
) async {
|
||||
await _saved('a', 'b');
|
||||
final app = _App(_Store());
|
||||
await app.start(tester, size: const Size(430, 900));
|
||||
// A phone's open chat covers the list; Back returns to the list.
|
||||
await tester.tap(find.byKey(const Key('chat-back')).first);
|
||||
await tester.pumpAndSettle();
|
||||
final labels = await _listMenu(tester, 'b');
|
||||
expect(labels, contains('Add chat pane'));
|
||||
expect(labels, contains('Open chats (2)'));
|
||||
expect(labels.any((label) => label.startsWith('Center stage')), isFalse);
|
||||
expect(labels, isNot(contains('Float (Alt+Y)')));
|
||||
expect(labels, isNot(contains('Open to the right')));
|
||||
// A phone's one-at-a-time layout never moves panes, so no move is listed.
|
||||
expect(labels.any((label) => label.startsWith('Move ')), isFalse);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
|
||||
await tester.pumpAndSettle();
|
||||
await app.stop(tester);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,11 +1,29 @@
|
||||
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/chat/ui/sessions/session_pane_menu.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_pane_commands.dart';
|
||||
|
||||
import 'chat_test_harness.dart';
|
||||
import 'fake_chat_gateway.dart';
|
||||
import 'expand_closed.dart';
|
||||
|
||||
/// A pane menu whose choices the test sets, recording what the row ran.
|
||||
class _PaneMenu implements SessionPaneMenu {
|
||||
List<SessionPaneChoice> choices = const [];
|
||||
final ran = <(String, SessionPaneAction)>[];
|
||||
|
||||
@override
|
||||
List<SessionPaneChoice> choicesFor(BuildContext context, JsonMap session) =>
|
||||
choices;
|
||||
|
||||
@override
|
||||
void run(BuildContext context, JsonMap session, SessionPaneAction action) {
|
||||
ran.add(('${session['id']}', action));
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('material row star, rename, close confirm and reopen', (
|
||||
tester,
|
||||
@@ -130,4 +148,181 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(opened?['id'], 's2');
|
||||
});
|
||||
|
||||
testWidgets('row menu offers the open panes choices before the list items', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = FakeChatGateway()
|
||||
..sessionsReply = {'chat_sessions': sampleSessions()};
|
||||
addTearDown(gateway.pushed.close);
|
||||
final panes = _PaneMenu()
|
||||
..choices = const [
|
||||
(
|
||||
action: SessionPaneAction.addPane,
|
||||
label: 'Add chat pane',
|
||||
enabled: true,
|
||||
),
|
||||
(
|
||||
action: SessionPaneAction.openChats,
|
||||
label: 'Open chats (2)',
|
||||
enabled: true,
|
||||
),
|
||||
];
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: ChatSessionsScreen(
|
||||
gateway: gateway,
|
||||
onOpen: (_) {},
|
||||
paneMenu: panes,
|
||||
localStore: MemoryChatSessionLocalStore(),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.byKey(const Key('chat-actions-s2')));
|
||||
await tester.pumpAndSettle();
|
||||
final labels = _menuLabels(tester);
|
||||
expect(
|
||||
labels,
|
||||
containsAllInOrder(['Add chat pane', 'Open chats (2)', 'Star']),
|
||||
);
|
||||
|
||||
await tester.tap(find.text('Open chats (2)'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(panes.ran, [('s2', SessionPaneAction.openChats)]);
|
||||
expect(
|
||||
gateway.calls.where((call) => call.type != 'chat_sessions'),
|
||||
isEmpty,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('row menu reads the pane choices each time it opens', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = FakeChatGateway()
|
||||
..sessionsReply = {'chat_sessions': sampleSessions()};
|
||||
addTearDown(gateway.pushed.close);
|
||||
final panes = _PaneMenu()
|
||||
..choices = const [
|
||||
(
|
||||
action: SessionPaneAction.closePane,
|
||||
label: 'Close pane',
|
||||
enabled: true,
|
||||
),
|
||||
];
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: ChatSessionsScreen(
|
||||
gateway: gateway,
|
||||
onOpen: (_) {},
|
||||
paneMenu: panes,
|
||||
localStore: MemoryChatSessionLocalStore(),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.byKey(const Key('chat-actions-s2')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Close pane'), findsOneWidget);
|
||||
await tester.tapAt(const Offset(5, 5));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
panes.choices = const [];
|
||||
await tester.tap(find.byKey(const Key('chat-actions-s2')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Close pane'), findsNothing);
|
||||
expect(find.text('Star'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('row menu lists a disabled pane move and does not run it', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = FakeChatGateway()
|
||||
..sessionsReply = {'chat_sessions': sampleSessions()};
|
||||
addTearDown(gateway.pushed.close);
|
||||
final panes = _PaneMenu()
|
||||
..choices = const [
|
||||
(action: SessionPaneAction.moveUp, label: 'Move up', enabled: false),
|
||||
(
|
||||
action: SessionPaneAction.moveRight,
|
||||
label: 'Move right',
|
||||
enabled: true,
|
||||
),
|
||||
];
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: ChatSessionsScreen(
|
||||
gateway: gateway,
|
||||
onOpen: (_) {},
|
||||
paneMenu: panes,
|
||||
localStore: MemoryChatSessionLocalStore(),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.byKey(const Key('chat-actions-s2')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
tester
|
||||
.widget<PopupMenuItem<Object>>(
|
||||
find.widgetWithText(PopupMenuItem<Object>, 'Move up'),
|
||||
)
|
||||
.enabled,
|
||||
isFalse,
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.widget<PopupMenuItem<Object>>(
|
||||
find.widgetWithText(PopupMenuItem<Object>, 'Move right'),
|
||||
)
|
||||
.enabled,
|
||||
isTrue,
|
||||
);
|
||||
|
||||
await tester.tap(find.text('Move up'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(panes.ran, isEmpty);
|
||||
await tester.tapAt(const Offset(5, 5));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.byKey(const Key('chat-actions-s2')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Move right'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(panes.ran, [('s2', SessionPaneAction.moveRight)]);
|
||||
});
|
||||
|
||||
testWidgets('pane command requests reach the chat once, in order', (
|
||||
tester,
|
||||
) async {
|
||||
final commands = ChatPaneCommands();
|
||||
commands
|
||||
..request('s1', ChatPaneCommand.files)
|
||||
..request('s2', ChatPaneCommand.runCommand)
|
||||
..request('s1', ChatPaneCommand.details);
|
||||
expect(commands.take('s1'), ChatPaneCommand.files);
|
||||
expect(commands.take('s1'), ChatPaneCommand.details);
|
||||
expect(commands.take('s1'), isNull);
|
||||
expect(commands.take('s2'), ChatPaneCommand.runCommand);
|
||||
expect(commands.take('s2'), isNull);
|
||||
|
||||
expect(commands.hasFinished('s1'), isFalse);
|
||||
commands.setFinished('s1', true);
|
||||
expect(commands.hasFinished('s1'), isTrue);
|
||||
commands.setFinished('s1', false);
|
||||
expect(commands.hasFinished('s1'), isFalse);
|
||||
});
|
||||
}
|
||||
|
||||
List<String> _menuLabels(WidgetTester tester) => [
|
||||
for (final text in tester.widgetList<Text>(
|
||||
find.descendant(
|
||||
of: find.byType(PopupMenuItem<Object>),
|
||||
matching: find.byType(Text),
|
||||
),
|
||||
))
|
||||
text.data!,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user