feat(renderer): implement streaming SSR + update future work checklist#33
Merged
feat(renderer): implement streaming SSR + update future work checklist#33
Conversation
Co-authored-by: Asjas <3828967+Asjas@users.noreply.github.com> Agent-Logs-Url: https://github.com/Asjas/scratchyjs/sessions/496d54d7-906d-4d6e-9dfc-5b0896542525
Copilot
AI
changed the title
[WIP] Update future work module in implementation plan document
feat(renderer): implement streaming SSR + update future work checklist
Mar 23, 2026
Contributor
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||
Contributor
There was a problem hiding this comment.
Pull request overview
Adds first-pass streaming SSR support to the renderer package (worker task + Fastify route handler), and updates planning docs to reflect completion.
Changes:
- Extend renderer worker to support a new
"ssr-stream"task and return aStreamingRenderResult(chunk array). - Add
createStreamingSSRHandler()to dispatch streaming render tasks and stream chunks to clients. - Export new handler/types from
packages/renderer/src/index.tsand add unit/integration tests; updateIMPLEMENTATION_PLAN.md.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/renderer/src/worker.ts | Adds "ssr-stream" task type, task/result interfaces, streaming render implementation, and handler overloads. |
| packages/renderer/src/worker.test.ts | Adds tests for "ssr-stream" worker output shape, chunk ordering, and XSS escaping. |
| packages/renderer/src/streaming-ssr-handler.ts | Introduces Fastify handler that runs "ssr-stream" tasks and streams returned chunks via reply.send(stream). |
| packages/renderer/src/streaming-ssr-handler.test.ts | Adds Fastify-inject tests validating headers/body behavior for streaming SSR handler. |
| packages/renderer/src/index.ts | Re-exports the streaming handler and new worker task/result types from the public entrypoint. |
| IMPLEMENTATION_PLAN.md | Marks Streaming SSR + Turborepo + create-scratchy-app as completed future-work items. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: A-J Roos <asjasroos@pm.me>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: A-J Roos <asjasroos@pm.me>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: A-J Roos <asjasroos@pm.me>
…dd index re-export test Co-authored-by: Asjas <3828967+Asjas@users.noreply.github.com> Agent-Logs-Url: https://github.com/Asjas/scratchyjs/sessions/19ecbf25-cf9f-4dd0-b2a1-bd1966ad7bf7
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.
Two of the future work items in
IMPLEMENTATION_PLAN.mdwere already shipped (create-scratchy-app, Turborepo) but still marked unchecked. This PR corrects the checklist and implements the remainingStreaming SSRitem.Future work checklist (
IMPLEMENTATION_PLAN.md)Turborepo or Nx✅ —turbo.jsonalready existscreate-scratchy-app✅ —packages/create-scratchy-appalready existsStreaming SSR✅ — implemented belowStreaming SSR (
@scratchyjs/renderer)worker.tsStreamingRenderResult—{ chunks: string[], statusCode, headers? }NonStreamingRenderTask/StreamingRenderTasknarrowed task interfacesrenderStreamingSSR()— splits HTML into three ordered chunks: shell+<head>(critical path, flushed first), above-fold content, closing tags"ssr-stream"task type via thehandler()switchhandler()preserve the correct return type at call sites (NonStreamingRenderTask → RenderResult,StreamingRenderTask → StreamingRenderResult) so existing code is unaffectedstreaming-ssr-handler.ts(new)createStreamingSSRHandler()mirrors the existingcreateSSRHandler()API but dispatches"ssr-stream"tasks and pipes chunks viaReadable.from()→reply.send(), triggering HTTPTransfer-Encoding: chunkedautomatically.The shell chunk (DOCTYPE + full
<head>) is sent before the worker resolves the body, letting the browser fetch critical CSS/JS while the content renders. XSS prevention uses the sameescapeHtml()path as SSR/SSG.index.tsExports
createStreamingSSRHandler,StreamingSSRHandlerOptions,StreamingRenderResult,StreamingRenderTask, andNonStreamingRenderTask.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.