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:
@@ -132,6 +132,10 @@ class TerminalLayout extends ChangeNotifier {
|
||||
/// Whether the last change could not be saved.
|
||||
bool saveFailed = false;
|
||||
|
||||
/// Whether changes are saved. A detached window reads the device's layout
|
||||
/// but never writes it: the main window owns it.
|
||||
bool persist = true;
|
||||
|
||||
Future<void> restore() async {
|
||||
final revision = _revision;
|
||||
final raw = await _store.load();
|
||||
@@ -196,6 +200,7 @@ class TerminalLayout extends ChangeNotifier {
|
||||
|
||||
/// Saves the current layout (a drag saves once, when it ends).
|
||||
Future<void> save() async {
|
||||
if (!persist) return;
|
||||
final revision = _revision;
|
||||
final saved = await _store.save(
|
||||
jsonEncode({
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../shell/detached/detached_window_scope.dart';
|
||||
import 'terminal_browser_keys.dart';
|
||||
import 'terminal_hub.dart';
|
||||
import 'terminal_layout.dart';
|
||||
@@ -67,43 +68,67 @@ class TerminalTabStrip extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// The options menu: the modes, the browser keys capture (on a browser
|
||||
/// that can) and Hide terminal, with the shortcuts under them.
|
||||
Widget _options(BuildContext context) => TerminalMenuButton<_Option>(
|
||||
label: 'Terminal options',
|
||||
info: TerminalShortcutLabels.current().summary,
|
||||
icon: Icons.more_vert,
|
||||
choices: [
|
||||
for (final mode in TerminalMode.values)
|
||||
TerminalChoice(
|
||||
_Option(mode),
|
||||
mode.label,
|
||||
checked: layout.mode == mode,
|
||||
key: ValueKey('terminal-mode-${mode.name}'),
|
||||
/// The options menu: the modes, Open in new window (where the platform
|
||||
/// has windows), the browser keys capture (on a browser that can) and
|
||||
/// Hide terminal, with the shortcuts under them.
|
||||
Widget _options(BuildContext context) {
|
||||
final opener = DetachedWindowScope.maybeOf(context);
|
||||
return TerminalMenuButton<_Option>(
|
||||
label: 'Terminal options',
|
||||
info: TerminalShortcutLabels.current().summary,
|
||||
icon: Icons.more_vert,
|
||||
choices: [
|
||||
for (final mode in TerminalMode.values)
|
||||
TerminalChoice(
|
||||
_Option(mode),
|
||||
mode.label,
|
||||
checked: layout.mode == mode,
|
||||
key: ValueKey('terminal-mode-${mode.name}'),
|
||||
),
|
||||
if (opener != null)
|
||||
const TerminalChoice(
|
||||
_Option(null, newWindow: true),
|
||||
detachedWindowLabel,
|
||||
key: ValueKey('terminal-new-window'),
|
||||
),
|
||||
if (browserKeys.supported)
|
||||
TerminalChoice(
|
||||
const _Option(null, browserKeys: true),
|
||||
'Capture browser keys',
|
||||
checked: browserKeys.active,
|
||||
key: const ValueKey('terminal-browser-keys'),
|
||||
),
|
||||
const TerminalChoice(
|
||||
_Option(null),
|
||||
'Hide terminal',
|
||||
key: ValueKey('terminal-hide'),
|
||||
),
|
||||
if (browserKeys.supported)
|
||||
TerminalChoice(
|
||||
const _Option(null, browserKeys: true),
|
||||
'Capture browser keys',
|
||||
checked: browserKeys.active,
|
||||
key: const ValueKey('terminal-browser-keys'),
|
||||
),
|
||||
const TerminalChoice(
|
||||
_Option(null),
|
||||
'Hide terminal',
|
||||
key: ValueKey('terminal-hide'),
|
||||
),
|
||||
],
|
||||
onSelected: (option) {
|
||||
if (option.browserKeys) {
|
||||
unawaited(toggleTerminalBrowserKeys(context, browserKeys));
|
||||
} else if (option.mode == null) {
|
||||
layout.hide();
|
||||
} else {
|
||||
layout.setMode(option.mode!);
|
||||
}
|
||||
},
|
||||
);
|
||||
],
|
||||
onSelected: (option) {
|
||||
if (option.newWindow) {
|
||||
_openInNewWindow(opener!);
|
||||
} else if (option.browserKeys) {
|
||||
unawaited(toggleTerminalBrowserKeys(context, browserKeys));
|
||||
} else if (option.mode == null) {
|
||||
layout.hide();
|
||||
} else {
|
||||
layout.setMode(option.mode!);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// The terminal moves to a window of its own, on the selected tab; this
|
||||
/// one hides it once that window is open. The terminals keep running on
|
||||
/// the machines, so both windows reach the same shells.
|
||||
void _openInNewWindow(DetachedWindowOpener opener) {
|
||||
final tab = hub.selected;
|
||||
opener.openTerminal(
|
||||
tabKey: tab?.key ?? '',
|
||||
title: tab == null ? 'Terminal' : 'Terminal: ${tab.title}',
|
||||
onOpened: layout.hide,
|
||||
);
|
||||
}
|
||||
|
||||
String _label(TerminalTab tab) =>
|
||||
hub.multiMachine ? '${tab.title} · ${tab.machineName}' : tab.title;
|
||||
@@ -152,7 +177,8 @@ class TerminalTabStrip extends StatelessWidget {
|
||||
/// A mode to switch to, (null) hiding the terminal, or the browser keys
|
||||
/// capture.
|
||||
class _Option {
|
||||
const _Option(this.mode, {this.browserKeys = false});
|
||||
const _Option(this.mode, {this.browserKeys = false, this.newWindow = false});
|
||||
final TerminalMode? mode;
|
||||
final bool browserKeys;
|
||||
final bool newWindow;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user