[VSCode] Set projectPath to workspaceFolder if there's only one repository open in VSCode
Checklist
-
I'm using the latest version of the extension (see the latest version in the right column of this page) - Extension version: Put your extension version here
-
I'm using the latest VS Code version (find the latest version here) - VS Code version: Put your VS Code version here
-
I'm using a supported version of GitLab (see README for the supported version) - GitLab version: Put your GitLab version here, or say "happens on
gitlab.com"
- GitLab version: Put your GitLab version here, or say "happens on
Summary
When a project is open in VSCode and there are multiple cloned project within the directory, it's setting projectPath to empty string because it can't figure out exactly which repository to choose.
In this case, there's one top-level project open so let's set the projectPath to it to unblock the users from accessing workflow and agentic chat.
Steps to reproduce
-
Install GDK
-
Open gdk in VSCode
-
Click Workflow in the sidebar and you will see this UI
What is the current bug behavior?
Can't access the workflow and agentic chat
What is the expected correct behavior?
Access the workflow and the agentic chat
Relevant logs and/or screenshots
Possible fixes
- Set the workspace folder repository, if available, as the active project
diff --git a/src/desktop/commands/run_with_valid_project.ts b/src/desktop/commands/run_with_valid_project.ts
index 6f33c9e6..5470e8cb 100644
--- a/src/desktop/commands/run_with_valid_project.ts
+++ b/src/desktop/commands/run_with_valid_project.ts
@@ -74,8 +74,14 @@ export const getActiveProject: () => ProjectInRepository | undefined = () => {
const projects = getProjectRepository().getDefaultAndSelectedProjects();
if (projects.length === 1) return projects[0];
- return undefined;
-};
+ const { workspaceFolders } = vscode.workspace;
+ if (workspaceFolders && workspaceFolders.length === 1) {
+ const singleWorkspaceFolder = workspaceFolders[0];
+ const repositoryRoot = getRepositoryRootForUri(singleWorkspaceFolder.uri);
+ if (repositoryRoot) {
+ return getProjectRepository().getSelectedOrDefaultForRepository(repositoryRoot);
+ }
+ }
Edited by Juhee Lee
