Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(desktop): a locked Linux keyring no longer freezes startup #35065

Openjuliusmarmingewants to merge 2 commits intomain fromrefs/pull/35065/headopened View on GitHub

juliusmarmingecommented

Item 1 was correct and is fixed. Chromium encrypts empty plaintext to an empty buffer with no version prefix. A probe under pinned Electron 44.10.1 with an unlocked GNOME keyring (backend gnome_libsecret) gave emptyLength=0 and nonemptyPrefix=v11. So the Linux availability check, which encrypted "" and looked for the v11 keyring prefix, always returned false. That hid existing encrypted catalogs, made set return false and skipped legacy credential reads. The availability probe now encrypts a nonempty string ("probe"), and a short comment records why. The rest of the fix is unchanged: on Linux the async safe-storage API replaces the main-thread-blocking sync calls, and encryption counts as available only when it produces keyring-backed v11 ciphertext (a v10 fixed-key fallback is refused). macOS and Windows keep the sync API. The unit test's encryptStringAsync mock now returns an empty buffer for empty input, as Chromium does. With that change, the 'waits for a locked Linux keyring' test fails on the previous head and passes with the fix. The full desktop app was not rerun this round; the evidence is the real-Electron probe and the unit tests.

Fixes pingdotgg/t3code#9239

Reproduction on main

Commit b68aedfdb7 (origin/main). Built with vp run build:desktop:bundle (build:desktop needs libsecret dev headers, which this VM lacks) and ran apps/desktop/node_modules/electron/dist/electron --no-sandbox --disable-gpu --remote-debugging-port=9339 dist-electron/main.cjs under headless-desktop (Xvfb, D-Bus session, GNOME Keyring) with Openbox and an isolated HOME/XDG/T3CODE_HOME and T3CODE_DEV_SEED=0. Run 1, keyring unlocked: logged 'backend ready' after about 4 s and showed the 'Welcome to T3 Code' onboarding; DevTools /json/list answered 200. Run 2, same state, login collection locked with org.freedesktop.Secret.Service.Lock (Locked=true confirmed): the log stopped at 'desktop app control socket ready' with no 'backend ready'; the window showed only the T3 splash logo for the whole 40 s, next to a GNOME 'Unlock Login Keyring' prompt; DevTools HTTP answered nothing at 3, 6, 10, 15, 25 and 40 s, so the main process was blocked; SIGTERM did not end it and SIGKILL was needed. Not tested: Niri/Wayland, the AppImage FUSE mount path, and the variant where no prompt appears.

Evidence

Reproduce on each commit with fresh isolated state: launch unlocked, stop, lock the GNOME login collection and confirm Locked=true, relaunch and wait 40 seconds, click Cancel, then click Add more agents. Stop and relaunch still locked, then submit the synthetic keyring password. Environment for all captures: real Electron desktop, Linux Xvfb/Openbox, D-Bus, GNOME Keyring, light theme, 1920x1080, T3CODE_DEV_SEED=0. Local environment labels are redacted.

BeforeAfter
b68aedfdb75a948d6a2d
Before: splash blocked after 40 secondsAfter: connection screen remains responsive while keyring waits
Before: interaction cannot recover blocked appAfter: Cancel recovers onboarding and Add more agents expands
Before recordingAfter recording

Base: DevTools was unavailable at every probe through 40 seconds, backend ready was absent, and SIGTERM required SIGKILL. Head: every probe returned HTTP 200, backend ready was present, Cancel recovered onboarding, and the onboarding control worked. Both reached onboarding after entering the unlock password on the second launch.

Driver · Capture redaction script · Run instructions · Runtime transcript · Sanitized runtime logs

AI-assisted; verified with the tests and tools listed above.

