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>
84 lines
2.9 KiB
Dart
84 lines
2.9 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/application/detached/detached_platform.dart';
|
|
import 'package:pipelines_app/application/detached/detached_route.dart';
|
|
|
|
void main() {
|
|
test('each kind round-trips through its path', () {
|
|
final routes = [
|
|
DetachedRoute.chat('sess_01-A')!,
|
|
DetachedRoute.terminal(),
|
|
DetachedRoute.terminal('mac/term 1'),
|
|
DetachedRoute.diff('Tok_en-9')!,
|
|
];
|
|
for (final route in routes) {
|
|
expect(DetachedRoute.parse(route.path), route, reason: route.path);
|
|
}
|
|
expect(DetachedRoute.chat('a')!.path, '/window/chat/a');
|
|
expect(DetachedRoute.terminal().path, '/window/terminal');
|
|
expect(
|
|
DetachedRoute.terminal('server/t1').path,
|
|
'/window/terminal?tab=server%2Ft1',
|
|
);
|
|
expect(DetachedRoute.diff('abc')!.path, '/window/diff/abc');
|
|
});
|
|
|
|
test('a full URL with an origin and fixture parameters parses', () {
|
|
final route = DetachedRoute.parse(
|
|
'https://tank.example.ts.net/window/chat/perf-chat-0?chats=2&theme=dark',
|
|
);
|
|
expect(route, DetachedRoute.chat('perf-chat-0'));
|
|
expect(
|
|
DetachedRoute.parse('http://x/window/terminal?tab=s%2F7&theme=dark'),
|
|
DetachedRoute.terminal('s/7'),
|
|
);
|
|
});
|
|
|
|
test('ordinary app locations and malformed windows are not detached', () {
|
|
for (final location in [
|
|
'/',
|
|
'/chat/a',
|
|
'/runs/7',
|
|
'/window',
|
|
'/window/chat',
|
|
'/window/chat/a/b',
|
|
'/window/chat/not%20valid',
|
|
'/window/diff/has.dot',
|
|
'/window/diff/${'x' * 65}',
|
|
'/window/pipelines/3',
|
|
'/windows/chat/a',
|
|
'',
|
|
]) {
|
|
expect(DetachedRoute.parse(location), isNull, reason: location);
|
|
}
|
|
expect(DetachedRoute.chat('no spaces'), isNull);
|
|
expect(DetachedRoute.diff(''), isNull);
|
|
expect(DetachedRoute.terminal('k' * 600).id, isEmpty);
|
|
});
|
|
|
|
test('a native launch names its window by argument or environment', () {
|
|
final chat = DetachedRoute.chat('a');
|
|
expect(DetachedRoute.fromLaunch(['--detached', '/window/chat/a']), chat);
|
|
expect(DetachedRoute.fromLaunch(['--detached=/window/chat/a']), chat);
|
|
expect(
|
|
DetachedRoute.fromLaunch(const [], {
|
|
'PIPELINES_DETACHED': '/window/terminal',
|
|
}),
|
|
DetachedRoute.terminal(),
|
|
);
|
|
expect(DetachedRoute.fromLaunch(const []), isNull);
|
|
expect(
|
|
DetachedRoute.fromLaunch(const [], {'PIPELINES_DETACHED': ''}),
|
|
isNull,
|
|
);
|
|
expect(DetachedRoute.fromLaunch(['--detached']), isNull);
|
|
});
|
|
|
|
test('messages carry a marker; anything else is ignored', () {
|
|
final text = encodeDetachedMessage({'type': 'bring-back', 'id': 'a'});
|
|
expect(decodeDetachedMessage(text), {'type': 'bring-back', 'id': 'a'});
|
|
expect(decodeDetachedMessage('{"type":"bring-back"}'), isNull);
|
|
expect(decodeDetachedMessage('not json'), isNull);
|
|
expect(decodeDetachedMessage('[1]'), isNull);
|
|
});
|
|
}
|