Repository navigation
Scale website containers with page visibility - #403
Conversation
…rtup # Conflicts: # worker/test/config.test.ts # worker/wrangler.toml
leaf-agent
left a comment
There was a problem hiding this comment.
Closing the stream on hidden also stops the only writer of viewed.json, which I think is a semantics decision worth making deliberately rather than a side effect.
_news is the sole bumper (http.py:413) and viewed is spread straight through full_state into the agent-facing state, so leaf state prints it. The recorded meaning is "when a browser last held the page open" (page-storage.md:90, and the comment at presence.py:216), and the distinction it exists for is stated in both places and again in test_an_open_stream_records_that_the_page_is_open: "a page nobody ever opened and one the user studied and left used to be indistinguishable from the agent's side."
After this change a tab the reader still has open behind another one stops bumping it, so from the moment it hides it reads to the agent exactly like a page the reader closed. The fact narrows to "when a browser last had it visible". That may well be the better fact for an agent asking whether anyone is looking — but it is a different one from what those three places describe, and the diff does not say so.
The rest reads clean to me. The stream lifecycle holds up on the paths I traced — a stale opened cannot rearm the silence timer or schedule a reopen, feedStarted keeps the visibility handler from racing the first read, and gating the shared clock is what stops an offline hidden tab from holding its container through ask every two seconds. max_instances = 15000 matches the README's own derivation from a 2 GB lite disk.
I can push the doc-only version of either reading if you say which one you want.
leaf-agent
left a comment
There was a problem hiding this comment.
The visibility reading is now stated in the three places the earlier round named, so the narrowing of viewed.json reads as a decision rather than a side effect.
One sentence still states the old lifecycle. The ear comment in skills/leaf/assets/runtime/state-feed.js opens with "one stream, open for the page's life", a dozen lines above the new paragraph saying hidden tabs close their streams — a page now opens and releases a stream per visible interval, so that opening claim is the one place left in the file reading against the change. It sits outside this diff; I can push the one-line correction if you want it.
Leaf currently holds one EventSource connection open for every tab, including hidden ones. Cloudflare counts each streaming response as an in-flight container request, so those sessions never begin the existing idle timeout and consume the public instance ceiling indefinitely. This change raises the public `lite` container limit from 100 to Cloudflare's current account capacity of 15,000. It also makes document visibility the browser lease: hidden tabs close their news stream and stop timed reads, while visible tabs reconnect and catch up from the canonical state projection. The ten-minute idle grace remains, and one visible tab is enough to keep a multi-tab reader session alive. The browser test proves a hidden page neither hears nor polls for changed state, stops advancing reader presence, then reconnects once and catches up when visible. The storage contract now defines `viewed.json` as visible reader attention rather than background-tab lifetime. The parsed deployment-config test pins both the exact capacity and `lite` instance type while retaining the existing production application-identity guard. > _This was written by Codex on behalf of max-sixty_
Leaf currently holds one EventSource connection open for every tab, including hidden ones. Cloudflare counts each streaming response as an in-flight container request, so those sessions never begin the existing idle timeout and consume the public instance ceiling indefinitely.
This change raises the public
litecontainer limit from 100 to Cloudflare's current account capacity of 15,000. It also makes document visibility the browser lease: hidden tabs close their news stream and stop timed reads, while visible tabs reconnect and catch up from the canonical state projection. The ten-minute idle grace remains, and one visible tab is enough to keep a multi-tab reader session alive.The browser test proves a hidden page neither hears nor polls for changed state, stops advancing reader presence, then reconnects once and catches up when visible. The storage contract now defines
viewed.jsonas visible reader attention rather than background-tab lifetime. The parsed deployment-config test pins both the exact capacity andliteinstance type while retaining the existing production application-identity guard.