Skip to content

Keep completed delivery answers visible after settlement - #925

Merged
max-sixty merged 9 commits into
mainfrom
fix/ci-35704376889
Sep 22, 2026
Merged

max-sixty merged 9 commits into
mainfrom
fix/ci-35704376889

Conversation

@leaf-agent

@leaf-agent leaf-agent commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

A hosted turn could resolve its delivered move before its final answer committed. The commit treated that completed answer like an unnecessary failure receipt, dropping the answer and its streamed draft. Keeping the answer in a resolved thread also hid it from the default Open Threads view and failed the publication verifier's visibility check.

Completed delivery answers now retain their exact responds identity after settlement. A substantive reply reopens its conversation; reactions and failure receipts leave closure standing, and a later resolution closes it again. Native thread disclosure survives filtering, so an answer returns where the reader left it unless they selected another conversation. Exact response identity keeps the answered move settled while preserving newer reader input. Reopening restores still-unanswered widget Asks, as an explicit reopen does.

Validation: the hosted regression uses the real composer, delivery commit, and verify-site-browser.js visibility observer, waits for resolution to finish hiding the card, and covers both retained and changed reader selection. Backend regressions cover frozen-widget completion, closure exceptions, newer input, and retry. After integrating current main, local runs passed all 630 delivery, conversation-contract, and session tests, 59 browser-framework tests, runtime tests, the committed-bundle reproducibility gate, and lint. The pending-reply regression covers optimistic reopening and restoration after rejection. Matched browser previews showed the baseline hiding the answer and the candidate displaying it, with no browser errors.

This was written by Codex on behalf of max-sixty

A hosted turn binds its reply seat before the turn and commits the completed
text at the end of it. Anything that settled that move in between made the
commit a no-op and cleared the streamed draft with it, so the reader lost the
answer they had watched arrive and nothing recorded the loss.

`cmd_reply`'s settled disposition now says what the write is for: a giving-up
receipt skips, and a writer holding the agent's own completed words posts them
in the thread as its own message.

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The answer reaches the log, but not the reader it was kept for. Where the settlement was a resolve — the case in the run this is against — the thread it lands in is closed, and the panel's default narrowing is open-only: DEFAULT_INTENT in skills/leaf/assets/runtime/conversation/narrowing.js carries state: "open", which matchesState reads as !thread.resolved; the card renders collapsed besides (thread-card.js, this.node.open = !model.resolved). tests/test_render_conversations.py::test_a_late_reply_to_a_resolved_thread_stays_above_its_reopen_footer clicks [data-filter-value="resolved"] to see exactly this shape. So session-lifetime.md's "The reader watched it arrive, so it is never dropped" and host-codex.md's "it is posted in the same thread as your own message instead" both promise more than the reader gets: the answer is in the log and under the Resolved filter, and nowhere in the view they were looking at.

That leaves the gate this is against unreached rather than cleared. scripts/verify_site.py holds a second check past the state poll — visibleReplyAt, whose failure reads reply never became visible in Threads — and scripts/verify-site-browser.js satisfies it only from an .lf-msg.agent node that intersects and passes checkVisibility(). On the description's own timing the resolve landed at 11.1 s and the first streamed text at 13.95 s, so the draft painted after the thread closed, and the committed answer lands in the same closed thread. The state poll passes now; the visibility check is what the diff does not reach.

What sits under it is a product call rather than a defect in this code — whether an agent's answer arriving in a resolved thread reopens it, surfaces some other way, or leaves the reader to the Resolved filter, and what verify_site then holds a deployment to. It is worth settling before this lands, because the deferral the description names is the agent's misreading of resolve, not this one.

Separable and smaller: skills/leaf/scripts/leaf/events.md owns the reply event's fields and still says "a proactive --initiates reply records initiates: true". A delivery's committed answer now writes that field too and is the opposite of proactive, so the reference a log reader consults is the one place that does not say what the field can mean. I can push that alignment.

What I verified
  • tests/test_website_server.py, tests/test_interact_contract.py, tests/test_interact_session.py: 592 passed, 4 failed — all four OSError: [Errno 97] out of socket.AF_UNIX, which this sandbox does not provide.
  • The new case reproduces its bug: putting _commit back on when_settled="skip" fails it with ValueError: not enough values to unpack (expected 1, got 0), the empty reply list.
  • The relaxed same_scope for a post writer is safe. delivery_reply_attempt keys on the delivery id, so the attempt is unique per delivery, and the relaxation is what lets a retry after an unresolve recognise its own event rather than exit on it.
  • An initiates reply settles nothing it should not: acknowledgments.py matches on responds alone.
  • The version-thread guard that posting_settled steps past is unreachable from this writer — _response derives a version obligation from the thread root's own declaration, so a move in such a thread never binds a reply seat.
  • The other cmd_reply callers are unaffected: cli.py takes the refuse default, and worker/server.py is the receipt writer this renames to skip.

