feat(studio-server): preview variable injection + render variables forwarding#2049
Open
Conversation
This was referenced Jul 8, 2026
Collaborator
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
a4cd1b5 to
a2085a5
Compare
5870b13 to
c843527
Compare
…rwarding
Fourth PR of the template-variables Studio stack — the HTTP plumbing.
- preview routes (/preview and /preview/comp/*) accept
?variables=<url-encoded json> and inject
`window.__hfVariables = {...}` into <head>, before the runtime and any
composition script — the exact global the engine sets via
evaluateOnNewDocument at render time, so preview-with-values cannot
diverge from render output. Values are escaped against </script>
breakout, malformed payloads 400 instead of silently previewing
defaults, and the ETag is salted with a hash of the payload so cached
previews revalidate when values change.
- POST /projects/:id/render accepts variables ({variableId: value}) and
forwards them through StudioApiAdapter.startRender into the producer's
RenderConfig.variables — the same channel `hyperframes render
--variables` uses. Wired in both adapters (CLI embedded server + vite
dev adapter).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
c843527 to
dc24770
Compare
a2085a5 to
6acf033
Compare
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
Fourth PR of the template-variables stack: the HTTP plumbing.
/previewand/preview/comp/*) accept?variables=<url-encoded json>and injectwindow.__hfVariables = {...}before the runtime and any composition script — the exact global the engine sets viaevaluateOnNewDocumentat render time, so preview-with-values cannot diverge from render outputPOST /projects/:id/renderacceptsvariablesand forwards them throughStudioApiAdapter.startRenderinto the producer'sRenderConfig.variables— the same channelhyperframes render --variablesuses. Wired in both adapters (CLI embedded server + vite dev adapter)Why
Render-time injection existed; preview had no equivalent, so "preview with values" was impossible. Mirroring the engine's exact injection mechanism (rather than a bespoke postMessage protocol) is what makes the Studio preview render-truthful.
How
Safety/correctness details worth reviewing:
<-escaped against</script>breakout<head…>→<html…>→ after doctype → prepend (review fix — the original bare-<head>regex could land the tag before the doctype)helpers/variablesPayload.ts) used by both routesTest plan
variablesto this route🤖 Generated with Claude Code