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
@@ -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),