Skip to content

fix(startup): stop panicking before the window exists - #666

Merged
EVWorth merged 1 commit into
mainfrom
fix/startup-panics
Sep 12, 2026
Merged

EVWorth merged 1 commit into
mainfrom
fix/startup-panics

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 12, 2026

Copy link
Copy Markdown
Owner

From the full-project review.

Four .expect() calls ran before any window existed: the data directory, the log directory, the connection store, the history store. Each turned an ordinary environment problem — a read-only home, a full disk, a corrupt SQLite file — into a process that vanishes, leaving a Rust panic in a terminal a desktop user does not have open. #278 fixed this shape for the keyring; these four were left.

The worst was the history store. #585 put history in its own file specifically so that "a corrupt or oversized history cannot take the connection profiles down with it" — and the .expect() two lines below that comment did exactly that.

What happens now

data directory falls back to a temp directory, then to the working directory
log directory console logging only
connections.db an in-memory store: no saved profiles, app runs
history.db an in-memory store: no history kept, everything else works

A corrupt file is left exactly as it is — the fallback is in memory precisely so that nothing overwrites what still needs recovering. There is a test for that.

Each failure becomes a StartupProblem: a kind, a summary in the user's terms ("Your saved connections could not be opened… nothing you do now will overwrite it"), and the underlying error for a bug report. The status bar shows them, each dismissible, with the detail in the title.

Docs

ARCHITECTURE §7.4 was an ASCII diagram of three hypothetical degradations, two of which are not implemented (SSH, SSL fallback). It now lists the eight that exist — keyring, data dir, log dir, both stores, SSH refusal, AI, a server that has gone — and the rule behind them: nothing in startup panics.

Tests

+6 Rust (including that a corrupt file is byte-for-byte unchanged afterwards), +6 frontend. 2778 unit, 344 browser.

Four `.expect()` calls ran before any window: the data directory, the
log directory, the connection store and the history store. Each one
turned an ordinary environment problem — a read-only home, a full disk,
a corrupt SQLite file — into a process that vanishes, leaving a Rust
panic in a terminal a desktop user does not have open. #278 fixed this
shape for the keyring; these four were left.

The worst of them was the history store. #585 put history in its own
file specifically so that "a corrupt or oversized history cannot take
the connection profiles down with it" — and the `.expect()` two lines
below that comment did exactly that.

Now each degrades and says so:

  - the data directory falls back to a temp directory, then to the
    working directory
  - the log directory failing means console logging only
  - either store falling back to an in-memory one, so the app runs with
    that part missing

A corrupt file is left exactly as it is — the fallback is in memory
precisely so nothing overwrites what still needs recovering.

Each failure becomes a StartupProblem: a kind, a summary in the user's
terms ("Your saved connections could not be opened... nothing you do now
will overwrite it"), and the underlying error for a bug report. The
status bar shows them and lets each be dismissed.

ARCHITECTURE §7.4 was a diagram of three hypothetical degradations, two
of which are not implemented. It now lists the eight that exist and the
rule behind them.

+6 Rust tests, +6 frontend tests.
@EVWorth
EVWorth merged commit a1c1839 into main Sep 12, 2026
12 checks passed
@EVWorth
EVWorth deleted the fix/startup-panics branch September 12, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant