Skip to content

#2040: Fix buggy workspace selection - #2309

Open
samuelkos17 wants to merge 4 commits into
devonfw:mainfrom
samuelkos17:feature/2040-workspace-selection-buggy
Open

#2040: Fix buggy workspace selection#2309
samuelkos17 wants to merge 4 commits into
devonfw:mainfrom
samuelkos17:feature/2040-workspace-selection-buggy

Conversation

@samuelkos17

@samuelkos17 samuelkos17 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

This PR fixes #2040

Implemented changes:


Testing instructions

Please add conscise, understandable instructions on how a reviewer can test/verify the functionality of your contribution here:

  1. For more details look at #2040: Fix workspace ComboBox reset on project switch #2095

Checklist for this PR

Make sure everything is checked before merging this PR. For further info please also see
our DoD.

  • When running mvn clean test locally all tests pass and build is successful
  • PR title is of the form #«issue-id»: «brief summary» (e.g. #921: fixed setup.bat and not feature/921 fixed setup.bat). If no issue ID exists, title only.
  • PR top-level comment summaries what has been done and contains link to addressed issue(s)
  • PR and issue(s) have suitable labels
  • Issue is set to In Progress and assigned to you or there is no issue (might happen for very small PRs)
  • You followed all coding conventions
  • You have added the issue implemented by your PR in CHANGELOG.adoc unless issue is labelled
    with internal
  • You have not changed any dependency in pom.xml files or otherwise if runtime dependencies changed, you have updated our LICENSE.asciidoc
  • You have formulated clear instructions on how to test your contribution under "Testing instructions"

KarimALotfy and others added 2 commits June 30, 2026 11:53
…election-buggy

# Conflicts:
#	gui/src/main/java/com/devonfw/ide/gui/MainController.java
@samuelkos17

Copy link
Copy Markdown
Contributor Author

I've taken this PR since i encountered this bug while working on #2214. This fix works perfectly fine, I merged the current main-branch into it and tested the fix. I think this counts as a Team Review so I'll move it to In Review.

@samuelkos17 samuelkos17 self-assigned this Aug 11, 2026
@samuelkos17 samuelkos17 moved this from 🆕 New to 👀 In review in IDEasy board Aug 11, 2026
@coveralls

coveralls commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 31779828913

Warning

No base build found for commit 31dabbf on main.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 72.916%

Details

  • Patch coverage: No coverable lines changed in this PR.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 17555
Covered Lines: 13347
Line Coverage: 76.03%
Relevant Branches: 7759
Covered Branches: 5111
Branch Coverage: 65.87%
Branches in Coverage %: Yes
Coverage Strength: 3.23 hits per line

💛 - Coveralls

@samuelkos17 samuelkos17 added GUI Graphical User Interface of IDEasy (aka dashboard) build with JavaFx bugfix PR that fixes a bug issue labels Aug 11, 2026

@maybeec maybeec left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up and carrying #2095 over the finish line 👍 The diagnosis here is good, and the fix attacks the actual root cause rather than papering over the symptom.

Worth spelling out, because it explains the odd symptom in #2040: the old code re-registered the handler at the end of setWorkspaceComboBox(), so on the second project selection the previous handler was still attached while getItems().clear() / addAll(...) mutated the list. It fired with a stale workspace name, updateContext(...) hit FileNotFoundException in GuiStateManager.switchContext, and errorDialog.showAndWait() then spun up a nested JavaFX event loop in the middle of that mutation - which is almost certainly how you end up with an empty selection field and a duplicated item list. Registering once in initialize() plus the null guard closes exactly that window. Good fix.

No blockers. Everything below is Should-fix or Minor.


Should-fix

1. CHANGELOG.adoc entry is missing

The checkbox is unchecked in the PR description, and I confirmed there is no 2040 entry in CHANGELOG.adoc. #2040 is labelled GUI, not internal, and the bug shipped to users (the reporter hit it on 2026.06.001-...-SNAPSHOT), so per DoD.adoc it belongs in the next open release section. On current main that section is == 2026.08.002 (milestone 49) and it is still empty:

== 2026.08.002

Release with new features and bugfixes:

* https://github.com/devonfw/IDEasy/issues/2040[#2040]: Fixed buggy workspace selection in the GUI