leaf-agent and others added 4 commits September 22, 2026 09:29
A delivery's completed answer now records `initiates: true` when the move it
was bound to was settled before the commit, so the field no longer means the
reply was proactive. It means the reply settles nothing; state that, and name
both writers that reach it.
Keep completed delivery answers scoped to the delivered move after settlement. New spoken replies reopen the conversation; reactions and failure receipts retain closure. Preserve native disclosure through filtering so late answers remain visible unless the reader selected another thread. Update the floor test to distinguish settlement before a new question from reopening after it.
@max-sixty max-sixty changed the title Post a delivery's completed answer when its move was settled first Keep completed delivery answers visible after settlement Sep 22, 2026

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test is red on this head, and the failure is the diff's: npm run check:browser reports skills/leaf/assets/vendor/browser-runtime.js, scripts/browser/generated/browser-runtime.js.map, and scripts/browser/generated/browser-runtime.manifest.json stale. skills/leaf/assets/runtime/conversation/model.js is a declared input of that bundle — scripts/browser/index.ts exports createSemanticApplication, application.ts imports foldThreads, and the committed manifest's sourceInputs lists the file — so the one-line thread.resolved = null makes the committed payload stale.

The consequence runs past the gate. foldThreads has exactly one consumer, application.ts, which reaches a page only through the vendored bundle; nothing loads conversation/model.js at runtime. Until the bundle is rebuilt, the optimistic half of the new rule — the reader's own reply reopening a resolved thread in the turn that sends it — is not in the shipped runtime, even though the Python fold beside it is. Rebuilding is the fix, per The install runs this tree in CLAUDE.md: run npm run build:browser and commit the three outputs rather than editing the bundle.

Worth naming alongside it: nothing in the suite would have caught this. Both new browser cases append the agent's reply server-side, so they exercise build_threads and read the result off the state feed; no case drives a reader's local reply into a resolved thread, which is the only path through the changed JavaScript. That is why 99 conversation cases pass against a bundle that does not contain the change.

I'll push the rebuild.

How the staleness was established

The PR's tree is byte-identical to origin/main under scripts/browser/ and skills/leaf/assets/vendor/, so the check's failure is not a base-branch drift: node scripts/browser/build.mjs --check exits clean on a freshly installed origin/main worktree and reports the three files on this head, same node_modules in both.

The first differing byte in the rebuilt bundle is the change itself:

committed: ...c&&(c.msgs.push(l),le(l)||(c.awaits_agent=!0,c.awaits_reader=!1))...
built    : ...c&&(c.msgs.push(l),le(l)||(c.resolved=null,c.awaits_agent=!0,c.awaits_reader=!1))...

The manifest diff is only the two digest entries, so no dependency moved.

max-sixty and others added 3 commits September 22, 2026 11:12
`conversation/model.js` is a declared input of `skills/leaf/assets/vendor/browser-runtime.js`, so the thread-reopening line reaches a page only once the bundle carries it. Regenerated with `npm run build:browser`.
# Conflicts:
#	tests/test_interact_session.py
@max-sixty
max-sixty merged commit e61c0a6 into main Sep 22, 2026
4 checks passed
@max-sixty
max-sixty deleted the fix/ci-35704376889 branch September 22, 2026 19:33
max-sixty pushed a commit that referenced this pull request Sep 22, 2026
)

