App: open a chat, the terminal or a diff in a new window

"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>
This commit is contained in:
2026-12-03 12:47:42 +00:00
parent c4de1de27b
commit 61c7eee2b0
46 changed files with 3223 additions and 72 deletions
@@ -14,6 +14,8 @@ import 'diff_search_bar.dart';
import 'diff_search_controller.dart';
import 'file_diff_viewer.dart';
import 'stacked_diff_view.dart';
import '../../../shell/detached/detached_window_scope.dart';
import '../../../shell/windows/window_scope.dart';
import '../windows/diff_windows.dart';
/// Whether diff pages show every file stacked (GitHub's Files changed) rather
@@ -54,6 +56,7 @@ class FileDiffPage extends StatefulWidget {
required this.files,
this.initialIndex = 0,
this.inWindow = false,
this.actions = const [],
});
final List<FileChange> files;
@@ -62,6 +65,10 @@ class FileDiffPage extends StatefulWidget {
/// Shown inside a floating window: no Back, and no Open in a window.
final bool inWindow;
/// The host's own bar buttons, after the diff's (a detached window's
/// Bring back).
final List<Widget> actions;
@override
State<FileDiffPage> createState() => _FileDiffPageState();
}
@@ -184,6 +191,25 @@ class _FileDiffPageState extends State<FileDiffPage> {
windows.open(widget.files, initialIndex: _index);
}
/// Sends the diff to a window of its own; once it opens, this page closes
/// (or the floating window it is in).
void _openInNewWindow(DetachedWindowOpener opener, String title) {
final window = WindowScope.maybeOf(context);
opener.openDiff(
[for (final file in widget.files) file.toJson()],
initialIndex: _index,
title: title,
onOpened: () {
if (!mounted) return;
if (window != null) {
window.manager.close(window.entry.id);
} else {
Navigator.of(context).maybePop();
}
},
);
}
void _toggleFile(int index) => setState(() {
if (!_collapsed.remove(index)) _collapsed.add(index);
});
@@ -288,6 +314,13 @@ class _FileDiffPageState extends State<FileDiffPage> {
),
null => null,
},
if (DetachedWindowScope.maybeOf(context) case final opener?)
IconButton(
key: const ValueKey('diff-open-new-window'),
tooltip: detachedWindowLabel,
onPressed: () => _openInNewWindow(opener, title),
icon: const Icon(Icons.open_in_browser),
),
IconButton(
key: const ValueKey('diff-search-open'),
tooltip: 'Find in diff (/)',
@@ -315,6 +348,7 @@ class _FileDiffPageState extends State<FileDiffPage> {
_all ? Icons.article_outlined : Icons.view_agenda_outlined,
),
),
...widget.actions,
],
),
body: body,