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>
90 lines
3.5 KiB
Dart
90 lines
3.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/application/detached/detached_route.dart';
|
|
import 'package:pipelines_app/application/detached/detached_windows.dart';
|
|
import 'package:pipelines_app/application/pipelines_app.dart';
|
|
import 'package:pipelines_app/core/transport/pipelines_client.dart';
|
|
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
|
|
import 'package:pipelines_app/shell/detached/detached_window_scope.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import '../../core/transport/pipelines_client_test.dart' show FakeChannel;
|
|
import '../chat_registration_test.dart' show webServer;
|
|
import 'detached_fixtures.dart';
|
|
|
|
Future<void> _run(WidgetTester tester, ChatServer server, Duration d) async {
|
|
for (var t = 0; t < d.inMilliseconds; t += 16) {
|
|
server.answer();
|
|
await tester.pump(const Duration(milliseconds: 16));
|
|
}
|
|
server.answer();
|
|
}
|
|
|
|
void main() {
|
|
Future<(ChatServer, FakeDetachedPlatform)> pump(
|
|
WidgetTester tester, {
|
|
String route = '/chat/a',
|
|
}) async {
|
|
SharedPreferences.setMockInitialValues({});
|
|
tester.view.physicalSize = const Size(1600, 1000);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
final platform = FakeDetachedPlatform();
|
|
final channel = FakeChannel()..readyCompleter.complete();
|
|
final server = ChatServer(
|
|
channel,
|
|
openChats: [
|
|
{'session_id': 'a'},
|
|
],
|
|
);
|
|
final provider = PlatformRouteInformationProvider(
|
|
initialRouteInformation: RouteInformation(uri: Uri.parse(route)),
|
|
);
|
|
addTearDown(provider.dispose);
|
|
await tester.pumpWidget(
|
|
PipelinesApp(
|
|
androidSupported: false,
|
|
server: webServer(),
|
|
client: PipelinesClient(channelFactory: (_) => channel),
|
|
routeInformationProvider: provider,
|
|
detachedPlatform: platform,
|
|
),
|
|
);
|
|
await _run(tester, server, const Duration(milliseconds: 1200));
|
|
return (server, platform);
|
|
}
|
|
|
|
testWidgets('the main window offers new windows and sends the chat out of '
|
|
'its workspace', (tester) async {
|
|
final (server, platform) = await pump(tester);
|
|
final thread = find.byType(ChatThreadView);
|
|
expect(thread, findsOneWidget);
|
|
expect(DetachedWindowScope.maybeOf(tester.element(thread)), isNotNull);
|
|
await tester.tap(
|
|
find
|
|
.descendant(of: thread, matching: find.byTooltip('More actions'))
|
|
.hitTestable(),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
await tester.tap(find.text('Open in new window (Alt+Shift+Y)'));
|
|
await _run(tester, server, const Duration(milliseconds: 600));
|
|
expect(platform.launches.single.route, DetachedRoute.chat('a'));
|
|
expect(platform.launches.single.title, 'Chat a');
|
|
expect(find.byType(ChatThreadView), findsNothing);
|
|
// The main window's own workspace is written without the chat.
|
|
final write = server.workspaceWrites.last['chat_open_workspace_request'];
|
|
expect((write as Map)['entries'], isEmpty);
|
|
});
|
|
|
|
testWidgets('a chat brought back opens in the main window', (tester) async {
|
|
final (server, platform) = await pump(tester, route: '/runs');
|
|
expect(find.byType(ChatThreadView), findsNothing);
|
|
platform.incoming.add(
|
|
const DetachedReturn(DetachedKind.chat, 'b').toMessage(),
|
|
);
|
|
await _run(tester, server, const Duration(milliseconds: 900));
|
|
final thread = tester.widget<ChatThreadView>(find.byType(ChatThreadView));
|
|
expect(thread.sessionId, 'b');
|
|
});
|
|
}
|