Float the last chat and float from the chat list

Any tiled chat can float now, including the only one; the tiling is left
empty. A chat list row's More menu offers Float too: a tiled chat leaves
the tiling, a chat with a window shows it, any other opens a new window.
This commit is contained in:
2026-11-12 00:43:03 +00:00
parent b264043eee
commit 4f1b45571f
16 changed files with 147 additions and 37 deletions
+18 -1
View File
@@ -44,7 +44,24 @@ mixin _ChatScreenFloat on State<ChatScreen>, _ChatScreenWorkspace {
/// the same frame.
void _floatPane(String paneId) {
final pane = _workspace.detach(paneId);
if (pane != null) widget.windows?.float(pane.sessionId);
if (pane == null) return;
widget.windows?.float(pane.sessionId);
// Floating the last tiled chat leaves the list, as closing it does.
if (_workspace.paneCount == 0) _back();
}
/// The chat list's Float choice: a tiled chat leaves the tiling, a chat
/// already in a window comes to the top, any other opens in a new window.
void _floatSession(JsonMap session) {
final id = '${session['id'] ?? ''}';
final windows = widget.windows;
if (id.isEmpty || windows == null || windows.show(id)) return;
final pane = _workspace.panes.where((p) => p.sessionId == id).firstOrNull;
if (pane != null) {
_floatPane(pane.id);
} else {
windows.float(id);
}
}
void _dockSession(String sessionId) {
+1
View File
@@ -466,6 +466,7 @@ class _ChatScreenState extends State<ChatScreen>
onOpen: _openBySelection,
onOpenBeside: beside ? _openBeside : null,
onOpenBelow: _openBelow,
onFloat: _floatsHere ? _floatSession : null,
onShortcutOpen: _openByShortcut,
onSessions: _adoptRows,
activeSessionId: selected,
@@ -33,6 +33,7 @@ class ChatSessionsBody extends StatelessWidget {
required this.onOpen,
this.onOpenBeside,
this.onOpenBelow,
this.onFloat,
required this.onRename,
required this.onClose,
required this.onReopen,
@@ -63,6 +64,7 @@ class ChatSessionsBody extends StatelessWidget {
final ValueChanged<JsonMap> onOpen;
final ValueChanged<JsonMap>? onOpenBeside;
final ValueChanged<JsonMap>? onOpenBelow;
final ValueChanged<JsonMap>? onFloat;
final ValueChanged<JsonMap> onRename;
final ValueChanged<JsonMap> onClose;
final ValueChanged<JsonMap> onReopen;
@@ -100,6 +102,7 @@ class ChatSessionsBody extends StatelessWidget {
onOpen: onOpen,
onOpenBeside: onOpenBeside,
onOpenBelow: onOpenBelow,
onFloat: onFloat,
onRename: onRename,
onClose: onClose,
onReopen: onReopen,
@@ -32,6 +32,7 @@ class ChatSessionsScreen extends StatefulWidget {
required this.onOpen,
this.onOpenBeside,
this.onOpenBelow,
this.onFloat,
this.onShortcutOpen,
this.embedded = false,
this.syncToken = 0,
@@ -50,6 +51,9 @@ class ChatSessionsScreen extends StatefulWidget {
final ValueChanged<JsonMap>? onOpenBeside;
final ValueChanged<JsonMap>? onOpenBelow;
/// Floats the chat in a window over the app; absent when it cannot.
final ValueChanged<JsonMap>? onFloat;
/// 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;
@@ -348,6 +352,7 @@ class _ChatSessionsScreenState extends State<ChatSessionsScreen> {
onOpenBelow: widget.onOpenBelow == null
? null
: _openBelow,
onFloat: widget.onFloat,
onRename: _rename,
onClose: _close,
onReopen: _reopen,
@@ -2,12 +2,14 @@ import 'package:flutter/material.dart';
import '../../../../core/api_gateway.dart';
import '../../domain/chat_sessions.dart';
import '../../workspace/chat_float_shortcut.dart';
import 'session_row_style.dart';
import '../../../../ui/layout/app_overflow_menu.dart';
enum SessionAction {
openBeside,
openBelow,
float,
star,
color,
rename,
@@ -31,6 +33,7 @@ class SessionActionsButton extends StatelessWidget {
this.duplicateTitles = const {},
this.allowOpenBeside = false,
this.allowOpenBelow = false,
this.allowFloat = false,
});
final JsonMap session;
@@ -38,6 +41,7 @@ class SessionActionsButton extends StatelessWidget {
final Set<String> duplicateTitles;
final bool allowOpenBeside;
final bool allowOpenBelow;
final bool allowFloat;
@override
Widget build(BuildContext context) {
@@ -55,6 +59,11 @@ class SessionActionsButton extends StatelessWidget {
value: SessionAction.openBelow,
label: 'Open below',
),
if (allowFloat)
AppMenuAction(
value: SessionAction.float,
label: 'Float (${chatFloatShortcutLabel()})',
),
for (final item in _items(session))
AppMenuAction(value: item.action, label: item.label),
],
@@ -89,6 +89,7 @@ SessionListItem chatSessionRowItem(
required ValueChanged<JsonMap> onOpen,
ValueChanged<JsonMap>? onOpenBeside,
ValueChanged<JsonMap>? onOpenBelow,
ValueChanged<JsonMap>? onFloat,
required ValueChanged<JsonMap> onStar,
required ValueChanged<JsonMap>? onColor,
required ValueChanged<JsonMap> onRename,
@@ -111,6 +112,7 @@ SessionListItem chatSessionRowItem(
onOpen: onOpen,
onOpenBeside: onOpenBeside,
onOpenBelow: onOpenBelow,
onFloat: onFloat,
onStar: onStar,
onColor: onColor,
onRename: onRename,
@@ -15,6 +15,7 @@ class MaterialSessionList extends StatelessWidget {
required this.onOpen,
this.onOpenBeside,
this.onOpenBelow,
this.onFloat,
required this.onRename,
required this.onClose,
required this.onReopen,
@@ -41,6 +42,7 @@ class MaterialSessionList extends StatelessWidget {
final ValueChanged<JsonMap> onOpen;
final ValueChanged<JsonMap>? onOpenBeside;
final ValueChanged<JsonMap>? onOpenBelow;
final ValueChanged<JsonMap>? onFloat;
final ValueChanged<JsonMap> onRename;
final ValueChanged<JsonMap> onClose;
final ValueChanged<JsonMap> onReopen;
@@ -114,6 +116,7 @@ class MaterialSessionList extends StatelessWidget {
onOpen: onOpen,
onOpenBeside: onOpenBeside,
onOpenBelow: onOpenBelow,
onFloat: onFloat,
onStar: onStar,
onColor: onColor,
onRename: onRename,
@@ -33,6 +33,7 @@ class ChatSessionRow extends StatelessWidget {
required this.onOpen,
this.onOpenBeside,
this.onOpenBelow,
this.onFloat,
required this.onAction,
this.selected = false,
this.visible = false,
@@ -50,6 +51,7 @@ class ChatSessionRow extends StatelessWidget {
final ValueChanged<JsonMap> onOpen;
final ValueChanged<JsonMap>? onOpenBeside;
final ValueChanged<JsonMap>? onOpenBelow;
final ValueChanged<JsonMap>? onFloat;
final VoidCallback? onLongPress;
final ValueChanged<SessionAction> onAction;
final bool selected;
@@ -164,6 +166,7 @@ class ChatSessionRow extends StatelessWidget {
onSelected: onAction,
allowOpenBeside: onOpenBeside != null,
allowOpenBelow: onOpenBelow != null,
allowFloat: onFloat != null,
),
),
);
@@ -22,6 +22,7 @@ Widget memoChatSessionRow({
required ValueChanged<JsonMap> onOpen,
ValueChanged<JsonMap>? onOpenBeside,
ValueChanged<JsonMap>? onOpenBelow,
ValueChanged<JsonMap>? onFloat,
required ValueChanged<JsonMap> onStar,
required ValueChanged<JsonMap>? onColor,
required ValueChanged<JsonMap> onRename,
@@ -42,6 +43,7 @@ Widget memoChatSessionRow({
onOpen,
onOpenBeside,
onOpenBelow,
onFloat,
onStar,
onColor,
onRename,
@@ -60,6 +62,7 @@ Widget memoChatSessionRow({
onOpen: onOpen,
onOpenBeside: onOpenBeside,
onOpenBelow: onOpenBelow,
onFloat: onFloat,
// A long-press is the touch way to the colour, the row's quick mark.
onLongPress: selectionOnly || onColor == null
? null
@@ -67,6 +70,7 @@ Widget memoChatSessionRow({
onAction: (action) => switch (action) {
SessionAction.openBeside => onOpenBeside?.call(session),
SessionAction.openBelow => onOpenBelow?.call(session),
SessionAction.float => onFloat?.call(session),
SessionAction.star => onStar(session),
SessionAction.color => onColor?.call(session),
SessionAction.rename => onRename(session),
@@ -8,9 +8,8 @@ extension ChatWorkspaceFloat on ChatWorkspaceController {
bool holdsSession(String sessionId) =>
panes.any((pane) => pane.sessionId == sessionId);
/// A tiled pane can float while another chat stays in the tiling.
bool canFloat(String paneId) =>
paneCount > 1 && panes.any((pane) => pane.id == paneId);
/// Any tiled pane can float, the last one too; the tiling is then empty.
bool canFloat(String paneId) => panes.any((pane) => pane.id == paneId);
/// Takes the tiled pane [paneId] out of the tiling for a window; the pane
/// beside it becomes active. Null when it cannot float.
@@ -21,7 +20,9 @@ extension ChatWorkspaceFloat on ChatWorkspaceController {
_root = _remove(_root!, paneId);
if (_active == paneId) {
final after = panes;
_active = after[index.clamp(0, after.length - 1)].id;
_active = after.isEmpty
? null
: after[index.clamp(0, after.length - 1)].id;
}
_changed();
return pane;