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:
2026-11-12 01:17:46 +00:00
parent 4f1b45571f
commit 3ce7f7a5dd
21 changed files with 1000 additions and 20 deletions
@@ -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 =