Repository navigation
fix(tray): only rebuild the Linux tray menu when its content changed - #11023
EagleEyeElite wants to merge 1 commit into
Conversation
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
|
I reproduced the before/after table independently (Qt 6.10.2, CI container, offscreen):
So the regression test fails before and passes after, as claimed. Note that One non-blocking observation from reading the code (not covered by a test I ran): (Run with Claude Code assistance; results reviewed by me.) |
The tray context menu was cleared and rebuilt on every aboutToShow, even when nothing in it had changed. Over the D-Bus tray menu each removed and re-added action is its own com.canonical.dbusmenu LayoutUpdated with new item ids, so tray hosts such as GNOME's AppIndicator extension tore the open menu down and built it up again entry by entry. Rebuild only when a snapshot of everything the menu shows differs from the one taken at the last build. It covers all UserModel data of every account, because on GNOME the account submenus only get new content from this rebuild (see nextcloud#10646), plus their apps, the sync control state, add-account, and the icon palette and size. The snapshot is compared as QVariant, so a value that cannot be compared causes a rebuild rather than a stale menu. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Conrad Klaus <conrad.klaus@outlook.de>
b924956 to
ce6d797
Compare
|
@maksimtech Thanks for taking the time and reproducing it! Both points are addressed in the updated commit (ce6d797):
Re-ran (Changes made with Claude Code assistance; reviewed and tested by me.) |
|
Which Model of Claude Code you use? I use Opus 5.5. @EagleEyeElite |
|
@maksimtech Yes, I use Opus 5.5 as well. It's also in the commit's |
|
@EagleEyeElite is written only Claude Code without model used |
|
@maksimtech Not sure if we talk past each other. I mean the commit message itself in ce6d797 I am not sure if it's mandatory or advised to write the used model in the PR itself as well. Thanks! |
it is mandatory. |
Resolves
Refs #10586 (defect 2: the whole tray menu is rebuilt and renumbered)
Summary
On Linux the tray context menu is cleared and rebuilt on every
aboutToShow(setupQtTrayContextMenu()→populateTrayMenu()→clearDynamicMenu()), even when nothing in it changed. Over the D-Bus tray menu every removed and re-added action is its owncom.canonical.dbusmenu.LayoutUpdatedwith new item ids, so tray hosts tear the open menu down and build it up again. In GNOME (AppIndicator extension) the menu briefly shows up empty and refills entry by entry.The fix keeps the rebuild, but skips it while nothing the menu shows has changed.
trayMenuState()builds a snapshot (QVariantList) of:UserModeldata (all roles: status, notifications, recent activities, alerts, …) and its apps,On
aboutToShowthe menu is only rebuilt when that snapshot differs from the one taken at the last build. It is compared withQVariant::operator==, so a value that cannot be compared causes a rebuild rather than a stale menu. The snapshot covers all account data on purpose: since #10646 the account submenu on GNOME only gets new content from this rebuild.Measured with one
AboutToShow(0)on/MenuBar(GNOME 50.5 + AppIndicator v64, Qt 6.11.2):LayoutUpdatedper openingThe account submenu stays complete (user status, local folder, search, apps, recent activity). Built and tested on 34.0.3 and 34.0.5; built and unit tested on master.
Re-measured after switching the state comparison from JSON to
QVariant(34.0.4, same GNOME setup, one offline account): before 13LayoutUpdatedper opening with new item ids each time; after 0 over 5 openings, item ids unchanged, account submenu complete.Before / after (34.0.5, plain NixOS + GNOME VMs side by side, window titles say which is which):
nextcloud-tray-menu-before-after.mp4
Tests
Two tests added to
test/testtrayaccountmenuqt.cpp:openingUnchangedMenuKeepsActions: opening the menu again without changes keeps the same actions (none deleted).openingAfterAccountChangeRebuildsMenu: after the account goes from offline to connected, the next opening rebuilds the menu and the hidden account submenu shows the connected entries (the fix(tray): GNOME + AppIndicator compatibility #10646 case). It also passes without the fix: it guards against the state check skipping a rebuild that is needed, rather than reproducing the bug.TrayAccountMenuQtTeston master, without and with the fix:openingUnchangedMenuKeepsActionsopeningAfterAccountChangeRebuildsMenu'firstAction' returned FALSE, line 198)Checklist
AI (if applicable)
How AI was used: root cause analysis, the patch, the tests and the measurements were done with Claude Code; I reviewed, built and tested it myself on my machine and in the VMs shown above.