From 30cbfeedd6edf07bed7cefa1884c0b8ca2e20fb6 Mon Sep 17 00:00:00 2001 From: kwyvern Date: Wed, 14 Oct 2026 18:06:22 -0700 Subject: [PATCH] Prepare Linux builds and validate native desktop runtime --- .gitignore | 3 + browser-runtime/scripts/package-target.mjs | 25 +++ browser-runtime/scripts/package.mjs | 14 +- browser-runtime/scripts/stage-host.mjs | 14 +- browser-runtime/scripts/stage-runtime.mjs | 48 ++++++ browser-runtime/test/package-target.test.mjs | 13 ++ browser-runtime/test/stage-runtime.test.mjs | 65 ++++++++ docs/development.md | 5 +- docs/linux.md | 162 ++++++++++++++++++- src-tauri/src/browser.rs | 2 +- src-tauri/src/lib.rs | 1 + src-tauri/src/pty.rs | 6 +- src-tauri/src/terminal_platform.rs | 125 ++++++++++++++ src-tauri/src/workspace.rs | 9 +- src-tauri/tauri.linux.conf.json | 16 ++ 15 files changed, 481 insertions(+), 27 deletions(-) create mode 100644 browser-runtime/scripts/package-target.mjs create mode 100644 browser-runtime/scripts/stage-runtime.mjs create mode 100644 browser-runtime/test/package-target.test.mjs create mode 100644 browser-runtime/test/stage-runtime.test.mjs create mode 100644 src-tauri/src/terminal_platform.rs create mode 100644 src-tauri/tauri.linux.conf.json diff --git a/.gitignore b/.gitignore index 55ea546..e9e815a 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,6 @@ output/browser-test.conf.json /output/ /releases/ + +# Temporary runtime staging trees (normally removed automatically) +src-tauri/.browser-stage-*/ diff --git a/browser-runtime/scripts/package-target.mjs b/browser-runtime/scripts/package-target.mjs new file mode 100644 index 0000000..f2f823a --- /dev/null +++ b/browser-runtime/scripts/package-target.mjs @@ -0,0 +1,25 @@ +const supported = { platform: ['win32', 'linux'], arch: ['x64', 'arm64'] }; + +export function packageTarget(args, defaults = process) { + const target = { platform: defaults.platform, arch: defaults.arch }; + const seen = new Set(); + for (const argument of args) { + const match = /^--(platform|arch)=(.+)$/.exec(argument); + if (!match || !supported[match[1]].includes(match[2]) || seen.has(match[1])) { + throw new Error('Use --platform=win32|linux and --arch=x64|arm64, at most once each.'); + } + seen.add(match[1]); + target[match[1]] = match[2]; + } + for (const key of Object.keys(supported)) { + // Preserve Electron's native macOS packaging default; explicit cross-build + // options remain the Windows/Linux targets supported by this project. + if (key === 'platform' && target.platform === 'darwin' && !seen.has('platform')) continue; + if (!supported[key].includes(target[key])) throw new Error(`Unsupported Browser ${key}: ${target[key]}`); + } + return target; +} + +export function executableName(platform) { + return platform === 'win32' ? 'RuneStone-Browser.exe' : 'RuneStone-Browser'; +} diff --git a/browser-runtime/scripts/package.mjs b/browser-runtime/scripts/package.mjs index 8f8c4b9..24d5144 100644 --- a/browser-runtime/scripts/package.mjs +++ b/browser-runtime/scripts/package.mjs @@ -1,12 +1,12 @@ import { packager } from '@electron/packager'; -const options = Object.fromEntries(process.argv.slice(2).map(arg => { - const match = /^--(platform|arch)=(win32|linux|x64|arm64)$/.exec(arg); - if (!match) throw new Error('Use --platform=win32|linux and --arch=x64|arm64.'); - return [match[1], match[2]]; -})); +import { dirname, resolve } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { packageTarget } from './package-target.mjs'; +const project = resolve(dirname(fileURLToPath(import.meta.url)), '..'); +const target = packageTarget(process.argv.slice(2)); const outputs = await packager({ - dir: '.', name: 'RuneStone-Browser', out: 'dist', overwrite: true, - platform: options.platform || process.platform, arch: options.arch || process.arch, + dir: project, name: 'RuneStone-Browser', out: resolve(project, 'dist'), overwrite: true, + ...target, ignore: [/^\/(test|scripts|output|plugin|releases|\.github)(\/|$)/, /^\/src\/(ui\/|host\.mjs|main\.mjs|preload\.cjs)/], }); for (const output of outputs) console.log(output); diff --git a/browser-runtime/scripts/stage-host.mjs b/browser-runtime/scripts/stage-host.mjs index 8f19156..4268a65 100644 --- a/browser-runtime/scripts/stage-host.mjs +++ b/browser-runtime/scripts/stage-host.mjs @@ -1,11 +1,13 @@ -import { cp, mkdir, access } from 'node:fs/promises'; import { resolve, dirname } from 'node:path'; import { fileURLToPath } from 'node:url'; +import { packageTarget } from './package-target.mjs'; +import { stageRuntime } from './stage-runtime.mjs'; const project = resolve(dirname(fileURLToPath(import.meta.url)), '..'); const host = resolve(process.env.RUNESTONE_ROOT || resolve(project, '..')); -const source = resolve(project, `dist/RuneStone-Browser-${process.platform}-${process.arch}`); -await access(resolve(source, process.platform === 'win32' ? 'RuneStone-Browser.exe' : 'RuneStone-Browser')); -const destination = resolve(host, 'src-tauri/browser-engine'); -await mkdir(destination, { recursive: true }); -await cp(source, destination, { recursive: true }); +const target = packageTarget(process.argv.slice(2)); +if (target.platform !== process.platform || target.arch !== process.arch) { + throw new Error('Stage the Browser runtime on the same platform and architecture as the native host build.'); +} +const { destination, backup } = await stageRuntime({ project, host, ...target }); console.log(`Browser runtime staged in ${destination}`); +if (backup) console.log(`Previous runtime retained in ${backup}`); diff --git a/browser-runtime/scripts/stage-runtime.mjs b/browser-runtime/scripts/stage-runtime.mjs new file mode 100644 index 0000000..8310d80 --- /dev/null +++ b/browser-runtime/scripts/stage-runtime.mjs @@ -0,0 +1,48 @@ +import { cp, mkdir, access, mkdtemp, rename, rm, lstat, chmod } from 'node:fs/promises'; +import { constants } from 'node:fs'; +import { resolve, join } from 'node:path'; +import { executableName } from './package-target.mjs'; + +// Copy into a new tree instead of merging Windows and Linux runtime files. +// Retain the previous tree in output/ so a failed switch can be recovered. +export async function stageRuntime({ project, host, platform, arch }) { + const source = resolve(project, `dist/RuneStone-Browser-${platform}-${arch}`); + const executable = join(source, executableName(platform)); + const stat = await lstat(executable); + if (!stat.isFile()) throw new Error(`Browser executable is not a regular file: ${executable}`); + await access(executable, platform === 'win32' ? constants.R_OK : constants.R_OK | constants.X_OK); + const parent = resolve(host, 'src-tauri'); + await mkdir(parent, { recursive: true }); + const destination = join(parent, 'browser-engine'); + const temporary = await mkdtemp(join(parent, '.browser-stage-')); + // Copy to a new child so cp preserves the source root mode, not mkdtemp's 0700. + const staged = join(temporary, 'browser-engine'); + let backup; + let moved = false; + try { + await cp(source, staged, { recursive: true }); + // Electron Packager can leave its temporary root at 0700. Installed resources + // must remain traversable after the package manager changes ownership to root. + if (platform === 'linux') await chmod(staged, 0o755); + await access(join(staged, executableName(platform)), platform === 'win32' ? constants.R_OK : constants.X_OK); + try { + await lstat(destination); + const backups = resolve(host, 'output/browser-stage-backups'); + await mkdir(backups, { recursive: true }); + backup = join(await mkdtemp(join(backups, 'previous-')), 'browser-engine'); + await rename(destination, backup); + moved = true; + } catch (error) { + if (error.code !== 'ENOENT') throw error; + } + try { + await rename(staged, destination); + } catch (error) { + if (moved) await rename(backup, destination); + throw error; + } + return { destination, backup: moved ? backup : undefined }; + } finally { + await rm(temporary, { recursive: true, force: true }); + } +} diff --git a/browser-runtime/test/package-target.test.mjs b/browser-runtime/test/package-target.test.mjs new file mode 100644 index 0000000..84995bb --- /dev/null +++ b/browser-runtime/test/package-target.test.mjs @@ -0,0 +1,13 @@ +import assert from 'node:assert/strict'; +import test from 'node:test'; +import { packageTarget } from '../scripts/package-target.mjs'; + +test('packaging uses native defaults and validates each option independently', () => { + assert.deepEqual(packageTarget([], { platform: 'linux', arch: 'arm64' }), { platform: 'linux', arch: 'arm64' }); + assert.deepEqual(packageTarget(['--platform=linux', '--arch=x64'], { platform: 'win32', arch: 'arm64' }), { platform: 'linux', arch: 'x64' }); + for (const args of [['--platform=x64'], ['--arch=linux'], ['--arch=x64', '--arch=arm64'], ['--unknown=linux']]) { + assert.throws(() => packageTarget(args), /Use --platform/); + } + assert.deepEqual(packageTarget([], { platform: 'darwin', arch: 'arm64' }), { platform: 'darwin', arch: 'arm64' }); + assert.throws(() => packageTarget([], { platform: 'linux', arch: 'ia32' }), /Unsupported/); +}); diff --git a/browser-runtime/test/stage-runtime.test.mjs b/browser-runtime/test/stage-runtime.test.mjs new file mode 100644 index 0000000..43e63e3 --- /dev/null +++ b/browser-runtime/test/stage-runtime.test.mjs @@ -0,0 +1,65 @@ +import assert from 'node:assert/strict'; +import test from 'node:test'; +import { mkdtemp, mkdir, writeFile, readFile, readdir, chmod, rm, stat } from 'node:fs/promises'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; +import { stageRuntime } from '../scripts/stage-runtime.mjs'; + +async function fixture(t) { + const root = await mkdtemp(join(tmpdir(), 'runestone-stage-test-')); + t.after(() => rm(root, { recursive: true, force: true })); + const project = join(root, 'browser-runtime'); + const source = join(project, 'dist/RuneStone-Browser-linux-x64'); + const destination = join(root, 'src-tauri/browser-engine'); + await mkdir(source, { recursive: true }); + await chmod(source, 0o755); + await mkdir(destination, { recursive: true }); + await writeFile(join(source, 'RuneStone-Browser'), 'fixture', { mode: 0o755 }); + await writeFile(join(destination, 'RuneStone-Browser.exe'), 'old runtime'); + return { project, host: root, source, destination, platform: 'linux', arch: 'x64' }; +} + +test('staging replaces a foreign runtime tree and preserves a recoverable backup', async t => { + const options = await fixture(t); + const result = await stageRuntime(options); + assert.deepEqual(await readdir(options.destination), ['RuneStone-Browser']); + if (process.platform !== 'win32') { + assert.equal((await stat(options.destination)).mode & 0o777, 0o755); + assert.equal((await stat(join(options.destination, 'RuneStone-Browser'))).mode & 0o777, 0o755); + } + assert.equal(await readFile(join(result.backup, 'RuneStone-Browser.exe'), 'utf8'), 'old runtime'); + assert.equal(await readFile(join(options.source, 'RuneStone-Browser'), 'utf8'), 'fixture'); +}); + +test('missing source leaves the previous runtime intact', async t => { + const options = await fixture(t); + await assert.rejects(stageRuntime({ ...options, arch: 'arm64' }), /ENOENT/); + assert.equal(await readFile(join(options.destination, 'RuneStone-Browser.exe'), 'utf8'), 'old runtime'); +}); + +test('Linux staging rejects a non-executable runtime before replacing the old tree', { skip: process.platform === 'win32' }, async t => { + const options = await fixture(t); + await chmod(join(options.source, 'RuneStone-Browser'), 0o644); + await assert.rejects(stageRuntime(options), /EACCES/); + assert.equal(await readFile(join(options.destination, 'RuneStone-Browser.exe'), 'utf8'), 'old runtime'); +}); + + +test('Windows staging retains the exe layout without Linux execute permissions', async t => { + const options = await fixture(t); + const source = join(options.project, 'dist/RuneStone-Browser-win32-x64'); + await mkdir(source, { recursive: true }); + await writeFile(join(source, 'RuneStone-Browser.exe'), 'windows fixture', { mode: 0o644 }); + const result = await stageRuntime({ ...options, platform: 'win32' }); + assert.deepEqual(await readdir(result.destination), ['RuneStone-Browser.exe']); + assert.equal(await readFile(join(result.destination, 'RuneStone-Browser.exe'), 'utf8'), 'windows fixture'); +}); + + +test('Linux staging normalizes a private packager output root for installation', { skip: process.platform === 'win32' }, async t => { + const options = await fixture(t); + await chmod(options.source, 0o700); + const result = await stageRuntime(options); + assert.equal((await stat(result.destination)).mode & 0o777, 0o755); + assert.equal((await stat(options.source)).mode & 0o777, 0o700); +}); diff --git a/docs/development.md b/docs/development.md index 62c40e9..7d17fa0 100644 --- a/docs/development.md +++ b/docs/development.md @@ -90,8 +90,9 @@ The [installation guide](installation.md) has separate Windows, Linux, and macOS 1. Download or clone this repository. 2. Open a terminal in the repository folder. 3. Run `pnpm install --frozen-lockfile`. -4. Run `pnpm tauri dev`. -5. Use the folder button in the app to open a workspace or create one. +4. Prepare the built-in Browser runtime using the [runtime steps](#built-in-browser-runtime) below. +5. Run `pnpm tauri dev`. +6. Use the folder button in the app to open a workspace or create one. See the [build guide](builds.md) to build a Windows installer. diff --git a/docs/linux.md b/docs/linux.md index 47c2fc2..f68b206 100644 --- a/docs/linux.md +++ b/docs/linux.md @@ -2,9 +2,12 @@ [Developer guide](development.md) -Linux support is experimental. No native Linux build or desktop test is recorded yet. +Linux support is experimental. Limited native validation is recorded below; +the complete desktop and installer acceptance checks remain outstanding. Voice typing is outside the Linux acceptance criteria. -The first target is one known Linux desktop, with a local workspace and Bash. +The initial target is Ubuntu 24.04 LTS, x86_64, with a local workspace and Bash. +This is a validation target, not a claim of tested support. Record the actual host below; +results on another distribution do not establish Ubuntu compatibility. ## 1. Record the target @@ -44,8 +47,31 @@ From the Linux checkout, install the project dependencies: ```sh pnpm install --frozen-lockfile +npm ci --prefix browser-runtime ``` +The built-in Browser is a separate Electron executable. A fresh checkout does not +contain `src-tauri/browser-engine`; prepare it on the same Linux architecture before +building or launching the native host: + +```sh +pnpm browser:check +pnpm browser:test +npm --prefix browser-runtime run package +pnpm browser:stage +``` + +Use the native `package` command on ARM64 too; `package:linux` explicitly selects +x86_64. Staging verifies the executable permission and replaces the whole runtime +tree, so files from an older Windows or Linux package cannot leak into the new one. +An existing staged runtime is retained under `output/browser-stage-backups/` for +recovery. Do not copy Windows `browser-engine` output into a Linux build. + +Electron must run as an ordinary desktop user with its sandbox enabled. Do not +work around sandbox failures with `--no-sandbox` or by running RuneStone as root. +Test the Browser on the intended distro, including its user-namespace policy. +The native host uses WebKitGTK and the Browser uses Electron; both need testing. + The full test suite needs the Table formulas package. Clone `RuneStone_TableFormulas` beside RuneStone and install its dependencies, as described in the [plugin guide](plugins.md). Then run these checks from RuneStone: @@ -71,13 +97,15 @@ Browser tests use mocked desktop calls and Chromium. They do not test Linux file Use a disposable workspace outside the installation folder. Record each result, the source commit, and any error message. -All checks below remain unverified on Linux. +The complete acceptance checks below remain unverified on Linux. The validation +record distinguishes the limited smoke checks already completed. | Area | Pass criteria | | --- | --- | | Launch and windows | Open from the desktop, move, resize, minimize, maximize, and close. Unsaved edits trigger the close guard. | | Files and paths | Create, save, reopen, rename, copy, and delete files. Check spaces, Unicode, and distinct `Note.md` and `note.md` files. | | External edits | Edit a file in another editor. RuneStone detects the change and prevents silent replacement of conflicting edits. | +| Built-in Browser | Open a web page, type and scroll, open/close tabs, download a file, and restart the app. Check the packaged runtime too. | | Editors | Edit Markdown, source code, tables, images, and diagrams. Check undo, keyboard shortcuts, and both themes. | | Clipboard and dialogs | Copy and paste text, tables, and images. Check folder selection, external links, and file reveal. | | Plugins | Install plugin ZIPs through Settings, enable them, restart, disable them, and remove them. Check plugin data persistence. | @@ -106,6 +134,12 @@ pnpm tauri build --bundles appimage -- --locked ``` Do not use `pnpm build:installer` on Linux. That command selects the Windows installer. +These direct Tauri commands do not manage the project release version or archive a +release. Before making a distributable, select the next version using the +[version policy](../AGENTS.md#versioning), keep all four version fields consistent, +and restore them if packaging fails. Move completed packages into +`releases//` together with checksums and the recorded source/test results; +do not leave duplicate completed packages in the toolchain bundle directory. Packages appear under `src-tauri/target/release/bundle/deb/` or `src-tauri/target/release/bundle/appimage/`. Install the Debian package with the distribution package manager, or make the AppImage executable and open it. @@ -120,3 +154,125 @@ See [Tauri's AppImage guidance](https://v2.tauri.app/distribute/appimage/) and [ Call a distribution supported only after its native tests and package checks pass. Repeat the automated checks on a Linux runner before each Linux release. No Linux automation is configured yet. Add it when the build host and target distribution are known. + +## Validation record: 2026-10-14 + +Validated on `desk`: Ubuntu 26.04.1 LTS, x86_64, four CPUs, 7.2 GiB reported RAM, +XFCE/X11, Linux 7.0.0-38-generic. The execution environment reports a container +boundary and underlying KVM virtualization. This does not validate Ubuntu 24.04, +Wayland, ARM, or another distribution. + +Source: base commit `edef2520afc92f7896454bf94a8ea15bbf4e1684` plus the Linux +readiness patch and the Browser window portability fix. The original transferred +source archive had SHA-256 +`b16643bfc7a634e5a5d17a7c246e87d95a458c06fb8afb45899a28a460e03047`. +The first native compile found a Windows-only `drag_and_drop(false)` call in +`src-tauri/src/browser.rs`; it now uses the cross-platform +`disable_drag_drop_handler()` API already used by the settings window. + +Toolchain: Node.js 24.22.0, pnpm 10.34.7, Rust/Cargo 1.93.1, GLib 2.88.0, +GTK 3.24.52, and WebKitGTK 4.1 version 2.52.6. Native builds used one job and +`CARGO_PROFILE_DEV_DEBUG=0 CARGO_PROFILE_TEST_DEBUG=0` to conserve RAM and disk. + +| Check | Recorded result | +| --- | --- | +| `pnpm install --frozen-lockfile` and `npm ci --prefix browser-runtime` | Passed | +| `pnpm check` | Passed; zero errors and warnings | +| `pnpm build` | Passed; bundle-size warnings remain | +| `pnpm browser:check` and `pnpm browser:test` | Passed; 44 Browser unit tests | +| Browser Linux packaging and `pnpm browser:stage` | Passed; x86_64 runtime staged | +| `npm --prefix browser-runtime run test:packaged` | Passed; all 12 engine smoke checks, sandbox enabled | +| `pnpm test` | 238 passed, one skipped, two test files failed because the Table Formulas package was absent | +| `cargo test --manifest-path src-tauri/Cargo.toml --lib --locked --offline -j 1` | Passed after the portability fix; 92 passed, three ignored | +| `pnpm tauri build --debug --no-bundle -- --locked --offline -j 1` | Passed; native debug executable, version 0.1.34 | +| Tauri X11 launch | Visible 1400 by 900 window; rendered frontend verified with an internal capture | +| Host Browser integration | Open Browser opened a Browser tab with address and profile controls; no webpage-navigation claim | + +GUI checks used isolated task-local XDG settings/data directories, and the test +processes were closed afterward. Virtual-GPU EGL/VAAPI warnings occurred; they did +not prevent these smoke checks. No sandbox, security, swap, or permission workaround +was used. Existing user settings and workspaces were not used. + +No installer or release package was produced, versions were unchanged, and nothing +was published. Remaining work includes supplying/building `RuneStone_TableFormulas` +and rerunning the full source suite, completing the desktop checks above, and +validating Debian/AppImage installation and lifecycle behavior on the intended +target distribution. These results do not establish full Linux support. + +### Initial bounded release attempt + +The normal release profile (`opt-level = 3`, full LTO, one codegen unit) was +attempted with one Cargo job, locked/offline dependencies, and the already-tested +frontend output. Before starting, desk had about 2.0 GiB available RAM, effectively +full 4.0 GiB swap, and 4.1 GiB free disk. A temporary user service bounded the +entire build to 1,677,721,600 bytes of RAM and no additional swap. + +The release build reached the GTK Rust crate but exceeded that hard cap. The +service recorded `Result=oom-kill`, `MemoryPeak=1677721600`, and zero swap use after +14 minutes 47 seconds. Soft memory throttling was tried first; it caused repeated +reclaim, so the soft threshold was removed while retaining the hard cap. No larger +memory allowance was attempted. The temporary service was cleaned up; dependency +and build caches were preserved. About 3.3 GiB disk remained afterward. + +No optimized executable, Debian package, or AppImage was produced. AppImage +bundling was not attempted because it needs the release executable. Package +contents, generated dependency metadata, and installation lifecycle therefore +remain unvalidated. `ldd` found no missing libraries for the previously tested +debug host and staged Browser on desk. In addition to host libraries, the Browser +needs NSPR/NSS, CUPS, and ALSA libraries; their Ubuntu 26.04 providers include +`libnspr4`, `libnss3`, `libcups2t64`, and `libasound2t64`. Check the eventual package +declares the appropriate runtime dependencies; the current machine having them +installed does not prove that package metadata is complete. + +The smallest next step is to free more RAM on desk, or use a host with more +available memory, then retry the cached release build with a larger bounded +allowance. Starting with at least 3 GiB available RAM provides more headroom but +does not establish the required peak; measure it during the retry. Recheck disk +before bundling. Existing debug-build and smoke-test results above still stand. + +### Release package validation: 2026-10-15 + +After desk returned with more headroom, a fresh resource check found 4,956,172 KiB +available RAM (about 4.73 GiB), nearly all 4 GiB swap free, and 47 GiB free disk. +No finite inherited user-cgroup memory limit was found. The cached release build +was retried with one job, a temporary 3.5 GiB memory cap, and no build-group swap. +It completed successfully in 12 minutes 32 seconds, with 3.5 GiB peak group memory +and no OOM event. The earlier failure establishes only that the chosen 1,600 MiB +cap was insufficient; it does not establish that the 8 GB VM cannot build. + +The initial Debian bundle declared only GTK and WebKitGTK. Added +`src-tauri/tauri.linux.conf.json` to declare OpenSSL plus the Browser's NSS/NSPR and +ALSA dependencies. The release executable requires GLIBC 2.39, so the Debian +metadata also declares `libc6 (>= 2.39)`. Tauri retains its default GTK/WebKitGTK +dependencies. Recheck symbol requirements when changing the compiler or build host; +this floor is evidence from this build, not a permanent portability guarantee. +The Debian package was regenerated and its final dependency metadata verified. + +| Release check | Recorded result | +| --- | --- | +| Normal optimized release profile and Debian bundling | Passed, using locked/offline Cargo dependencies and the previously validated frontend | +| Debian package | `RuneStone_0.1.34_amd64.deb`, package name `rune-stone`, version `0.1.34`, architecture `amd64` | +| Debian package checksums, desktop entry, resources and permissions | Passed; host and Browser executables are executable, Browser resource directory is traversable, packaged checksums match | +| Debian shared libraries on desk | All host and Browser libraries resolve | +| Extracted Debian GUI smoke | Host rendered a visible window, launched its own packaged Browser executable, and rendered an HTTPS page | +| AppImage bundling | Passed from the same optimized release executable; 2 minutes 18 seconds, about 1.6 GiB peak memory, no build-group swap | +| Extracted AppImage GUI smoke | AppRun launched, bundled WebKitGTK child processes were used, its packaged Browser launched, and an HTTPS page rendered | + +Both package tests used isolated task-local settings/data and closed their test +processes afterward. AppImage's supported extraction route was used because the +VM does not expose `/dev/fuse`; FUSE-mounted execution was not tested. Virtual-GPU +acceleration warnings did not prevent rendering. Versions remain 0.1.34 under the +explicit validation-build instruction. These are unsigned experimental artifacts, +not published releases. Completed package files, metadata, test limits, and +checksums are archived under `releases/0.1.34/` outside Git. + +No app was installed system-wide and no existing user workspace/settings were +used. Installation, same-version reinstall, upgrade, removal, the full desktop +acceptance matrix, Ubuntu 24.04, Wayland, and other architectures remain untested. +The Table Formulas external dependency remains absent. Native library resolution +on desk and successful extraction smoke checks do not prove clean-machine package +installation or compatibility with other distributions. +The AppImage's bundled WebKitGTK and JavaScriptCoreGTK libraries require GLIBC +2.43. The Debian executable's GLIBC 2.39 floor therefore does not describe the +AppImage's minimum runtime. Treat this AppImage as an Ubuntu 26.04 validation +artifact rather than a portable Ubuntu 24.04 build. diff --git a/src-tauri/src/browser.rs b/src-tauri/src/browser.rs index cecd793..ab99427 100644 --- a/src-tauri/src/browser.rs +++ b/src-tauri/src/browser.rs @@ -437,7 +437,7 @@ impl BrowserState { url.query_pairs_mut().append_pair("browserTab", id); if args["pinned"] == true { url.query_pairs_mut().append_pair("browserPinned", "true"); } let result = tauri::WebviewWindowBuilder::new(app, &label, tauri::WebviewUrl::App(format!("?{}", url.query().unwrap_or_default()).into())) - .title("RuneStone Browser").inner_size(1100.0, 750.0).min_inner_size(500.0, 300.0).decorations(false).drag_and_drop(false).build(); + .title("RuneStone Browser").inner_size(1100.0, 750.0).min_inner_size(500.0, 300.0).decorations(false).disable_drag_drop_handler().build(); if let Err(error) = result { worker.routing.lock().map_err(fail)?.close(&label); return Err(fail(error)); diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index d34931a..7495024 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1,4 +1,5 @@ mod pty; +mod terminal_platform; mod plugins; mod plugin_sources; mod workspace; diff --git a/src-tauri/src/pty.rs b/src-tauri/src/pty.rs index 40d207c..a4e182c 100644 --- a/src-tauri/src/pty.rs +++ b/src-tauri/src/pty.rs @@ -9,6 +9,7 @@ use serde::Serialize; use tauri::{AppHandle, Emitter, Manager, State}; use crate::workspace::{current_root_path, WorkspaceError, WorkspaceState}; +use crate::terminal_platform::find_executable; type PtyResult = Result; @@ -85,11 +86,6 @@ pub struct ShellProfile { executable: PathBuf, } -fn find_executable(name: &str) -> Option { - std::env::split_paths(&std::env::var_os("PATH").unwrap_or_default()) - .map(|dir| dir.join(name)).find(|path| path.is_file()) -} - #[tauri::command] pub fn pty_profiles() -> Vec { let candidates = if cfg!(windows) { diff --git a/src-tauri/src/terminal_platform.rs b/src-tauri/src/terminal_platform.rs new file mode 100644 index 0000000..80db2a1 --- /dev/null +++ b/src-tauri/src/terminal_platform.rs @@ -0,0 +1,125 @@ +use std::path::PathBuf; + +pub(crate) fn find_executable(name: &str) -> Option { + find_executable_in_path(name, &std::env::var_os("PATH").unwrap_or_default()) +} + +fn find_executable_in_path(name: &str, search_path: &std::ffi::OsStr) -> Option { + std::env::split_paths(search_path) + .map(|dir| dir.join(name)).find(|path| { + let Ok(metadata) = path.metadata() else { return false }; + if !metadata.is_file() { return false; } + #[cfg(unix)] + { + use std::os::unix::fs::PermissionsExt; + metadata.permissions().mode() & 0o111 != 0 + } + #[cfg(not(unix))] + { true } + }) +} + +#[cfg(all(unix, not(target_os = "macos")))] +pub(crate) fn open_external_terminal(folder: &std::path::Path) -> std::io::Result<()> { + spawn_external_terminal(folder, |command| command.spawn().map(|_| ())) +} + +#[cfg(all(unix, not(target_os = "macos")))] +fn spawn_external_terminal( + folder: &std::path::Path, + mut spawn: impl FnMut(&mut std::process::Command) -> std::io::Result<()>, +) -> std::io::Result<()> { + // x-terminal-emulator is a Debian alternative, not a cross-desktop standard. + // Explicit directory flags also work with terminals using an existing server. + let candidates = [ + ("x-terminal-emulator", None), + ("gnome-terminal", Some("--working-directory")), + ("konsole", Some("--workdir")), + ("xfce4-terminal", Some("--working-directory")), + ("mate-terminal", Some("--working-directory")), + ("lxterminal", Some("--working-directory")), + ("xterm", None), + ]; + for (program, directory_flag) in candidates { + let mut command = std::process::Command::new(program); + command.current_dir(folder); + if let Some(flag) = directory_flag { command.arg(flag).arg(folder); } + match spawn(&mut command) { + Ok(()) => return Ok(()), + Err(reason) if reason.kind() == std::io::ErrorKind::NotFound => continue, + Err(reason) => return Err(std::io::Error::new(reason.kind(), format!("Could not start {program}: {reason}"))), + } + } + Err(std::io::Error::new(std::io::ErrorKind::NotFound, + "No supported external terminal was found. Install a supported terminal emulator or use RuneStone's Terminal plugin.")) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[cfg(unix)] + #[test] + fn shell_lookup_skips_non_executable_files_and_directories() { + use std::os::unix::fs::PermissionsExt; + let unique = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos(); + let root = std::env::temp_dir().join(format!("rs-shell-path-{}-{unique}", std::process::id())); + let first = root.join("first"); + let second = root.join("second"); + std::fs::create_dir_all(&first).unwrap(); + std::fs::create_dir_all(&second).unwrap(); + let blocked = first.join("bash"); + let executable = second.join("bash"); + for path in [&blocked, &executable] { std::fs::write(path, "#!/bin/sh\n").unwrap(); } + std::fs::set_permissions(&blocked, std::fs::Permissions::from_mode(0o644)).unwrap(); + std::fs::set_permissions(&executable, std::fs::Permissions::from_mode(0o755)).unwrap(); + let paths = std::env::join_paths([&first, &second]).unwrap(); + assert_eq!(find_executable_in_path("bash", &paths), Some(executable.clone())); + std::fs::remove_file(&blocked).unwrap(); + std::fs::create_dir(&blocked).unwrap(); + assert_eq!(find_executable_in_path("bash", &paths), Some(executable.clone())); + std::fs::set_permissions(&executable, std::fs::Permissions::from_mode(0o644)).unwrap(); + assert!(find_executable_in_path("bash", &paths).is_none()); + std::fs::remove_dir_all(root).unwrap(); + } + + #[cfg(all(unix, not(target_os = "macos")))] + #[test] + fn external_terminal_falls_back_and_preserves_working_directory() { + let folder = std::path::Path::new("/tmp/workspace with spaces"); + let mut attempted = Vec::new(); + spawn_external_terminal(folder, |command| { + let program = command.get_program().to_string_lossy().into_owned(); + attempted.push(program.clone()); + assert_eq!(command.get_current_dir(), Some(folder)); + if program == "gnome-terminal" { + assert_eq!(command.get_args().collect::>(), vec![std::ffi::OsStr::new("--working-directory"), folder.as_os_str()]); + Ok(()) + } else { + Err(std::io::Error::from(std::io::ErrorKind::NotFound)) + } + }).unwrap(); + assert_eq!(attempted, ["x-terminal-emulator", "gnome-terminal"]); + } + + #[cfg(all(unix, not(target_os = "macos")))] + #[test] + fn external_terminal_does_not_hide_launch_errors() { + let mut attempts = 0; + let error = spawn_external_terminal(std::path::Path::new("/tmp"), |_| { + attempts += 1; + Err(std::io::Error::from(std::io::ErrorKind::PermissionDenied)) + }).unwrap_err(); + assert_eq!(attempts, 1); + assert!(error.to_string().contains("Could not start x-terminal-emulator")); + } + + #[cfg(all(unix, not(target_os = "macos")))] + #[test] + fn external_terminal_reports_missing_emulators() { + let error = spawn_external_terminal(std::path::Path::new("/tmp"), |_| { + Err(std::io::Error::from(std::io::ErrorKind::NotFound)) + }).unwrap_err(); + assert!(error.to_string().contains("No supported external terminal")); + } +} diff --git a/src-tauri/src/workspace.rs b/src-tauri/src/workspace.rs index c144dd3..55dc0b0 100644 --- a/src-tauri/src/workspace.rs +++ b/src-tauri/src/workspace.rs @@ -988,10 +988,13 @@ pub fn workspace_open_terminal(window: tauri::Window, state: State= 2.39)", + "libssl3t64 | libssl3", + "libnss3", + "libnspr4", + "libasound2t64 | libasound2" + ] + } + } + } +} -- 2.54.0