Skip to content

Have a leaf.page visitor's focus compose the page's layer in their container - #5812

Merged
max-sixty merged 3 commits into
mainfrom
agent-launch-state
Nov 12, 2026
Merged

max-sixty merged 3 commits into
mainfrom
agent-launch-state

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

When a leaf.page visitor focuses a text box, the Worker's prewarm (#5802) now asks the session's container to compose the page's layer, rather than only starting the container. The visitor's first write then finds the composition done instead of paying for it.

Why here. A first write spends most of its admission composing the page's layer (theme, package modules, merged registry), which leaf.layer keeps only in process memory. Shipping it pre-built in the image would need a saved form of those caches in main code, so this computes it earlier instead: website code calls the public registry.storage.selected for the focused page. Everything is in worker/.

Measured in the website image with a stub page store, on 1 vCPU, admission of the first write (median of 2–3 runs):

Write sent after boot Today Every page composed at boot This PR (focused page, at focus)
0 s, no focus (a first click) 1.13 s 1.47 s 1.13 s
2 s after focus 0.93 s 0.45 s 0.17 s
8 s after focus 0.94 s 0.18 s 0.18 s

Composing one page takes about 0.9 s on 1 vCPU. Composing all 47 at boot took 2.0 s and slowed a write that arrived meanwhile, so the container composes only what the focus names.

Changes. The container answers POST <page>/_leaf/agent/prewarm by composing that page's layer and logging layer_prewarm_completed. prewarmContainer posts there through the session's Durable Object, which starts the container as before. tests/process/website_server/test_dispatch.py and the Worker's prewarm test cover each side.

This was written by Claude Code on behalf of max-sixty

…ntainer

The focus prewarm only started the container, so the first write still spent
most of its admission composing the page's layer. The Worker now posts
/_leaf/agent/prewarm, which starts the container and composes the focused
page's layer through registry.storage.selected; the process keeps it, so the
write finds it done. On 1 vCPU in the website image, admission of a write sent
2 s after focus fell from 0.93 s to 0.17 s. Composing every page at boot was
tried and dropped: it took 2.0 s and slowed a write that arrived meanwhile
from 1.13 s to 1.47 s.
…ning a thread

Opening a thread focuses its comment box, which since #5802 starts the session's
container for the reply. verify-site opened the saved thread before checking that
the revision resource and document came from the Durable Object, so the prewarm
could wake the container first; publish-site for #5802's merge failed with
'private revision resource woke its container'. The thread check now runs after
the checks that reading left the container asleep.
@max-sixty max-sixty changed the title Have a leaf.page visitor's focus compose the page's layer in their container Have a leaf.page visitor's focus compose the page's layer, and keep verify-site's sleep checks before the thread opens Nov 10, 2026
leaf-agent
leaf-agent previously approved these changes Nov 10, 2026
# Conflicts:
#	dev/leaf_dev/commands/verify_site.py
@max-sixty max-sixty changed the title Have a leaf.page visitor's focus compose the page's layer, and keep verify-site's sleep checks before the thread opens Have a leaf.page visitor's focus compose the page's layer in their container Nov 11, 2026
@max-sixty
max-sixty merged commit 73374b3 into main Nov 12, 2026
5 checks passed
@max-sixty
max-sixty deleted the agent-launch-state branch November 12, 2026 00:44
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.

2 participants