extensions icon indicating copy to clipboard operation
extensions copied to clipboard

fix(visual-studio-code-project-manager): Fix optional Projects Location setting

Open gadenbuie opened this issue 3 months ago • 5 comments

Description

This PR is a follow up to #11383 with the intent of fixing #11520.

Prior to #11383, the extension used a textField for a path that should be optionally provided, and I replaced this setting with a directory type preference with required: false and without a default, hoping this would make the setting optional.

It seems that sometimes Raycast picks a directory, possibly root (i.e. /), for this setting type. The extension assumes that if the directory exists it contains data from the companion VSCode extension, but if the wrong directory is passed, this could lead to the errors described in #11520.

This PR reverts back to the previous setting behavior using a textField. I also improved the error screen that is shown when no projects are found or when the Projects Location field is invalid.

Screencast

Projects Location is now a text field:

image

Projects Location points to an invalid location:

image

The VS Code extension is not installed or no projects are saved:

image

Checklist

gadenbuie avatar Mar 27 '24 16:03 gadenbuie

Thank you for your contribution! :tada:

🔔 @MarkusLanger @GastroGeek @4very @theherk @TobiasYin @yossizahn @eduwass @gadenbuie you might want to have a look.

raycastbot avatar Mar 27 '24 16:03 raycastbot

I'm not sure I understand the fix. Well, I understand the fix, but I'm not clear on why it is warranted. It works as expected when no directory is selected, it works correctly when the correct directory is selected, but it doesn't work correctly when the wrong directory is selected? Is that correct? If so, isn't that expected behavior?

theherk avatar Mar 27 '24 18:03 theherk

@theherk You're totally right. My working theory is that optional directory-type preferences aren't well defined in Raycast. I noticed in testing that the directory setting would sometimes be filled with a value even if I had cleared it previously. I was testing this code path so I assumed it was that I had gotten into a weird state locally, but the user report changed my mind.

If Raycast automatically fills in the directory option, though, it can break the extension in non-obvious ways, which is why it seems safer to use the textField type where it's very obvious that the value is or is not set.

gadenbuie avatar Mar 27 '24 18:03 gadenbuie

Cool. Makes sense to me. It would be good if somebody in the Raycast team could comment on the expected behavior of the directory type preference.

theherk avatar Mar 27 '24 18:03 theherk

directory will return the path if the path exists, it can be removed since it was added to preferences so it would be better to check for that. Does that make sense?

pernielsentikaer avatar Apr 09 '24 10:04 pernielsentikaer

directory will return the path if the path exists, it can be removed since it was added to preferences so it would be better to check for that. Does that make sense?

Hi @pernielsentikaer, sorry I'm not sure I follow. Maybe I can clarify: a key detail is that the extension does not require the preference using the directory. In fact, the extension fails badly if the user picks the wrong directory, especially if that directory exists.

In my testing I noticed some unusual behavior around this preference. At the moment, I can't even set "required": false for the preference using the code in this PR. When I do, Raycast gives me the "Before you start using this extension" screen and forces me to pick a folder. That is not good (picking a folder isn't great and is probably only used by a small number of people).

What I've seen so far is that "type": "textfield" works a lot better as a non-required field. This particular preference is an expert level preference, it's completely appropriate that it be slightly less easy to use. That said, this PR adds a few conveniences so that it's not a complete pain to use this preference.

Another question for you @pernielsentikaer: I've worked on a few more improvements to the extension to bring frecency sorting to the project list. Would it be better to add those to this PR so they can be reviewed at once or to open a new PR?

gadenbuie avatar Apr 16 '24 17:04 gadenbuie

It should be possible to set default:false for directory, I just tried with this code and it works as expected

    {
      "name": "test",
      "type": "directory",
      "required": false,
      "label": "Test",
      "title": "Test",
      "description": "Test",
      "default": true
    }

I think it might be a good idea to open a new PR after this with the new stuff 🙂

pernielsentikaer avatar Apr 17 '24 08:04 pernielsentikaer

It should be possible to set default:false for directory, I just tried with this code and it works as expected

Thanks. For me "default": true (or false) shows a type error squiggle (Incorrect type. Expected "string".)

I've figured out my confusion, though. For some reason I was landing on this screen

image

I didn't realize that I could a) clear the selection from this screen or b) move forward without picking a directory by activating "Continue".

I hear you that the directory type would be preferable and I'm hoping I was landing on the above screen just because I got into a weird state during local dev. I just pushed an update to go back to the directory type preference.

gadenbuie avatar Apr 17 '24 21:04 gadenbuie

So is there visually no difference between picking / and not picking a directory?

theherk avatar Apr 18 '24 06:04 theherk

I'd also like to know that @gadenbuie

pernielsentikaer avatar Apr 18 '24 07:04 pernielsentikaer

No, I can't really explain the / above or how I got into that state or why that screen appeared for me. To fix it, I'm pretty certain I first cleared the selection and then moved forward, at which point everything worked like normal again. Having done that, I can't get the extension back into the weird state.

Now that things are working, though, there is a difference between picking / and not picking a directory. When / is selected..

image

...the extension now shows the new informative error screen because the expected json files don't exist there.

image

gadenbuie avatar Apr 18 '24 12:04 gadenbuie

Is the ready for a review?

pernielsentikaer avatar Apr 19 '24 10:04 pernielsentikaer

Is the ready for a review?

Yes, thank you

gadenbuie avatar Apr 19 '24 11:04 gadenbuie

@MarkusLanger are you still around?

pernielsentikaer avatar Apr 22 '24 10:04 pernielsentikaer

Yes, if it works, that's fine with me.

MarkusLanger avatar Apr 22 '24 11:04 MarkusLanger

I just tried to clear everything and start over; now I'm experiencing a crash.

vscode-project-manager 2024-04-22 at 14 11 31

Could you handle that gracefully, @gadenbuie?

pernielsentikaer avatar Apr 22 '24 12:04 pernielsentikaer

I just tried to clear everything and start over; now I'm experiencing a crash. ... Could you handle that gracefully

Thanks for catching that @pernielsentikaer. It should be fixed now.

gadenbuie avatar Apr 22 '24 15:04 gadenbuie

Published to the Raycast Store: https://raycast.com/MarkusLanger/vscode-project-manager

github-actions[bot] avatar Apr 23 '24 08:04 github-actions[bot]

:tada: :tada: :tada:

We've rewarded your Raycast account with some credits. You will soon be able to exchange them for some swag.

raycastbot avatar Apr 23 '24 08:04 raycastbot