kit
kit copied to clipboard
I ran into some confusion / odd-to-me behavior while trying out `path()` with an argument
I ran into some confusion / odd-to-me behavior while trying out `path()` with an argument. It is possible that I'm not specifying the option correctly. I wanted to specify a path relative to my home directory (`~/code/til`). That didn't seem to work, so I ended up using the absolute path. Here is a video demonstrating the behavior. The format might be a little weird as I was half in the mindset of demonstrating the behavior and half in the mindset of recording a screencast.
https://user-images.githubusercontent.com/694063/202872232-bb84fa39-172f-46a9-ae10-9506d85ccc7d.mp4
Originally posted by @jbranchaud in https://github.com/johnlindquist/kit/discussions/809#discussioncomment-4185882
@jbranchaud does await path() without an argument have the same behavior for you? I should default to the home directory...
@jbranchaud does
await path()without an argument have the same behavior for you? I should default to the home directory...
@johnlindquist I just tried await path() without an arg and it exhibits the same behavior.
@jbranchaud Thanks, can't reproduce on my main machine, hoping I can on my mac mini and my old laptop 😅
Some repro details:
- ScriptKit v1.36.0
- OSX Catalina v10.15.7 (Intel chip)
I wanted to come up with a minimal repro script and found a potential clue.
This script works as expected:
// Name: View a TIL
import "@johnlindquist/kit";
await path();
When I add in the Shortcut comment and trigger it with the shortcut is when the path() bug shows up:
// Name: View a TIL
// Shortcut: cmd shift j
import "@johnlindquist/kit";
await path();
When I trigger the above script from the scriptkit UI, the path bug doesn't show up. So, it seems the shortcut trigger and path are mixing poorly.
@jbranchaud THANKS! I couldn't reproduce anywhere, but I can definitely reproduce when invoking from a shortcut! Yay
Ok, figured it out.
- Prompts have Filter/Generate choices modes
- The mode is set when the prompt is opened
- When using a shortcut,
await path()sets the choices before the prompt is opened and the mode is set
Note: await path() manually calls
setChoices()instead of usingarg/div/etc which create "prompt data". It's extremely rare to setChoices before a prompt is open, so this shouldn't impact anything and probably only shows up in this specific scenario.
The fix is a one-liner in the app:
// If the promptData isn't set, default to Mode.FILTER
const mode = g(promptData)?.mode || Mode.FILTER;
I'll get out a bugfix build later this week. Thanks for the help.
@jbranchaud Can you test this build? Just download, quit Kit.app, then drag this over to replace it.
https://github.com/johnlindquist/kitapp/releases/download/v1.36.1/Kit-1.36.1.dmg
@johnlindquist I just tried the build, that fixed it!