Repository navigation
Description
Two of the three civitai app init templates — including the default — appear to scaffold an app that can never signal readiness to the host, so the host times out and collapses it. This is the same symptom as #196 but a different cause, and the dev-tunnel preflight added in #198 deliberately does not catch it (it is gated to SDK projects).
The contract
The host marks a block ready only on a BLOCK_READY message. In civitai/civitai, src/components/AppBlocks/PageBlockHost.tsx has exactly one transition into ready, inside the BLOCK_READY handler:
// PageBlockHost.tsx:864
const off = onMessage<unknown>('BLOCK_READY', () => {
...
setStatus((current) => (current === 'loading' ? 'ready' : current)); // :871Enumerating every setStatus( in that file, :871 is the only path to 'ready'. The failure path is :733, loading → 'timeout', after BLOCK_READY_TIMEOUT_MS = 10_000 (pageBlockHostLogic.ts:571).
A timeout is not a visible error card. hostRenderDecision.ts documents:
Every TERMINAL-FAILURE state collapses →
'collapse'(the host renders null; the slot takes no space — no visible broken card, no reserved gap). This covers: …'timeout'(no BLOCK_READY in 10s) …
Who actually sends it
Not the SDK. @civitai/app-sdk@0.31.0's runtime JS contains no BLOCK_READY at all — only a type in dist/blocks/messages.d.ts:467 and a README line. The sender is @civitai/blocks-react:
// @civitai/blocks-react@0.39.0 — dist/internal/iframeTransport.js:311
this.dispatch('BLOCK_READY', { height: 0 });What each template does
| template | depends on blocks-react |
messages it sends | reaches data-block-ready="true" |
|---|---|---|---|
page-money |
yes | via IframeTransport |
yes |
page-vite |
no | RESIZE_IFRAME only |
no |
static (default) |
no | RESIZE_IFRAME only |
no |
Grepping the whole of internal/scaffold/templates/page-vite/ and .../static/ for BLOCK_ returns zero matches. Each contains exactly one postMessage call, sending RESIZE_IFRAME — which PageBlockHost.tsx does not reference at any line, so it is not treated as a liveness signal either.
All three manifests declare page + iframe, so all three route through the same host path. static is the default: civitai app init "My Block" with no --template produces it (internal/cmd/app_init.go:59).
Ruled out
- A server-injected ready shim. No bootstrap/shim injection found in the block-serving path; every server-side
BLOCK_READYreference is the analytics beacon (app-views.service.ts,track/block-render.ts), not a sender. - A render mode that skips the handshake.
hostRenderDecisioncollapses ontimeoutregardless, andIframeHost.tsx:1956gatesdata-block-readyon the sameisReady.
Not verified
I have not loaded a scaffolded page-vite or static app in a real host browser and watched it time out — the tunnel endpoint is not exposed and the feature is kill-switched, the same limit recorded on #198. The evidence above is read directly from both sides of the contract (host source and template source), not observed end-to-end. Worth one browser confirmation before acting, since a fix touches the default template.
Possible directions
Not prescribing one — the trade-off is a product call:
- Emit
BLOCK_READYfrom the raw templates. A few lines ofwindow.parent.postMessage({ type: 'BLOCK_READY', height: 0 }, '*')keeps them dependency-free. Needs care:IframeTransportfreezesparentOriginto the first sender and dedupes re-inits (iframeTransport.js:291-295), so a hand-rolled version should not re-emit on every render. - Give them
@civitai/blocks-react. Correct by construction, but turns the "no-build"statictemplate into a build. - Document them as non-hosted previews and change the default to one that works.
Whichever way, a scaffold seam guard like internal/scaffold/dev_embed_contract_test.go — asserting each template that declares page emits the ready ack — would keep this from regressing silently.
Activity
fix(scaffold): the wiring guard matched a basename, and Guard B gated…
docs: the emitter pins a window, not an identity — and the mirror moved
fix(scaffold): "blocks the merge" was false, and the SDK control was …
docs(agents): record how the "intentional decisions" list is numbered
fix(scaffold): the static and page-vite templates never posted BLOCK_…
ZacxDev commentedon Aug 6, 2026
Fixed in #208 (
4018e2c). Two corrections to this issue, both measured — recording them because the original framing understates how the failure presents and would mislead anyone triaging by severity.1. It does not silently collapse. The host renders a visible card: "This app didn't load in time. It may be a temporary network or server hiccup. Try again. We already retried 2 times automatically. [Retry]". The collapse claim comes from
hostRenderDecision.ts, which governs the slot host. The page host deliberately does the opposite —pageBlockHostLogic.ts:Since no template declares
targets, these apps can only ever reach the page host. Closed #196 independently recorded the same card text.2. It takes ~37 s, not 10 s.
MAX_AUTO_RETRIES = 2withAUTO_RETRY_BACKOFF_MS = [2000, 5000]: 10+2+10+5+10. Confirmed by the block postingRESIZE_IFRAMEexactly 3× — once per attempt.Reproduced end-to-end in Chromium against the real unmodified
PageBlockHost, with apps scaffolded by the real CLI, before and after:static(init default)page-vitepage-money(control)Two things this issue got right that turned out to matter more than stated. The suggested snippet
postMessage({ type: 'BLOCK_READY', height: 0 }, '*')carries a real defect: the host dispatchesdata.payload(usePostMessage.ts), so every block→host message is{ type, payload }and top-level fields arrive aspayload: undefined. It works for this one message only because the host ignores the ready payload — but it teaches the wrong shape for everything an author adds later. AndRESIZE_IFRAMEisn't merely ignored on a page surface;hostHandlerParity.tsmarks it N/A ("a page block fills the surface and does NOT size-to-content"), so it was removed from both templates rather than left alongside the ack.Not fixed here: anyone who scaffolded before
4018e2cstill has a broken app and nothing tells them. A follow-up adds aninternal/antipatternrule and anapp validatewarning for that.fix(validate): the ack evidence was the @civitai scope, not the packa…
fix(validate): tell existing page apps they never post BLOCK_READY (#206
fix(validate): the ready-ack advisory passed an emitter nothing loads (…
fix(validate): the ready-ack advisory names the reason it fell back, …