Skip to content

fix: default empty workspace to open the projects root folder - #798

Open
achdmbp wants to merge 1 commit into
che-incubator:mainfrom
achdmbp:fix/empty-workspace-default-folder
Open

fix: default empty workspace to open the projects root folder#798
achdmbp wants to merge 1 commit into
che-incubator:mainfrom
achdmbp:fix/empty-workspace-default-folder

Conversation

@achdmbp

@achdmbp achdmbp commented Aug 28, 2026

Copy link
Copy Markdown

What does this PR do?

Ensures an empty workspace always opens with the PROJECTS_ROOT directory mounted in the Explorer.

Previously, when a workspace had no projects, dependentProjects, or starterProjects (for example the dashboard's built-in "Empty Workspace" sample, whose devfile is just schemaVersion + generateName: empty), the launcher's CodeWorkspace.generate() produced a .code-workspace file with no folders array:

{
	"extensions": { "recommendations": ["..."] }
}

VS Code / che-code then opens this as a multi-root workspace with zero folders, so the Explorer is empty and nothing is mounted, even though /projects exists and is where the user is expected to work.

The fix adds a small fallback in generate(): after synchronizing devfile projects, if folders is still empty or absent, it defaults to a single entry pointing at PROJECTS_ROOT:

if (!workspace!.folders || workspace!.folders.length === 0) {
  workspace!.folders = [{ name: 'projects', path: projectsRoot }];
  saveRequired = true;
}

This is a no-op for workspaces that already resolve folders (single-project, multi-repo, or a VSCODE_DEFAULT_WORKSPACE file that already lists folders), so existing behavior is unchanged.

What issues does this PR fix?

Fixes eclipse-che/che#23938

How to test this PR?

  1. Start an Empty Workspace (a devfile with no projects, e.g. the dashboard's "Empty Workspace" sample).
  2. Wait for the editor to open.
  3. The Explorer should now show the /projects (PROJECTS_ROOT) folder mounted instead of opening empty.
  4. Inspect the generated file: cat /projects/.code-workspace — it should contain a folders entry for the projects root alongside the extension recommendations.

Automated coverage: a new unit test (should add PROJECTS_ROOT as a default folder when the workspace has no projects) and an empty devworkspace fixture were added. The full launcher build (npm install → format + tsc + eslint + jest) passes with all 66 tests green.

Does this PR contain changes that override default upstream Code-OSS behavior?

  • the PR contains changes in the code folder (you can skip it if your changes are placed in a che extension )
  • the corresponding items were added to the CHANGELOG.md file
  • rules for automatic git rebase were added to the .rebase folder

Note: this change is entirely within launcher/ and does not touch the code/ folder, so the CHANGELOG.md / .rebase items above do not apply.

Summary by CodeRabbit

  • Bug Fixes

    • Workspaces without configured projects now automatically include a projects folder based on the configured projects location.
    • Empty workspace configurations are now preserved with the default projects folder.
  • Tests

    • Added coverage for generating workspaces with a default projects folder.
    • Added test data for empty flattened development workspaces.

When a workspace has no projects, dependentProjects or starterProjects
(for example the dashboard's built-in "Empty Workspace" sample), the
launcher generated a `.code-workspace` file with no `folders` array.
As a result the editor opened with an empty Explorer and nothing mounted,
even though PROJECTS_ROOT exists and is where the user is expected to work.

Fix: after synchronizing devfile projects, if the workspace still has no
folders, default `folders` to a single entry pointing at PROJECTS_ROOT.
This is a no-op for workspaces that already resolve folders (single-project,
multi-repo, or a VSCODE_DEFAULT_WORKSPACE file that already lists folders).

Adds a unit test and an empty devworkspace fixture covering the no-project case.

Fixes: eclipse-che/che#23938
Signed-off-by: Adnan Al <98621989+achdmbp@users.noreply.github.com>
@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Click here to review and test in web IDE: Contribute

@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c2a47453-e59f-4d02-a368-f2a473d7cb49

📥 Commits

Reviewing files that changed from the base of the PR and between 231d00b and b7f6bfe.

📒 Files selected for processing (3)
  • launcher/src/code-workspace.ts
  • launcher/tests/_data/flattened.devworkspace.empty.yaml
  • launcher/tests/code-workspace.spec.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

CodeWorkspace.generate() now adds a projects folder rooted at PROJECTS_ROOT when project synchronization produces no folders. The change marks the workspace for persistence. New test data represents an empty devworkspace, and a test verifies that generation writes /tmp/projects/.code-workspace with the expected folder.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to b7f6b

This change makes empty workspaces open with the projects root visible in the Explorer while preserving existing folder behavior. No actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: azatsarynnyy, rgrunber, romannikitenko, vitaliy-guliy

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise at 61 characters, clearly describes the fallback behavior, and uses the imperative verb "fix".
Linked Issues check ✅ Passed The changes implement issue #23938 by adding PROJECTS_ROOT as the default folder for empty workspaces while preserving existing folders. Unit coverage and an empty-workspace fixture are included.
Out of Scope Changes check ✅ Passed All changes are limited to the launcher implementation and related test files. They directly support the empty-workspace folder fallback and do not introduce unrelated scope.
Rebase Rules For Upstream Changes ✅ Passed The pull request changes only three files under launcher/: launcher/src/code-workspace.ts and two launcher test files. The committed diff from the pull request parent contains no files under `code…
Full details: Rebase Rules For Upstream Changes

Explanation

The pull request changes only three files under launcher/: launcher/src/code-workspace.ts and two launcher test files. The committed diff from the pull request parent contains no files under code/, .rebase/, or rebase.sh. Therefore, the upstream rebase-rule requirements do not apply.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Successfully merging this pull request may close these issues.

Empty workspace generates a .code-workspace with no folders, so the editor opens with nothing mounted

1 participant