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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user