Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When running a service, incorrect service is invoked #15

Open
cdzombak opened this issue Nov 16, 2021 · 6 comments
Open

When running a service, incorrect service is invoked #15

cdzombak opened this issue Nov 16, 2021 · 6 comments

Comments

@cdzombak
Copy link

Given this list of services:

Screen Shot 2021-11-16 at 2 57 54 PM

Running m qr in Alfred finds and allows me to run the "Generate QR Code" service. However, when I do that, Menu-Bar-Search actually runs the "Compare Text in Kaleidoscope" service.

Oddly, if I try running m qr again, it runs the QR code service as expected.

This only seems to affect services; other menu items always work as expected.

Running Menu-Bar-Search 1.7, Alfred 4,6 and macOS 12.0.1.

@cdzombak
Copy link
Author

cdzombak commented Nov 16, 2021

This GIF shows trying to run the QR service once, which opens Kaleidoscope instead; then the second time, generating the QR code worked.

incorrect-service-first-time

@archetyped
Copy link

Confirming the same behavior here.

  • Hardware: M1 Mac Mini
  • OS: Monterey 12.1
  • Workflow: 1.8

Steps to Reproduce

  • Open Finder.
  • Select a file.
  • Launch workflow (hotkey, etc.).
  • Select a Service item from the list.
    • Wrong service will be executed (usually item directly above it in the actual menu).
  • Return to Finder window
  • Launch Workflow again
  • Select the same Service item from the list.
    • The selected service will be executed.

📒 Note: The issue repeats whenever a different file/folder is selected. You need to launch the workflow, close it, and then relaunch the workflow for the selected item to be executed.

@BenziAhamed
Copy link
Owner

BenziAhamed commented Dec 20, 2022

I've found the cause of the issue - it is to do with the way the menu items are cached currently.

For instance, in Finder, the services menu differs based on what you have selected. Eg on my system:

Finder Services when selecting a folder

  • Screenshot 2022-12-20 at 03 21 24

Finder Services when selecting a an image

  • Screenshot 2022-12-20 at 03 22 19

Since we are caching menu items, it can happen that the cache is out of date or not in sync with what is selected.

Top of my mind, there are a couple of ways to solve this

  • reduce the cache duration for Finder from a default of 5 seconds to something like 0.5 seconds
  • additionally detect if menu options have gotten stale (e.g. you action an item, but the menu item no longer exists or has changed), and let the user know about this

I'll work on tweaking this a bit and have something out when I release v2.0 of the workflow.

@BenziAhamed
Copy link
Owner

BenziAhamed commented Dec 20, 2022

§ You can actually tweak caching behaviour right now if you type ms into Alfred and create a settings file in the "Settings Folder" of the workflow. There is a sample settings file listed, which should let you provide an override for Finder's (or any other app's) cache duration setting.

In the settings file, you can have the following snippet:

appFilters {
    app: "Finder"
    cacheDuration: 0.1
}

NOTE In the case of Finder, the app name to be specified in the settings file could be "Finder" or "com.apple.finder" depending on which version of the workflow you have installed. You can figure the exact name to use by typing ms and selecting the "Cache Folder" option which should list cached menu files, it should either be named "Finder.cache" or "com.apple.finder".

@archetyped
Copy link

Thanks for looking into this. Unfortunately, even with caching disabled via the settings file, the wrong item is frequently executed when choosing a sub-item of the Services menu.

Settings used:

appFilters {
    app: "Finder"
    cacheDuration: 0
}

Any other things we could try to improve this?

Note: Finder has been confirmed as the proper app name to use, as including disabled: true disables menu searching in Finder.

@BenziAhamed
Copy link
Owner

Thanks for checking and getting back. I can't think of anything else for the interim - let me debug this more, since I can definitely reproduce 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

No branches or pull requests

3 participants