fix(sidebar): workspace source always wins environment dedup (#895) - #901
Merged
Conversation
…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
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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'sresolveEnvironment()added the environment toenvBySlugwithsource: "resolved"first. When the actual environment workspace folder was reached later, the dedup guard (!envBySlug.has(slug)) prevented thesource: "workspace"entry from overwriting it. The context menu checkedsource === "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 theenvBySlugentry. Workspace source wins regardless of iteration order.1 new test reproducing the exact scenario, 1 updated edge case test.