Repository navigation
Replace manual presentation choreography with epoch presenters - #795
Merged
Merged
Conversation
The projection, the conversation and the Ask inventory each become an epoch presenter: the publication that opens an epoch claims their regions, and one pass paints them in an order declared beside the coordinator. `state-application.js` loses the four-step sandwich — prepare chrome, apply the conversation, present chrome, apply the conversation again — and waits for the pass instead. The `prepareProjection`/`presentProjection` split that sandwich existed to hold is gone, as are the open-coded projection-then-conversation pairs in `invalidateDom`, `startPost`, `settleRejected` and `readNothing`. The five hand-written copies of "claim a ticket now, paint later, supersede the prior claim" collapse into one primitive, `createPresentationSchedule`. Two of those copies had diverged on the order they released a superseded hold, which is what let a failed paint acknowledge an epoch it had not drawn. The pass orders the renderers it collects and nothing more. It starts them in rank order, so one that reads DOM another materializes runs after those writes, and then leaves them alone: a renderer may hold its reading open on a widget that has not prepared, and anything waiting on that hold — a later renderer in the same turn, the next turn's paint, a reader's own gesture — would never reach the page. For the same reason a claim supersedes whatever its region was drawing rather than queueing behind it, and the coordinator reports the superseded paint's failure, because the document keeps whatever state that failure reached. Five defects the change surfaced, each fixed where it lives: - `seatFab` told positioning waiters the response bar had no position through the very call that was giving it one, and one answer drains the list, so the `true` that followed reached nobody. A reader whose composer opened into a widget outlet was left outside the field. - A reader's gesture painted through `invalidateDom`, which a state application holds. What the page can draw of a gesture does not wait for an answer the log has not given, so the gesture claims its regions directly. - `projectionDeferred` — a reader's drag holding the document-wide pass — never said when it moved, so the approval gate's Ask selection was repainted by hand from `retryProjection`. It now tells its watchers. - One fault drew a report from every caller that touched it. The presentation coordinator reports a failed paint once, for the region that owns it; callers observe the rejection instead of accounting for it again. - `conversation.repaintCurrent`, `refreshNarrowing` and the `renderAsks`/`syncAsks` alias were unreachable or duplicate, and are deleted. Not landable as it stands. The everyday suite is green (1142 passed) and so is the browser framework's own (26 passed), but two nightly browser cases fail: a diff's landing does not focus the reply it opens, and a settlement control stays busy after its reopen settles. Both read DOM the conversation paint writes in the turn they ask for it, while the pass answers a claim one microtask later. The remaining work is to give those two call sites an explicit wait on the pass instead of an assumption about when it runs. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The thread card asked the pending ledger whether a settlement was in flight. The ledger is not what the epoch is derived from: when the server's answer lands, the fold already reads the thread as settled, so removing the entry behind it changes nothing anyone publishes and no epoch follows it. The card kept the disabled, busy control it had drawn an epoch earlier, and the reader could not resolve a thread they had just reopened. The four-step sandwich hid this by repainting after accounting; nothing does that now. `resolved` alone cannot carry the fact, because a reopen leaves it null exactly as an untouched open thread does. `foldThreads` records which way the thread is being settled, the card reads it, and the clearing of that field is a change to the publication like any other. The same turn-versus-pass mistake was in `scrollToThread`: it called `refreshConversation()` and then read the marks, the placement and the widget outlet the conversation pass had yet to write, so a diff that landed left focus on the quote instead of the reply it opened. It waits for the pass. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Seven findings from an independent review of the branch, of which three were defects and the rest were the code promising more than it did. A paint superseded while it was still running lost its failure. `claim` answered the ticket the older paint's rejection was going to travel on, so when that paint threw, the rejection landed on a settled promise and the pass went green over a region the fault had left half-drawn. Only a withheld reading needs answering for — it will never answer for itself — so that is the only one a claim releases now. A running paint keeps its ticket and reports through the coordinator; a reading superseded before it painted drew nothing and releases its own. `conversation.done` was not in the publication. The thread list draws a row for each accepted approval and the banner's button reads them for the word it wears, but neither could see one arrive: the list because the removed sandwich used to repaint it unconditionally, the button because it never could. Both read the published fold now, and an approval arriving on its own moves the epoch like any other semantic change. `invalidateDom` still named two of the three document-wide renderers, so a mechanical invalidation repainted the projection and the conversation and left the Ask inventory alone. `presentDocument` claims every region the schedule knows about, and the two callers that were naming renderers use it. `showThreadNow` read the thread list in the turn that opened the panel, past the fold it needed to cancel; it waits for the pass. The response bar's comment about where its hover refresh comes from named a call that no longer paints. The schedule's own docstring said each presenter is awaited before the next. It is not, and cannot be — anything queued behind a held reading would never be drawn. What rank order buys is that lower-ranked presenters have run to their first `await`, so a renderer may rely on the markup one writes synchronously and not on a widget it upgrades later. That is now what the docstring says. Two deletions the review turned up. `settling === kind` was unreachable: a settlement in flight has already flipped `resolved`, because what the page can draw of a gesture stands in the turn that sends it, so there is no "Resolving…" state to name and no width to reserve for it. And `createPresentationSchedule`'s injectable `schedule` had no caller and would have busy-spun on anything slower than a microtask. Not a defect, but worth stating: `refreshNarrowing` was not "unreachable or duplicate" as an earlier message here claimed. It rendered the thread list alone, and the search box called it on every keystroke; that path now runs the whole conversation pass. The output is the same and the extra work is idempotent, and a second narrow paint path is the mechanism this change exists to remove. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`presentDocument` claimed every registered region, including ones whose renderer was never mounted. On an interactive export there is no chrome, so the Ask inventory took a ticket it could never commit, the application barrier never completed, and the page never stamped itself presented: six export cases waited out `data-lf-presented` and got nothing. Each region already knew when it had nothing to draw — before the page has read the log, before an admitted server reading, before its chrome is mounted — but each knew it in its own subscription, which is the one caller that asked it to paint. A caller that has changed the document and wants every region to redraw cannot be expected to know which of them are alive. So the answer moves into the presenter: `current` returns null for a region that owes nothing yet, `present` claims nothing, and the three subscriptions lose the guard they were each carrying separately. Reverted with it: making `showThreadNow` wait for the pass before reading the thread list. The list it reads is already the pass's, by construction — a destination that is not there yet goes down the reveal path, which awaits — and waiting up front deadlocked a send that reveals its own comment, taking four conversation cases with it. The narrow case it was meant to close, a fold left uncancelled on a card the list has not repainted, is worth less than that. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Gating the conversation on `phase` took away the one reading it owes before the log arrives: "Loading current threads…" is this region's to draw, and its paint has always had a branch for every phase. The region that owes nothing is a copy with no chrome, which is what `available` already names. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Follow-up review of the repairs. No correctness defect in the four contracts they changed; what follows is what it found around them. The conversation claimed its region on every epoch, including the ones before the page has read the log. Each of those draws the same line about waiting, so the margin sweep and the anchor pass ran twice over an empty fold ahead of the first paint a reader is waiting on. The subscription filters them again, as it did before this branch. What changed is that the filter no longer decides whether the region exists: `current` answers that, which is why a reader who opens the panel in that window still gets the line, and why a copy with no chrome claims nothing. The dead `available` check inside the paint goes with it — one gate, in one place. `documentPresented` and `presentDocument` were one word apart, returned the same type and did opposite things: one waits for the pass, the other claims into it. Calling the waiting one where the claiming one belonged is the deadlock this branch already had to back out, and nothing in the names would have caught it. The waiting one is `whenDocumentPresented` now, beside the `whenApplicationPresented` and `whenWidgetsPresented` it belongs with. An approval accepted elsewhere now has a test of its own. The three that touch `done` all move the epoch by something else in the same read — a seeded log, a local pending approval, an agent reply carrying markup — so none of them could fail. This one changes nothing but the approval, and both halves discriminate: faulting the publication alone takes the panel row away, and faulting the reader takes the banner's word away. That test earned its place immediately. Removing `present` from the projection owner's returned object removed the function the region's own subscription calls, which parses clean, lints clean, and throws `present is not defined` at boot. It stays, unexported: the region has two ways in, its subscription and `presentDocument`, and handing a third to one caller is how the Ask inventory came to be left out of a document-wide repaint in the first place. Three comments now say what the code does. Releasing a superseded ticket frees the coordinator's continuation rather than answering a region that was waiting; the guard on a withheld hold keeps one name meaning one thing and changes nothing observable; and a clock tick landing mid-paint commits on a reading still in flight, which is a real gap rather than the sound arrangement the comment claimed. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
leaf-agent
approved these changes
Sep 18, 2026
max-sixty
added a commit
that referenced
this pull request
Sep 18, 2026
#800) Three preview tests in `test_render_export.py` went red on a loaded machine and green on a quiet one, which read as contention. Neither cause was. ## The interrupt landed on nothing `test_interrupting_a_live_preview_exits_without_a_traceback` and `test_automation_preview_records_real_gestures_outside_the_task` timed out whenever the run was launched as a shell's background job, and passed whenever it was launched in the foreground — 2/2 each way, with no concurrency in either. A background job has SIGINT set to `SIG_IGN`, which is the shell's protection for a job no terminal can interrupt, and an inherited `SIG_IGN` survives both Python startup and `exec`. So every process the run spawns ignores the signal too: the interrupt landed on nothing, `communicate` waited out its ten seconds, and the watcher outlived the run still serving its page. The run now catches SIGINT itself, which is what `exec` resets to the default in each child — the disposition the interrupt is about. `spawn` ends the group of a child given a session of its own, since `scripts/preview.py` re-executes into `uv run` and the handle a test keeps names the launcher rather than the watcher below it. ## The suite never took its preview slots back `test_a_detached_preview_restarts_under_its_original_codex_claim` misses its thirty-second reload once `.tmp/previews` holds a few hundred entries, and the suite was adding four per preview and removing one: `preview_slot` deleted the page directory and left `<slot>.preview.{json,lock,log,state.lock}` beside it, while `test_named_live_previews_serve_one_source_in_independent_runtime_slots` named its two slots itself and so was swept by nothing. The fixture now discards every slot in its namespace through the preview's own `retire_preview`, which writes the stop flag the watcher polls and then waits for the lease — so a watcher that outlived its test is retired rather than having its page pulled from under it. The named-slots test takes the fixture and derives its names from it. `scripts/preview.py` is unchanged. Measured, two arms launched together on a machine under a sibling nightly: this branch 59 passed with nothing left in `.tmp/previews`; 602e895 3 failed and left 74 entries. ## A conversation paint that answered for the wrong reading `conversation/presentation.js` drives its paint through `clocked`, so a relative-time tick arriving while the pass waits on a frozen widget starts a second `renderReading`. `surfaceGeneration` settles which reading the page keeps — the newer one — and the first then returned early but resolved its ticket anyway, committing the region on a reading still being written and leaving that reading's failure with no ticket to travel on. The paint now waits for whichever reading the region last started, not the one it began itself, which is what makes its ticket true. It drains the region before raising anything, too: a superseded reading rejects rather than returning, so leaving on the first rejection would settle the ticket on a reading the page had already discarded while its replacement wrote the region — the same commit-too-early, surviving on the failure path. The first failure is kept and raised once the region is quiet, which is the first-failure `whenDocumentPresented` reports anyway. This is the follow-up #795 left open. Full nightly suite green at 2723, run backgrounded — the condition that used to fail. > _This was written by Claude Code on behalf of max-sixty_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.
The projection, the conversation and the Ask inventory each become an epoch presenter: the publication that opens an epoch claims their regions, and one pass paints them in an order declared beside the coordinator.
state-application.jsloses the four-step sandwich — prepare chrome, apply the conversation, present chrome, apply the conversation again — and waits for the pass instead. TheprepareProjection/presentProjectionsplit that sandwich existed to hold is gone, as are the open-coded projection-then-conversation pairs ininvalidateDom,startPost,settleRejectedandreadNothing. No caller names a renderer now:presentDocumentclaims every region the schedule knows about, which is also what stops one from being left out.Five hand-written copies of "claim a ticket now, paint later, supersede the prior claim" collapse into one primitive,
createPresentationSchedule. Two of them had diverged on the order they released a superseded hold, which is what let a failed paint acknowledge an epoch it had not drawn.The pass orders the renderers it collects and nothing more. It starts them in rank order, so one that reads DOM another materializes runs after those writes, and then leaves them alone: a renderer may hold its reading open on a widget that has not prepared, and anything waiting on that hold — a later renderer in the same turn, the next turn's paint, a reader's own gesture — would never reach the page. The guarantee rank order actually buys is therefore narrow, and the docstring says so: when a presenter begins, every lower-ranked one has run as far as its first
await, so a renderer may rely on markup one writes synchronously and not on a widget it upgrades later.Nine defects this surfaced, each fixed where it lives
seatFabtold positioning waiters the response bar had no position through the very call that was giving it one, and one answer drains the list, so thetruethat followed reached nobody. A reader whose composer opened into a widget outlet was left outside the field.invalidateDom, which a state application holds. What the page can draw of a gesture does not wait for an answer the log has not given, so the gesture claims its regions directly.projectionDeferred— a reader's drag holding the document-wide pass — never said when it moved, so the approval gate's Ask selection was repainted by hand fromretryProjection. It tells its watchers now.foldThreadsrecords which way a thread is being settled, becauseresolvedalone cannot say — a reopen leaves it null exactly as an untouched open thread does.scrollToThreadcalledrefreshConversation()and then read the marks, the placement and the widget outlet the pass had yet to write, so a diff that landed left focus on the quote instead of the reply it opened.claimanswered the ticket the rejection was going to travel on, so the pass went green over a region the fault had left half-drawn. Only a withheld reading needs answering for; a running paint keeps its ticket and reports through the coordinator.conversation.donewas not in the publication. The thread list draws a row per accepted approval and the banner's button reads them for the word it wears, but neither could see one arrive. Both read the published fold now, and an approval accepted elsewhere moves the epoch like any other semantic change.conversation.repaintCurrent,refreshNarrowingand therenderAsks/syncAsksalias were unreachable or duplicate, and are deleted.settling === kindwas unreachable too: a settlement in flight has already flippedresolved, because what the page can draw of a gesture stands in the turn that sends it, so there is no "Resolving…" state to name and no width to reserve for it.On the two names
documentPresentedandpresentDocumentwere one word apart, returned the same type and did opposite things — one waits for the pass, the other claims into it. Calling the waiting one where the claiming one belonged is a deadlock this branch hit and backed out. The waiting one iswhenDocumentPresented, beside thewhenApplicationPresentedandwhenWidgetsPresentedit belongs with.A presenter also answers for itself whether it owes a reading at all.
current()returns null for a region whose renderer was never mounted — an interactive export has no chrome — andpresentthen claims nothing. That answer cannot live in each region's subscription, because a caller that has changed the document has no business knowing which regions are alive.Verification
uv run pytest tests --run-nightlyis green at 2722 passed.npm run check:browserandnpm run test:browsercover the TypeScript half at 63 passed, including a new case pinning that a superseded paint's failure is still reported.test_an_approval_made_elsewhere_reaches_the_panel_and_the_banneris new and isolates thedonefix — the three existing tests that touchdoneeach move the epoch by something else in the same read, so none of them could fail; both halves of the new one were bug-backed separately.Two preview-watcher cases in
test_render_export.pytime out under heavy parallel load. They reproduce identically on the merge base — four concurrent copies per arm, launched together, failed the same two node ids in every baseline copy — and this branch changes nothing underscripts/preview.py.This is the second item on the priority list, which
TODO.mdno longer carries. The number there is a list position, not an issue.