Skip to content

refactor(workbench): drop reactRefreshHost plumbing#1109

Open
gu-stav wants to merge 3 commits into
feat/workbenchfrom
SDK-1427
Open

refactor(workbench): drop reactRefreshHost plumbing#1109
gu-stav wants to merge 3 commits into
feat/workbenchfrom
SDK-1427

Conversation

@gu-stav
Copy link
Copy Markdown
Member

@gu-stav gu-stav commented May 20, 2026

Description

With dev.remoteHmr: true landing in @module-federation/vite (via workbench PR sanity-io/workbench#208), the federation plugin wires Fast Refresh through the host automatically. The workbench port no longer needs to leak from devAction down through start{Studio,App}DevServerstartDevServergetViteConfig into @vitejs/plugin-react.

Also drops the .__mf__temp ignore entries from templates and fixtures — federation no longer writes that directory at build time, so the entries are stale.

Net: the build pipeline has zero awareness of whether a workbench host exists.

Depends on a @sanity/federation release containing sanity-io/workbench#208 before merging.


Note

Medium Risk
Changes dev/build server configuration for federated development by removing reactRefreshHost propagation into Vite/React, which could impact Fast Refresh/HMR behavior if federation plugin assumptions differ. Also updates template/fixture ignores, low risk but could change generated project git status.

Overview
Removes the reactRefreshHost option end-to-end (CLI devActionstart{Studio,App}DevServerstartDevServergetViteConfig), so federated dev no longer injects a host URL into @vitejs/plugin-react for Fast Refresh.

Cleans up associated tests and types, and drops stale .__mf__temp ignore entries from templates/fixtures (and the related changeset) now that federation no longer writes that directory.

Reviewed by Cursor Bugbot for commit 6da820b. Bugbot is set up for automated code reviews on this repo. Configure here.

@gu-stav gu-stav requested a review from a team as a code owner May 20, 2026 07:07
@gu-stav gu-stav requested a review from joshuaellis May 20, 2026 07:07
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 20, 2026

📦 Bundle Stats — @sanity/cli

Compared against feat/workbench (d73d5518)

@sanity/cli

Metric Value vs feat/workbench (d73d551)
Internal (raw) 2.1 KB -8 B, -0.4%
Internal (gzip) 799 B -2 B, -0.2%
Bundled (raw) 10.97 MB -8 B, -0.0%
Bundled (gzip) 2.06 MB -8 B, -0.0%
Import time 822ms -5ms, -0.6%

bin:sanity

Metric Value vs feat/workbench (d73d551)
Internal (raw) 1023 B -
Internal (gzip) 486 B -
Bundled (raw) 9.84 MB -
Bundled (gzip) 1.77 MB -
Import time 2.27s +18ms, +0.8%

🗺️ 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 feat/workbench (d73d5518)

Metric Value vs feat/workbench (d73d551)
Internal (raw) 99.5 KB -
Internal (gzip) 23.4 KB -
Bundled (raw) 21.64 MB -
Bundled (gzip) 3.43 MB -
Import time 788ms -9ms, -1.2%

🗺️ 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 feat/workbench (d73d5518)

Metric Value vs feat/workbench (d73d551)
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.

Comment thread packages/@sanity/cli/src/actions/dev/devAction.ts Outdated
@gu-stav gu-stav changed the title refactor(workbench): drop reactRefreshHost plumbing now that federation owns HMR refactor(workbench): drop reactRefreshHost plumbing May 20, 2026
@gu-stav gu-stav changed the title refactor(workbench): drop reactRefreshHost plumbing refactor(workbench): drop reactRefreshHost plumbing May 20, 2026
@claude
Copy link
Copy Markdown

claude Bot commented May 20, 2026

Claude finished @gu-stav's task in 2m 54s —— View job


Review

I reviewed the diff against origin/feat/workbench and the open bugbot findings.

Bugbot findings on the latest commit (6da820b) — all three earlier bugbot reports were against pre-6da820b snapshots:

  • Dev URL omits basePathresolved. The studio URL is now built as http://${httpHost}:${port}${config.basePath} in startStudioDevServer.ts:111.
  • Command tests expect old logsresolved. The "ms and running at …" and "App dev server started on port …" strings exist again in startStudioDevServer.ts:117-122 and startAppDevServer.ts:40-42, matching the assertions in commands/__tests__/dev.test.ts (lines 103, 134, 166-167, 207, 249, 299, 336, 450).
  • Federated dev loses Fast Refreshstill applicable and is the only real merge blocker. pnpm-lock.yaml still resolves @sanity/federation@0.1.0-alpha.7, which doesn't ship dev.remoteHmr wiring. Until @sanity/federation is bumped to a release that includes sanity-io/workbench#208, federated dev will silently lose Fast Refresh on remotes. The PR body already calls this out as a merge dependency — just don't forget to bump packages/@sanity/cli/package.json:83 before merging.

Other observations

  • Cleanup is complete: no remaining reactRefreshHost or __mf__temp references anywhere under packages/ or fixtures/.
  • All test removals match the removed surface area.
  • No changeset, but this targets feat/workbench (a feature branch), so it inherits the feature's changeset story. Removing the auto-generated .changeset/pr-1028.md is correct since the __mf__temp entry never shipped to main.

Suggestions (non-blocking)

  • startStudioDevServer.ts:121(workbenchAvailable ? '' : \ and running at ${styleText('cyan', url)}`)is fine, but it means the studio URL is never printed when workbench is up.devAction.ts:75-77then logs"Workbench dev server started at (app on port )"— butappPortisn't a full URL, and the studio'sbasePathis dropped from any user-visible log in the workbench-on path. Consider also logging the studio URL (includingbasePath`) in the workbench branch so users can copy/paste it.
  • devAction.ts:74const appPort = typeof addr === 'object' && addr ? addr.port : server.config.server.port — the fallback path can yield undefined (vite types server.config.server.port as number | undefined). Worth a quick guard, since the log would render … (app on port undefined).

  • Gather context (diff vs origin/feat/workbench)
  • Validate cursor bugbot findings
  • Check for missing tests / changeset
  • Post review
    · Branch

Comment thread packages/@sanity/cli/src/actions/dev/startStudioDevServer.ts Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 05b0145. Configure here.

Comment thread packages/@sanity/cli/src/actions/build/getViteConfig.ts
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 20, 2026

Coverage Delta

File Statements
packages/@sanity/cli-core/src/config/cli/getCliConfig.ts 100.0% (±0%)
packages/@sanity/cli-core/src/config/cli/schemas.ts 100.0% (±0%)
packages/@sanity/cli-core/src/services/cliUserConfig.ts 100.0% (±0%)
packages/@sanity/cli-core/src/util/getSanityConfigDir.ts 66.7% (new)
packages/@sanity/cli/src/actions/build/buildApp.ts 95.3% (±0%)
packages/@sanity/cli/src/actions/build/buildStaticFiles.ts 97.6% (+ 1.0%)
packages/@sanity/cli/src/actions/build/buildStudio.ts 96.7% (±0%)
packages/@sanity/cli/src/actions/build/getViteConfig.ts 100.0% (±0%)
packages/@sanity/cli/src/actions/build/writeSanityRuntime.ts 96.2% (+ 0.7%)
packages/@sanity/cli/src/actions/deploy/deployApp.ts 80.5% (±0%)
packages/@sanity/cli/src/actions/deploy/deployStudioSchemasAndManifests.ts 100.0% (±0%)
packages/@sanity/cli/src/actions/dev/devAction.ts 96.7% (- 3.3%)
packages/@sanity/cli/src/actions/dev/devServerRegistry.ts 93.8% (new)
packages/@sanity/cli/src/actions/dev/extractDevServerManifest.ts 20.0% (new)
packages/@sanity/cli/src/actions/dev/getDevServerConfig.ts 100.0% (±0%)
packages/@sanity/cli/src/actions/dev/startAppDevServer.ts 100.0% (+ 13.0%)
packages/@sanity/cli/src/actions/dev/startDevManifestWatcher.ts 90.9% (new)
packages/@sanity/cli/src/actions/dev/startFederationRegistration.ts 100.0% (new)
packages/@sanity/cli/src/actions/dev/startStudioDevServer.ts 100.0% (+ 5.0%)
packages/@sanity/cli/src/actions/dev/startWorkbenchDevServer.ts 98.7% (new)
packages/@sanity/cli/src/actions/dev/writeWorkbenchRuntime.ts 100.0% (new)
packages/@sanity/cli/src/actions/init/bootstrapLocalTemplate.ts 89.7% (±0%)
packages/@sanity/cli/src/actions/init/bootstrapTemplate.ts 0.0% (±0%)
packages/@sanity/cli/src/actions/init/createAppCliConfig.ts 100.0% (±0%)
packages/@sanity/cli/src/actions/init/createCliConfig.ts 100.0% (+ 50.0%)
packages/@sanity/cli/src/actions/init/createStudioConfig.ts 83.3% (±0%)
packages/@sanity/cli/src/actions/init/initAction.ts 97.2% (+ 0.1%)
packages/@sanity/cli/src/actions/init/initApp.ts 96.0% (±0%)
packages/@sanity/cli/src/actions/init/initStudio.ts 87.0% (±0%)
packages/@sanity/cli/src/actions/init/scaffoldTemplate.ts 100.0% (±0%)
packages/@sanity/cli/src/actions/init/types.ts 100.0% (±0%)
packages/@sanity/cli/src/actions/manifest/extractCoreAppManifest.ts 93.1% (new)
packages/@sanity/cli/src/actions/manifest/extractManifest.ts 100.0% (±0%)
packages/@sanity/cli/src/actions/manifest/types.ts 100.0% (±0%)
packages/@sanity/cli/src/actions/manifest/writeManifestFile.ts 100.0% (±0%)
packages/@sanity/cli/src/commands/dev.ts 100.0% (±0%)
packages/@sanity/cli/src/commands/init.ts 100.0% (±0%)
packages/@sanity/cli/src/commands/manifest/extract.ts 100.0% (±0%)
packages/@sanity/cli/src/commands/schemas/deploy.ts 95.0% (±0%)
packages/@sanity/cli/src/prompts/init/federation.ts 100.0% (new)
packages/@sanity/cli/src/server/devServer.ts 94.1% (±0%)
packages/@sanity/cli/src/util/resolveReactStrictMode.ts 100.0% (new)

Comparing 42 changed files against main @ cd110e7c2b0cdad7438f53d958a0831fea2a3773

Overall Coverage

Metric Coverage
Statements 84.6% (+ 0.3%)
Branches 74.7% (+ 0.4%)
Functions 84.5% (+ 0.3%)
Lines 85.1% (+ 0.4%)

gu-stav and others added 3 commits May 22, 2026 09:48
…on owns HMR

With `dev.remoteHmr: true` landing in `@module-federation/vite` (via workbench PR
sanity-io/workbench#208), the federation plugin wires Fast Refresh through the host
automatically. The workbench port no longer needs to leak from `devAction` down through
`start{Studio,App}DevServer` → `startDevServer` → `getViteConfig` into `@vitejs/plugin-react`.

Removing that field exposed `workbenchAvailable` as the last piece of workbench-derived state
on `DevActionOptions`, used only to suppress a URL log suffix in the leaf starters. Hoisted
that output into `devAction`, which already owns the "Workbench dev server started at …"
line — all dev-server output formatting now lives in one place.

Net: the build pipeline has zero awareness of whether a workbench host exists.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The federation pipeline no longer creates `.__mf__temp` directories, so
the gitignore entry (and the test asserting it gets scaffolded) are
obsolete. Removes the entry from the template gitignore, the federated
fixture, and the bootstrap test, and drops the changeset that introduced
the entry since the change is no longer shipping.
The reactRefreshHost cleanup also dropped the "App dev server started on port X"
and "...ms and running at http://..." lines from the leaf starters and replaced
them with a single "${label} dev server started at ${appUrl}" line in devAction.
That changed user-visible text and broke dev.test.ts on every shard.

Restore the original log lines (and the workbenchAvailable plumbing they depend
on for the no-workbench branch). The reactRefreshHost removal stays untouched —
build pipeline still has zero awareness of workbench hosts.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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