fix(desktop): Select Linux secret storage backend#2916
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Needs human review This PR introduces new Linux secret storage backend selection with substantial new logic affecting credential storage configuration. The changes are security-adjacent and modify app initialization behavior. Additionally, an unresolved review comment identifies a potential bug where early DBUS configuration could prevent proper session bus detection. You can customize Macroscope's approvability policy. Learn more. |
1ec83f0 to
57dcaa9
Compare
57dcaa9 to
9bf124e
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9bf124e. Configure here.
c4ee8d6 to
5f02a0e
Compare
5f02a0e to
a8ab180
Compare
a8ab180 to
f38b824
Compare
f38b824 to
7de405c
Compare

Summary
Closes #2539.
Closes #2880.
This selects an encrypted Linux safeStorage backend before Electron is ready, so desktop SSH environment credentials can be persisted on Linux sessions Electron does not recognize automatically.
Problem and Fix
basic_texton Linux sessions such as Niri or unversioned KDE/Plasma because the desktop name is not one of Electron's recognized backend selectors.app.readyand default unknown non-KDE sessions tognome-libsecret, while using KWallet for KDE/Plasma sessions.linuxPasswordStoresetting synchronously during early Electron startup, with unsupported values normalized toautowithout dropping unrelated settings.Defensive Fixes
ready.readyand the selected backend afterready, without probing keyring availability during startup.Application Startup Sequence
Before this change,
main.tsonly serialized scheme privilege registration before the broader runtime:After this change,
main.tsalso requires the pre-ready command-line switch work to finish before the broader runtime:Validation
bun fmtbun lintbun typecheckbun run --filter @t3tools/desktop test -- linuxSecretStorage DesktopEarlyElectronStartup DesktopAppSettings DesktopShellEnvironment DesktopSavedEnvironmentsChecklist
Note
Medium Risk
Touches credential encryption and early Electron startup order; wrong backend choice could break saving SSH secrets on Linux, though CLI overrides and extensive tests reduce exposure.
Overview
Fixes Linux desktop safeStorage falling back to unencrypted storage on sessions Electron does not recognize (e.g. Niri, unversioned KDE/Plasma) by choosing the
--password-storeswitch beforeapp.ready.Adds
linuxPasswordStoreto desktop settings (defaultauto) and reads it synchronously fromdesktop-settings.jsonduring early startup, including JSONC and invalid-value normalization.linuxSecretStorage.tsmapsautoto no switch on known GNOME/KDE desktops,kwalleton KDE/Plasma heuristics, andgnome-libsecretotherwise; explicit CLI--password-storewins and is not overridden.main.tswires adesktopElectronPreReadyLayerthat registers scheme privileges and applies pre-ready switches (WM class + password store) alongsideDesktopPreReadyElectronOptions. After login-shell hydration,DesktopAppcan remove/re-appendpassword-storewhen env or settings change, and logs the configured choice plussafeStorage.getSelectedStorageBackend()on Linux.DesktopShellEnvironmentnow pulls Linux session vars (includingDBUS_SESSION_BUS_ADDRESS, XDG/Wayland) from the login shell and can set D-Bus from the default runtime socket when missing.ElectronApp.removeCommandLineSwitchandselectedStorageBackendsupport the new flow; remediation copy for failed secret storage is added inlinuxSecretStoragefor follow-on credential errors.Reviewed by Cursor Bugbot for commit 7de405c. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Select Linux secret storage backend based on desktop environment and user preference
linuxPasswordStoreto desktop settings (default:auto) and normalizes it vianormalizeLinuxPasswordStorePreferenceinlinuxSecretStorage.ts.--password-storeElectron command-line switch before app readiness using desktop environment heuristics (KDE → kwallet, others → gnome-libsecret); explicit preferences bypass the heuristic.resolveEarlyLinuxElectronOptionsandDesktopPreReadyElectronOptionsso thepassword-storeand WM class switches are set during early startup, before Electron firesready.installPosixEnvironmentto propagateXDG_CURRENT_DESKTOP,WAYLAND_DISPLAY,DBUS_SESSION_BUS_ADDRESS, and related vars; auto-setsDBUS_SESSION_BUS_ADDRESSon Linux when the default socket exists.ElectronSafeStorage.selectedStorageBackendand logs the selected backend after readiness for diagnostics.password-storeswitch is removed and re-appended at startup if settings differ from what was on the command line; launching with an explicit--password-storeCLI flag takes precedence and is preserved.Macroscope summarized 7de405c.