Stop pushing QL pack as top level folder to avoid confusing the user#2310
Stop pushing QL pack as top level folder to avoid confusing the user#2310elenatanasoiu merged 10 commits intomainfrom
Conversation
So that we can re-use it in the QLPackGenerator.
In the original flow for creating skeleton packs, we were starting out by choosing a database (e.g. github/codeql) and having the extension create the QL pack for us. At that point, we were storing the QL pack together with the database in the extension storage because we weren't interested in committing it to the repo. This means we weren't able to see it in the file explorer so in order to make it visible, we decided to push it as a top-level folder in the workspace. Hindsight is 20/20. Let's change this original flow by just creating the folder in the workspace storage instead of the extension storage (which will make it visible in the file explorer) and stop pushing it as an extra top level folder in the workspace. NB: For this flow, we exit early in the `createSkeletonPacks` method if the folder already exists so we don't need to check this again.
shati-patel
left a comment
There was a problem hiding this comment.
Looks good! Though I think there's still some confusion around naming (left comments inline). Let me know if they don't make sense! 🙃
💭 Rough overview of my understanding of the 3 kinds of "storage":
- The folders that you have open in your workspace (shown in the sidebar)
- A folder generated/managed by the extension, which stores databases and general "state" about a particular workspace. There's a different folder per workspace.
- This is what we typically call "workspace storage".
- Looks something like
User\workspaceStorage\e261f5bb3c3fc94ac91b18302744f6ad\GitHub.vscode-codeql\...
- A folder generated/managed by the extension, which stores the CodeQL CLI executable and various other "global" things.
- This is what we typically call "global storage".
- Looks something like
User\globalStorage\github.vscode-codeql\...
This PR is about adding QL packs to 1, rather than 2, which is why "workspace storage" is a slightly confusing name! 🗳️
c8d6611 to
dbcbaa5
Compare
dbcbaa5 to
669c724
Compare
There was a problem hiding this comment.
Cool! 😎 Just a note from testing: now that we no longer add codeql-custom-queries-xxx as a top-level folder, we get into a clash with the previous "skeleton pack generator" ☠️ 😄
E.g. When running Create Query in the codespaces-codeql repo, it successfully creates codeql-custom-queries-xxx as a subfolder of my first workspace folder, and then adds a database.
After the database gets added, I get the message
We've noticed you don't have a CodeQL pack available to analyze this database. Can we set up a query pack for you?
which would try to create another pack.
Can we turn off this prompt, or change isFolderAlreadyInWorkspace to also check for subfolders?
669c724 to
b6eaf93
Compare
That's weird. When I tested this I didn't get that behaviour. This line should stop it from trying to generate again. 🤔 I'll do some more testing on this. Thanks! |
|
Oh I see what you mean by subfolders 👍 |
|
Are you planning to make the choice of workspace folder configurable in future, or unconditionally create the pack within the first workspace folder? |
@adityasharad Not at the moment. The main target is people that are using the Codespace template. Once we get to implementing the new Queries panel in the extension, we can revisit. Do you think it's something we should consider earlier? |
In an arbitrary workspace I would find it somewhat confusing as a user to have a new pack quietly written to my first workspace folder; for the Codespaces template we have more control and know exactly what the first folder is so it makes sense. Should not hold up this PR, but I think it's worth considering a follow-up of having the unconditional first-folder insertion only in the template workspace, and a user choice of folder in other workspaces. |
When running Create Query in the codespaces-codeql repo, it successfully creates codeql-custom-queries-xxx as a subfolder of the first workspace folder, and then adds a database. After the database gets added, we get prompted with this message: ``` We've noticed you don't have a CodeQL pack available to analyze this database. Can we set up a query pack for you? ``` which would try to create another QL pack. Since we're no longer pushing QL packs as top level folders in the workspace when we use the new "Create Query" flow, we also need to adapt the original flow to take into account subfolders. Just as a reminder, the original flow is: - Be in the codespace template - Download a database from GitHub - The extension will offer to create a QL pack for the database The new flow: - Run the "Create Query" command - Choose a language - Create a QL pack - Download a database for it In the new flow the last step of downloading a database would trigger the extension to offer to create a QL pack. Let's fix this by detecting subfolders as well and exiting early.
We've made an exception to fetch the parent folder when we're in the vscode-codeql-starter workspace. We'd like to make this more specific so that it doesn't interfere with other repos.
|
Thanks for your input everyone! This PR is ready for review again. I have some time to look into being able to configure the workspace folder. Discussed this with Shati, we want to prompt non-codespace users for a workspace folder and then save it as config. |
shati-patel
left a comment
There was a problem hiding this comment.
One more comment from me 😎
(I haven't got round to testing the "Don't offer to create skeleton pack again" change yet, though the code looks good 💻 )
| // For the vscode-codeql-starter repo, the first folder will be a ql pack | ||
| // so we need to get the parent folder | ||
| if ( | ||
| firstFolderFsPath.includes("vscode-codeql-starter/codeql-custom-queries") |
There was a problem hiding this comment.
This might need to use platform-specific separators, e.g. with path.join or path.sep 🪟
There was a problem hiding this comment.
Thanks Shati! You'd think I would've learned my lesson by now!
The separator character is different on Windows.
b9e734a to
70d533f
Compare
|
Thanks @aeisenberg ! |
Offer non-codespace users the option to configure their storage folder for skeleton packs. Suggested here: #2310 (comment) At the moment we're choosing to create our skeleton packs in the first folder in the workspace. This is fine for the codespace template because we can control the folder structure in that repo. For users outside of this we'd like to offer them the option to choose where to save their skeleton packs.
Offer non-codespace users the option to configure their storage folder for skeleton packs. Suggested here: #2310 (comment) At the moment we're choosing to create our skeleton packs in the first folder in the workspace. This is fine for the codespace template because we can control the folder structure in that repo. For users outside of this we'd like to offer them the option to choose where to save their skeleton packs.
Offer non-codespace users the option to configure their storage folder for skeleton packs. Suggested here: #2310 (comment) At the moment we're choosing to create our skeleton packs in the first folder in the workspace. This is fine for the codespace template because we can control the folder structure in that repo. For users outside of this we'd like to offer them the option to choose where to save their skeleton packs.
Offer non-codespace users the option to configure their storage folder for skeleton packs. Suggested here: #2310 (comment) At the moment we're choosing to create our skeleton packs in the first folder in the workspace. This is fine for the codespace template because we can control the folder structure in that repo. For users outside of this we'd like to offer them the option to choose where to save their skeleton packs.
Offer non-codespace users the option to configure their storage folder for skeleton packs. Suggested here: #2310 (comment) At the moment we're choosing to create our skeleton packs in the first folder in the workspace. This is fine for the codespace template because we can control the folder structure in that repo. For users outside of this we'd like to offer them the option to choose where to save their skeleton packs.
Came out of #2250 (comment)
In the original flow for creating skeleton packs, we were starting out
by choosing a database (e.g.
github/codeql) and having the extensioncreate the QL pack for us.
At that point, we were storing the QL pack together with the database in
the extension storage because we weren't interested in committing it to
the repo.
This means we weren't able to see it in the file explorer so in order to
make it visible, we made a decision to push it as a top-level folder in the
workspace.
Hindsight is 20/20.
Let's change this original flow by just creating the folder in the
in the repo instead of the extension storage (which will make it
visible in the file explorer) and stop pushing it as an extra top level folder
in the workspace.
This makes it consistent with what we're doing for the skeleton query
wizard where we start by:
For this original flow we:
Bonus: For both flows we're not pushing the QL pack as a top folder
so it won't show up twice if you use the skeleton wizard flow, as Shati
discovered.