Skip to content

Share saved connections between Stroke and Stroke Nightly - #417

Merged
broisnees merged 1 commit into
nightlyfrom
fix/shared-connections
Nov 24, 2026
Merged

broisnees merged 1 commit into
nightlyfrom
fix/shared-connections

Conversation

@broisnees

Copy link
Copy Markdown
Collaborator

Bug: add a connection in Nightly, open Stable, go back to Nightly, and Nightly's connection has lost its saved password.

Cause: Stable and Nightly kept connections.json in separate data folders (com.broisnischal.stroke and com.broisnischal.stroke.nightly) but share one keychain vault (app.stroke.desktop). Stable removed Nightly's passwords in two places:

  1. At startup, hydrateConnectionSecrets pruned every vault id missing from its own list.
  2. Every save rewrote the whole vault from that process's in-memory cache.

Fix:

  • One file: both apps use connections.json in Stable's folder (connection_store::shared_dir). On first read, Nightly's own file is merged in, with the newer lastConnectedAt winning per id, then renamed to connections.json.merged.
  • Merge on write: each write merges with what's on disk, so both apps can run at once. Rows only on disk are kept. A tombstone in deleted wins over a stale copy, and revived lifts one for an explicit re-add (the sample database).
  • Keychain merge: the new conn_secrets_merge reads the vault fresh from the keychain and changes only this app's ids and the deleted ids. Startup prunes only tombstoned ids.
  • Refresh on focus: when the window gains focus, refreshConnectionsFromDisk re-reads the list and passwords (conn_secrets_read_fresh), so the other app's changes show up without a restart.
  • Copy: the Stable/Nightly switch dialog no longer says connections stay with each app.

Testing

  • Rust: cargo test --lib passes, 521 tests. New ones cover a write keeping the other app's rows, a delete beating a stale copy, revive, the tombstone cap, the one-time Nightly-to-shared merge, writes from both folders landing in one file, and a secrets merge leaving the other track's ids alone.
  • JS: npm test passes (2009 node tests, 20 DOM tests). New tests cover startup pruning only deleted ids, a save keeping the other track's password, the focus refresh picking up a new connection with its password (and ignoring key order), and a revive reaching the disk copy.
  • Other checks: svelte-check shows 0 errors, the design lint has no new violations, and the build passes.
  • Not tested end to end: I didn't run two real installs (Stable and Nightly) side by side.
  • Older builds: a Stable build from before this change still prunes the vault the old way until it updates.

Stable and Nightly each kept connections.json in their own data folder but
share one keychain vault. A connection added in Nightly was missing in Stable,
and Stable then deleted Nightly's passwords twice over: at startup it pruned
every vault id missing from its own list, and every save rewrote the whole
vault from its own cache.

- connections.json lives in Stable's folder for both apps. Nightly's own file
  is merged in once (newer lastConnectedAt wins per id) and renamed to
  connections.json.merged.
- Every write merges with the file on disk: rows the other app added are kept,
  and a tombstone in `deleted` wins over a stale copy. `revived` lifts one for
  an explicit re-add.
- Connection secrets are written with conn_secrets_merge, which reads the vault
  fresh and only touches this app's ids and deleted ids. Startup prunes only
  tombstoned ids.
- On window focus the list and passwords are re-read, so what the other app
  saved shows up without a restart.
@broisnees broisnees added the release:skip Merge into nightly without a version bump (docs, CI, chores) label Nov 24, 2026
@broisnees
broisnees merged commit 1380eb0 into nightly Nov 24, 2026
1 check passed
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release:skip Merge into nightly without a version bump (docs, CI, chores)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant