Skip to content

Made options to hide search bar, private mode, clear, and/or settings buttons & fixed Paste on Select bug.#534

Open
JaredTweed wants to merge 36 commits intoTudmotu:masterfrom
JaredTweed:clear-timeouts
Open

Made options to hide search bar, private mode, clear, and/or settings buttons & fixed Paste on Select bug.#534
JaredTweed wants to merge 36 commits intoTudmotu:masterfrom
JaredTweed:clear-timeouts

Conversation

@JaredTweed
Copy link

This pull request is built on top of my other pull request.

This ensures that:

  • Text always pastes.
  • The text that pastes is always the selected item, and never accidentally pastes the previously selected item.

Both of those bugs were frequent especially on slower hardware, but I think I entirely fixed those errors.

… buttons. Also made pressing Enter and clicking on an item have consistent behaviour. Fixed glitch where Paste on Select only worked when pressing Enter, and not when clicking.
… my version but forgot to include them in the commit), and fixed whitespace edits
…. Hopefully eliminates unsuccessful pasting attempts.
@JaredTweed JaredTweed changed the title Reorganized the code instead of using timeouts Made the code sequential instead of using timeouts Aug 13, 2025
@Tudmotu
Copy link
Owner

Tudmotu commented Sep 21, 2025

Hi @JaredTweed,
I appreciate your intention of improving this extension with your PRs.
Can you please explain:

  1. What is Meta.Laters and why should we use it over GLib?
  2. Do you understand why the entry selection was made with delay in the first place?
  3. Can the pasting fix be split in to a separate PR, and if not, why?
  4. Additionally, can you explain the scenario in which pasting doesn't work properly?For example this was pasted with paste-on-select

You claimed in other PRs the extension "works better" with these changes, but I am a very heavy user of this extension and I rarely encounter any issues. In addition, other than the paste-on-select, none of the changes seem meaningful (some seem detrimental). Can you please elaborate on the issues you encountered?

@JaredTweed
Copy link
Author

Q1) Meta.Laters is Mutter’s frame-synchronized scheduler. It runs callbacks at compositor phases like AFTER_REDRAW, which is ideal for preview image swaps and avoids UI races that idle/timers can’t. The code falls back to GLib.idle_add() if Meta.Laters isn’t present, keeping compatibility across versions.

Q2) Yes, the original delay buffered against focus and relayout churn while the menu opened. In #529 the focus delay is preserved using GLib.idle_add() so it doesn’t fight Shell’s animation, but the separate selection delay is removed and replaced with synchronous selection. This prevents the paste-ordering races caused by timers, and #534 then fully replaces them with event-driven sequencing.

Q3) The pasting fix can not be split, because the way it loads the menu causes it to load differently, causing some issues in the timers and the order in which they load things. #529 introduced the unified activation path and the _pastePending/owner-change hooks. #534 builds on this by replacing the last timeouts with sequential, signal-driven logic and fixing the “previous vs current selection” problem. While it could be split, #534 is a direct continuation of #529 and simpler to test together.

Q4) I had it on my last computer (a very old slow computer), where it would occasionally paste the second most recent instead of the most recent code (only when I copied large sections of text. Paste-on-select also failed when clicking an entry, because the paste is attempted before the clipboard owner switches and before focus returns to the target app. With #529 and #534, activation is unified: the menu closes first to return focus, the clipboard is updated, and the paste only happens once the owner-change signal is seen. This guarantees correct ordering and consistent behavior for both click and Enter. On my newer computer I don't have that issue.

@JaredTweed
Copy link
Author

The other benefit of making it run sequentially, is that it will be more reliable, and not rely on specific animation/loading speeds.

@JaredTweed
Copy link
Author

JaredTweed commented Sep 21, 2025

If you want, I can modify PR #529 to evade the same bugs as #534, but avoid using meta.laters instead of glib (so as to keep the change minimal). Would you like me to do that? I could get that done by tomorrow night. I just think it will be less reliable for future updates if we don't make this change.

@Tudmotu
Copy link
Owner

Tudmotu commented Sep 22, 2025

The delay has nothing to do with animations or layouts. You can see the delay is only used when the "move item to top" setting is enabled. This is because otherwise, iterating through the list of items via shortcuts becomes impossible: every time you select an entry it moves to the top, you select the next entry it moves to the top, the previous entry is now in place 2, you move to the next item and it's actually the previous entry, so you are effectively stuck in a loop between 2 entries. This delay should not be removed as it is crucial.

This PR has some issues which makes me uncomfortable merging it. I am leaving a review, but I highly suggest that you try first submitting a smaller PR, that does not include any fundamental changes to the way this extension works. Thousands of people if not more use it every day, and if it was this broken then I'd hear about it.

The scenario you are describing with the paste-on-select window focus race condition might present an actual issue. If that's the case, I suggest you find a reproducible example. I think maybe a moving the paste action to the "activate" handler is all that is needed (not sure about it). In any case, for me to be able to test a fix like that, I need to be able to first reproduce the underlying issue.

I know you put a lot of effort into this PR and I don't want to discourage you. But I have to consider the many many many users of this extension when I merge PRs, especially ones that make fundamental changes to the code. Thank you.

@JaredTweed
Copy link
Author

Okay, I did all the changes I found to be necessary and did a thorough bug search as well. Is this code sufficient? You can ignore PR #529 now and just pull this instead.

@JaredTweed
Copy link
Author

Sorry for not checking it better before.

@JaredTweed JaredTweed changed the title Made the code sequential instead of using timeouts Made options to hide search bar, private mode, clear, and/or settings buttons & fixed Paste on Select bug. Sep 22, 2025
@JaredTweed
Copy link
Author

This is the smallest I know how to make this PR, I am sorry. Thank you so much for the work you have put into this project!! I really appreciate your time.

@JaredTweed
Copy link
Author

@Tudmotu, I made the changes as clean as possible for you. Is it clean enough to be added to the extension?

@JaredTweed
Copy link
Author

@Tudmotu I made the PR much smaller now, and kept your version of the timeouts that you like so that there is no longer that risk of making it create breaking changes. I also updated the code so that it has no conflicts with the base and can now be merged with the click of a button. I hope these additions are sufficient.

@JaredTweed
Copy link
Author

@Tudmotu I also got rid of all that Meta.Laters stuff and all those unnecessary changes that I made before

@JaredTweed JaredTweed requested a review from Tudmotu September 23, 2025 22:11
Copy link
Owner

@Tudmotu Tudmotu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left another review. This PR is still too much of a mess. Follow the comments I left you and I will review it again afterwards. I'm not sure if you are using claude or if it's you that is adding all these unnecessary changes, but please stop. If you are using an agent to help, you need to double review its changes and make sure everything works properly.

One more thing: DO NOT resolve comments on your own. Only the reviewer should resolve comments. Resolving comments others leave makes it harder to see if you actually implemented the proper changes. This is basic open source etiquette.

Comment on lines +1412 to +1413
if (currentlySelected && currentlySelected.entry)
this.#updateClipboard(currentlySelected.entry);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what situation is currentlySelected not defined?

prefs.js Outdated
Comment on lines +188 to +197
// Toggleable UI rows
this.field_show_search_bar = new Adw.SwitchRow({title: _("Show Search Bar")});
this.ui.add(this.field_show_search_bar);
this.field_show_private_mode = new Adw.SwitchRow({title: _("Show Private Mode")});
this.ui.add(this.field_show_private_mode);
this.field_show_settings_button = new Adw.SwitchRow({title: _("Show Settings Button")});
this.ui.add(this.field_show_settings_button);
this.field_show_clear_history_button = new Adw.SwitchRow({title: _("Show Clear History Button")});
this.ui.add(this.field_show_clear_history_button);

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you create the fields and add them here instead of following the pattern used throughout the rest of the file where the fields are created on top and are only attached here?

extension.js Outdated
Comment on lines +1161 to +1214
if (ENABLE_KEYBINDING)
that._bindShortcuts();
else
that._unbindShortcuts();
if (ENABLE_KEYBINDING) that._bindShortcuts();
else that._unbindShortcuts();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meaningless whitespace changes like these clutter your PR. Please undo this change unless it is meaningful somehow. Avoid any changes that do not affect functionality.

extension.js Outdated
Comment on lines +1183 to +1184

// NEW toggles
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does "NEW" mean here? If someone sees this code in 3 years, would these still be "NEW"?
Please remove this comment and just maintain the same code style and patterns of the surrounding code.

this.#selectNextMenuItem(menuItem);
this._removeEntry(menuItem, 'delete');
break;
return Clutter.EVENT_STOP;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to return these EVENT_STOP consts?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we may want to return Clutter.EVENT_STOP to prevent the event from propagating up the actor hierarchy — otherwise GNOME Shell may also handle it (e.g., close the popup or trigger other UI reactions).

Comment on lines +784 to +787
// Ensure MOVE_ITEM_FIRST also applies when PASTE_ON_SELECT fast-path skips _refreshIndicator()
if (PASTE_ON_SELECT && MOVE_ITEM_FIRST && !menuItem.entry.isFavorite()) {
this._moveItemFirst(menuItem);
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to manually move the item here?

extension.js Outdated
Comment on lines +640 to +644
menuItem.icoBtn.visible = DELETE_ENABLED;
menuItem.deletePressId = icoBtn.connect('clicked', () => {
if (!DELETE_ENABLED) return;
this._removeEntry(menuItem, 'delete');
});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you re-enable support for this feature? It's long gone as far as I can see.

extension.js Outdated
Comment on lines +215 to +223
// Create menu sections for items
// Favorites
// Favorites section
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undo every unnecessary change. I will not accept a PR that has any unnecessary changes. Keep you PR as clean as possible and adhere to the style and patterns used in the existing code.

extension.js Outdated
Comment on lines +50 to +51

// NEW: toggleable UI elements
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the "NEW" comment here as well.

@dynobo
Copy link

dynobo commented Sep 24, 2025

@Tudmotu, as a grateful user of your extension who curiously follows this topic here (as I like the idea), I just want to take the opportunity to thank you for insisting on high quality standards and appropriate workflows. 👍
A clipboard manager deals with quite sensitive information, and the way you handle this here increases my trust in the extension even further! Thank you for your great work! ❤️

@JaredTweed
Copy link
Author

@Tudmotu I will be more careful with the changes. Sorry about resolving the comments. I will let you resolve those. Thank you so much for being willing to take the time to review my code, I really appreciate your discipline in that. I really hope my contributions make it into the final product. Let me know if you would like any more changes.

@JaredTweed JaredTweed requested a review from Tudmotu September 24, 2025 15:47
@JaredTweed
Copy link
Author

@Tudmotu Thank you for your patience with me. Just so you know, I am ready for you to review it!

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.

4 participants