fix(sandbox): scope user-driven SANDBOX_START to the locked provider kind#4478
Open
pedrofrxncx wants to merge 1 commit into
Open
fix(sandbox): scope user-driven SANDBOX_START to the locked provider kind#4478pedrofrxncx wants to merge 1 commit into
pedrofrxncx wants to merge 1 commit into
Conversation
…kind Auto-start and self-heal already passed sandboxProviderKind to SANDBOX_START so provisioning stays pinned to the thread's locked provider (#4025), but the user-driven start() — which retry() and resume() also call — built its args without it. Retrying a failed locked-provider sandbox (or resuming a suspended one) could get re-provisioned on a different provider than the one the preview is locked to, the exact 'different-provider sibling' the surrounding code says should never happen. Extract the shared arg-builder (buildSandboxStartArgs) so all three call sites stay in sync, and add a regression test.
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.
Source
Bug found reading
sandbox-lifecycle-context.tsx(high-churn file this run).What's wrong
SandboxLifecycleProviderreceives asandboxProviderKindprop specifically so "entry selection and SANDBOX_START are scoped to this kind [and] the preview never silently shows a different-provider sibling" (per the prop's own doc comment). Commit #4025 wired this through for the auto-start and self-heal effects, but the user-drivenstart()action — whichretry()andresume()also call — built itsSANDBOX_STARTargs withoutsandboxProviderKind.Failure scenario: a thread is locked to
sandboxProviderKind: "user-desktop". That sandbox fails to start (erroredstate, nopreviewUrlyet, nobranchMapentry recorded). The user clicks Retry.retry()→start()callsSANDBOX_STARTwith nosandboxProviderKind, so the server falls back to its link-or-env default provider policy instead of honoring the lock — the sandbox can come up onagent-sandboxinstead, exactly the "different-provider sibling" the surrounding code says should never happen.Fix
Extracted the SANDBOX_START arg-building into one pure, exported helper (
buildSandboxStartArgs) matching the existing tested-pure-helper pattern already used in this file (shouldAutoStart,shouldSelfHeal,computeDrawerStatus), and reused it at all three call sites (auto-start effect, self-heal effect, userstart()). Added a regression test asserting the built args includesandboxProviderKindwhen the thread has a locked kind.To verify
bun test apps/mesh/src/web/components/sandbox/hooks/sandbox-lifecycle-context.test.tsChecks run locally
bun run fmtbunx tsc --noEmitinapps/mesh(no new errors)bun test apps/mesh/src/web/components/sandbox/hooks/sandbox-lifecycle-context.test.ts(24 pass)Full CI will validate the rest.
Summary by cubic
Scopes user-driven SANDBOX_START to the thread’s locked provider to prevent starting on a different provider.
buildSandboxStartArgsand used in auto-start, self-heal, and userstart()so all calls includesandboxProviderKindwhen locked.sandboxProviderKindwhen locked; omits optional fields when absent).Written for commit 253110f. Summary will update on new commits.