fix(workbench): claim lock when developing workbench remote#1387
Merged
Conversation
Contributor
📦 Bundle Stats —
|
| Metric | Value | vs fix/workbench-mf-remoteentry (bc2931a) |
|---|---|---|
| Internal (raw) | 2.7 KB | - |
| Internal (gzip) | 1.0 KB | - |
| Bundled (raw) | 11.16 MB | - |
| Bundled (gzip) | 2.10 MB | - |
| Import time | 870ms | -2ms, -0.2% |
bin:sanity
| Metric | Value | vs fix/workbench-mf-remoteentry (bc2931a) |
|---|---|---|
| Internal (raw) | 782 B | - |
| Internal (gzip) | 423 B | - |
| Bundled (raw) | 9.87 MB | - |
| Bundled (gzip) | 1.78 MB | - |
| Import time | 2.23s | -10ms, -0.4% |
🗺️ View treemap · Artifacts
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
📦 Bundle Stats — @sanity/cli-core
Compared against fix/workbench-mf-remoteentry (bc2931ac)
| Metric | Value | vs fix/workbench-mf-remoteentry (bc2931a) |
|---|---|---|
| Internal (raw) | 106.7 KB | - |
| Internal (gzip) | 26.7 KB | - |
| Bundled (raw) | 21.72 MB | - |
| Bundled (gzip) | 3.46 MB | - |
| Import time | 773ms | +1ms, +0.1% |
🗺️ View treemap · Artifacts
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
📦 Bundle Stats — create-sanity
Compared against fix/workbench-mf-remoteentry (bc2931ac)
| Metric | Value | vs fix/workbench-mf-remoteentry (bc2931a) |
|---|---|---|
| Internal (raw) | 908 B | - |
| Internal (gzip) | 483 B | - |
| Bundled (raw) | 931 B | - |
| Bundled (gzip) | 491 B | - |
| Import time | ❌ ChildProcess denied: node | - |
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
Contributor
Preview this PR with pkg.pr.newRun the Sanity CLInpx https://pkg.pr.new/sanity-io/cli/@sanity/cli@936949a <command>...Or upgrade project dependencies📦
|
fa76352 to
6e3f89d
Compare
Contributor
Coverage Delta
Comparing 4 changed files against main @ Overall Coverage
|
The #RUNTIME-002 fix landed in module-federation/vite#854 (findRemoteEntryFile resolves the manifest's remoteEntry to the container, not a same-named ./App expose). 1.16.11 (#850) didn't carry it, so pin the #854 preview until release.
70efbab to
bc2931a
Compare
…workbench The remote takes a plain dev path (it can't render itself), so it never claimed the lock or registry — every app dev run started its own workbench shell, and the remote logged a bare port. devAction now routes every workbench app to startWorkbenchDev, which runs the remote as a plain app server that still claims the singleton lock and bridges the registry (shared with the shell via attachViteDevServerBridge). That plain server also announces a clickable URL.
mockAppServer returned the full union, so server/close access failed and the start mock did not satisfy StartAppServer — the type-check errored. Type the mock as the started arm and the helper param as StartAppServer.
6e3f89d to
936949a
Compare
joshuaellis
approved these changes
Jun 25, 2026
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.
Description
The workbench remote runs as a plain
sanity dev(it can't render itself), so it never claimed the workbench lock or the dev-server registry. Two fallouts:App dev server started on port 5173— no clickable URL.sanity devfor dev apps saw no running workbench, so each started its own shell instead of registering into the remote.Now the workbench remote claims the lock and bridges the registry, and the plain app server prints a clickable URL. Apps discover the remote and register into it.
I've used that opportunity to move even more code into the workbench-cli package.
Testing
Verified against sanity-io/workbench#262: the remote claims
workbench.lockand prints a clickable URL, and afavoritesdev run reportsWorkbench dev server started at http://localhost:5173 (app on port 5174). No automated coverage for the multi-process dev orchestration yet.Note
Medium Risk
Changes multi-process workbench dev orchestration (lock, registry, HMR bridge); scope is dev-only but incorrect behavior could still break local federation workflows.
Overview
Workbench remote
sanity devno longer bypasses workbench orchestration indevAction—every workbench app goes throughstartWorkbenchDev, which handles the remote internally.When
SANITY_INTERNAL_IS_WORKBENCH_REMOTEis set,startWorkbenchDevstarts a plain app/studio server and attachesstartWorkbenchRemoteCoordinator, which claims the workbench lock (when free) and bridges the dev-server registry into the Vite HMR channel via sharedattachViteDevServerBridgelogic (extracted from the full workbench shell path). Other appsanity devruns can discover the remote and register instead of each spawning its own shell.startAppDevServernow prints a styled, clickablehttp://…URL for workbench apps that announce their own URL, usingtoDisplayHostso bind addresses like0.0.0.0show aslocalhost. Tests and a changeset cover the routing and logging updates.Reviewed by Cursor Bugbot for commit 936949a. Bugbot is set up for automated code reviews on this repo. Configure here.