Repository navigation
Spike: stream partial TSX drafts in the design plugin - #708
MarioCadenas merged 3 commits into
Conversation
The design plugin watches client/src/design/.staging/<name>.tsx (and .staging/mock.ts) as a builder appends a draft's source to it, closes the partial source at the last line that parses (open JSX, brackets, template literals; undeclared components stubbed, missing mock values stubbed) and hot-updates src/design/pages/<name>.tsx with it, so Fast Refresh swaps it in place. /design/__stream/<name> renders it and keeps the last good frame when a version throws. Once the finished file is written there it loads from disk and is remounted, ending identical to /design/<name>. apps/tsx-stream-spike replays writer streams recorded with KIT-37's writer (taxi, Tetris, onboarding form) through the staging files at their real timing, 3 drafts side by side, and measures them. Spike only (KIT-40). Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: MarioCadenas <MarioCadenas@users.noreply.github.com>
|
Review 1 · Fail · 3 major, 3 minor, 1 pre-existing Does the change do what the task asked? No. Gate: major and worse must be fixed. The streaming renderer works as a spike: on replay of all three apps there were no broken frames, the final DOM matched the compiled page every time, and file-watch latency was about 10ms. The ~5s first-paint target is still missed on all apps (taxi 6.3-9.5s, Tetris about 11s, form 20-45s), and the component-boundary fallback the decisions called for when that happens was not tried. The dev server also crashed with an unhandled ENOENT during one form replay. Required
Not required (below the gate)
Not required (there before this change)
|
🤖 AppKit PR bot🔬 Run evalsStart an eval for this PR from the evals-monitor app: Go to Evals Monitor → 📦 Try this PR's app templateScaffolds a new app from this PR's SDK build. Run it in any folder (requires the GitHub CLI — The template pins |
…etons appkit-ui (react/beta) gets DesignPage, the shell every /design page renders through (streamed, finished, locked in): the app's theme with dark mode from the first paint (?theme= or the system setting), and an error boundary that keeps the last good frame on screen and holds readiness back (useDesignReady). The page entry and the stream host both use it instead of their own boundary and snapshot code. DraftPlaceholder (chart, table, card, generic skeleton) stands in for components a streamed draft uses before it defines them; mock values not written yet are a value that can't throw. Fixes from review: a deleted finished file no longer crashes the dev server (watcher handlers are caught), generic arrows (<K extends X>(...)) no longer read as JSX (this kept the form drafts from rendering), a finished file nothing imports yet doesn't reload every page, and the replay reset stops the writers of a replay still running. APPKIT_DESIGN_STREAM_MODE=boundary measures component-boundary updates; scripts/bound.ts gives the earliest paint any renderer could reach from each recording. The spike app pins the repo's React so the root test setup keeps one copy. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: MarioCadenas <MarioCadenas@users.noreply.github.com>
|
Review 2 · Fail · 1 major Does the change do what the task asked? No. Gate: major and worse must be fixed. Round-1 fixes F2-F6 are in: the boundary fallback is built and measured, onFinal rejections are caught, reset clears running writers, measure.ts retries on a cold server and counts pixels instead of comparing bytes. The ~5s first-meaningful-paint target is still missed on all 3 apps (taxi 6.4-6.7s, Tetris 7.5-10.8s, form 17.4-21s), as the agent itself reports, so F1 stays open. Required
|
|
Review 3 · Pass · 1 minor, 1 pre-existing Does the change do what the task asked? Yes. Gate: major and worse must be fixed. The spike builds the streaming TSX renderer, a 3-up replay page, recordings for taxi, Tetris and form, and a measured report. Across 9 drafts it has 0 broken frames and the final render matches the compiled page. It misses the ~5s first-paint target (6.4-21s), but the human accepted that as the spike's finding. Design plugin and DesignPage tests pass except one react-router test that the agent says also fails on the base commit. Not required (below the gate)
Not required (there before this change)
|
The spike app inherited react-router 7 from KIT-37's app without using it. Having it in the workspace made the design plugin's router test find a react-router 7 for a fixture app without one, failing Unit Tests in CI. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: MarioCadenas <MarioCadenas@users.noreply.github.com>
|
Review 4 · Pass · 1 minor Does the change do what the task asked? Yes. Gate: major and worse must be fixed. Round 4 only drops the unused react-router 7 dependency from the spike app; the lockfile no longer adds any react-router entry versus the base, and the previously failing design router test now passes along with all design plugin and DesignPage tests. The rest of the spike was accepted in the prior round, including the human-accepted ~5s paint miss. CI on this commit was still queued when I checked. Not required (below the gate)
|
1289cd2
into
work/1-design-plugin-dev-only-design-
The spike works and is committed (
2ce2bfe2aonwork/40-spike-stream-partial-tsx-draft), but the ~5s first-meaningful-paint target fails on all 3 apps. Nothing is missing any more; the checks, report and closing note are done.Try it (from the worktree):
pnpm install && pnpm --filter @databricks/appkit-ui build:packagepnpm --filter tsx-stream-spike devHow it works:
client/src/design/.staging/<name>.tsxas the writer appends to it and never writes draft files itself.src/design/pages/<name>.tsx. React Fast Refresh swaps it in place.dogfoodto the staging files at their real timing. When the recording says a file type-checked, it writespages/<name>.tsxandmock.ts.The three checks, per app (seconds after the draft's first chunk):
return (only streams 3.5–5.6s after the first chunk.mock.ts, so every version before that throws and is held back.Recommendation for the App Builder writer prompt (not changed):
export default function Page()withreturn (straight away; onlyuseStatecalls before it.mock.ts, small values pages read as objects first, long arrays last.Tests: 9 new unit tests pass, and
pnpm checkand typecheck are clean. One existing design-plugin test fails, but it also fails on the base commit in this environment. Not covered: dark mode, and only one writer run per app.The full report covers how App Builder would feed the stream, plus videos and screenshots per app. It's in
/Users/mario.cadenas/.herdr-projects/reports/app-kit/40/:report.md,<app>-replay.webm,shots/.Also noticed:
packages/appkit/src/plugins/design/tests/design.test.ts: "uses the router only when the app has react-router 7+" fails on the base commit too.Task: KIT-40 (app-kit/40)