A deployed turn published its revision, replied, and went back to
listening, and the reader's Threads panel showed one agent bubble with
no words in it. `publish-site` failed on [run
35762205415](https://github.com/max-sixty/leaf/actions/runs/35762205415)
with `reply never became visible in Threads` while every server reading
of that page held the answer. The conversation projection retires a
streaming reply by the response address it was sent to, while every
consumer keys the message on the delivery attempt it was reserved under
— so an answer that does not name that address leaves its own
placeholder standing beside it, the two collide on one key, and the
draft is what gets drawn. The projection now retires the placeholder on
either identity.


`tests/test_render_conversations.py::test_a_durable_answer_retires_the_placeholder_its_attempt_reserved`
reproduces the run's exact DOM — one user message with text, one agent
message with none — on a local page in five seconds, and fails on the
unchanged tree.

## The two identities

`set_stream_reply` reserves a provisional reply under a delivery attempt
and addresses it to a response, and the durable answer names itself by
either. `browser_conversation` appended the placeholder to its thread
while no logged event carried its `responds`, and asked nothing about
the attempt. `readThreadRecords` then keys every message on `attempt ??
id`, which is what the panel draws by, so both records arrive under one
key and only one row survives.

Retiring on either identity states the rule the two were expressing
separately: the placeholder stands in for one delivery attempt sent to
one response, and a logged event naming either is its answer.
`skills/leaf/scripts/leaf/session-lifetime.md` carries that sentence
beside the `stream.reply` row it belongs to.

What I could not read is the failing page's own log — its container is
gone, and leaf.page keys one per reader and release. So the mechanism
here is established by reproduction rather than by reading that turn's
reply event.

## Why the gate could not say so

The failure arrived as a bare DOM snapshot, which fits three causes
equally — a page that stopped asking, one whose read never landed, and
one that took the answer in and drew nothing. The page already paints
what separates them, so `undrawn_reply` now reports the reading the page
last applied against the reading the gate read the answer out of, the
traffic ledger, and each message's `data-mid`, `data-attempt` and
`data-stream-state`. On this failure it would have printed `mid=stream:…
stream=active text=no` beside a matching reading, which names the cause
in one line. This follows `unpresented`, added to the same file for the
same reason on the presentation wait.

## What this does not settle

#925 is open against the other end of the same surface: it stops a
completed delivery answer from losing its response address when the move
is settled during the turn, which is one way an answer comes to name
only its attempt. That PR keeps the address; this one makes the panel
draw the answer whatever happened to the address. They touch different
files and neither depends on the other.

The duplicate key itself stays silent — two messages sharing an attempt
are still one row in `repeat`. This change removes the producer of that
state that the log can reach, so nothing here needs it to be loud, but
it is not an invariant the projection states.

<details><summary>Evidence from the failing run</summary>

The container's own records for event `b9150470` (turn
`01a0ca49-fedb-7e23-8665-20e9623a6fed`) name no fault:
`turn_delivery_bound` at +0.3 s, `fileChange` completed at +19.5 s,
`turn_reply_first_text_published` at +21.5 s, `turn_stream_completed`
`completed` at +21.9 s, and no `turn_reply_commit_failed`. The gate's
own polls agree — `published at 22.8 s`, `replied at 25.1 s`, `answered
at 25.1 s` — and it then waited a further 30 s for the panel.