Not shown:

  • KWallet and KeePassXC were not exercised; this comparison used GNOME Keyring.
  • Niri/Wayland, the AppImage FUSE mount path and the variant where no unlock prompt appears were not exercised; these runs used the bundled Electron app under Xvfb/Openbox.
  • The reported HTTP 500 after dismissal was not reproduced: on the base, clicking Cancel left the unlock prompt visible and the main process blocked.
  • Saved remote-connection credential persistence and decryption of existing credentials were not exercised; the proof used fresh synthetic onboarding state.

Tests

Real Electron 44.10.1 probe under headless-desktop (unlocked keyring, --password-store=gnome-libsecret): backend=gnome_libsecret emptyLength=0 nonemptyPrefix=v11. vp test run src/electron/ElectronSafeStorage.test.ts with the source fix stashed and the new mock: 1 failed, 1 passed (the waits-for-keyring test fails). With the fix: vp test run src/electron/ElectronSafeStorage.test.ts src/app/DesktopConnectionCatalogStore.test.ts src/settings/DesktopSavedEnvironments.test.ts gave 3 files, 10 tests passed. vp run check:changed: format, lint, knip, typecheck (2 packages) and test all passed.

Not in this change

  • After the user cancels the keyring prompt, Electron caches the fallback encryptor for the rest of the process, so saved connections come back only after a restart; reinitialising it would need Electron support.
  • The renderer shows 'Still connecting / could not confirm this workspace' while it waits for the keyring; a dedicated 'waiting for keyring unlock' message would be a UI change.
  • decryptStringAsync's shouldReEncrypt flag is ignored; re-encrypting rotated keys would be new behaviour.
  • macOS and Windows still use the sync safeStorage API; they don't block like Linux, so they were left unchanged.
  • After a cancelled keyring prompt, Electron keeps the fallback encryptor for the rest of the process, so saved connections come back only after a restart.
  • decryptStringAsync's shouldReEncrypt flag is still ignored.
  • macOS and Windows still use the sync safeStorage API, which does not block there.

