Merge branch 'worktree-agent-ae3af4174afca7f4d'
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -24,10 +24,18 @@ COPY --chmod=0755 build.sh /usr/local/bin/pipelines-app-build
|
||||
WORKDIR /tmp
|
||||
|
||||
FROM web AS linux
|
||||
# Flutter's CMake backend passes `-dTreeShakeIcons="true"` with the quotes
|
||||
# kept (no shell parses them), so `flutter build linux` never tree-shakes the
|
||||
# icon fonts and ships the full 1.6 MB MaterialIcons font. Pass the plain value
|
||||
# in this image's copy; the grep fails the build if the line ever changes.
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends clang cmake ninja-build pkg-config libgtk-3-dev libstdc++-12-dev liblzma-dev \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& flutter precache --linux \
|
||||
&& backend=/opt/flutter/packages/flutter_tools/bin/tool_backend.dart \
|
||||
&& grep -q "'-dTreeShakeIcons=\"\$treeShakeIcons\"'," "$backend" \
|
||||
&& sed -i "s/'-dTreeShakeIcons=\"\$treeShakeIcons\"',/'-dTreeShakeIcons=\$treeShakeIcons',/" "$backend" \
|
||||
&& grep -q "'-dTreeShakeIcons=\$treeShakeIcons'," "$backend" \
|
||||
&& chmod -R a+rwX /opt/flutter /home/builder
|
||||
|
||||
FROM web AS android
|
||||
|
||||
+5
-1
@@ -42,8 +42,12 @@ PROPERTIES
|
||||
/tmp/apk-certificates.txt > /out/signing-certificate-sha256.txt
|
||||
;;
|
||||
linux)
|
||||
flutter build linux --release "$@"
|
||||
# Dart symbols go beside the bundle, not into libapp.so (about 18%
|
||||
# smaller); `flutter symbolize -i <trace> -d .debug-info/app.linux-x64.symbols`
|
||||
# reads a release stack trace. Icon fonts are tree-shaken (see Dockerfile).
|
||||
flutter build linux --release --split-debug-info=/tmp/debug-info "$@"
|
||||
cp -a build/linux/x64/release/bundle/. /out/
|
||||
cp -a /tmp/debug-info /out/.debug-info
|
||||
;;
|
||||
*)
|
||||
echo "unknown build: $kind" >&2
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -97,6 +97,11 @@ install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
|
||||
install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
|
||||
COMPONENT Runtime)
|
||||
|
||||
# The window icon (runner/my_application.cc); the installer also puts it in
|
||||
# the icon theme for the desktop entry.
|
||||
install(FILES "runner/resources/app_icon.png" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
|
||||
COMPONENT Runtime)
|
||||
|
||||
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
|
||||
COMPONENT Runtime)
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ project(runner LANGUAGES CXX)
|
||||
add_executable(${BINARY_NAME}
|
||||
"main.cc"
|
||||
"my_application.cc"
|
||||
"clipboard_files.cc"
|
||||
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
#include "clipboard_files.h"
|
||||
|
||||
#include <gio/gio.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
namespace {
|
||||
|
||||
FlMethodChannel* channel = nullptr;
|
||||
|
||||
// The MIME type of [path] from its name and contents, or "".
|
||||
gchar* mime_of(const gchar* path, const guchar* data, gsize length) {
|
||||
gboolean uncertain = FALSE;
|
||||
g_autofree gchar* type =
|
||||
g_content_type_guess(path, data, MIN(length, (gsize)4096), &uncertain);
|
||||
gchar* mime = type == nullptr ? nullptr : g_content_type_get_mime_type(type);
|
||||
return mime == nullptr ? g_strdup("") : mime;
|
||||
}
|
||||
|
||||
FlValue* file_entry(const gchar* name, const gchar* mime, const guchar* data,
|
||||
gsize length) {
|
||||
FlValue* entry = fl_value_new_map();
|
||||
fl_value_set_string_take(entry, "name", fl_value_new_string(name));
|
||||
fl_value_set_string_take(entry, "mime", fl_value_new_string(mime));
|
||||
fl_value_set_string_take(entry, "bytes",
|
||||
fl_value_new_uint8_list(data, length));
|
||||
return entry;
|
||||
}
|
||||
|
||||
// Adds each copied local file; folders and unreadable files become errors.
|
||||
gboolean add_uris(GtkClipboard* clipboard, FlValue* files, FlValue* errors) {
|
||||
g_auto(GStrv) uris = gtk_clipboard_wait_for_uris(clipboard);
|
||||
if (uris == nullptr || uris[0] == nullptr) return FALSE;
|
||||
gboolean any = FALSE;
|
||||
for (gchar** uri = uris; *uri != nullptr; uri++) {
|
||||
g_autofree gchar* path = g_filename_from_uri(*uri, nullptr, nullptr);
|
||||
if (path == nullptr) continue;
|
||||
any = TRUE;
|
||||
g_autofree gchar* name = g_path_get_basename(path);
|
||||
if (g_file_test(path, G_FILE_TEST_IS_DIR)) {
|
||||
g_autofree gchar* message =
|
||||
g_strdup_printf("%s is a folder; paste its files instead.", name);
|
||||
fl_value_append_take(errors, fl_value_new_string(message));
|
||||
continue;
|
||||
}
|
||||
g_autofree gchar* contents = nullptr;
|
||||
gsize length = 0;
|
||||
g_autoptr(GError) error = nullptr;
|
||||
if (!g_file_get_contents(path, &contents, &length, &error)) {
|
||||
g_autofree gchar* message =
|
||||
g_strdup_printf("Could not read %s: %s", name, error->message);
|
||||
fl_value_append_take(errors, fl_value_new_string(message));
|
||||
continue;
|
||||
}
|
||||
g_autofree gchar* mime =
|
||||
mime_of(path, reinterpret_cast<const guchar*>(contents), length);
|
||||
fl_value_append_take(
|
||||
files, file_entry(name, mime,
|
||||
reinterpret_cast<const guchar*>(contents), length));
|
||||
}
|
||||
return any;
|
||||
}
|
||||
|
||||
// The clipboard's own PNG (a screenshot tool's), else any image GTK can read
|
||||
// converted to PNG.
|
||||
void add_image(GtkClipboard* clipboard, FlValue* files) {
|
||||
g_autoptr(GtkSelectionData) png = gtk_clipboard_wait_for_contents(
|
||||
clipboard, gdk_atom_intern_static_string("image/png"));
|
||||
if (png != nullptr && gtk_selection_data_get_length(png) > 0) {
|
||||
fl_value_append_take(
|
||||
files, file_entry("", "image/png", gtk_selection_data_get_data(png),
|
||||
gtk_selection_data_get_length(png)));
|
||||
return;
|
||||
}
|
||||
g_autoptr(GdkPixbuf) image = gtk_clipboard_wait_for_image(clipboard);
|
||||
if (image == nullptr) return;
|
||||
g_autofree gchar* buffer = nullptr;
|
||||
gsize length = 0;
|
||||
if (gdk_pixbuf_save_to_buffer(image, &buffer, &length, "png", nullptr,
|
||||
nullptr)) {
|
||||
fl_value_append_take(
|
||||
files, file_entry("", "image/png",
|
||||
reinterpret_cast<const guchar*>(buffer), length));
|
||||
}
|
||||
}
|
||||
|
||||
FlValue* read_clipboard() {
|
||||
GtkClipboard* clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
|
||||
FlValue* files = fl_value_new_list();
|
||||
FlValue* errors = fl_value_new_list();
|
||||
FlValue* types = fl_value_new_list();
|
||||
GdkAtom* targets = nullptr;
|
||||
gint count = 0;
|
||||
if (gtk_clipboard_wait_for_targets(clipboard, &targets, &count)) {
|
||||
for (gint i = 0; i < count; i++) {
|
||||
g_autofree gchar* name = gdk_atom_name(targets[i]);
|
||||
fl_value_append_take(types, fl_value_new_string(name));
|
||||
}
|
||||
g_free(targets);
|
||||
}
|
||||
if (!add_uris(clipboard, files, errors)) add_image(clipboard, files);
|
||||
FlValue* reply = fl_value_new_map();
|
||||
fl_value_set_string_take(reply, "files", files);
|
||||
fl_value_set_string_take(reply, "errors", errors);
|
||||
fl_value_set_string_take(reply, "types", types);
|
||||
return reply;
|
||||
}
|
||||
|
||||
void method_call_cb(FlMethodChannel* channel, FlMethodCall* call,
|
||||
gpointer user_data) {
|
||||
g_autoptr(FlMethodResponse) response = nullptr;
|
||||
if (g_strcmp0(fl_method_call_get_name(call), "read") == 0) {
|
||||
g_autoptr(FlValue) reply = read_clipboard();
|
||||
response = FL_METHOD_RESPONSE(fl_method_success_response_new(reply));
|
||||
} else {
|
||||
response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new());
|
||||
}
|
||||
g_autoptr(GError) error = nullptr;
|
||||
if (!fl_method_call_respond(call, response, &error)) {
|
||||
g_warning("Failed to answer a clipboard read: %s", error->message);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void clipboard_files_register(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "ClipboardFiles");
|
||||
g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
|
||||
g_clear_object(&channel);
|
||||
channel = fl_method_channel_new(fl_plugin_registrar_get_messenger(registrar),
|
||||
"pipelines/clipboard_files",
|
||||
FL_METHOD_CODEC(codec));
|
||||
fl_method_channel_set_method_call_handler(channel, method_call_cb, nullptr,
|
||||
nullptr);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef RUNNER_CLIPBOARD_FILES_H_
|
||||
#define RUNNER_CLIPBOARD_FILES_H_
|
||||
|
||||
#include <flutter_linux/flutter_linux.h>
|
||||
|
||||
// Answers `read` on the `pipelines/clipboard_files` channel with the
|
||||
// clipboard's files (a file manager's copied URIs), else its image as PNG,
|
||||
// plus the clipboard's target names; the same reply shape as the macOS
|
||||
// Runner (lib/features/chat/domain/chat_clipboard_paste_native.dart).
|
||||
void clipboard_files_register(FlPluginRegistry* registry);
|
||||
|
||||
#endif // RUNNER_CLIPBOARD_FILES_H_
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <gdk/gdkx.h>
|
||||
#endif
|
||||
|
||||
#include "clipboard_files.h"
|
||||
#include "flutter/generated_plugin_registrant.h"
|
||||
|
||||
struct _MyApplication {
|
||||
@@ -15,6 +16,18 @@ struct _MyApplication {
|
||||
|
||||
G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
|
||||
|
||||
// The bundle's icon (data/app_icon.png beside the executable) for X11 window
|
||||
// managers and task bars. Wayland compositors take the icon from the desktop
|
||||
// entry named by the application id instead.
|
||||
static void set_window_icon(GtkWindow* window) {
|
||||
g_autofree gchar* executable = g_file_read_link("/proc/self/exe", nullptr);
|
||||
if (executable == nullptr) return;
|
||||
g_autofree gchar* directory = g_path_get_dirname(executable);
|
||||
g_autofree gchar* icon =
|
||||
g_build_filename(directory, "data", "app_icon.png", nullptr);
|
||||
gtk_window_set_icon_from_file(window, icon, nullptr);
|
||||
}
|
||||
|
||||
// Called when first Flutter frame received.
|
||||
static void first_frame_cb(MyApplication* self, FlView* view) {
|
||||
gtk_widget_show(gtk_widget_get_toplevel(GTK_WIDGET(view)));
|
||||
@@ -33,21 +46,18 @@ static void my_application_activate(GApplication* application) {
|
||||
? detached_title
|
||||
: "Pipelines";
|
||||
|
||||
// Use a header bar when running in GNOME as this is the common style used
|
||||
// by applications and is the setup most users will be using (e.g. Ubuntu
|
||||
// desktop).
|
||||
// If running on X and not using GNOME then just use a traditional title bar
|
||||
// in case the window manager does more exotic layout, e.g. tiling.
|
||||
// If running on Wayland assume the header bar will work (may need changing
|
||||
// if future cases occur).
|
||||
gboolean use_header_bar = TRUE;
|
||||
// A GTK header bar only on GNOME, whose shell expects client-side title
|
||||
// bars. Elsewhere (Hyprland, Sway, KDE, any X11 window manager) the window
|
||||
// takes the compositor's own decorations, or none on a tiling compositor,
|
||||
// instead of drawing a second title bar inside the tile.
|
||||
const gchar* desktop = g_getenv("XDG_CURRENT_DESKTOP");
|
||||
gboolean use_header_bar =
|
||||
desktop != nullptr && g_strrstr(desktop, "GNOME") != nullptr;
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
GdkScreen* screen = gtk_window_get_screen(window);
|
||||
if (GDK_IS_X11_SCREEN(screen)) {
|
||||
const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen);
|
||||
if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
|
||||
use_header_bar = FALSE;
|
||||
}
|
||||
use_header_bar = g_strcmp0(wm_name, "GNOME Shell") == 0;
|
||||
}
|
||||
#endif
|
||||
if (use_header_bar) {
|
||||
@@ -59,6 +69,7 @@ static void my_application_activate(GApplication* application) {
|
||||
} else {
|
||||
gtk_window_set_title(window, title);
|
||||
}
|
||||
set_window_icon(window);
|
||||
|
||||
gint width = 1280, height = 720;
|
||||
const gchar* detached_size = g_getenv("PIPELINES_WINDOW_SIZE");
|
||||
@@ -91,6 +102,7 @@ static void my_application_activate(GApplication* application) {
|
||||
gtk_widget_realize(GTK_WIDGET(view));
|
||||
|
||||
fl_register_plugins(FL_PLUGIN_REGISTRY(view));
|
||||
clipboard_files_register(FL_PLUGIN_REGISTRY(view));
|
||||
|
||||
gtk_widget_grab_focus(GTK_WIDGET(view));
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 72 KiB |
@@ -0,0 +1,69 @@
|
||||
# Linux desktop: optimized build, Linux gaps, bench
|
||||
|
||||
Flutter 3.44.6, Docker build image (`app/docker`), tank (Ryzen, RTX 2080 Ti,
|
||||
Omarchy/Hyprland). Measured 2026-12-03.
|
||||
|
||||
## Build flags
|
||||
|
||||
- `flutter build linux --release --split-debug-info` (symbols kept in the
|
||||
build cache as `.debug-info/`, not archived): libapp.so 13.96 MB -> 11.27 MB.
|
||||
- Icon tree shaking was silently off: Flutter's CMake backend
|
||||
(`tool_backend.dart`) passes `-dTreeShakeIcons="true"` with literal quotes.
|
||||
The Linux build image patches its own SDK copy (grep-guarded).
|
||||
MaterialIcons-Regular.otf 1,645,184 -> 24,952 bytes.
|
||||
- Bundle 37.1 MiB -> 33.1 MiB; archive 16.1 MB -> 14.3 MB.
|
||||
- Not used: `--obfuscate` (no speed gain, breaks symbol names in errors);
|
||||
Impeller (below).
|
||||
|
||||
## Impeller
|
||||
|
||||
The Linux release engine ignores engine switches (`FLUTTER_ENGINE_SWITCHES`
|
||||
is read only in debug/profile builds) and `FlDartProject` has no Impeller
|
||||
setter, so a release Linux build cannot opt in. Measured in a profile build
|
||||
on Xvfb/llvmpipe (`tool/perf/linux_desktop_bench.py`, 3 runs, medians):
|
||||
|
||||
| renderer | startup | scroll frames | raster sum | raster median | worst frame |
|
||||
|---|---|---|---|---|---|
|
||||
| Skia (default) | 1553 ms | 31 | 1141 ms | 29.4 ms | 168 ms |
|
||||
| Impeller GL | 1919 ms | 14 | 1600 ms | 103.5 ms | 302 ms |
|
||||
|
||||
Impeller was slower and dropped frames on the CPU rasteriser; no GPU numbers
|
||||
(see below). Skia stays.
|
||||
|
||||
## Linux vs web (same fixture, same 30-notch wheel scroll of a rich chat)
|
||||
|
||||
| build | startup / first frame | frames | build sum | build max | raster sum | raster max |
|
||||
|---|---|---|---|---|---|---|
|
||||
| Linux release, Xvfb + llvmpipe (CPU), 1280x720 | 1241 ms (process launch) | 43 | 59 ms | 11.0 ms | 1031 ms | 105 ms |
|
||||
| Web wasm, headless Chromium, no GPU, 1280x800 | 896 ms (navigation) | 57 | 126 ms | 18.3 ms | 2485 ms | 130 ms |
|
||||
| Web wasm, headless Chromium, GPU, 1280x800 | 278 ms (navigation) | 69 | 128 ms | 10.6 ms | 174 ms | 8.9 ms |
|
||||
|
||||
Medians of 5 runs. Build (UI thread) time is GPU-independent: native
|
||||
~1.4 ms/frame vs web ~1.9-2.2 ms/frame. Raster on the CPU: native 21 ms median
|
||||
vs web ~44 ms mean. Native startup counts process launch, GTK, engine and
|
||||
llvmpipe shader setup; the web figure starts at navigation in a running
|
||||
browser, so the two are not like for like.
|
||||
No Linux GPU raster or Wayland numbers: nothing here runs a GPU-backed
|
||||
headless Wayland or X server (no cage/weston; Xvfb is software only), and the
|
||||
operator's Hyprland session was not used.
|
||||
|
||||
## Linux gaps fixed
|
||||
|
||||
- Notifications: the bridge reported Linux unsupported; now uses
|
||||
flutter_local_notifications' D-Bus implementation with the bundle icon.
|
||||
- HTML artifacts: `WebViewController()` throws on Linux (no webview
|
||||
implementation); the view now explains and points at Download.
|
||||
- Share: share_plus throws for files on Linux; Share is no longer offered.
|
||||
- Clipboard paste of files/screenshots: new GTK reader
|
||||
(`linux/runner/clipboard_files.cc`) answers `pipelines/clipboard_files`;
|
||||
Ctrl+V (also Omarchy's Super+V) in the composer. Compiled and contract-
|
||||
tested in Dart; not exercised against a real clipboard here.
|
||||
- Window: GTK header bar only on GNOME (no second title bar in a Hyprland
|
||||
tile); window icon on X11; installer desktop entry `com.pipelines.app.desktop`
|
||||
= GTK application id = Wayland app id.
|
||||
|
||||
Unchanged and already native: url_launcher (xdg-open plugin), file_picker
|
||||
(xdg-desktop-portal FileChooser), keyboard shortcuts (Ctrl on non-Apple),
|
||||
terminal (Dart xterm). The session cookie is stored by shared_preferences
|
||||
(`~/.local/share/com.pipelines.app/shared_preferences.json`) as on the other
|
||||
native platforms; there is no keyring-backed storage in the app.
|
||||
@@ -0,0 +1,53 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/artifacts/actions/artifact_transfer_io.dart'
|
||||
as transfer;
|
||||
import 'package:pipelines_app/features/artifacts/ui/artifact_html_view_native.dart';
|
||||
|
||||
final _linux = TargetPlatformVariant.only(TargetPlatform.linux);
|
||||
|
||||
/// The Linux app has no web view and no file share sheet: it says so rather
|
||||
/// than failing to create the web view or throwing from Share.
|
||||
void main() {
|
||||
test('only Android, iOS and macOS have the HTML web view', () {
|
||||
for (final platform in TargetPlatform.values) {
|
||||
expect(
|
||||
inertHtmlViewSupported(platform),
|
||||
platform == TargetPlatform.android ||
|
||||
platform == TargetPlatform.iOS ||
|
||||
platform == TargetPlatform.macOS,
|
||||
reason: '$platform',
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('an HTML artifact on Linux explains why it is not previewed', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Scaffold(body: InertHtmlView(html: '<p>report</p>')),
|
||||
),
|
||||
);
|
||||
expect(find.text(inertHtmlUnsupportedMessage), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
// A new document does not reach for a web view either.
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Scaffold(body: InertHtmlView(html: '<p>next</p>')),
|
||||
),
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
}, variant: _linux);
|
||||
|
||||
testWidgets('Linux offers Download but not Share', (tester) async {
|
||||
expect(transfer.artifactDownloadSupported, isTrue);
|
||||
expect(transfer.artifactShareSupported, isFalse);
|
||||
expect(transfer.artifactShareUnsupportedMessage, contains('Download'));
|
||||
}, variant: _linux);
|
||||
|
||||
test('other native platforms keep Share', () {
|
||||
expect(transfer.artifactShareSupported, isTrue);
|
||||
expect(transfer.artifactShareUnsupportedMessage, isEmpty);
|
||||
});
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_composer_bar.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_composer_controller.dart';
|
||||
import 'package:pipelines_app/features/chat/conversation/chat_draft_store.dart';
|
||||
import 'package:pipelines_app/features/chat/domain/chat_clipboard_paste_native.dart';
|
||||
|
||||
import '../../../core/keyboard/browser_keys.dart';
|
||||
import 'chat_composer_bar_fixtures.dart';
|
||||
@@ -32,6 +33,12 @@ void main() {
|
||||
if (call.method == 'Clipboard.hasStrings') return {'value': true};
|
||||
return null;
|
||||
});
|
||||
// The Linux Runner's clipboard reader: no files, so the text is pasted.
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
||||
.setMockMethodCallHandler(
|
||||
chatClipboardFilesChannel,
|
||||
(call) async => {'files': const [], 'errors': const []},
|
||||
);
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
@@ -39,6 +46,8 @@ void main() {
|
||||
gateway.close();
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
||||
.setMockMethodCallHandler(SystemChannels.platform, null);
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
||||
.setMockMethodCallHandler(chatClipboardFilesChannel, null);
|
||||
});
|
||||
|
||||
for (final merged in [false, true]) {
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:pipelines_app/features/chat/domain/chat_clipboard_paste_native.d
|
||||
import '../conversation/chat_composer_bar_fixtures.dart';
|
||||
|
||||
final _macOS = TargetPlatformVariant.only(TargetPlatform.macOS);
|
||||
final _linux = TargetPlatformVariant.only(TargetPlatform.linux);
|
||||
|
||||
Finder get _field => find.byKey(const Key('chat-composer-field'));
|
||||
|
||||
@@ -77,10 +78,10 @@ void main() {
|
||||
|
||||
Future<void> done(WidgetTester tester) => tester.pumpWidget(const SizedBox());
|
||||
|
||||
test('only the macOS host reads clipboard files natively', () {
|
||||
test('the macOS and Linux hosts read clipboard files natively', () {
|
||||
expect(chatHostReadsClipboardFiles(TargetPlatform.macOS), isTrue);
|
||||
expect(chatHostReadsClipboardFiles(TargetPlatform.linux), isTrue);
|
||||
for (final platform in [
|
||||
TargetPlatform.linux,
|
||||
TargetPlatform.windows,
|
||||
TargetPlatform.android,
|
||||
TargetPlatform.iOS,
|
||||
@@ -228,4 +229,47 @@ void main() {
|
||||
expect(composer.draft, isEmpty);
|
||||
await done(tester);
|
||||
}, variant: _macOS);
|
||||
|
||||
testWidgets('Ctrl+V attaches a copied screenshot on Linux', (tester) async {
|
||||
pasteboard = {
|
||||
'files': [
|
||||
{
|
||||
'name': '',
|
||||
'mime': 'image/png',
|
||||
'bytes': Uint8List.fromList([3]),
|
||||
},
|
||||
],
|
||||
'errors': const [],
|
||||
};
|
||||
expect(hostChatClipboardPaste.isSupported, isTrue);
|
||||
await mount(tester);
|
||||
await tester.showKeyboard(_field);
|
||||
await tester.pump();
|
||||
await paste(tester, modifier: LogicalKeyboardKey.controlLeft);
|
||||
|
||||
expect(fileReads, 1);
|
||||
expect(find.text('pasted-1.png'), findsOneWidget);
|
||||
expect(textReads, 0);
|
||||
await done(tester);
|
||||
}, variant: _linux);
|
||||
|
||||
testWidgets('Ctrl+V of plain text on Linux pastes it once', (tester) async {
|
||||
await mount(tester);
|
||||
await tester.showKeyboard(_field);
|
||||
await paste(tester, modifier: LogicalKeyboardKey.controlLeft);
|
||||
|
||||
expect(fileReads, 1);
|
||||
expect(composer.draft, 'copied text');
|
||||
await done(tester);
|
||||
}, variant: _linux);
|
||||
|
||||
testWidgets('the Super key is not the Linux paste shortcut', (tester) async {
|
||||
await mount(tester);
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
await tester.pump();
|
||||
await paste(tester);
|
||||
|
||||
expect(fileReads, 0);
|
||||
await done(tester);
|
||||
}, variant: _linux);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:pipelines_app/application/server_endpoint.dart';
|
||||
|
||||
import '../perf/frame_log_native.dart';
|
||||
import 'fixture_steps.dart';
|
||||
import 'narrow_view.dart';
|
||||
|
||||
@@ -31,8 +32,10 @@ Map<String, String> fixtureParams() {
|
||||
return raw.isEmpty ? const {} : Uri.splitQueryString(raw);
|
||||
}
|
||||
|
||||
/// The DevTools probes are browser-only.
|
||||
void installHostProbes(Map<String, String> params) {}
|
||||
/// The DevTools probes are browser-only; `perf=1` prints frame timings to
|
||||
/// stdout (tool/perf/frame_log_native.dart).
|
||||
void installHostProbes(Map<String, String> params) =>
|
||||
installNativeFrameLog(params);
|
||||
|
||||
/// The route goes through [fixtureRouteProvider] instead.
|
||||
void openFixtureRoute(String route) {}
|
||||
|
||||
@@ -9,7 +9,10 @@ import 'package:flutter/services.dart';
|
||||
/// [script] is `;`-separated steps run after the first frame, 700 ms apart:
|
||||
/// `wait:<ms>`, `tap:<label>` (a Text, Tooltip, Semantics label or field
|
||||
/// hint; `tap:<label>#<n>` picks the n-th match), `tapxy:<x>,<y>`,
|
||||
/// `drag:<x>,<y>,<dx>,<dy>`, `type:<text>` (into the focused field; `\n`
|
||||
/// `drag:<x>,<y>,<dx>,<dy>`, `wheel:<x>,<y>,<dy>,<count>` (mouse-wheel
|
||||
/// notches 16 ms apart, as the web interaction bench sends), `mark:<name>`
|
||||
/// (prints `FIXTURE_MARK <name>`, so a bench can tell its phases apart),
|
||||
/// `type:<text>` (into the focused field; `\n`
|
||||
/// is a newline), `orient:landscape|portrait` and `labels` (prints the
|
||||
/// visible labels with their centres to the device log).
|
||||
void runFixtureSteps(String script) {
|
||||
@@ -54,6 +57,12 @@ Future<void> _run(String verb, String value) async {
|
||||
case 'drag':
|
||||
final p = value.split(',').map(double.parse).toList();
|
||||
await _drag(Offset(p[0], p[1]), Offset(p[2], p[3]));
|
||||
case 'mark':
|
||||
// ignore: avoid_print
|
||||
print('FIXTURE_MARK $value');
|
||||
case 'wheel':
|
||||
final p = value.split(',').map(double.parse).toList();
|
||||
await _wheel(Offset(p[0], p[1]), p[2], p[3].toInt());
|
||||
case 'type':
|
||||
_type(value.replaceAll(r'\n', '\n'));
|
||||
case 'orient':
|
||||
@@ -141,6 +150,20 @@ Future<void> _drag(Offset from, Offset by) async {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _wheel(Offset at, double dy, int count) async {
|
||||
final binding = GestureBinding.instance;
|
||||
for (var i = 0; i < count; i++) {
|
||||
binding.handlePointerEvent(
|
||||
PointerScrollEvent(
|
||||
kind: PointerDeviceKind.mouse,
|
||||
position: at,
|
||||
scrollDelta: Offset(0, dy),
|
||||
),
|
||||
);
|
||||
await Future<void>.delayed(const Duration(milliseconds: 16));
|
||||
}
|
||||
}
|
||||
|
||||
void _type(String text) {
|
||||
EditableTextState? focused;
|
||||
void visit(Element element) {
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// Frame report for native fixture builds (the Linux desktop bench,
|
||||
// tool/perf/linux_desktop_bench.py), the native twin of frame_log.dart.
|
||||
//
|
||||
// With `perf=1` in FIXTURE_QUERY it prints every frame's Flutter timings as
|
||||
// `PERF_FRAME <build us> <raster us> <total us>`, and the first rasterised
|
||||
// frame as `PERF_FIRST_FRAME_EPOCH <ms since the Unix epoch>`, which the
|
||||
// bench subtracts from its own launch time. Without the flag nothing is
|
||||
// installed.
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
void installNativeFrameLog(Map<String, String> params) {
|
||||
if (params['perf'] != '1') return;
|
||||
final binding = WidgetsFlutterBinding.ensureInitialized();
|
||||
binding.addTimingsCallback((timings) {
|
||||
for (final timing in timings) {
|
||||
// ignore: avoid_print
|
||||
print(
|
||||
'PERF_FRAME ${timing.buildDuration.inMicroseconds} '
|
||||
'${timing.rasterDuration.inMicroseconds} '
|
||||
'${timing.totalSpan.inMicroseconds}',
|
||||
);
|
||||
}
|
||||
});
|
||||
binding.waitUntilFirstFrameRasterized.then((_) {
|
||||
// ignore: avoid_print
|
||||
print('PERF_FIRST_FRAME_EPOCH ${DateTime.now().millisecondsSinceEpoch}');
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Startup and chat-scroll bench for the Linux desktop build of the full-app
|
||||
fixture, the native counterpart of interaction_bench.mjs's `startup` and
|
||||
`desktop: scroll a rich chat` scenarios.
|
||||
|
||||
Build the fixture as a Linux bundle (release, or profile for engine switches):
|
||||
|
||||
docker run ... pipelines-app-build linux --target tool/search_selection_probe_entry.dart
|
||||
|
||||
then:
|
||||
|
||||
python3 tool/perf/linux_desktop_bench.py --bundle <bundle dir> [--repeat 5]
|
||||
[--switch enable-impeller=true] # profile builds only
|
||||
|
||||
Each run starts the bundle on a private Xvfb display (never the desktop
|
||||
session) with an isolated HOME and its own D-Bus session, with FIXTURE_QUERY
|
||||
`perf=1` (tool/perf/frame_log_native.dart). Startup is launch to the first
|
||||
rasterised frame; the scroll is 30 mouse-wheel notches of -240 px over the
|
||||
open rich chat. Xvfb has no GPU: Mesa's llvmpipe rasterises on the CPU, as
|
||||
headless Chrome without --gpu does, so compare builds and engines with each
|
||||
other rather than predicting a desktop with a GPU.
|
||||
"""
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import statistics
|
||||
import subprocess
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
QUERY = ("route=/chat/perf-chat-0&chats=2&header=1&rich=1&perf=1"
|
||||
"&do=wait:500;tap:Later;wait:800;mark:scroll;wheel:860,400,-240,30;wait:1500;mark:end")
|
||||
|
||||
|
||||
def run_once(bundle, display, switches, timeout, extra_env=()):
|
||||
root = Path(tempfile.mkdtemp(prefix="linux-bench-"))
|
||||
runtime = root / "run"
|
||||
runtime.mkdir(mode=0o700)
|
||||
env = {"HOME": str(root / "home"), "XDG_RUNTIME_DIR": str(runtime), "DISPLAY": f":{display}",
|
||||
"GDK_BACKEND": "x11", "PATH": "/usr/bin:/bin", "FIXTURE_QUERY": QUERY,
|
||||
**dict(e.split("=", 1) for e in extra_env)}
|
||||
if switches:
|
||||
env["FLUTTER_ENGINE_SWITCHES"] = str(len(switches))
|
||||
for index, switch in enumerate(switches, 1):
|
||||
env[f"FLUTTER_ENGINE_SWITCH_{index}"] = switch
|
||||
xvfb = subprocess.Popen(["Xvfb", f":{display}", "-screen", "0", "1280x800x24", "-nolisten", "tcp"],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
lines = []
|
||||
try:
|
||||
time.sleep(1)
|
||||
launched = time.time() * 1000
|
||||
app = subprocess.Popen(["dbus-run-session", "--", str(Path(bundle) / "pipelines-app")], env=env,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True,
|
||||
start_new_session=True)
|
||||
deadline = time.time() + timeout
|
||||
try:
|
||||
for line in app.stdout:
|
||||
lines.append(line.strip())
|
||||
if line.startswith("FIXTURE_MARK end") or time.time() > deadline:
|
||||
break
|
||||
finally:
|
||||
os.killpg(app.pid, 15)
|
||||
app.wait(timeout=10)
|
||||
finally:
|
||||
xvfb.terminate()
|
||||
xvfb.wait(timeout=10)
|
||||
shutil.rmtree(root, ignore_errors=True)
|
||||
first = next((int(l.split()[1]) for l in lines if l.startswith("PERF_FIRST_FRAME_EPOCH ")), None)
|
||||
phase, scroll = None, []
|
||||
for line in lines:
|
||||
if line.startswith("FIXTURE_MARK "):
|
||||
phase = line.split()[1]
|
||||
elif line.startswith("PERF_FRAME ") and phase == "scroll":
|
||||
build, raster, total = (int(v) for v in line.split()[1:4])
|
||||
scroll.append((build, raster, total))
|
||||
if first is None or not scroll:
|
||||
raise RuntimeError("the run reported no first frame or no scroll frames:\n" + "\n".join(lines[-20:]))
|
||||
return {"startupMs": first - launched, "frames": len(scroll),
|
||||
"buildSumMs": sum(f[0] for f in scroll) / 1000, "buildMaxMs": max(f[0] for f in scroll) / 1000,
|
||||
"rasterSumMs": sum(f[1] for f in scroll) / 1000, "rasterMaxMs": max(f[1] for f in scroll) / 1000,
|
||||
"rasterMedianMs": statistics.median(f[1] for f in scroll) / 1000,
|
||||
"worstFrameMs": max(f[2] for f in scroll) / 1000}
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
||||
parser.add_argument("--bundle", required=True)
|
||||
parser.add_argument("--repeat", type=int, default=5)
|
||||
parser.add_argument("--display", type=int, default=97)
|
||||
parser.add_argument("--switch", action="append", default=[], help="engine switch (profile builds)")
|
||||
parser.add_argument("--timeout", type=float, default=60)
|
||||
parser.add_argument("--env", action="append", default=[], help="extra VAR=value for the app")
|
||||
args = parser.parse_args()
|
||||
runs = [run_once(args.bundle, args.display, args.switch, args.timeout, args.env) for _ in range(args.repeat)]
|
||||
median = {key: round(statistics.median(r[key] for r in runs), 1) for key in runs[0]}
|
||||
print(json.dumps({"bundle": args.bundle, "switches": args.switch, "runs": len(runs), "median": median}, indent=2))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -182,6 +182,7 @@ Options: `--server-url ws(s)://host:port/connect`, `--notes TEXT`, `--prefix`.
|
||||
|
||||
```sh
|
||||
./install --linux --output ./dist
|
||||
./install --linux --install # also install it for this user (launcher, icon)
|
||||
./install --macos --flutter /path/to/flutter --output ./dist
|
||||
# Offer this desktop build through an installed server's update feed:
|
||||
./install --linux --publish --notes "Release notes"
|
||||
@@ -195,6 +196,25 @@ from the `pipelines` server CLI. The target Linux desktop needs GTK 3 and its
|
||||
runtime libraries (Debian/Ubuntu: `libgtk-3-0`, `libstdc++6`, `liblzma5`). This is a
|
||||
portable bundle, not a package-manager installation or a server installation.
|
||||
|
||||
`./install --linux --install` also installs it for the current user:
|
||||
the bundle goes to `<prefix>/lib/app-linux` (default
|
||||
`~/.local/share/pipelines/lib/app-linux`; the previous one is kept as
|
||||
`app-linux.previous`), with `~/.local/share/applications/com.pipelines.app.desktop`,
|
||||
its icon in `~/.local/share/icons/hicolor` and a `~/.local/bin/pipelines-app`
|
||||
link. `scripts/install-linux-app.sh <archive>` installs a downloaded archive the
|
||||
same way. The desktop entry is named after the GTK application id, which is
|
||||
also the Wayland app id (Hyprland's window class), so launchers, docks and
|
||||
window rules match the window. The app runs as a native Wayland client (GTK
|
||||
picks Wayland when `WAYLAND_DISPLAY` is set and `GDK_BACKEND` is not forced to
|
||||
`x11`); it draws a GTK header bar only on GNOME.
|
||||
|
||||
Release builds are size-optimised: Dart debug symbols are split out
|
||||
(`--split-debug-info`, kept in the build cache under `.debug-info/` for
|
||||
`flutter symbolize`) and the icon fonts are tree-shaken (the build image fixes
|
||||
Flutter 3.44's Linux backend, which otherwise ships the full MaterialIcons
|
||||
font). The Linux app has no web view or file share sheet, so HTML artifacts
|
||||
show an explanation instead of a preview and Share is not offered (Download is).
|
||||
|
||||
macOS 12 or newer is required. macOS builds run natively with Xcode and the pinned Flutter version from
|
||||
`app/.flutter-version`; they do not require Docker. The build targets the build
|
||||
machine's architecture and records the actual executable architecture in the
|
||||
|
||||
@@ -431,6 +431,8 @@ def main(argv=None):
|
||||
parser.add_argument("--notes", default="", help="APK release notes shown in Check for updates")
|
||||
parser.add_argument("--publish", action="store_true", help="Publish desktop archive and update feed to this installation")
|
||||
parser.add_argument("--output", type=Path, help="Desktop archive output directory (default: build cache)")
|
||||
parser.add_argument("--install", action="store_true",
|
||||
help="Linux: also install the client for this user (<prefix>/lib/app-linux and a desktop entry)")
|
||||
parser.add_argument("--flutter", help="Native Flutter executable for macOS and Android (or PIPELINES_FLUTTER/PATH)")
|
||||
parser.add_argument("--verbose", action="store_true", help="Show full build and tool output")
|
||||
build_mode = parser.add_mutually_exclusive_group()
|
||||
@@ -448,7 +450,8 @@ def main(argv=None):
|
||||
bundle, archive = desktop.build_desktop(args.kind, app=APP, cache=default_cache(), runner=subprocess.run,
|
||||
source_digest=digest, docker_build=build, docker_ready=docker_available,
|
||||
server_url=args.server_url, flutter=args.flutter, output=args.output,
|
||||
prune_cache=prune, update_keys=update_signing.dart_defines())
|
||||
prune_cache=prune, update_keys=update_signing.dart_defines(),
|
||||
install=args.install, prefix=args.prefix)
|
||||
if args.publish:
|
||||
manifest = load_manifest(args.prefix)
|
||||
updates = (manifest.get("web") or {}).get("updates")
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
"""Standalone desktop client artifacts; never installs or restarts a server."""
|
||||
"""Standalone desktop client artifacts; never installs or restarts a server.
|
||||
|
||||
`install=True` (Linux only) also installs the client for the current user
|
||||
with scripts/install-linux-app.sh."""
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
@@ -39,7 +42,8 @@ def _linux_archive(entry):
|
||||
try:
|
||||
with tarfile.open(staged, "w:gz") as output:
|
||||
for child in sorted(entry.iterdir()):
|
||||
if child.name not in (".complete", archive.name, staged.name):
|
||||
# Split Dart debug symbols stay in the build cache.
|
||||
if child.name not in (".complete", ".debug-info", archive.name, staged.name):
|
||||
output.add(child, arcname=f"pipelines-linux-x64/{child.name}")
|
||||
os.replace(staged, archive)
|
||||
finally:
|
||||
@@ -120,7 +124,9 @@ def _macos_build(*, app, cache, source_digest, runner, arguments, flutter, log):
|
||||
|
||||
def build_desktop(kind, *, app, cache, runner, source_digest, docker_build,
|
||||
docker_ready, server_url=None, flutter=None, output=None, log=print,
|
||||
prune_cache=None, update_keys=()):
|
||||
prune_cache=None, update_keys=(), install=False, prefix=None):
|
||||
if install and kind != "linux":
|
||||
raise ValueError("--install installs the Linux client only")
|
||||
arguments = _arguments(server_url) + tuple(update_keys)
|
||||
if kind == "macos":
|
||||
entry, bundle, archive = _macos_build(app=app, cache=cache, runner=runner,
|
||||
@@ -150,10 +156,21 @@ def build_desktop(kind, *, app, cache, runner, source_digest, docker_build,
|
||||
archive = published
|
||||
log(f"Desktop client bundle: {bundle}")
|
||||
log(f"Desktop client archive: {archive}")
|
||||
if install:
|
||||
install_linux(archive, runner=runner, prefix=prefix)
|
||||
log("No server was installed or restarted. Choose your server in the app.")
|
||||
return bundle, archive
|
||||
|
||||
|
||||
def install_linux(archive, *, runner, prefix=None):
|
||||
"""Installs [archive] into <prefix>/lib/app-linux with a desktop entry."""
|
||||
script = Path(__file__).with_name("install-linux-app.sh")
|
||||
env = dict(os.environ)
|
||||
if prefix is not None:
|
||||
env["PIPELINES_PREFIX"] = str(Path(prefix).expanduser())
|
||||
_run(runner, ["sh", str(script), str(archive)], env=env, timeout=300)
|
||||
|
||||
|
||||
def publish_desktop(kind, bundle, archive, updates, *, signer, notes="", log=print):
|
||||
"""Publish archive before its feed; versioned names preserve in-flight reads.
|
||||
|
||||
|
||||
@@ -1,43 +1,55 @@
|
||||
#!/bin/sh
|
||||
# Installs the Pipelines Linux desktop app for the current user from a release
|
||||
# archive (pipelines-linux-x64-*.tar.gz from the update feed or the build cache):
|
||||
# scripts/install-linux-app.sh <archive.tar.gz> [icon.png]
|
||||
# The app lives in ~/.local/share/pipelines-app (writable, so in-app updates
|
||||
# can swap it), with a launcher in ~/.local/bin and a desktop entry. An existing
|
||||
# install is kept as pipelines-app.previous.
|
||||
# archive (pipelines-linux-x64*.tar.gz from `./install --linux`, the build
|
||||
# cache or the update feed):
|
||||
# scripts/install-linux-app.sh <archive.tar.gz>
|
||||
# `./install --linux --install` builds the archive and runs this.
|
||||
#
|
||||
# The app lives in <prefix>/lib/app-linux (prefix: $PIPELINES_PREFIX, default
|
||||
# ~/.local/share/pipelines), whose parent is writable so in-app updates can
|
||||
# swap it. A desktop entry named after the GTK application id
|
||||
# (com.pipelines.app.desktop) lets Wayland compositors, launchers and
|
||||
# notification daemons match the window and its icon; ~/.local/bin/pipelines-app
|
||||
# links the executable. An existing install is kept as app-linux.previous.
|
||||
set -eu
|
||||
archive=$1
|
||||
icon=${2:-}
|
||||
data=${XDG_DATA_HOME:-$HOME/.local/share}
|
||||
target=$data/pipelines-app
|
||||
staging=$data/.pipelines-app-install.$$
|
||||
prefix=${PIPELINES_PREFIX:-$HOME/.local/share/pipelines}
|
||||
target=$prefix/lib/app-linux
|
||||
app_id=com.pipelines.app
|
||||
mkdir -p "$prefix/lib"
|
||||
staging=$(mktemp -d "$prefix/lib/.app-linux-install.XXXXXX")
|
||||
trap 'rm -rf "$staging"' EXIT
|
||||
mkdir -p "$staging"
|
||||
tar -xzf "$archive" -C "$staging"
|
||||
bundle=$(dirname "$(find "$staging" -maxdepth 3 -type f -name pipelines-app | head -n 1)")
|
||||
[ -x "$bundle/pipelines-app" ] && [ -d "$bundle/data/flutter_assets" ] && [ -d "$bundle/lib" ] || {
|
||||
echo "The archive has no complete pipelines-app bundle." >&2; exit 1; }
|
||||
missing=$(ldd "$bundle/pipelines-app" | grep "not found" || true)
|
||||
missing=$(ldd "$bundle/pipelines-app" 2>/dev/null | grep "not found" || true)
|
||||
[ -z "$missing" ] || { echo "Missing system libraries:" >&2; echo "$missing" >&2; exit 1; }
|
||||
rm -rf "$target.previous"
|
||||
[ -d "$target" ] && mv "$target" "$target.previous"
|
||||
mv "$bundle" "$target"
|
||||
mkdir -p "$HOME/.local/bin" "$data/applications"
|
||||
ln -sf "$target/pipelines-app" "$HOME/.local/bin/pipelines-app"
|
||||
if [ -n "$icon" ]; then
|
||||
icon=$app_id
|
||||
if [ -f "$target/data/app_icon.png" ]; then
|
||||
mkdir -p "$data/icons/hicolor/512x512/apps"
|
||||
cp "$icon" "$data/icons/hicolor/512x512/apps/pipelines-app.png"
|
||||
cp "$target/data/app_icon.png" "$data/icons/hicolor/512x512/apps/$app_id.png"
|
||||
else
|
||||
icon=utilities-terminal
|
||||
fi
|
||||
cat > "$data/applications/pipelines-app.desktop" <<DESKTOP
|
||||
cat > "$data/applications/$app_id.desktop" <<DESKTOP
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Pipelines App
|
||||
Name=Pipelines
|
||||
Comment=Pipelines native desktop app
|
||||
Exec=$target/pipelines-app
|
||||
Icon=pipelines-app
|
||||
Icon=$icon
|
||||
Terminal=false
|
||||
StartupWMClass=com.pipelines.app
|
||||
StartupWMClass=$app_id
|
||||
StartupNotify=true
|
||||
Categories=Development;
|
||||
DESKTOP
|
||||
command -v update-desktop-database >/dev/null 2>&1 && update-desktop-database "$data/applications" >/dev/null 2>&1 || true
|
||||
echo "Installed $(cat "$target/version.txt" 2>/dev/null || echo Pipelines) at $target"
|
||||
echo "Installed Pipelines at $target"
|
||||
echo "Launcher: $data/applications/$app_id.desktop (run: pipelines-app)"
|
||||
|
||||
@@ -190,6 +190,51 @@ class DesktopBuildTests(unittest.TestCase):
|
||||
run = next(c for c in self.runner.calls if c[:2] == ["docker", "run"])
|
||||
self.assertIn("--dart-define=PIPELINES_UPDATE_PUBLIC_KEY=abc", run)
|
||||
|
||||
def test_linux_archive_leaves_split_debug_symbols_in_the_cache(self):
|
||||
bundle, archive = self.build("linux")
|
||||
(bundle / ".debug-info").mkdir()
|
||||
(bundle / ".debug-info/app.linux-x64.symbols").write_bytes(b"symbols")
|
||||
archive.unlink()
|
||||
archive = desktop._linux_archive(bundle)
|
||||
with tarfile.open(archive) as package:
|
||||
self.assertFalse([n for n in package.getnames() if ".debug-info" in n])
|
||||
self.assertIn("pipelines-linux-x64/pipelines-app", package.getnames())
|
||||
|
||||
def test_linux_install_runs_the_user_installer_with_the_prefix(self):
|
||||
_, archive = self.build("linux", install=True, prefix=self.root / "prefix")
|
||||
command = self.runner.calls[-1]
|
||||
self.assertEqual(command[0], "sh")
|
||||
self.assertTrue(command[1].endswith("install-linux-app.sh"))
|
||||
self.assertEqual(command[2], str(archive))
|
||||
with self.assertRaisesRegex(ValueError, "Linux client only"):
|
||||
self.build("macos", install=True)
|
||||
|
||||
def test_linux_installer_installs_bundle_icon_and_desktop_entry(self):
|
||||
_, archive = self.build("linux")
|
||||
home = self.root / "home"
|
||||
icon = self.root / "icon-bundle"
|
||||
# A bundle with its icon, as the Linux CMake install lays it out.
|
||||
with tarfile.open(archive) as package:
|
||||
package.extractall(icon, filter="data")
|
||||
(icon / "pipelines-linux-x64/data/app_icon.png").write_bytes(b"png")
|
||||
with tarfile.open(archive, "w:gz") as package:
|
||||
package.add(icon / "pipelines-linux-x64", arcname="pipelines-linux-x64")
|
||||
environment = {"HOME": str(home), "XDG_DATA_HOME": str(home / ".local/share"),
|
||||
"PATH": "/usr/bin:/bin"}
|
||||
with patch.dict(desktop.os.environ, environment, clear=True):
|
||||
desktop.install_linux(archive, runner=subprocess.run, prefix=home / "prefix")
|
||||
desktop.install_linux(archive, runner=subprocess.run, prefix=home / "prefix")
|
||||
target = home / "prefix/lib/app-linux"
|
||||
self.assertEqual((target / "pipelines-app").read_bytes(), b"linux-client")
|
||||
self.assertTrue((home / "prefix/lib/app-linux.previous/pipelines-app").is_file())
|
||||
entry = (home / ".local/share/applications/com.pipelines.app.desktop").read_text()
|
||||
self.assertIn(f"Exec={target}/pipelines-app\n", entry)
|
||||
self.assertIn("Icon=com.pipelines.app\n", entry)
|
||||
self.assertIn("StartupWMClass=com.pipelines.app\n", entry)
|
||||
self.assertTrue((home / ".local/share/icons/hicolor/512x512/apps/com.pipelines.app.png").is_file())
|
||||
self.assertEqual((home / ".local/bin/pipelines-app").resolve(), (target / "pipelines-app").resolve())
|
||||
self.assertFalse(list((home / "prefix/lib").glob(".app-linux-install.*")))
|
||||
|
||||
def test_desktop_server_prefill_rejects_embedded_credentials(self):
|
||||
with self.assertRaisesRegex(ValueError, "embedded credentials"):
|
||||
self.build("linux", server_url="wss://secret@example.com/connect")
|
||||
|
||||
Reference in New Issue
Block a user