Skip to content

RPC answers bring the stylesheets of the elements in them - #16

Merged
e-cline merged 2 commits into
mainfrom
claude/modest-murdock-488492
Oct 25, 2026
Merged

e-cline merged 2 commits into
mainfrom
claude/modest-murdock-488492

Conversation

@e-cline

@e-cline e-cline commented Oct 25, 2026

Copy link
Copy Markdown
Owner

What and why

RPC answers now bring their stylesheets. Before, RpcServer encoded an RPC's result without Render's styles, so an element it returned (weft_shop's "Load more" cards) was styled only by the sheets the page had already loaded: a class from any other sheet showed unstyled. This is follow-up 1 of docs/weft_css_plan.md, now marked done with an "As built" note.

weft_server

  • RpcServer.respond takes ~assets (virtual:weft/assets, as Page.respond does), and encodes the answer with their styles: the C rows of what it renders go before the rows needing them, as in a page's payload. Without ~assets, nothing changes.
  • The client needed nothing: Rpc.call decodes with Decoder.valueFromStream, which already holds the root back until its sheets load. So the call resolves only once they have, and whatever the caller renders with the answer is styled; a later row (a card's stock) waits as any other does.
  • Page.stylesOf is public: the stylesheets in an app's assets, as Render takes them.
  • The assets go to respond rather than router, so the module listing the handlers needn't import them.

Examples

  • weft_shop and weft_notes pass ~assets to their RPC route.
  • weft_shop's product cards have a sale badge ("20% off") in a file of its own (SaleBadge), with its own sheet, which a page sends only if something on it is on sale.

Testing

  • weft_server's Sheets_test, "RPCs, with sheets": through the router in process, an answer whose element has a class from an unloaded sheet is held back until that sheet loads; a boundary in an answer keeps its fallback, after the call has resolved, until its later row's sheet loads; without assets, no sheets are sent and nothing waits. The first two fail with the styles left out.
  • weft_shop's Styles_test: shoes sorted dearest first have nothing on sale on the first page, so the badge's sheet isn't loaded; with it held, "Load more" keeps the grid as it was ("Loading…") until the sheet loads, then shows the cards with their badges, and WeftTesting.unstyled is empty at every step. With ~assets taken out of the route it fails: the cards show at once, unstyled.

Checklist

  • pnpm run check, pnpm run test and pnpm run e2e pass (the flash test in Chromium, Firefox and WebKit)
  • Tests cover the change
  • A changeset is included (pnpm changeset) if a published package changed

🤖 Generated with Claude Code

e-cline and others added 2 commits October 25, 2026 18:08
RpcServer.respond takes ~assets, as Page.respond does, and encodes the answer with their styles, so
an element an RPC returns sends the C rows its classes need. The client's call already waits for
them (valueFromStream holds the root back until its sheets load). weft_shop's cards gain a sale
badge with a sheet of its own, which "Load more" brings on a page that hasn't loaded it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@e-cline
e-cline merged commit f8a9a56 into main Oct 25, 2026
3 checks passed
@e-cline
e-cline deleted the claude/modest-murdock-488492 branch October 25, 2026 23:20
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.

1 participant