Skip to content

Labs: fix the crash on disconnect, switch without flicker, report crashes - #262

Merged
broisnees merged 1 commit into
nightlyfrom
fix/labs-switch-crash
Nov 16, 2026
Merged

broisnees merged 1 commit into
nightlyfrom
fix/labs-switch-crash

Conversation

@broisnees

Copy link
Copy Markdown
Collaborator

What was wrong

  • Crash. park_connection, resume_connection and close_parked are sync commands, which run with no Tokio runtime. Closing a pool there called tokio::spawn, which panics outside a runtime, and release builds use panic = "abort". Turning Labs off, editing a connection, or disconnecting with databases kept open closed the app without a word. D1 too, since the spawn ran for every engine.
  • Flicker. Switching to a database not open yet set connection = null first (the whole layout dropped), raised the full-screen Connecting overlay, then rebuilt an empty sidebar.
  • Data table. onConnected wiped every tab's row cache, including tabs kept for the other databases. Coming back, the grid got the proxied $state copy of its rows, the known slow-scroll path.
  • Tabs from other databases were missing whenever the workspace had a pane layout (even a single pane): the pane's bar listed only its own tab ids.

What changed

  • close_in_background spawns on tauri's runtime. New test closing_a_pool_outside_a_runtime_does_not_panic: fails on the old code (panics), passes now.
  • Crash reports: crash.rs installs a panic hook that writes message, location, thread, version, platform and backtrace to last-crash.json before the abort (the OS crash reporter still sees it). The next launch takes it once and opens the report dialog as "Stroke quit unexpectedly", prefilled as a crash report, with Open on GitHub.
  • Switching: the database on screen stays up while the next one connects (its calls keep reaching its parked pool through the route key), then everything swaps at once. The status bar shows "Opening ". A failed switch resumes the previous database in place.
  • Connecting keeps the caches of kept tabs; keeping a session drops the raw rows of the tabs it evicts.
  • Tab bar: no database label pills. Other databases' tabs are dimmed, a thin divider starts each database's group, the tooltip names the database. Works in single-pane layouts now.
  • Status bar: the open databases as small chips, the front one marked; click one to switch.
  • Disconnect with others open closes just this one and moves to the one used last.

Checked

  • Ran the real desktop app (debug build, WebKitGTK on Xvfb) with two SQLite databases and Labs on, recorded at 30fps:
    • switch to a new database: the old screen stays until the new one is ready, one-frame swap, no overlay
    • switch back (status bar chip, or the dimmed tab): one frame, grid comes back with its rows
    • tab bar shows the other database's tab dimmed after a divider, no labels
    • disconnect with two open: lands on the other, app stays up
    • planted crash report: dialog opens on launch, prefilled
  • cargo test (crash + parked), vitest 1798 passed, svelte-check 0 errors, npm run build.

…shes

Closing a set-aside pool from park_connection, resume_connection or
close_parked called tokio::spawn. Those are sync commands with no Tokio
runtime, so it panicked, and release builds abort on a panic: turning Labs
off, editing a connection or disconnecting with databases kept open closed
the app. close_in_background now spawns on tauri's runtime, with a test that
fails on the old code.

Crashes now leave a report: a panic hook writes the message, location,
version and platform to the data directory before the abort, and the next
launch opens the report dialog prefilled as a crash report.

Switching to a database not open yet keeps the current one on screen (its
calls still reach its parked pool) and swaps once the new one is connected:
no blank layout, no full-screen overlay. The status bar says what is opening.
A failed switch puts the previous database back in place.

Connecting no longer wipes the row and result caches of tabs kept for other
databases, so a resumed grid gets its raw rows back instead of the proxied
copy, which was slow to scroll.

Tab bar: no database labels. Other databases' tabs are dimmed, each group
starts with a divider, and the tooltip names the database. They also show in
a single pane, where they were missing. The status bar lists the open
databases; click one to switch. Disconnecting with others open closes only
this one and moves to the last used.
@broisnees
broisnees merged commit 43d4629 into nightly Nov 16, 2026
1 check passed
@broisnees
broisnees deleted the fix/labs-switch-crash branch November 16, 2026 02:19
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant