61c7eee2b0
"Open in new window" sits beside Float: the chat pane and chat list row menus, a floating chat window's title bar, the terminal options menu and the diff bar, plus Alt+Shift+Y for the chat with the keyboard (listed in the shortcut help). Once the window opens the item leaves the main window as Float takes a pane out of the tiling. The window is its own app instance at /window/chat/<id>, /window/terminal?tab=<key> or /window/diff/<token>: only that item, named after it, with "Bring back to main window". It has its own connection and writes no shared layout (no open-chat workspace, window store or terminal layout) and posts no notifications, so they stay the main window's. Web opens a popup window (a blocked popup offers a tab); Linux and macOS start a second process with --detached (Flutter's multi-window API is still experimental); Android and iOS hide the action. The capture kit gains a follow step for windows a page opens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
73 lines
2.0 KiB
Dart
73 lines
2.0 KiB
Dart
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'detached_route.dart';
|
|
|
|
/// The action that hands a detached item back to the main window.
|
|
const detachedBringBackLabel = 'Bring back to main window';
|
|
|
|
/// What a detached window offers the item it shows.
|
|
class DetachedWindowControls {
|
|
const DetachedWindowControls({
|
|
required this.ready,
|
|
required this.sync,
|
|
required this.setTitle,
|
|
required this.close,
|
|
required this.bringBackItem,
|
|
});
|
|
|
|
/// Whether the server has been reached, so the item can be read.
|
|
final ValueListenable<bool> ready;
|
|
|
|
/// Advances when the connection is replaced; open views re-subscribe.
|
|
final ValueListenable<int> sync;
|
|
|
|
/// Names the window after the item (the browser or desktop title).
|
|
final ValueChanged<String> setTitle;
|
|
|
|
/// Closes this window.
|
|
final VoidCallback close;
|
|
|
|
/// Gives the item back to the main window and closes this one.
|
|
final void Function(
|
|
DetachedKind kind,
|
|
String id,
|
|
List<Map<String, Object?>> files,
|
|
int initialIndex,
|
|
)
|
|
bringBackItem;
|
|
|
|
void bringBack(
|
|
DetachedKind kind,
|
|
String id, {
|
|
List<Map<String, Object?>> files = const [],
|
|
int initialIndex = 0,
|
|
}) => bringBackItem(kind, id, files, initialIndex);
|
|
}
|
|
|
|
/// Shown until the window's connection first succeeds.
|
|
class DetachedConnecting extends StatelessWidget {
|
|
const DetachedConnecting({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Center(
|
|
child: Text('Connecting…', style: Theme.of(context).textTheme.bodyMedium),
|
|
);
|
|
}
|
|
|
|
/// The "Bring back to main window" button of a window without a menu of its
|
|
/// own (the terminal's tab strip, the diff's bar).
|
|
class DetachedBringBackButton extends StatelessWidget {
|
|
const DetachedBringBackButton({super.key, required this.onPressed});
|
|
|
|
final VoidCallback onPressed;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => IconButton(
|
|
key: const ValueKey('detached-bring-back'),
|
|
tooltip: detachedBringBackLabel,
|
|
onPressed: onPressed,
|
|
icon: const Icon(Icons.login),
|
|
);
|
|
}
|