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:
@@ -0,0 +1,120 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/application/app_terminals.dart';
|
||||
import 'package:pipelines_app/application/detached/detached_route.dart';
|
||||
import 'package:pipelines_app/application/detached/detached_terminal.dart';
|
||||
import 'package:pipelines_app/application/detached/detached_window_body.dart';
|
||||
import 'package:pipelines_app/features/terminal/terminal_hub.dart';
|
||||
import 'package:pipelines_app/features/terminal/terminal_layout.dart';
|
||||
import 'package:pipelines_app/features/terminal/terminal_tab_strip.dart';
|
||||
import 'package:pipelines_app/shell/detached/detached_window_scope.dart';
|
||||
|
||||
import '../../application/detached/detached_fixtures.dart';
|
||||
import 'terminal_fixtures.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('the options menu sends the terminal to a new window', (
|
||||
tester,
|
||||
) async {
|
||||
final mac = TerminalGateway()..add('t1', text: 'hello\r\n');
|
||||
addTearDown(mac.close);
|
||||
final hub = TerminalHub(TestMachines([machine('mac', mac)]))..activate();
|
||||
addTearDown(hub.dispose);
|
||||
await tester.runAsync(hub.listed);
|
||||
final layout = TerminalLayout(store: MemoryLayoutStore())..show();
|
||||
final opener = FakeOpener();
|
||||
await tester.pumpWidget(
|
||||
DetachedWindowScope(
|
||||
opener: opener,
|
||||
child: MaterialApp(
|
||||
home: Scaffold(
|
||||
body: TerminalTabStrip(hub: hub, layout: layout),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.tap(find.byTooltip('Terminal options'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const ValueKey('terminal-new-window')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(opener.terminals, ['mac/t1']);
|
||||
expect(layout.visible, isFalse, reason: 'it leaves the main window');
|
||||
});
|
||||
|
||||
testWidgets('without platform windows the menu has no such choice', (
|
||||
tester,
|
||||
) async {
|
||||
final hub = TerminalHub(TestMachines([]));
|
||||
addTearDown(hub.dispose);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: TerminalTabStrip(
|
||||
hub: hub,
|
||||
layout: TerminalLayout(store: MemoryLayoutStore()),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.tap(find.byTooltip('Terminal options'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const ValueKey('terminal-new-window')), findsNothing);
|
||||
expect(find.text('Floating window'), findsOneWidget);
|
||||
});
|
||||
|
||||
test('a layout that does not persist never saves', () async {
|
||||
final store = MemoryLayoutStore();
|
||||
final layout = TerminalLayout(store: store)..persist = false;
|
||||
layout
|
||||
..setFontSize(18)
|
||||
..show();
|
||||
await layout.save();
|
||||
expect(store.saves, 0);
|
||||
expect(layout.fontSize, 18, reason: 'the window still follows it');
|
||||
});
|
||||
|
||||
testWidgets('a detached terminal opens on its tab, without modes, and '
|
||||
'gives it back', (tester) async {
|
||||
final mac = TerminalGateway()
|
||||
..add('t1', text: 'one\r\n')
|
||||
..add('t2', text: 'two\r\n');
|
||||
addTearDown(mac.close);
|
||||
final connection = ValueNotifier(0);
|
||||
final terminals = AppTerminals(
|
||||
pool: null,
|
||||
connection: connection,
|
||||
connected: () => true,
|
||||
gateway: mac,
|
||||
machineId: 'mac',
|
||||
machineName: () => 'Mac',
|
||||
layout: TerminalLayout(store: MemoryLayoutStore()),
|
||||
);
|
||||
addTearDown(terminals.dispose);
|
||||
final back = <(DetachedKind, String)>[];
|
||||
final titles = <String>[];
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: DetachedTerminal(
|
||||
terminals: terminals,
|
||||
tabKey: 'mac/t2',
|
||||
window: DetachedWindowControls(
|
||||
ready: ValueNotifier(true),
|
||||
sync: ValueNotifier(0),
|
||||
setTitle: titles.add,
|
||||
close: () {},
|
||||
bringBackItem: (kind, id, _, _) => back.add((kind, id)),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.runAsync(terminals.hub.listed);
|
||||
await tester.pump();
|
||||
expect(terminals.hub.selected?.key, 'mac/t2');
|
||||
expect(titles.last, startsWith('Terminal'));
|
||||
// There is no panel or floating mode to choose in a window of its own.
|
||||
expect(find.byTooltip('Terminal options'), findsNothing);
|
||||
await tester.tap(find.byTooltip('Bring back to main window'));
|
||||
expect(back, [(DetachedKind.terminal, 'mac/t2')]);
|
||||
await tester.pumpWidget(const SizedBox());
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user