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 a new Linux feature for secret storage backend selection, including new settings, desktop environment detection heuristics, D-Bus integration, and changes to Electron initialization. The scope and behavioral impact warrant human review despite the 'fix' prefix. You can customize Macroscope's approvability policy. Learn more. |
1ec83f0 to
57dcaa9
Compare
57dcaa9 to
9bf124e
Compare
c4ee8d6 to
5f02a0e
Compare
5f02a0e to
a8ab180
Compare
a8ab180 to
f38b824
Compare
f9c8c69 to
219f76d
Compare
219f76d to
7704609
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 7704609. Configure here.
7704609 to
e9f8d2e
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 bootstrap on Linux; wrong backend or switch timing could still break secret persistence, but CLI overrides are respected and changes are covered by targeted tests.
Overview
Linux desktop now picks Electron
safeStorage/--password-storebeforeapp.ready, so encrypted credentials work on sessions Electron does not auto-detect (e.g. Niri, unversioned KDE).Startup is split into a pre-ready layer (
main.ts): privileged scheme registration plus synchronous reads ofdesktop-settings.jsonforlinuxPasswordStore, WMclass, and optional--password-store(skipped when the user already passed--password-storeon the CLI). After login-shell env hydration,DesktopAppcan remove/re-applypassword-storefrom persisted settings and logs the chosen backend before/after ready.New
linuxSecretStorageheuristics mapauto→gnome-libsecretorkwalletfrom desktop env vars;DesktopAppSettingspersistslinuxPasswordStore(defaultauto, invalid values normalized).DesktopShellEnvironmentpulls more Linux session vars (includingDBUS_SESSION_BUS_ADDRESSfallback via/run/user/$UID/bus).ElectronAppgainsremoveCommandLineSwitch;ElectronSafeStorageexposesselectedStorageBackendon Linux for diagnostics.Reviewed by Cursor Bugbot for commit e9f8d2e. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Select Linux secret storage backend via pre-ready Electron command-line configuration
resolveEarlyLinuxElectronOptionsto compute thepassword-storeandwmClasscommand-line switches before Electron is ready, by readingdesktop-settings.jsonsynchronously from the resolved state directory.linuxPasswordStoresetting (default'auto') toDesktopSettings, persisted and normalized vianormalizeLinuxPasswordStorePreference.resolveLinuxPasswordStoreSwitchheuristic to choose betweenkwallet,gnome-libsecret, or no override depending on the detected desktop environment and user preference.ElectronAppwithremoveCommandLineSwitchandElectronSafeStoragewithselectedStorageBackend(Linux only) to support runtime inspection and reconfiguration.DesktopShellEnvironmentto include XDG/Wayland/D-Bus variables, and auto-infersDBUS_SESSION_BUS_ADDRESSon Linux when unset.password-storecommand-line switch is now removed and re-applied on each startup based on resolved settings, overriding any previously set value unless already specified via CLI.Macroscope summarized e9f8d2e.