Skip to content

fix(appkit): publish a streamed design page only once its mock is final - #746

Merged
MarioCadenas merged 3 commits into
mainfrom
work/13-design-plugin-publish-a-stream
Nov 24, 2026
Merged

MarioCadenas merged 3 commits into
mainfrom
work/13-design-plugin-publish-a-stream

Conversation

@MarioCadenas

Copy link
Copy Markdown
Collaborator

What

A streamed design page that imports ../mock is published only once src/design/mock.ts is final. Until now the plugin answered that import with the partial staging mock plus stub values (__draftValue Proxies). Those render as nothing, so a published version showed only titles and empty sections. A page whose final version landed before mock.ts stayed that way until a reload.

Builds on #745 (design pages report render failures and success).

How

packages/appkit/src/plugins/design/vite-plugin.ts:

  • Gate: a version that imports the mock isn't served or announced (appkit:stream) while mock.ts is missing. The finished page's done event and its hot update are held the same way, and /design/__stream/<name> reports it as not published. The page keeps its last version, or stays pending if it has none.
  • What counts as importing the mock: each version is compiled the way Vite serves it, then parsed with Vite's parseAst. importsMock (stream.ts) looks for an import, export-from or import() that resolves to src/design/mock. Comments, strings and import type don't count. An inline import { type T } counts only under verbatimModuleSyntax.
  • Release: the moment mock.ts is added or changed, every page waiting on it is published at once, however the page was first seen: a staging write, the final file's watcher event, the stream page, or a held hot update.
  • The stub mock is gone.

Tests

  • Watcher and stream tests: comments, strings, import type, inline type imports, export-from, a semicolon inside a comment, and a page first seen by its stream page or as a held hot update.
  • In real Vite with headless Chrome, no published frame shows stub values, and a waiting page renders its mock values without a reload once mock.ts lands.

Risks

  • A version that uses the mock waits for mock.ts, so builders should write it first. The docs say so.
  • A mock reached through another module isn't seen. Such a page shows an import error, never stubs.
  • With two tabs on one stream page while a finished page waits, the first may stay on its earlier version until reloaded.

This pull request and its description were written by Isaac.

MarioCadenas and others added 3 commits November 23, 2026 17:39
A streamed page that imports ../mock was published against stub values
(__draftValue proxies) until mock.ts existed, so it showed only titles and
empty cards; when the finished page landed before mock.ts, it stayed empty.

- A page version, and the finished page's done event, that imports ../mock
  at run time is held while mock.ts is missing: the stream page stays
  pending. The moment mock.ts lands, the held versions are published.
- A page without a ../mock import publishes as before.
- The stub mock (mockCode, stubMock, __draftValue, the ../mock redirect and
  the .staging/mock.ts stream that fed it) is removed: nothing reads it now.

Signed-off-by: mario.cadenas <mario.cadenas@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
The mock wait decided from a regex over the TSX source, which disagreed
with what Vite serves: an inline type-only import (`import { type T }`)
or a "../mock" string after an export held a page that needs no mock,
and a `;` in a comment inside an import let a page that needs it through.

