Skip to content

Fix 5 second freeze when reading secrets via the XDG portal - #1663

Merged
raivisdejus merged 6 commits into
mainfrom
fix-portal-secret-timeout
Oct 17, 2026
Merged

raivisdejus merged 6 commits into
mainfrom
fix-portal-secret-timeout

Conversation

@raivisdejus

Copy link
Copy Markdown
Collaborator

Problem

Opening a transcript in the viewer took about 10 seconds on Linux, sometimes with an "is not responding" prompt. Every get_password() call blocked for 5 seconds in _get_portal_secret(), and opening the viewer makes two of them (the viewer itself and Translator.__init__).

The portal sends a Response signal on the request object. When it refuses the request (seen with xdg-desktop-portal 1.21 for an app that is not sandboxed, response code 2), it never writes the secret. We didn't listen for that signal and waited for the full 5 second socket timeout instead.

Fix

  • Subscribe to the portal's Response signal and return straight away when the code is non-zero, without reading the socket.
  • Cache the portal secret, or its absence, for the lifetime of the process. It is fixed per app and get_password() is called from many widgets.
  • Close the D-Bus connection, which was previously leaked.

The first lookup now takes about 70ms, down from 5s, and later lookups take under 1ms.

Tests

New TestPortalSecret tests in tests/store/keyring_store_test.py cover the success path, a failed response returning without reading the socket, the caching, and non-Linux.

🤖 Generated with Claude Code

The portal answers RetrieveSecret with a Response signal. When it refuses
the request, e.g. for an app that is not sandboxed, it never writes the
secret, and we waited for the full socket timeout on every get_password()
call. Opening the transcription viewer did two such calls, freezing the UI
for about 10 seconds.

Wait for the Response signal and skip reading the socket on failure, cache
the portal secret for the process and close the D-Bus connection.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@raivisdejus
raivisdejus enabled auto-merge (squash) October 16, 2026 20:28
@codecov

codecov Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.22034% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.91%. Comparing base (c6c0a69) to head (b9fb529).

Files with missing lines Patch % Lines
buzz/widgets/audio_player.py 50.00% 3 Missing ⚠️
...ranscription_viewer/transcription_viewer_widget.py 94.11% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1663      +/-   ##
==========================================
+ Coverage   83.68%   83.91%   +0.22%     
==========================================
  Files         116      115       -1     
  Lines       13851    13831      -20     
==========================================
+ Hits        11591    11606      +15     
+ Misses       2260     2225      -35     
Flag Coverage Δ
Linux 83.16% <93.22%> (+0.21%) ⬆️
macOS 83.41% <55.93%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@raivisdejus
raivisdejus merged commit f1b943c into main Oct 17, 2026
15 of 16 checks passed
@raivisdejus
raivisdejus deleted the fix-portal-secret-timeout branch October 17, 2026 07:15
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