fix(lanes): allow creating a new lane when current lane has staged/diverged components #10155
+62
−4
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.
When a lane has unexported snaps or has diverged from the remote (e.g., another workspace pushed changes), users were blocked from creating a new lane with the error "please export or reset the following components first".
This is a valid use case - the user wants to fork their work to a new lane rather than merge with the diverged remote.
Background
This restriction was introduced in #6931 with the following concerns:
Why it's fine now
Export behavior: When creating a new lane, the bitmap heads (including local snaps) are copied to the new lane. Exporting the new lane exports those snaps as part of the new lane only. The old lane object is not exported, so it's not modified on the remote.
Scope mismatch: If the new lane has a different scope, the lane and components will be exported to their respective scopes correctly. This is standard behavior.
Old lane state: The old lane is left with staged components that show as "export-pending". This is the same confusing state that exists regardless of whether we allow lane creation - the divergence already happened. The difference is:
Changes
throwForStagedComponentscheck fromcreateLane()switch-lanes.ts)