Skip to content

refactor(workbench): own interface derivation in workbench-cli#1336

Merged
gu-stav merged 1 commit into
mainfrom
refactor/workbench-move-interfaces
Jun 24, 2026
Merged

refactor(workbench): own interface derivation in workbench-cli#1336
gu-stav merged 1 commit into
mainfrom
refactor/workbench-move-interfaces

Conversation

@gu-stav

@gu-stav gu-stav commented Jun 22, 2026

Copy link
Copy Markdown
Member

Description

Interface derivation and set-change detection are dev-server-registry concerns, so they belong in the package that owns the registry — and consolidating them lets the app-side rebuild check and the workbench-side reload check share one set differ instead of two hand-rolled trackers.

What to review

The moved deriveInterfaces/interfaceSetId, the new createRegistrySetTracker, and that startWorkbenchDevServer's registry watcher now uses it.

Testing

Existing unit tests moved with the code; added coverage for the shared registry tracker.


Note

Low Risk
Pure refactor with behavior preserved; dev orchestration only, covered by moved and new unit tests.

Overview
Moves deriveInterfaces, interfaceSetId, trackInterfaceSet, and the new createInterfacesTracker from @sanity/cli into @sanity/workbench-cli/dev, alongside the dev-server registry they describe.

The CLI now imports those helpers from workbench-cli (startDevServerRegistration, startDevManifestWatcher, startWorkbenchDevServer). The workbench registry watcher drops its inline Map + interfaceSetId logic in favor of createInterfacesTracker().hasChanged(servers) for full-reload vs soft reconcile.

Tests move with the implementation; @sanity/workbench-cli/dev mocks in CLI tests use importOriginal so pure tracking/derivation still runs under test. New unit tests cover createInterfacesTracker (first snapshot, new apps, reorders).

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

@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle Stats — @sanity/cli

Compared against main (8d59d3b3)

@sanity/cli

Metric Value vs main (8d59d3b)
Internal (raw) 2.7 KB -
Internal (gzip) 1.0 KB -
Bundled (raw) 11.16 MB -
Bundled (gzip) 2.10 MB -
Import time 876ms -1ms, -0.1%

bin:sanity

Metric Value vs main (8d59d3b)
Internal (raw) 782 B -
Internal (gzip) 423 B -
Bundled (raw) 9.87 MB -
Bundled (gzip) 1.78 MB -
Import time 2.01s +65ms, +3.3%

🗺️ 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 main (8d59d3b3)

Metric Value vs main (8d59d3b)
Internal (raw) 106.7 KB -
Internal (gzip) 26.7 KB -
Bundled (raw) 21.72 MB -
Bundled (gzip) 3.46 MB -
Import time 786ms +21ms, +2.7%

🗺️ 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 main (8d59d3b3)

Metric Value vs main (8d59d3b)
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.

@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Coverage Delta

File Statements
packages/@sanity/cli/src/actions/dev/registration/startDevManifestWatcher.ts 89.1% (±0%)
packages/@sanity/cli/src/actions/dev/registration/startDevServerRegistration.ts 100.0% (±0%)
packages/@sanity/cli/src/actions/dev/workbench/startWorkbenchDevServer.ts 98.8% (- 0.1%)
packages/@sanity/workbench-cli/src/actions/dev/deriveInterfaces.ts 100.0% (new)
packages/@sanity/workbench-cli/src/actions/dev/interfaceSetId.ts 100.0% (new)

Comparing 5 changed files against main @ 8d59d3b3a0d859137e9a54dc5301ea88e4418fce

Overall Coverage

Metric Coverage
Statements 74.2% (+ 0.0%)
Branches 64.2% (±0%)
Functions 69.1% (+ 0.0%)
Lines 74.8% (+ 0.0%)

Interface derivation and set-change detection are registry concerns;
co-locating them removes the cross-package import and lets the
app-rebuild and host-reload checks share one set differ.
@gu-stav gu-stav force-pushed the refactor/workbench-move-interfaces branch from e702336 to cd231d6 Compare June 24, 2026 09:19
@gu-stav gu-stav marked this pull request as ready for review June 24, 2026 09:46
@gu-stav gu-stav requested a review from a team as a code owner June 24, 2026 09:46
@gu-stav gu-stav requested a review from joshuaellis June 24, 2026 09:46
* its registry entry: `views` → panels, `services` → workers, `entry` → the
* navigable `app` view (`entry_point` is the raw `src`, not a resolved URL).
* `undefined` for a non-branded app; a studio that declares `entry` is rejected
* (FR-026, studio app views are not implemented yet).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

FR-026 has no meaning

@gu-stav gu-stav merged commit 38eaa5c into main Jun 24, 2026
64 checks passed
@gu-stav gu-stav deleted the refactor/workbench-move-interfaces branch June 24, 2026 11:22
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.

2 participants