The next deploy, [run
35763376891](https://github.com/max-sixty/leaf/actions/runs/35763376891),
shows what a healthy page does with the same turn:

```
  published at 18.0 s
  response visible at 19.5 s
  replied at 20.5 s
  answered at 20.5 s
```

`response visible` is the panel drawing the reply and `replied` is the
gate's two-second poll noticing it, so on a healthy page the panel is
painted a second before the gate knows to look. The failing run printed
no `response visible` line at all, which is why the wait is not the
thing to widen.

## Verification

`tests/test_render_conversations.py` and `tests/test_website_server.py`
together: 192 passed, with
`test_the_adapter_takes_its_app_server_with_it_when_it_is_told_to_stop`
failing on this sandbox's missing `AF_UNIX` support, which it does on
the unchanged tree too. All 34 `tests/runtime/` cases and pre-commit
pass.

</details>

Co-authored-by: leaf-agent <[email protected]>
leaf-agent added a commit that referenced this pull request Sep 22, 2026
#925 made narrowing retain a card's disclosure, stating it in its commit
message and in thread-list-view.js's module header. Two nightly cases press
the summary a second time to reopen the card the narrowing used to close, so
that press now closes an open card: the reaction strip's chips and a resolved
thread's Reopen are never visible and both cases time out on them. Each now
asserts the retained disclosure where it used to press for it.
max-sixty pushed a commit that referenced this pull request Sep 22, 2026
…r it (#955)

#952 reports `test_a_comments_quoted_passage_is_in_the_keyboard_journey`
as a runtime regression: the quote still takes focus with
`role="button"` and `aria-keyshortcuts="Enter Space"`, but the shortcut
bar shows the thread's `r reopen` rung where `return to the passage`
should stand. It is neither a runtime regression nor a reading of
`quote.found` — the quote is simply not on screen when the bar is read.

The case resolves the thread, narrows to Resolved on a covering phone
panel, and presses the card's summary to open it. #925 made narrowing
retain a card's disclosure, so the card the reader left open comes back
open and that press shuts it. Reading the card's `open` either side of
the press: `True` before, `False` after. With the card closed the quote
has no box, its command scope leaves the bar with it, and the bar falls
back to the thread's own rung — which is exactly what the case exists to
catch, arriving for a reason the case created itself.

The arrangement now states the retained disclosure instead of pressing
for it. #951 repairs two other cases of this same class the same way, in
`test_render_controls.py` and `test_render_reactions.py`; this is the
third, which #951 read as an open question about `quote.found` and left
alone.

The case does not go green on this branch alone: its later
`to_be_checked()` reading of the status filter is the other half, and
#951 owns that hunk. Applying #951's two-line change locally on top of
this one takes the case to green. The two diffs touch the same test
function at different hunks, thirty lines apart, and merge without
conflict in either order. This is a nightly case, so a pull request's
own `ci` reaches neither half.

Refs #952 — automated triage. The issue's other case, the panel strip's
scroll anchoring, is #954.

Co-authored-by: leaf-agent <[email protected]>
max-sixty pushed a commit that referenced this pull request Sep 23, 2026
…osure and message workflow line (#951)

`ci` on `main` is red. The complete suite on
[fd25b4a](https://github.com/max-sixty/leaf/actions/runs/35758716384)
reported twenty-one failures and two errors; nineteen of those node ids
are already repaired on `main` by #930, #917 and #931. This updates the
readings behind the rest, behind two cases those runs never reached,
behind two more that #925 reddened after that run — one of which #917
had just repaired — and behind the receipt element #933 removed while
this branch was open. No runtime code changes.

`main` moved while this branch was open, so it carries a merge of
`f4107f63` and every claim below is against that merge base rather than
the branch's original `26aa5e20`.

## What moved, and what each case reads now

**#936 gave go-to-threads one destination.** `g T` now selects the whole
panel whichever thread the reader stood on to ask for it.
`test_a_diff_surface_keeps_the_complete_thread_lifecycle_inline` pressed
it from an inline page thread, expected the matching panel card
selected, and walked back out in two Escapes; it now reads `.lf-threads`
and leaves in one. #936 updated the two navigation cases it could see —
this is the third, in a nightly file its gate does not reach.

**#933 replaced the message receipt with one workflow line.** Nothing
under `skills/leaf/assets/runtime/` writes `.lf-receipt` or
`data-receipt-id` any more: a message's status is the `.lf-msg-sending`
span in its head, labelled by `conversation/workflow.js`'s
`workflowLabel` with the claim detail on `title`. The same
`test_a_diff_surface_keeps_the_complete_thread_lifecycle_inline` read
the old element for the root thread on both surfaces and for two later
messages, so after #933 it died there — above the go-to-threads reading
this PR repairs. Each reading now takes the workflow line under the same
head; the identity probes still hold, because the span is retained
across the pickup update on both the inline and panel views.

**#945 made the thread filters toggles rather than one radio group.**
Two cases read the standing status filter with `to_be_checked()`, which
a toggle does not answer, and
`test_inner_state_is_left_before_the_surface_around_it` read the `w`
line as "all threads" where #945 renamed it "clear waiting filter" while
the narrowing stands. Each now reads `aria-pressed` and the current
wording.

**#925 made narrowing retain a card's disclosure.** Its commit message
states it — "Native thread disclosure survives filtering, so an answer
returns where the reader left it unless they selected another
conversation" — and the same commit rewrote `thread-list-view.js`'s
module header to match: "Narrowing retains that disclosure; opening
another named card closes it natively." Two nightly cases press a card's
summary a second time to reopen what the narrowing used to close, so
that press now *closes* an open card:

-
`test_an_ok_on_the_agents_latest_reply_takes_the_thread_out_of_waiting`
presses it after restoring the waiting narrowing, and the reaction chip
under the agent's message is never visible — `Locator.click: Timeout
30000ms exceeded` on `.lf-react[data-token="keep"]`, "element is not
visible". Reading the card's `open` either side of the press: `True`
before, `False` after.
- `test_every_control_the_layer_offers_is_a_box_the_reader_can_hit`
presses it after narrowing to Resolved, so `.lf-reopen` — the one
control that arrangement exists to stand up — reads hidden and the aim
sweep never reaches its own assertion.

Each now asserts the retained disclosure where it used to press for it,
so the contract is stated rather than depended on. A third case in the
same family took the other half of its repair through #955, now on
`main` — see below.

**#932 reset the thread card's inherited top margin and dropped its
chevron column.**
`test_covering_threads_keeps_the_reader_and_their_work_inside` holds the
thread list's raw `scrollTop` equal across the placement crossing, which
reads as the reader's place only while the list can hold that offset at
both placements — a covering sheet's list has a shorter scrollport than
the strip beside the document, so the two have different scroll limits.
With twelve comments the shorter cards left a list whose whole
scrollable range was 63px covering and 17px beside, so the place the
case established sat on the covering limit and the crossing clamped it
to 85 where 131 was recorded. That is Chromium enforcing the lower
limit, not the panel losing the reader's place.

The repair states that premise instead of widening the reading. The
fixture goes from twelve comments to twenty-four, which is what gives
the place headroom at both placements — at twelve the guard fires
immediately, `{'at': 36, 'limit': 36}`. `reading_place()` then takes the
offset together with the list's own limit and fails at the arrangement
unless the offset stands strictly inside it, and each crossing reads it
on the placement it leaves *and* on the one it arrives at, because the
arrival's limit is the one that can clamp. This replaces the
`min(list_at, max_scroll)` clamp #945 put on the same assertion: the
clamp settles the symptom, but it accepts whatever the limit imposes, so
the crossing assertion can no longer fail and the case stops saying what
its docstring says. Bug-backed by forcing a 600px offset before the
second crossing — clear of the covering limit at 617, past the beside
limit at 571 — which now fails at the arrangement (`the list holds no
reading place clear of its limit: {'at': 571, 'limit': 571}`) rather
than as `assert 571 == approx(600)`.

## What this leaves on `main`

- **The quoted passage's shortcut line is the third retained-disclosure
case, and #955 supplied its other half.**
`test_a_comments_quoted_passage_is_in_the_keyboard_journey` pressed the
card's summary after narrowing to Resolved on a 390px sheet, so —
exactly as in the reactions and aim cases above — the press shut a card
the narrowing kept open, the quote lost its box, and its command scope
left the shortcut bar with it. This branch carries that case's
`aria-pressed` hunk; #955 (`fc9d316e`) states the disclosure thirty
lines away in the same function. Neither takes it green alone, and with
both in it passes.
- **#948's strip regression is fixed on `main` by #954** (`13e84e14`).
`test_taking_the_panels_strip_leaves_the_reader_on_the_same_words` — the
reader landing three paragraphs back when the strip arrives — passes
there. Nothing here touches it. #952 tracks both cases with the
per-commit evidence; its remaining half closes when this branch lands.
- **#933's other stale receipt readings are unswept.**
`tests/test_render_startup.py` alone names `.lf-receipt` on twenty-four
lines, mostly as positive readings rather than count-zero guards, and
`test_render_options.py`, `test_render_margin.py`,
`test_render_conversations.py` and `test_render_export.py` carry more.
`test_a_thread_says_what_the_agent_is_doing_about_it` and
`test_a_work_line_says_when_its_claim_has_gone_quiet` both fail on this
branch for the same missing element, and
`test_the_thread_follows_the_decision_that_still_stands` reads the
status filter as `Resolved` where #945 gave it the `Resolved (0)` count
this branch already reads in `test_render_controls.py`. They are the
same class of stale reading as the six here, but a separate sweep in
files this branch does not touch: `main`'s own complete suite on
`f4107f63` is the run that enumerates them, and it was still queued when
this was written.

## Verification

The four touched files run entire on the branch under `--run-nightly`,
on the Linux CI runner, against the branch's own merge base `f4107f63`:
`tests/test_render_anchors.py` at 93 passed, and
`test_render_controls.py`, `test_render_navigation.py` and
`test_render_reactions.py` together at 322 passed with two failures —
`test_taking_the_panels_strip_leaves_the_reader_on_the_same_words` at
`assert 'p8' == 'p11'` and
`test_a_comments_quoted_passage_is_in_the_keyboard_journey` missing
`return to the passage`. `main` has since moved to `13e84e14`, which
settles both: this head merged with it takes those two cases green,
along with
`test_covering_threads_keeps_the_reader_and_their_work_inside`, whose
placement crossings #954's transition reordering could have reached. The
merge is clean. Every case this branch repairs on its own is green, and
nothing else in those four files is stale. `pre-commit` passes on the
changed files.

A pull request runs the everyday gate, which reaches none of these
files, so `ci` here says nothing about them. `main`'s own complete suite
on the merge is the first automatic run that reads them.

---------

Co-authored-by: leaf-agent <[email protected]>
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