Skip to content

fix(quick_launch): read clipboard history items on MTA thread - #1246

Open
n-crespo wants to merge 1 commit into
amnweb:mainfrom
n-crespo:fix/clipboard-history-sta
Open

n-crespo wants to merge 1 commit into
amnweb:mainfrom
n-crespo:fix/clipboard-history-sta

Conversation

@n-crespo

@n-crespo n-crespo commented Nov 19, 2026 •

Copy link
Copy Markdown

Since v2.0.8, every entry in Quick Launch's clipboard history shows up as "Clipboard item – Unsupported format", even plain text, and there's no preview. Restoring an entry still works, and Win+V shows the same items fine.

Cause

This is a regression from a420194, which added CoInitialize() to QueryWorker so file search could use Windows Search. That turned the query worker into a single-threaded apartment (STA) thread, and winrt refuses blocking .get() calls on STA threads.

The provider already worked around this for the history query by running it on a separate multi-threaded apartment (MTA) worker. But the items it returned were then read back on the query worker: get_text_async().get(), get_bitmap_async().get() and the bitmap stream reads. Each of those raised Cannot call blocking method from single-threaded apartment. A bare except: pass swallowed the error, so every item fell through to the unknown-format branch. Restore kept working because set_history_item_as_content doesn't block.

Fix

The whole load (the history query and the per-item parsing) now runs on the MTA worker, so the provider works no matter which apartment its caller is in. The two read errors that were silently swallowed are now logged at debug level, so a failure like this is easier to spot.

I tested this by running yasb from source, and all tests pass apart from tests/bar/test_adaptive_bar.py, which fails the same way on main.

Assisted-by: Claude Code noreply@anthropic.com

Clipboard history entries all showed "Unsupported format" in Quick Launch.
Only get_history_items_async() ran on the MTA worker; the per-item
get_text_async()/get_bitmap_async()/stream reads ran on the query worker
(STA) thread, where winrt's blocking .get() raises "Cannot call blocking
method from single-threaded apartment". The exception was swallowed, so
every item fell through to the unknown-format branch.

Run the whole history load and parse on the MTA worker, and log the
previously swallowed read errors at debug level.

Assisted-by: Claude Code <noreply@anthropic.com>
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