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>
97 lines
3.3 KiB
Dart
97 lines
3.3 KiB
Dart
import '../features/terminal/terminal_layout.dart';
|
|
import '../core/session/server_session.dart';
|
|
import '../ui/scale/ui_scale.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/widgets.dart';
|
|
|
|
import 'app_url_strategy.dart';
|
|
import 'detached/detached_platform.dart';
|
|
import 'pipelines_binding.dart';
|
|
import 'pipelines_root.dart';
|
|
import 'server_endpoint.dart';
|
|
import '../features/settings/settings_store.dart';
|
|
import '../ui/theme/app_font_controller.dart';
|
|
import '../ui/theme/app_font_licenses.dart';
|
|
import '../ui/motion/animation_speed.dart';
|
|
import '../ui/motion/quick_switch_animation.dart';
|
|
|
|
/// Native builds must supply their server explicitly; there is no baked host.
|
|
const configuredServerUrl = String.fromEnvironment('PIPELINES_SERVER_URL');
|
|
|
|
/// Resolves the launch endpoint: on a phone the server saved at onboarding,
|
|
/// else the build's default (which only pre-fills onboarding until saved).
|
|
Future<ServerEndpoint> resolveLaunchServer({
|
|
Uri? base,
|
|
String configured = configuredServerUrl,
|
|
bool web = kIsWeb,
|
|
SettingsStore? settingsStore,
|
|
}) async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
var endpoint = configured;
|
|
if (!web) {
|
|
try {
|
|
final saved =
|
|
(await (settingsStore ?? const SharedPreferencesSettingsStore())
|
|
.load())
|
|
.serverUrl;
|
|
if (saved.trim().isNotEmpty) endpoint = saved;
|
|
} catch (_) {
|
|
// Keep the build's default.
|
|
}
|
|
}
|
|
return ServerEndpoint.resolve(
|
|
base: base ?? Uri.base,
|
|
web: web,
|
|
configured: endpoint,
|
|
);
|
|
}
|
|
|
|
/// How long the first frame waits for a stored font before drawing in the
|
|
/// system font.
|
|
const appFontStartupWait = Duration(milliseconds: 1500);
|
|
|
|
/// Resolves the endpoint for this launch and starts the normal composition,
|
|
/// or a detached window's when the launch names one ([args] on a desktop,
|
|
/// the location on the web; see `detachedLaunchRoute`).
|
|
Future<void> runPipelinesApp({
|
|
Uri? base,
|
|
String configured = configuredServerUrl,
|
|
SettingsStore? settingsStore,
|
|
List<String> args = const [],
|
|
}) async {
|
|
useAppUrlStrategy();
|
|
final detached = detachedLaunchRoute(args);
|
|
// A detached window reads the device's terminal layout, never writes it.
|
|
if (detached != null) TerminalLayout.instance.persist = false;
|
|
PipelinesBinding.ensureInitialized();
|
|
registerAppFontLicenses();
|
|
// The device's chosen font loads beside the session; a slow download does
|
|
// not hold the first frame, and applies when it lands.
|
|
final animationSpeed = AnimationSpeedController.instance.restore();
|
|
final uiScale = UiScaleController.instance.restore();
|
|
final terminalLayout = TerminalLayout.instance.restore();
|
|
final quickSwitchAnimation = QuickSwitchAnimationController.instance
|
|
.restore();
|
|
final font = AppFontController.instance.restore(wait: appFontStartupWait);
|
|
// A phone behind the web login reconnects with its kept session.
|
|
await ServerSession.load();
|
|
await font;
|
|
await animationSpeed;
|
|
await uiScale;
|
|
await terminalLayout;
|
|
await quickSwitchAnimation;
|
|
final server = await resolveLaunchServer(
|
|
base: base,
|
|
configured: configured,
|
|
settingsStore: settingsStore,
|
|
);
|
|
runApp(
|
|
PipelinesRoot(
|
|
server: server,
|
|
buildDefault: configured,
|
|
signedIn: kIsWeb || ServerSession.cookie != null,
|
|
detached: detached,
|
|
),
|
|
);
|
|
}
|