- Each version is compiled as Vite serves it (transformWithOxc, or
  transformWithEsbuild on plain Vite, with the page's own path, so the
  app's tsconfig and its verbatimModuleSyntax apply), and importsMock
  walks the parsed output for an import, export-from or import() of the
  mock.
- A finished page waiting for mock.ts now holds its hot update too: a
  failed update left the page on an earlier version once mock.ts landed.
  It's sent when mock.ts lands, before the done event.

Signed-off-by: mario.cadenas <mario.cadenas@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Only a page seen through a staging write or its finished file's watcher
event was recorded as waiting for mock.ts. A finished page never streamed
and first seen by its stream page stayed pending once mock.ts landed, and
one first seen as a held hot update never got that update.

The stream page's published check and the hot-update hold now record the
page as waiting too, so mock.ts landing publishes it (its module reloaded,
then done), however it was first seen.

Signed-off-by: mario.cadenas <mario.cadenas@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
@MarioCadenas
MarioCadenas marked this pull request as ready for review November 23, 2026 18:31
@MarioCadenas
MarioCadenas requested a review from a team as a code owner November 23, 2026 18:31
@github-actions

Copy link
Copy Markdown
Contributor

📦 Bundle size report

Compared against bundle-size-baseline.json (main).

@databricks/appkit

npm tarball (packed): 1.3 MB (-174 B) — gzipped download (dist + bin; excludes release-only docs/NOTICE).

dist raw gzip
JS (runtime) 1.4 MB (-4 B) 500 KB (-102 B)
Type declarations 483 KB 174 KB
Source maps 2.7 MB (+840 B) 929 KB (-2 B)
Other 11 KB 3.7 KB
Total 4.6 MB (+836 B) 1.6 MB (-104 B)
Per-entry composition (own code — deps external (as shipped))
Entry Initial (gz) Lazy (gz) Total (gz) node_modules (min) Own code (min)
. 118 KB 2.4 KB 121 KB external 378 KB
./beta 115 KB (-183 B) 486 B 116 KB (-183 B) external 342 KB (-342 B)
./testing 47 KB 38 KB 85 KB external 246 KB
./tsdown 520 B 0 B 520 B external 813 B
./type-generator 31 KB 0 B 31 KB external 90 KB

Chunks:

Entry Chunk Load Size (gz)
. index.js initial 114 KB
. utils.js initial 4.6 KB
. remote-tunnel-manager.js lazy 2.4 KB
./beta beta.js initial 95 KB
./beta modular.js initial 6.1 KB
./beta stream-manager.js initial 5.9 KB
./beta service-context.js initial 4.3 KB
./beta databricks.js initial 3.3 KB
./beta client.js initial 649 B
./beta index.js initial 20 B
./beta supervisor-api.js lazy 193 B
./beta databricks.js lazy 178 B
./beta index.js lazy 115 B
./testing manifest.js initial 33 KB
./testing index.js initial 10 KB
./testing wide-event-emitter.js initial 2.9 KB
./testing index.js lazy 34 KB
./testing remote-tunnel-manager.js lazy 2.4 KB
./testing utils.js lazy 1.8 KB
./tsdown index.js initial 520 B
./type-generator index.js initial 31 KB

@databricks/appkit-ui

npm tarball (packed): 431 KB (+4 B) — gzipped download (dist + bin; excludes release-only docs/NOTICE).

dist raw gzip
JS (runtime) 459 KB 158 KB
Type declarations 283 KB 105 KB (+1 B)
Source maps 912 KB 308 KB
CSS 16 KB 3.2 KB
Total 1.6 MB 574 KB (+1 B)
Per-entry composition (consumer bundle — deps bundled, peerDeps external)
Entry Initial (gz) Lazy (gz) Total (gz) node_modules (min) Own code (min)
./js 5.3 KB 49 KB 55 KB 208 KB 14 KB
./js/beta 3.5 KB 0 B 3.5 KB 0 B 9.4 KB
./react 441 KB 49 KB 489 KB 1.4 MB 179 KB
./react/beta 16 KB 0 B 16 KB 25 KB 23 KB

Chunks:

Entry Chunk Load Size (gz)
./js index.js initial 5.2 KB
./js chunk initial 120 B
./js apache-arrow lazy 49 KB
./js/beta beta.js initial 3.5 KB
./react index.js initial 439 KB
./react tslib initial 2.1 KB
./react apache-arrow lazy 49 KB
./react/beta beta.js initial 16 KB

@github-actions

Copy link
Copy Markdown
Contributor

🤖 AppKit PR bot

🔬 Run evals

Start an eval for this PR from the evals-monitor app: Go to Evals Monitor →

📦 Try this PR's app template

Scaffolds a new app from this PR's SDK build. Run it in any folder (requires the GitHub CLI — gh auth login — and the Databricks CLI):

gh run download 45238876376 -R databricks/appkit -n appkit-template-0.103.0-pr.011055f-work-13-design-plugin-publish-a-stream-746 -D appkit-pr-746 \
  && unzip -o "appkit-pr-746/appkit-template-0.103.0-pr.011055f-work-13-design-plugin-publish-a-stream-746.zip" -d "appkit-pr-746" \
  && databricks apps init --template "appkit-pr-746"

The template pins @databricks/appkit and @databricks/appkit-ui to tarballs built from this branch, so the scaffolded app runs against this PR's code.

@MarioCadenas
MarioCadenas enabled auto-merge (squash) November 24, 2026 09:44
@MarioCadenas
MarioCadenas merged commit dc20841 into main Nov 24, 2026
12 checks passed
@MarioCadenas
MarioCadenas deleted the work/13-design-plugin-publish-a-stream branch November 24, 2026 10:08
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