Repository navigation
Unify agent activity across Leaf surfaces - #322
Conversation
…-activity # Conflicts: # skills/leaf/assets/runtime/banner.js
leaf-agent
left a comment
There was a problem hiding this comment.
Three places where the new canonical fold still lets two surfaces disagree, plus one hole in the "browser only asks at next_transition_at" invariant. Inline.
The first one is worth the most attention: pending sits above the status["state"] == "working" branch in the precedence chain, so any un-picked-up reader move suppresses the page-wide turn-ended reading. test_banner_reports_whether_anyone_is_attending was changed from serve(LONG_PAGE, comments=1) to serve(LONG_PAGE), which is what let the "left when its turn ended … Nudge it in the terminal" assertions keep passing — the combination they used to cover (a reader comment standing while the turn has ended) is no longer exercised anywhere.
How I checked the first two
Calling canonical_activity directly against the merged tree:
# working declaration 6m old, turn closed 5m ago, one unsettled "sent" comment
with pending comment: pending dropped=False count=1
without comment: away dropped=True
# session_alive None, quiet working declaration, one "active" interaction
kind=unheld held=False
interaction: {'phase': 'active', 'detail': 'looking at the numbers', 'agent': 'Claude', 'quiet': True}
Heads up on overlap: #320 also edits examples/ship-review.jsonl, so the new 91f7c2a8 reply and that PR's screenshot event will want reconciling in whichever lands second.
…-activity # Conflicts: # tests/test_render_controls.py
leaf-agent
left a comment
There was a problem hiding this comment.
The four threads from the last pass are addressed: pending no longer displaces the turn-ended reading, held is computed once and passed into _canonical_interactions, the status deadline covers every non-idle declaration, and claimActivity is indexed by target so a consumed thread claim keeps its quiet. One new thing on the branch that replaced pending, inline.
Unrelated: #323 also touches living-margin.js, registry.json, and the generated examples/corpus.html, so whichever lands second will want a corpus regeneration on top of the merge.
tests/test_site.py::test_the_product_site_accepts_a_leaf_comment fails for me on this head, but it fails identically on the merge base 7411a841 with none of this PR applied, so it isn't from here.
leaf-agent
left a comment
There was a problem hiding this comment.
Four test_render_* tests are red on c8c28bef and green on the merge base 7411a841, all deterministic — I ran each one alone, on both trees, several times. They are nightly-marked, so the PR's test job never selects them and neither does the uv run pytest tests in the Verification section; the first run is after main moves, where running-tend treats a red ci as already live.
| test | first red at | reading |
|---|---|---|
test_render_startup.py::test_a_thread_says_what_the_agent_is_doing_about_it |
f3d6a854 |
assertion is stale, behaviour is right |
test_render_startup.py::test_conversation_timestamps_age_without_new_state |
8869538a |
fixture no longer arranges a quiet page |
test_render_margin.py::test_an_acknowledgment_uses_status_until_an_active_claim_restores_a_disclosure |
84be6f16 |
fixture moves the browser clock; the word now comes from the server |
test_render_margin.py::test_the_shipped_long_thread_opens_beside_its_source_in_the_right_margin |
f3d6a854 |
cardScroll is 14, not 0 |
The first two are inline, with the one-line fixes I verified. The test_render_margin.py file isn't in this PR, so those two are below rather than inline — happy to push both if you want them.
test_an_acknowledgment_uses_status_until_an_active_claim_restores_a_disclosure. The marker's word came from waitingForPickupSince(receipt.ts) in acknowledgments.js, a clockValue, so page.clock.set_fixed_time(+3m) plus an lf-actions repaint reached it. This PR deletes that helper and reads receipt.phase === "waiting", which only the server fold sets — and set_fixed_time doesn't run timers, so the tick that would ask() at next_transition_at never fires and the label stays Sent,. Nothing is wrong in a real browser, where time actually passes and the read lands; the fixture now has to move the server's evidence (backdate the send) rather than only the browser's clock. Note the same test's assert_status("Waiting for pickup", "Sent 3m ago") needs both halves at once, and Sent 3m ago still ages locally — so whichever way it advances time, it has to advance it for both.
test_the_shipped_long_thread_opens_beside_its_source_in_the_right_margin. assert geometry["cardScroll"] == 0 gets 14: the margin preview opens already scrolled by 14px. Green at 84be6f16 and red at 7e011338, so it arrived with f3d6a854. I didn't isolate the cause beyond that.
Reds I ruled out as pre-existing
Each of these fails identically on the merge base 7411a841 with none of this PR applied, so they aren't from here:
test_render_startup.py::test_a_failed_thread_surface_returns_its_threads_to_core_fallback(all 8 params)test_render_controls.py::test_page_fixtures_have_no_serious_wcag_a_or_aa_violations[feature-gallery]test_render_conversations.py::test_a_coined_class_cannot_reach_the_chromes_rules(#325)test_render_widgets.py::test_an_ask_arrival_starts_with_the_context_that_frames_it(#315)
Green on this head: tests (889 passed), test_render_export.py, test_render_pages.py, test_render_options.py, test_render_commands.py, test_render_outbox.py. I did not run test_site.py.
Mechanism for the timestamps test
8869538a is right about the hole it closes — I confirmed the new test fails on 7e011338 at exactly the predicted status.ts + 16m, and that every clock-driven transition in the fold now publishes a deadline. But an idle declaration written moments ago now publishes next_transition_at = status.ts + 15m, and session_model.cmd_status(d, "idle", "") is what the test uses to quiet the page. Jump the clock 3h, state-feed.js sees activityTransitionDue, ask() fires, and state-application.js calls observeServerNow(state.now) on the accepted reading — which resets clockSkew to the real offset and snaps every ago() back to just now. Backdating status.ts past WORKING_GRACE leaves no deadline pending and restores the arrangement; with that change both tests pass.
|
Addressed the two review-body findings as well. The acknowledgment test now advances the server-owned activity clock and reads the canonical waiting phase through
|
|
Three of the four are fixed on The card's steady scroll position after opening that thread is 14, on both the first open and the reopen. The two reads that report otherwise are early: the first-open The mechanism is What changed is the fixture, not the card: That means "each reading starts with its first comment" and the composer landing are now in tension whenever a thread overflows, which is the choice worth making explicitly rather than at whichever read lands first:
One environment caveat: the overflow is 21px, so a machine whose fonts render that thread a little shorter never overflows and the whole file passes. That is the likeliest reason it was green for you, and it also makes How I measuredProbe on this head, opening the same marker as the test: Same probe with The four cases on |
leaf-agent
left a comment
There was a problem hiding this comment.
Three of the four reds from the last pass are green on dde77ee9 — I ran each alone with --run-nightly -n0 on ubuntu-24.04, the same image ci.yaml gives the nightly job. The fourth is still red, and the runtime change that was meant to close it does not reach the state the assertion reads. Both inline.
test_the_shipped_long_thread_opens_beside_its_source_in_the_right_margin fails at assert geometry["cardScroll"] == 0 with 14, exactly as before, and it is a regression from this PR: on the merge base 7411a841 the same test passes and the card settles at 0. Reproduced three times on this head, deterministically.
The mechanism is that showPreview is not the last thing the marker press does. pressMarker → openThreadChoice → togglePinned calls showPreview(entry, button) and then landInConversation(reply), which reaches revealConversation's scrollIntoView({behavior: scrollBehavior(), block: "nearest"}) on the card. The new preview.scrollTop = 0 runs inside showPreview, so the landing scroll overwrites it a moment later. The card overflows in the first place because 9ad50941 added the 91f7c2a8 reply to examples/ship-review.jsonl; that is what pushed the reply box out of view and made the landing produce a scroll where the merge base had none. Worth knowing that #320 adds a screenshot event to the same thread, so whichever lands second grows the card further.
So the two behaviors in the tree now contradict each other: the comment on the new line says each reading starts with its first comment, while togglePinned deliberately lands the reader in the reply box. Which one the card should do is your call — but only one of them can be true, and today the landing wins.
How I checked
Overriding the card's scrollTop setter to capture the stack, then reading the settled value:
=== scrollTop after settling: 14
--- set 0
at showPreview (living-margin.js:2797)
at togglePinned (living-margin.js:2814)
at openThreadChoice (living-margin.js:2890)
at HTMLSpanElement.pressMarker (living-margin.js:1968)
--- scroll event -> 7
--- scroll event -> 12
--- scroll event -> 14
=== activeElement: lf-ui|TEXTAREA
Same probe on the merge base 7411a841 prints first open settled: 0, no scroll events.
Green on this head, run alone: test_render_startup.py::test_a_thread_says_what_the_agent_is_doing_about_it, test_render_startup.py::test_conversation_timestamps_age_without_new_state, test_render_margin.py::test_an_acknowledgment_uses_status_until_an_active_claim_restores_a_disclosure. The acknowledgment fixture's now_iso patch across served_page, events_model and service_model holds through the later record_pickup assertions too — the pickup event and the server's now move together, so just now stays right.
leaf-agent
left a comment
There was a problem hiding this comment.
The landing is the choice I'd have made, and showPreview is coherent without the reset — both call sites (togglePinned, openInlineThread) follow it with a deliberate scrollIntoView, so no open leaves the card holding a previous thread's scroll. The assertion that replaced cardScroll == 0 reads mid-animation, though; inline, with the measurement.
Happy to push the one-line fix if you want it.
Leaf previously projected interaction receipts separately from page-wide presence. A reader move could therefore say “Picked up” while the banner still reported an old check-in or said Claude awaited the reader. This change derives one server-side activity reading and sends it to every consumer.
What changed
Verification
pre-commit run --all-filesuv run pytest tests(895 passed)uv run pytest -n0 -q tests/test_render_margin.py(78 passed)test_render_startup.pyandtest_render_margin.py(4 passed)