Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ jobs:
shell: bash
run: npx tauri build --config nightly.conf.json ${{ matrix.args }}
env:
# Nightly trades a little binary size and speed for build time. The
# release profile's fat LTO with one codegen unit re-optimizes the
# whole dependency graph on one thread every build (~9 of the ~11
# minutes, with every dependency already cached). Thin LTO keeps most
# of the gain and runs in parallel. Stable (release.yml) keeps fat LTO.
CARGO_PROFILE_RELEASE_LTO: thin
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: "16"
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
NO_STRIP: ${{ matrix.name == 'linux' && '1' || '' }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ scoop install stroke

Or grab an installer from [Releases](https://github.com/stroke-app/stroke/releases): `.dmg` for macOS (Apple Silicon or Intel), `-setup.exe` for Windows, `.deb` (Ubuntu 22.04+, Debian 12+), `.rpm` (Fedora 41+, RHEL 10) or `.AppImage` (Arch and any distro with glibc 2.35+) for Linux.

The AppImage runs through XWayland by default. To try native Wayland, start it with `STROKE_WAYLAND=1`.
On Wayland, Stroke runs natively. If a launch can't draw there (some GPU and driver setups), the next one falls back to X11 by itself. `STROKE_X11=1` forces X11; `STROKE_WAYLAND=1` forces Wayland and forgets the fallback.

**Stroke Nightly** is built every night from the `nightly` branch and installs as a separate app beside Stroke, with its own settings, so you can try what's coming without risking your setup: [download the nightly](https://github.com/stroke-app/stroke/releases/tag/nightly). It updates itself every night something lands.

Expand Down
15 changes: 8 additions & 7 deletions scripts/appimage-strip-host-libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
# Tested on Arch, Fedora 41/45, Debian 12/13 and Ubuntu 22.04/24.04.
# Issue: https://github.com/stroke-app/stroke/issues/112
#
# It also lets the AppImage run on native Wayland when asked. linuxdeploy's
# GTK hook hard-sets GDK_BACKEND=x11, so the window always went through
# XWayland and a GDK_BACKEND=wayland on the command line was ignored. X11 stays
# the default (it is the fallback for the WebKit EGL_BAD_ALLOC crash some
# Wayland setups hit); STROKE_WAYLAND=1 opts into the native backend.
# It also stops linuxdeploy's GTK hook from hard-setting GDK_BACKEND=x11, so
# Stroke can choose: native Wayland, with an automatic X11 fallback when a
# Wayland launch never draws (display_backend.rs).
#
# The image is repacked with its own runtime and the same squashfs settings,
# so nothing else about the AppImage changes. Needs squashfs-tools.
Expand Down Expand Up @@ -67,8 +65,11 @@ fi
# X11 by default, native Wayland with STROKE_WAYLAND=1.
hook="$root/apprun-hooks/linuxdeploy-plugin-gtk.sh"
if [ -f "$hook" ] && grep -qE '^export GDK_BACKEND=x11' "$hook"; then
sed -i -E 's|^export GDK_BACKEND=x11.*$|if [ "${STROKE_WAYLAND:-}" = 1 ]; then export GDK_BACKEND=wayland; else export GDK_BACKEND=x11; fi|' "$hook"
echo "appimage: GDK_BACKEND=x11 unless STROKE_WAYLAND=1"
# Stroke picks the backend itself (src-tauri/src/display_backend.rs: Wayland,
# falling back to X11 if a Wayland launch never draws), so the hook only
# passes the two overrides through.
sed -i -E 's|^export GDK_BACKEND=x11.*$|if [ "${STROKE_WAYLAND:-}" = 1 ]; then export GDK_BACKEND=wayland; elif [ "${STROKE_X11:-}" = 1 ]; then export GDK_BACKEND=x11; fi|' "$hook"
echo "appimage: GDK_BACKEND left to Stroke (STROKE_X11=1 / STROKE_WAYLAND=1 override)"
changed=1
fi

Expand Down
2 changes: 2 additions & 0 deletions src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ pub async fn open_new_window(app: tauri::AppHandle) -> Result<(), String> {
/// capability file only grants core window permissions to `main`.
#[tauri::command]
pub fn reveal_window(window: tauri::WebviewWindow) {
// The page drew a finished screen, so this display backend works here.
crate::display_backend::drawn();
if !window.is_visible().unwrap_or(false) {
let _ = window.show();
let _ = window.set_focus();
Expand Down
121 changes: 121 additions & 0 deletions src-tauri/src/display_backend.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
//! Linux: native Wayland by default, X11 where it can't draw.
//!
//! Stroke used to force X11 (XWayland) everywhere, because on some Wayland
//! setups WebKit's web process aborts while creating its EGL display and the
//! window stays blank (issue #112 and the EGL_BAD_ALLOC reports). Most setups
//! draw fine on Wayland and look sharper there, so Wayland is now the default,
//! with a launch check:
//!
//! - Before GTK starts, a Wayland launch leaves a `wayland-pending` marker.
//! - The page's first finished screen (`reveal_window`) removes it.
//! - If the next launch still finds it, the last Wayland launch never drew a
//! page: this one, and every one after, uses X11 (`use-x11`).
//!
//! Overrides: `GDK_BACKEND` set by the user wins; `STROKE_X11=1` forces X11;
//! `STROKE_WAYLAND=1` forces Wayland and forgets an earlier fallback.

#[cfg(target_os = "linux")]
mod imp {
use std::path::PathBuf;

use std::sync::atomic::{AtomicBool, Ordering};

const PENDING: &str = "wayland-pending";
/// This launch is a Wayland trial (it left the marker).
static TRIAL: AtomicBool = AtomicBool::new(false);
const FALLBACK: &str = "use-x11";

/// `~/.local/state/<binary>`: Stroke and Stroke Nightly keep their own.
fn state_dir() -> Option<PathBuf> {
let base = std::env::var_os("XDG_STATE_HOME")
.map(PathBuf::from)
.or_else(|| std::env::var_os("HOME").map(|h| PathBuf::from(h).join(".local/state")))?;
let exe = std::env::current_exe().ok()?;
let name = exe.file_stem()?.to_string_lossy().to_lowercase();
Some(base.join(format!("{name}-display")))
}

fn set(backend: &str) {
// SAFETY: called from run() before any thread is spawned.
unsafe { std::env::set_var("GDK_BACKEND", backend) };
}

/// Pick the backend. Must run before GTK initialises and before any thread.
pub fn choose() {
let Some(dir) = state_dir() else { return };
let pending = dir.join(PENDING);
let fallback = dir.join(FALLBACK);
if std::env::var("STROKE_WAYLAND").as_deref() == Ok("1") {
let _ = std::fs::remove_file(&fallback);
set("wayland");
return;
}
if std::env::var("STROKE_X11").as_deref() == Ok("1") {
set("x11");
return;
}
// The user (or their desktop) already chose.
if std::env::var_os("GDK_BACKEND").is_some() {
return;
}
// An X11 session: nothing to decide.
if std::env::var_os("WAYLAND_DISPLAY").is_none() {
return;
}
if fallback.exists() {
set("x11");
return;
}
if pending.exists() {
log::warn!("display: the last Wayland launch never drew a page; using X11 from now on (STROKE_WAYLAND=1 to try Wayland again)");
let _ = std::fs::write(&fallback, "The last Wayland launch didn't draw. Delete this file, or start Stroke with STROKE_WAYLAND=1, to try Wayland again.\n");
let _ = std::fs::remove_file(&pending);
set("x11");
return;
}
let _ = std::fs::create_dir_all(&dir);
if std::fs::write(&pending, b"").is_ok() {
TRIAL.store(true, Ordering::Relaxed);
}
}

/// A Wayland launch that hasn't drawn in 25s won't: the web process died
/// creating its EGL display and the window stays hidden. Restart on X11
/// now instead of leaving a blank launch. Release builds only (a dev
/// build's first page waits on the Vite dev server).
pub fn watch(app: tauri::AppHandle) {
if cfg!(debug_assertions) || !TRIAL.load(Ordering::Relaxed) {
return;
}
std::thread::spawn(move || {
std::thread::sleep(std::time::Duration::from_secs(25));
let Some(dir) = state_dir() else { return };
if !dir.join(PENDING).exists() {
return;
}
log::warn!("display: no page drawn on Wayland after 25s; restarting on X11");
let _ = std::fs::write(dir.join(FALLBACK), "A Wayland launch didn't draw. Delete this file, or start Stroke with STROKE_WAYLAND=1, to try Wayland again.\n");
let _ = std::fs::remove_file(dir.join(PENDING));
app.restart();
});
}

/// The page drew: this backend works here.
pub fn drawn() {
if let Some(dir) = state_dir() {
let _ = std::fs::remove_file(dir.join(PENDING));
}
}
}

#[cfg(target_os = "linux")]
pub use imp::{choose, drawn, watch};

#[cfg(not(target_os = "linux"))]
pub fn choose() {}

#[cfg(not(target_os = "linux"))]
pub fn drawn() {}

#[cfg(not(target_os = "linux"))]
pub fn watch(_app: tauri::AppHandle) {}
5 changes: 5 additions & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mod nightly;
mod agents;
mod app_lock;
mod cloudflare;
mod display_backend;
mod commands;
mod connection_store;
mod copilot;
Expand Down Expand Up @@ -429,6 +430,9 @@ pub fn run() {
// connection. ring keeps TLS exactly as it was.
let _ = rustls::crypto::ring::default_provider().install_default();

// Wayland or X11, before GTK starts and before any thread (display_backend.rs).
display_backend::choose();

// Linux WebKitGTK rendering fix - set before any threads spawn.
#[cfg(target_os = "linux")]
// SAFETY: called before any threads are spawned.
Expand Down Expand Up @@ -490,6 +494,7 @@ pub fn run() {
.manage(updates::UpdateState::default())
.manage(launch::LaunchState::default())
.setup(move |app| {
display_backend::watch(app.handle().clone());
// Linux packages renamed the binary from `app` to `stroke` (2.5.6), and
// a launch-at-login entry stores the binary's path. Re-enabling an
// enabled entry rewrites it with the current path, so it doesn't
Expand Down
32 changes: 26 additions & 6 deletions src/lib/components/StudioShell.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@
import SidebarQueries from './SidebarQueries.svelte'
import TabBar from './TabBar.svelte'
import PaneLayout from './PaneLayout.svelte'
import PaneSnapshot from './PaneSnapshot.svelte'
import * as PaneTree from '$lib/pane-layout.js'
import TabLoading from './TabLoading.svelte'
import TableToolbar from './TableToolbar.svelte'
import DataTable from './DataTable.svelte'
import RowDetailPanel from './RowDetailPanel.svelte'
// TableJsonView / TableTextView are NOT imported here: both reach the CodeMirror
// editor and its languages statically, which would drag them into the boot
Expand Down Expand Up @@ -658,6 +656,17 @@
// once the window is idle (below), so the first open is still instant.
// Keep these specifiers identical to the {#await import()} blocks in the
// markup so Vite resolves both to the same chunk.
// The data grid (about 400KB) is the first thing a table tab needs but
// nothing before one opens, so it is not in the startup bundle: it loads
// the first time a table renders, or earlier, the moment a connection
// starts, so it is in memory by the time the rows arrive.
/** @type {Promise<typeof import('./DataTable.svelte')> | null} */
let dataTableModule = null
const loadDataTable = () => (dataTableModule ??= import('./DataTable.svelte'))
$effect(() => {
if (connection) void loadDataTable()
})

const lazyDialogs = {
settings: () => import('./SettingsDialog.svelte'),
aiSettings: () => import('./AiSettingsDialog.svelte'),
Expand All @@ -680,7 +689,7 @@
})
onMount(() => {
// The palette and Settings first: they are the ones a shortcut opens.
const order = [lazyDialogs.palette, lazyDialogs.settings, lazyDialogs.aiSettings, lazyDialogs.share, lazyDialogs.createTable, lazyDialogs.importData, lazyDialogs.docker]
const order = [loadDataTable, lazyDialogs.palette, lazyDialogs.settings, lazyDialogs.aiSettings, lazyDialogs.share, lazyDialogs.createTable, lazyDialogs.importData, lazyDialogs.docker]
let i = 0
let cancel = () => {}
const pump = () => {
Expand Down Expand Up @@ -7333,7 +7342,11 @@ let rowSearch = $state('')
// Windowed results keep only a few resident windows, so read the full
// ordered set from the server for export instead of the sparse client array.
let sourceRows = rows
if (windowed) {
// Paged mode holds only the page on screen. An export is of the table (with
// its filters and sort), so read the rest too; it used to save the one page
// and say "Exported 100 rows" of a table that has 5,000.
const wholeTable = windowed || (selected.size === 0 && total > rows.length)
if (wholeTable) {
const fetchId = toast.info('Fetching all rows for export…', { duration: 60 * 60 * 1000 })
try {
sourceRows = await fetchAllRows()
Expand Down Expand Up @@ -7376,7 +7389,10 @@ let rowSearch = $state('')
content = format === 'csv'
? await rowsToCsvAsync(exportColumns, exportCells)
: await rowsToJsonAsync(exportColumns, exportCells)
// The other formats build in one go (Excel and Parquet as files).
} else {
// The other formats build in one go (Excel and Parquet as files). This
// was outside an else, so a big CSV was built twice: once in chunks,
// then thrown away and built again in one blocking pass.
content = ''
}
const saved = content
Expand Down Expand Up @@ -10579,7 +10595,9 @@ let rowSearch = $state('')
{#if isFocused}
{@render sharedContent()}
{:else}
<PaneSnapshot tab={tabsById.get(group.activeTabId ?? '') ?? null} toolbarSpacer={tableToolbarVisible} connectionId={persistConnectionId} {schemas} />
{#await import('./PaneSnapshot.svelte') then { default: PaneSnapshot }}
<PaneSnapshot tab={tabsById.get(group.activeTabId ?? '') ?? null} toolbarSpacer={tableToolbarVisible} connectionId={persistConnectionId} {schemas} />
{/await}
{/if}
{/snippet}

Expand Down Expand Up @@ -11435,6 +11453,7 @@ let rowSearch = $state('')
<!-- The grid stays mounted (hidden) in other view modes so staged
edits, selection and scroll position survive mode switches. -->
<div class={dataViewMode === 'table' ? 'flex min-h-0 min-w-0 flex-1' : 'hidden'}>
{#await loadDataTable() then { default: DataTable }}
<DataTable
bind:this={dataTable}
{columns}
Expand Down Expand Up @@ -11539,6 +11558,7 @@ let rowSearch = $state('')
bind:stageDeleteSelected={stageDeleteSelectedRows}
readonly={tableReadonly}
/>
{/await}
</div>
{#if dataViewMode === 'json'}
{#await import('./TableJsonView.svelte')}<TabLoading />{:then { default: TableJsonView }}
Expand Down
8 changes: 4 additions & 4 deletions src/lib/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ export const UTF8_BOM = ''
export function rowsToCsv(columns, rows) {
const header = columns.map((c) => csvEscape(c.name)).join(',')
const body = rows.map((row) => row.map(csvEscape).join(',')).join('\n')
// TODO: surface backend row-cap/truncation here once a `truncated` flag is
// threaded through to this layer (append a trailing note when capped).
// A note about a capped result belongs in the export toast, not in here: a
// trailing line in the file would be read as a data row by anything that
// parses it.
return UTF8_BOM + header + '\n' + body
}

Expand Down Expand Up @@ -46,8 +47,7 @@ export async function rowsToCsvAsync(columns, rows, opts = {}) {
onProgress?.(end, total)
await yieldToUi()
}
// TODO: surface backend row-cap/truncation here once a `truncated` flag is
// threaded through to this layer (append a trailing note when capped).
// See rowsToCsv: what was left out is said in the toast, never in the file.
return blocks.join('\n')
}

Expand Down
Loading