AI-assisted; verified with the tests and tools listed above.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. Approvability

      Verdict: Approved at 5a948d6

      Macroscope's review found this PR approvable — Linux keyring operations become asynchronous so a locked keyring does not block the desktop main loop. Encryption rejects insecure fixed-key fallback, while other platforms and existing persistence safeguards remain unchanged.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      Linux safe storage now uses asynchronous encryption and decryption APIs. Its availability check validates the encrypted output prefix. Other platforms continue to use synchronous APIs. Tests cover delayed keyring unlock, encryption and decryption, and unavailable encryption.

      Changes: Linux Safe Storage

      Layer / File(s)Summary
      Async backend and platform validation
      apps/desktop/src/electron/ElectronSafeStorage.ts, apps/desktop/src/electron/ElectronSafeStorage.test.ts
      Linux availability encrypts a probe asynchronously and checks for the v11 prefix. Linux encryption and decryption use asynchronous APIs. Other platforms retain the synchronous implementation. Tests cover delayed keyring unlock, round-tripping, and unavailable encryption.

      Estimated code review effort: 3 (Moderate) | ~20 minutes

      Change: Bug fix · Severity of issue fixed: Medium

      Possibly related issues

      • pingdotgg/t3code#27398 — The issue concerns Linux encryption availability when Secret Service is unavailable. This change updates the Linux availability check and rejects ciphertext without the v11 prefix.
      • pingdotgg/t3code#28717 — The issue describes a hang with a locked keyring. This change uses asynchronous safe-storage APIs on Linux.

      Suggested reviewers: maria-rcks

      Merge Risk: Minimal · up to 5a948

      This change makes Linux safe-storage detection and keyring unlock handling work asynchronously, which addresses the startup stall on a locked keyring. No actionable merge-blocking risk remains. The full desktop startup flow was not rerun, which is normal validation uncertainty.

      Pre-merge checks: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe title names the main change: a locked Linux keyring no longer freezes desktop startup. The changeset moves Linux safe-storage calls to the async API and fixes the availability probe that caused th…
      Linked Issues checkPassed[#9239] The issue asks that the Linux window stay responsive while the credential store is locked, and that it show the authentication request or a recoverable error. At head, makeLinux in apps/deskto…
      Out of Scope Changes checkPassedThe changes are confined to apps/desktop/src/electron/ElectronSafeStorage.ts and its unit test ElectronSafeStorage.test.ts. Each change serves the Linux keyring objective of #9239: the async Linux pat…
      Description checkPassedThe description is detailed and mostly follows the template. It has a clear problem statement (Linux availability probe encrypted an empty string, so it always returned false and hid existing catalogs…
      Full details: Title check

      Explanation

      The title names the main change: a locked Linux keyring no longer freezes desktop startup. The changeset moves Linux safe-storage calls to the async API and fixes the availability probe that caused the startup stall. The title follows the conventional commit form the template suggests and is specific enough for a reviewer scanning history.

      Full details: Linked Issues check

      Explanation

      [#9239] The issue asks that the Linux window stay responsive while the credential store is locked, and that it show the authentication request or a recoverable error. At head, makeLinux in apps/desktop/src/electron/ElectronSafeStorage.ts uses the async safe-storage APIs (encryptStringAsync, decryptStringAsync). The sync calls that blocked the main loop are removed from the Linux path. The sync path remains only in makeSync for macOS and Windows. The availability check now encrypts the nonempty string "probe" and requires the v11 prefix, so existing keyring-backed catalogs are no longer misread as unavailable. The unit test 'waits for a locked Linux keyring' covers the async wait. The OS authentication prompt is shown by the keyring service, and the renderer's existing 'Still connecting' state covers the wait. Limits: the real-app before/after evidence section is empty, and the full desktop app was not rerun on this head. These affect verification, not the code requirement. The dedicated waiting-for-keyring UI message and the post-cancel recovery are declared follow-ups, not required by this change.

      Full details: Out of Scope Changes check

      Explanation

      The changes are confined to apps/desktop/src/electron/ElectronSafeStorage.ts and its unit test ElectronSafeStorage.test.ts. Each change serves the Linux keyring objective of #9239: the async Linux path, the v11 availability probe and encrypt guard, the sync path kept for macOS and Windows (not changed in behavior), and the mock update that matches Chromium's empty-input behavior. The other two test files listed in the description are only run for regression, not modified. The declared follow-ups are excluded from this change and are not present in the diff. No unrelated change was found in the reviewed summary.

      Full details: Description check

      Explanation

      The description is detailed and mostly follows the template. It has a clear problem statement (Linux availability probe encrypted an empty string, so it always returned false and hid existing catalogs; the locked keyring also stalled startup), the change (nonempty "probe" string, async Linux safe-storage API, v11-only availability), and a scope link to issue #9239 with a bug-fix framing. Verification is extensive: a real Electron probe, reproduction on base and head with screenshots and recordings, and specific unit test and check results. The template asks for a conventional commit title, which the description does not show, though the PR title is not part of the provided context. The Scope section does not explicitly state why the issue is the only scope, but it links the bug. The agent-model attribution is given as 'AI-assisted' without naming the model and harness, which the template requests. The 'Not in this change' and 'Not shown' sections repeat several bullets (cancelled keyring prompt, shouldReEncrypt, macOS/Windows sync API appear twice), which reduces clarity but does not remove required information.

      Finishing Touches

      Generate unit tests (beta)

      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Recent review info

      Run configuration

      Commits

      Reviewing files that changed from the base of the PR and between ee90bdc9405d8d4b8ff78ce2133ccb04844298ab and 5a948d6a2d5d607fedfef0641463d6dbba303f23.

      Files selected for processing: 2

      • apps/desktop/src/electron/ElectronSafeStorage.test.ts
      • apps/desktop/src/electron/ElectronSafeStorage.ts

      Limit details: You’ve used all 10 included reviews currently available.

    4. tanstack-source added labelsbug

Sign in to join this conversation.