feat(canvas): scaffold-by-default freeform builds + Tailwind v4 JIT#2949
Open
adamleithp wants to merge 2 commits into
Open
feat(canvas): scaffold-by-default freeform builds + Tailwind v4 JIT#2949adamleithp wants to merge 2 commits into
adamleithp wants to merge 2 commits into
Conversation
Seed freeform canvas generation with a known-good starter scaffold by default (opt out in the generate bar): the agent edits a compiling app instead of authoring boilerplate from scratch — faster, fewer first-render errors. Threaded as a useStarter flag through the generate hook + prompt builder; the scaffold wires the easy-to-get-wrong bits (date picker, theme tokens, loading skeletons, typed-node result reading, refresh). Swap the edit-mode sandbox Tailwind engine from the v3 Play CDN to the v4 browser JIT (Quill is authored for v4). v4's layered preflight, native not-* variants, and @theme inline token mapping let us drop the preflight-off hack, the not-disabled shim, the hand-rolled reset, and the hand-mirrored color map. Pinned to 4.3.1; v3 kept behind a flag. Tighten the authoring contract: Tailwind utilities over inline style; token-only color with the status-token foreground convention (text-success-foreground, not bare text-success); date picker rendered bare with PopoverContent w-auto p-0 and no compact. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
React Doctor found 1 issue in 1 file · 1 warning. 1 warning
Reviewed by React Doctor for commit |
There was a problem hiding this comment.
T1d-complex (439 lines, 8 files) with zero reviews touching sandbox CSP policy. The script-src and connect-src directives now trust the entire cdn.jsdelivr.net origin rather than just the pinned path, in a sandbox that already runs unsafe-eval. The changes are well-reasoned and documented, but a security-adjacent CSP expansion in the code-execution sandbox should have at least one human sign-off before merging.
Contributor
|
Reviews (1): Last reviewed commit: "feat(canvas): scaffold-by-default freefo..." | Re-trigger Greptile |
…e starter doc Address PR review: - CSP now trusts only the ACTIVE engine's CDN (not both v3 + v4), and the v4 build is path-scoped to cdn.jsdelivr.net/npm/@tailwindcss/ rather than the whole jsdelivr origin — narrows the sandbox's egress to what it fetches. Re-validated live: v4 still compiles, canvas renders styled, no CSP errors. - Correct the freeformStarter.ts header (drop stale "COMPACT" / "opt-in"; scaffold is on by default and the picker self-sizes without compact). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Addressed review feedback in
|
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.
What
Two changes to freeform (React) canvas generation, aimed at faster, more consistent first renders.
1. Scaffold-by-default first builds
Freeform canvas generation now seeds the agent with a known-good starter scaffold by default instead of authoring the whole single-file app from scratch. The agent edits a compiling baseline → fewer first-render errors, less boilerplate to (re)derive.
packages/core/src/canvas/freeformStarter.ts— a complete, whitelist-legal.tsxthat already wires the easy-to-get-wrong bits: date picker (Popover +quickRanges), theme tokens, per-card loading skeletons, correct typed-node result reading, and a working Refresh.useStarterflag throughuseGenerateFreeformCanvas→buildFreeformGenerationPrompt.2. Tailwind v4 browser JIT in the edit sandbox
Swapped the edit-mode sandbox Tailwind engine from the v3 Play CDN to the v4 browser build (
@tailwindcss/browser@4.3.1, pinned). Quill is authored for v4, so v4's layered preflight, nativenot-*variants, and@theme inlinetoken mapping let us delete several hand-patches:@layer base, sorts below Quill's@layer components, can't clobber itnot-disabledvariant shim → native in v4@layer basereset → v4 preflight covers it@theme inlinereferencing Quill's CSS varsv3 kept behind a
TAILWIND_ENGINEflag as a one-line fallback. CSP opened forcdn.jsdelivr.net(edit mode only).3. Authoring-contract tightening
style.text-success-foreground, not baretext-successwhich is the pale fill) — fixes invisible deltas.<PopoverContent className="w-auto p-0">, nocompact(it self-sizes).Testing
pnpm --filter @posthog/core typecheck && test(1727 pass),pnpm --filter @posthog/ui typecheck, biome lint — all green.@theme inlinecompiles, Quill components render styled, and the success delta renders readable green.🤖 Generated with Claude Code