Why: the CHANGELOG is the release-notes source for end users; if it is not written while the change is fresh, nobody reconstructs it at release time.

2. Commit message points at the wrong issue

The single functional commit is:

#1936:fix workspace ComboBox reset on project switch

#1936 is "Improve localization of the GUI" (closed, unrelated). GitHub will auto-link this commit to that issue. Two things per commit.adoc: the issue id must be the one actually addressed, and the format is #<issue-id>: <describe your change> - note the space after the colon.

#2040: fix workspace ComboBox reset on project switch

Why: the #id: prefix is not decoration, it is the mechanism that ties the commit to the issue in GitHub's timeline. A wrong id silently attaches this change to unrelated history.

3. No regression test, although the harness for one already exists

This is the part I would most like to see added. gui/src/test/java/com/devonfw/ide/gui/AppBaseTest.java is already a headless TestFX test of this exact controller, and already covers neighbouring behaviour (testIdeOpenButtonsEnabledWhenWorkspaceSelected, testWorkspaceComboboxEnabledEnabledWhenProjectSelected). Per AGENTS.md a bugfix should start from a test that reproduces the bug, and here that is roughly a dozen lines:

  @Test
  public void testWorkspaceSelectionIsResetWhenProjectChanges() {

    interact(() -> selectedProject.getSelectionModel().select("project-1"));
    interact(() -> selectedWorkspace.getSelectionModel().select("main"));

    interact(() -> selectedProject.getSelectionModel().select("project-2"));

    // no stale selection, no duplicated items, buttons back to disabled
    ...
  }

Two caveats so this is not a trap:

  • FakeProjectFolderStructureHelper currently creates only a main workspace per project, so it needs a second workspace folder to exercise the "workspace other than main" path from the issue.
  • AppBaseTest static-imports org.testfx.assertions.api.Assertions.assertThat; for the item-list assertion you will want AssertJ (doesNotHaveDuplicates()), so qualify it or import it explicitly - AGENTS.md mandates AssertJ for assertions.

Why: without it, the next refactoring of setWorkspaceComboBox() silently reopens exactly this bug, and it is a bug that only manifests on the second project switch - the kind nobody re-checks manually.

4. Verify in the environment where the bug actually reproduces

The reporter was explicit in #2040: "I could not reproduce this behavior when running AppLauncher.main() from my IDE; in this case the selector works absolutely fine." The testing instructions inherited from #2095 say "Open GUI by running AppLauncher", i.e. the one environment where the bug never showed. Green CI does not cover this either.

Please confirm before merge that this was verified via ide gui on a snapshot build (ideally macOS, as reported). If it was already tested that way, just say so in the PR and this is resolved.

5. Branch is behind main

GitHub reports BEHIND. Per DoD.adoc, the feature branch has to be up-to-date with main before merge. Update branch should suffice, mergeable is clean.

6. Issue #2040 has no milestone

Milestones must be set before issues/PRs get closed (DoD.adoc). Also worth closing the loop on #2095 by linking it here as superseded.


Minor

Inline comments cover: the @FXML annotation on onWorkspaceSelected, the duplicated four-button enable/disable blocks (2 sites), and the ordering of setValue(null).

One more, pre-existing and not introduced by you, so purely optional while you are in this method. setWorkspaceComboBox() still has:

    } catch (NotDirectoryException e) {
      throw new RuntimeException(e);
    }

Per coding-conventions.adoc, section "Catching and handling Exceptions" the cause is kept (good) but the message is not: throw new IllegalStateException("Failed to read workspaces for project " + selectedProject.getValue(), e) makes the stacktrace self-explaining. Entirely non-blocking.

Comment thread gui/src/main/java/com/devonfw/ide/gui/MainController.java Outdated
Comment thread gui/src/main/java/com/devonfw/ide/gui/MainController.java Outdated
Comment thread gui/src/main/java/com/devonfw/ide/gui/MainController.java Outdated
Comment thread gui/src/main/java/com/devonfw/ide/gui/MainController.java Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix PR that fixes a bug issue GUI Graphical User Interface of IDEasy (aka dashboard) build with JavaFx

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

Workspace selection buggy

4 participants