Files
pipelines/app/lib/application/bootstrap.dart
T
alan 3d739c3bfc Copy and paste: the desktop's universal copy key works; Ctrl+C at the terminal login keeps the terminal
Omarchy's Super+C sends Ctrl+C by setting the modifier state with no Ctrl key
event while Super is held. Flutter's web engine only presses a modifier on its
own key event, so the app saw a plain "c": the chat selection was not copied
and the terminal typed the letter. A key modifier sync in front of the
framework's key handler now presses the modifiers the browser event's flags
hold (and outside Apple platforms lets go of a held Meta for Ctrl+C/V/X/A/
Insert), installed by the app's binding.

The terminal copies a selection on Ctrl+C without sending ^C, treats the
injected copy key as copy only, and pastes on Shift+Insert. A refused
clipboard write or read now shows a message instead of failing silently.

Server: before the login completes, Ctrl+C and Ctrl+\ erase the typed
password (Ctrl+U) and Ctrl+Z is dropped, so su is not killed and the terminal
no longer ends.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 17:57:28 +00:00

89 lines
2.9 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 '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.
Future<void> runPipelinesApp({
Uri? base,
String configured = configuredServerUrl,
SettingsStore? settingsStore,
}) async {
useAppUrlStrategy();
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,
),
);
}