feat(mpris): make the player rows tell you which is which - #39
Open
Zakkaus wants to merge 3 commits into
Open
Conversation
This was referenced Aug 15, 2026
Zakkaus
force-pushed
the
feat/player-picker-detail
branch
2 times, most recently
from
August 15, 2026 23:21
6cbe477 to
b766b09
Compare
With Firefox and Chrome both playing, the picker listed four rows: Chrome,
Mozilla firefox, Mozilla Firefox, Google Chrome. Each browser publishes its own
MPRIS endpoint and Plasma Browser Integration bridges the same tab, so half the
list is duplicates and two of the names differ only in one letter's case. The
user cannot tell which row is their music.
Names cannot fix that, so the rows now say what each endpoint is actually doing:
自動 · Mozilla Firefox · 播放中 · 大石碎胸口 - 万能青年旅店
Google Chrome · 播放中 · 下山 (梦幻西游方寸山门派曲) - 要不要买菜
Identity, playback status, and the loaded track. The row the automatic choice
would pick is marked, so a user who does not want to choose can see the default
is already sensible. Reading `Metadata` and `PlaybackStatus` rides on the
round trip that already fetched `Identity`.
Nothing is deduplicated or hidden. Two endpoints for one browser are a real
choice — the bridge usually reports a cleaner artist, but not always, and hiding
the wrong one would leave the user with only the broken option.
MPRIS reports the status as a protocol constant, so it is translated for
display; a Chinese UI showing "Playing" was the first version of this.
Eliding happens where the row is built. A QStyledItemDelegate was the obvious
tool and the wrong one: its initStyleOption runs during sizeHint, where the
option's widget can already be destroyed, and Qt then crashes inside
QWidget::style(). That segfaulted the suite.
The row automatic selection is currently on was prefixed with the word automatic, directly under a row labelled Automatic. Two rows starting with the same word is exactly the confusion the picker was added to remove. Mark it as the current one instead.
Zakkaus
force-pushed
the
feat/player-picker-detail
branch
from
August 16, 2026 07:54
b766b09 to
34a95b4
Compare
The settings picker carried its own copy of the rule that decides which player to follow, and the two copies ordered the last fallbacks the other way round: with a Playing player reporting no metadata beside a Paused one that reports a track, the row marked Current named the first while the poll followed the second. The rule now lives in one method that both call, so they cannot drift again, and the poll no longer accumulates five parallel candidate variables to express it. Identity and detail also shared one try, so a player that answered its name but failed the optional status and metadata read vanished from the picker entirely and could not be selected. The detail read now degrades to an empty status.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem, from a real desktop
With Firefox and Chrome both playing, #22's picker lists four rows:
Each browser publishes its own MPRIS endpoint, and Plasma Browser Integration bridges the same tab, so half the list is duplicates — and two of the names differ only in one letter's case. There is no way to tell which row is the music you want.
Fix: say what each endpoint is doing
Identity, playback status, and the loaded track. Now the two Firefox rows are visibly the same song and the two Chrome rows are visibly the other one, so the choice is obvious. The row the automatic selection would pick is marked, so a user who does not want to choose can see the default is already sensible.
MetadataandPlaybackStatusride on the D-Bus round trip that already fetchedIdentity, so this costs no extra traffic.What it deliberately does not do
No deduplication. Two endpoints for one browser are a real choice, not noise. The bridge usually reports a cleaner artist — that is why the automatic ranking prefers it, as the comment above
_selection_scoreexplains — but "usually" is not "always", and hiding the wrong one would leave the user with only the broken option.Two defects fixed while building it
Status was untranslated. MPRIS reports it as a protocol constant, so the first version showed
Playinginside an otherwise Chinese row.A delegate segfaulted the suite. Eliding long rows with a
QStyledItemDelegatelooks right and is not:initStyleOptionruns duringsizeHint, where the option's widget can already be destroyed, and Qt crashes insideQWidget::style(). The backtrace wasQComboBox::changeEvent→QListView::doItemsLayout→QStyledItemDelegate::sizeHint→QWidget::style(). Eliding now happens where the row is built, which is our own string and needs no delegate.Validation
QT_QPA_PLATFORM=offscreen uv run pytest— 386 passed, run three times for the segfaultuv run ruff check .uv run ty checkChecked against a live session with four real endpoints, rendered in
zh-Hantanden— the rows above are the actual output, not test data.Follow-up: the marker read as a second automatic option
Verified with two browsers publishing on the session bus at once. The rows come out as intended —
Firefox · Playing · アイドル by YOASOBIagainstChromium · Paused · Bad Apple!! by nomico— but the row automatic selection had landed on was prefixed with the wordautomatic, directly under the row labelledAutomatic. Two rows opening with the same word is the confusion this picker exists to remove, so the marker now says which row is the current one instead.