Skip to content

fix(sidebar): workspace source always wins environment dedup (#895) - #901

Merged
jeonghun-jj-lee merged 1 commit into
mainfrom
fix/895-env-dedup-order
Sep 8, 2026
Merged

fix(sidebar): workspace source always wins environment dedup (#895)#901
jeonghun-jj-lee merged 1 commit into
mainfrom
fix/895-env-dedup-order

Conversation

@jeonghun-jj-lee

Copy link
Copy Markdown
Contributor

Root cause of 'Remove from Workspace' never appearing on environment roots.

The bug: getRoots() iterates workspace folders in a single pass. If a research project appeared before the environment folder in the workspace list, the project's resolveEnvironment() added the environment to envBySlug with source: "resolved" first. When the actual environment workspace folder was reached later, the dedup guard (!envBySlug.has(slug)) prevented the source: "workspace" entry from overwriting it. The context menu checked source === "resolved" and always showed 'Add to Workspace' instead of 'Remove from Workspace'.

The fix: Remove the has() guard for workspace-folder environments — they always overwrite the envBySlug entry. Workspace source wins regardless of iteration order.

1 new test reproducing the exact scenario, 1 updated edge case test.

…ss of folder order (#895)

Root cause: getRoots() iterated workspace folders in order. If a research
project appeared before the environment folder, the project's resolution
added the environment to envBySlug with source 'resolved' first. When the
actual environment workspace folder was reached later, the dedup guard
(!envBySlug.has(slug)) prevented the workspace entry from overwriting it.

Fix: workspace-folder environments always overwrite the envBySlug entry
(removed the has() guard). This ensures source is 'workspace' regardless
of iteration order, so the context menu correctly shows 'Remove from
Workspace'.

- 1 new test reproducing the exact bug scenario
- 1 updated test for duplicate-slug edge case
@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 9a0b3368-2922-47f6-b6a5-d34ed23a8782


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.

@jeonghun-jj-lee
jeonghun-jj-lee merged commit 20c8dc1 into main Sep 8, 2026
10 checks passed
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.

1 participant