Linux desktop: optimized release build, installer, Linux gaps
Build: split Dart debug info out of libapp.so (13.96 -> 11.27 MB, symbols kept in the cache) and fix icon tree shaking, which Flutter 3.44's Linux CMake backend silently disables by quoting the define; the build image patches its SDK copy (MaterialIcons 1.6 MB -> 25 KB). Impeller cannot be enabled in a Linux release build and was slower in a profile-build bench. Install: `./install --linux --install` installs the bundle into <prefix>/lib/app-linux with com.pipelines.app.desktop (the GTK/Wayland app id), its icon and a ~/.local/bin/pipelines-app link, through scripts/install-linux-app.sh. Linux gaps: notifications through the freedesktop daemon; HTML artifacts explain the missing web view instead of throwing; no Share for files; a GTK clipboard reader for pasting files and screenshots (Ctrl+V and Omarchy's Super+V); GTK header bar only on GNOME; window icon. Bench: native fixture frame log, wheel/mark steps and tool/perf/linux_desktop_bench.py (private Xvfb); results in app/notes/linux-desktop-optimized.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,18 +1,25 @@
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
import 'artifact_file.dart';
|
||||
import 'artifact_transfer.dart';
|
||||
|
||||
/// Phones and desktops: Download asks where to save the exact bytes (the
|
||||
/// system "Save as"), Share hands the named file to the share sheet.
|
||||
/// system "Save as"; on Linux the desktop portal's file chooser), Share hands
|
||||
/// the named file to the share sheet. Linux has no share sheet for files
|
||||
/// (share_plus throws), so Share is not offered there.
|
||||
bool get artifactDownloadSupported => true;
|
||||
|
||||
bool get artifactShareSupported => true;
|
||||
bool get artifactShareSupported =>
|
||||
defaultTargetPlatform != TargetPlatform.linux;
|
||||
|
||||
String get artifactDownloadUnsupportedMessage => '';
|
||||
|
||||
String get artifactShareUnsupportedMessage => '';
|
||||
String get artifactShareUnsupportedMessage =>
|
||||
defaultTargetPlatform == TargetPlatform.linux
|
||||
? 'Sharing files is not available on Linux; use Download.'
|
||||
: '';
|
||||
|
||||
Future<ArtifactTransferResult> saveArtifactFile(ArtifactFile file) async {
|
||||
try {
|
||||
|
||||
@@ -12,6 +12,18 @@ import 'artifact_external_open.dart';
|
||||
/// the full-screen view needs no zoom buttons.
|
||||
const bool inertHtmlZoomButtons = false;
|
||||
|
||||
/// The webview plugin has Android, iOS and macOS implementations only; the
|
||||
/// Linux and Windows apps say so instead of failing to create a web view.
|
||||
bool inertHtmlViewSupported([TargetPlatform? platform]) => switch (platform ??
|
||||
defaultTargetPlatform) {
|
||||
TargetPlatform.android || TargetPlatform.iOS || TargetPlatform.macOS => true,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
const String inertHtmlUnsupportedMessage =
|
||||
'This app cannot preview HTML on this platform: it has no web view. '
|
||||
'Download the file to open it in a browser.';
|
||||
|
||||
/// A web view with JavaScript disabled that refuses every navigation after the
|
||||
/// recorded document itself loads.
|
||||
///
|
||||
@@ -99,6 +111,7 @@ class _InertHtmlViewState extends State<InertHtmlView> {
|
||||
@override
|
||||
void didUpdateWidget(covariant InertHtmlView oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (!inertHtmlViewSupported()) return;
|
||||
if (oldWidget.html != widget.html || oldWidget.dark != widget.dark) {
|
||||
_loaded = false;
|
||||
_controller.loadHtmlString(_document);
|
||||
@@ -106,8 +119,20 @@ class _InertHtmlViewState extends State<InertHtmlView> {
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => WebViewWidget(
|
||||
controller: _controller,
|
||||
gestureRecognizers: widget.interactive ? _allGestures : _inlineGestures,
|
||||
);
|
||||
Widget build(BuildContext context) => inertHtmlViewSupported()
|
||||
? WebViewWidget(
|
||||
controller: _controller,
|
||||
gestureRecognizers: widget.interactive
|
||||
? _allGestures
|
||||
: _inlineGestures,
|
||||
)
|
||||
: const Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Text(
|
||||
inertHtmlUnsupportedMessage,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
|
||||
import 'notification_bridge.dart';
|
||||
@@ -7,8 +8,10 @@ import 'notification_models.dart';
|
||||
|
||||
/// System notifications from the native app: Android's notification shade (when
|
||||
/// its background notification service is off), iOS's and macOS's
|
||||
/// notification centre. [close] removes a delivered one by its tag. The permission is cached so [environment] stays synchronous; it
|
||||
/// is refreshed when the bridge starts and after every request.
|
||||
/// notification centre, and the Linux desktop's notification daemon (the
|
||||
/// freedesktop D-Bus service: mako, dunst, GNOME Shell, Plasma). [close]
|
||||
/// removes a delivered one by its tag. The permission is cached so
|
||||
/// [environment] stays synchronous; it is refreshed when the bridge starts and after every request.
|
||||
class NativeNotificationBridge implements NotificationBridge {
|
||||
NativeNotificationBridge() {
|
||||
_ready = _start();
|
||||
@@ -40,13 +43,27 @@ class NativeNotificationBridge implements NotificationBridge {
|
||||
requestSoundPermission: false,
|
||||
);
|
||||
|
||||
/// The bundle's icon (installed by the Linux runner's CMake beside
|
||||
/// `flutter_assets`), so a portable, uninstalled bundle has one too.
|
||||
static final _linuxSettings = LinuxInitializationSettings(
|
||||
defaultActionName: 'Open',
|
||||
defaultIcon: FilePathLinuxIcon(
|
||||
'${File(Platform.resolvedExecutable).parent.path}/data/app_icon.png',
|
||||
),
|
||||
);
|
||||
|
||||
/// The Linux app, by its target platform rather than the host's, so a test
|
||||
/// on a Linux machine still sees the (Android) test platform.
|
||||
static bool get _linux => defaultTargetPlatform == TargetPlatform.linux;
|
||||
|
||||
Future<void> _start() async {
|
||||
try {
|
||||
await _plugin.initialize(
|
||||
settings: const InitializationSettings(
|
||||
settings: InitializationSettings(
|
||||
android: AndroidInitializationSettings('@mipmap/ic_launcher'),
|
||||
iOS: _darwin,
|
||||
macOS: _darwin,
|
||||
linux: _linuxSettings,
|
||||
),
|
||||
onDidReceiveNotificationResponse: (response) {
|
||||
final id = response.id;
|
||||
@@ -63,7 +80,10 @@ class NativeNotificationBridge implements NotificationBridge {
|
||||
}
|
||||
|
||||
Future<void> _refresh() async {
|
||||
if (Platform.isAndroid) {
|
||||
if (_linux) {
|
||||
// A notification daemon asks no permission.
|
||||
_permission = 'granted';
|
||||
} else if (Platform.isAndroid) {
|
||||
final enabled = await _plugin
|
||||
.resolvePlatformSpecificImplementation<
|
||||
AndroidFlutterLocalNotificationsPlugin
|
||||
@@ -82,7 +102,8 @@ class NativeNotificationBridge implements NotificationBridge {
|
||||
|
||||
@override
|
||||
NotificationEnvironment environment() => NotificationEnvironment(
|
||||
supported: Platform.isAndroid || Platform.isIOS || Platform.isMacOS,
|
||||
supported:
|
||||
Platform.isAndroid || Platform.isIOS || Platform.isMacOS || _linux,
|
||||
// A native app needs no secure origin.
|
||||
secureContext: true,
|
||||
permission: _permission,
|
||||
|
||||
@@ -7,7 +7,9 @@ import 'package:flutter/widgets.dart';
|
||||
import 'chat_attachment_picker.dart';
|
||||
import 'chat_clipboard_paste.dart';
|
||||
|
||||
/// The macOS Runner's pasteboard reader (macos/Runner/MainFlutterWindow.swift).
|
||||
/// The desktop Runners' clipboard reader: macOS's
|
||||
/// (macos/Runner/MainFlutterWindow.swift) and Linux's
|
||||
/// (linux/runner/clipboard_files.cc).
|
||||
const MethodChannel chatClipboardFilesChannel = MethodChannel(
|
||||
'pipelines/clipboard_files',
|
||||
);
|
||||
@@ -17,7 +19,7 @@ const MethodChannel chatClipboardFilesChannel = MethodChannel(
|
||||
///
|
||||
/// Flutter's own [Clipboard] carries text only, so a native host reads the
|
||||
/// pasteboard through the Runner. Each subscription watches for the platform
|
||||
/// paste shortcut (Cmd+V). When its composer may take the paste it consumes
|
||||
/// paste shortcut (Cmd+V on macOS, Ctrl+V on Linux). When its composer may take the paste it consumes
|
||||
/// the key, asks the Runner for the pasteboard's files (Finder file URLs, else
|
||||
/// a copied or screenshot image) and hands them over; a pasteboard without
|
||||
/// files pastes its text into the composer instead, so the consumed key never
|
||||
@@ -46,13 +48,14 @@ ChatClipboardPaste nativeChatClipboardPaste({
|
||||
);
|
||||
|
||||
/// Whether the held modifiers make V the host's paste shortcut: Cmd alone on
|
||||
/// macOS.
|
||||
bool chatIsNativePasteShortcut() {
|
||||
/// macOS; Ctrl on Linux, also with Super held (Omarchy's universal Super+V
|
||||
/// sends Ctrl+V while Super is down).
|
||||
bool chatIsNativePasteShortcut([TargetPlatform? platform]) {
|
||||
final keys = HardwareKeyboard.instance;
|
||||
return keys.isMetaPressed &&
|
||||
!keys.isControlPressed &&
|
||||
!keys.isAltPressed &&
|
||||
!keys.isShiftPressed;
|
||||
if (keys.isAltPressed || keys.isShiftPressed) return false;
|
||||
return (platform ?? defaultTargetPlatform) == TargetPlatform.linux
|
||||
? keys.isControlPressed
|
||||
: keys.isMetaPressed && !keys.isControlPressed;
|
||||
}
|
||||
|
||||
Future<void> _readPasteboard(
|
||||
@@ -121,4 +124,5 @@ String chatNothingToPasteMessage(List<String> types) => types.isEmpty
|
||||
|
||||
/// Whether [platform] has a Runner that answers [chatClipboardFilesChannel].
|
||||
bool chatHostReadsClipboardFiles(TargetPlatform platform) =>
|
||||
!kIsWeb && platform == TargetPlatform.macOS;
|
||||
!kIsWeb &&
|
||||
(platform == TargetPlatform.macOS || platform == TargetPlatform.linux);
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'chat_clipboard_paste_native.dart';
|
||||
|
||||
/// Native clipboard-file paste.
|
||||
///
|
||||
/// macOS reads the pasteboard through its Runner
|
||||
/// macOS and Linux read the clipboard through their Runners
|
||||
/// ([nativeChatClipboardPaste]). Other native hosts have no pasteboard reader
|
||||
/// yet: they report that missing capability rather than pretending no paste
|
||||
/// happened, and the composer keeps the host field's own text paste.
|
||||
|
||||
Reference in New Issue
Block a user