Repository navigation
Add expandable agent-written thread summaries - #886
Conversation
leaf-agent
left a comment
There was a problem hiding this comment.
The feature reads well and the claimed path works — I ran the new runtime folds, the three browser cases, the admission and fold tests, and tests/test_interact_product.py (corpus generation and vocabulary floor), all green. Three findings, the first of which I'd want settled before this merges.
A reader's reaction can be a summary endpoint, and taking it back destroys the summary
_summary_error accepts any MESSAGE_KINDS event as from or through, and a reaction is a reply carrying a token, so it qualifies. active_summaries then locates the range by position in thread["msgs"], and build_threads drops a withdrawn message from msgs — so positions.get(event["through"]) comes back None and the summary is skipped whole. undo_error permits exactly the gesture that triggers it: a reader's own reaction, in an unresolved thread, with no reply of its own, is withdrawable at any time. The reader un-reacts and an agent's checkpoint vanishes, re-expanding a range that gesture had nothing to do with.
The rule nothing currently states is that a summary's endpoints are turns, not marks. spoken_turns is the list the panel actually folds, and summary-ranges.js already treats an interior reaction as something to place around rather than an endpoint — the endpoint case is the one nothing covers. Stating it at the append door retires the class: the endpoint can no longer be withdrawn, and the admitted range can no longer disagree with the visible one. summary_hint needs the same list, or it starts naming through ids the door would now refuse — msgs[:-2] can end a run on a reaction, and the len(candidate) >= 8 threshold counts marks as messages today.
Reproduction against the merged tree
A comment, a reply, and a reader reaction on that reply; summarize the root through the reaction; then undo the reaction and re-read active_summaries:
ADMITTED 0 {"kind": "summary", ... "from": "0e877...", "through": "d9391..."}
SUMMARIES BEFORE UNDO [{"id": "8c0f2...", "covers": ["0e877...", "70346...", "d9391..."], "text": "Covered."}]
SUMMARIES AFTER UNDO []
Every ThreadView.present reads geometry, whether or not a summary arrived
The if (prior) block measures the scrollport and calls getClientRects() and getBoundingClientRect() on every .lf-msg[data-mid] in the card before the loop that consumes the result. It runs on inline cards, whose summaries is always the frozen empty array, and on every panel card without a summary. Each card's present measures and then writes DOM, so a panel update interleaves reads and writes card by card. The block is only needed when model.summaries holds an id prior.summaries didn't — gating on that keeps the behaviour and leaves the common present untouched.
A forced-open checkpoint reserves a rail it doesn't render
.lf-summary-originals is a two-track grid whose second track is var(--aim-floor), but #summaryRange renders nothing in place of .lf-summary-refold when range.forced. The track keeps its width: measured on the forced path, gridTemplateColumns reports 361px 24px with one child, and the retained originals end 24px short of the card edge (44px on a coarse pointer) beside a blank gutter. That is the path the feature promises stays open — a covered unanswered question, and a search match. Sizing the rail track from its own content collapses it to 0px when the rail is absent, and the originals line up with the messages around them again.
The two inline suggestions on chrome.css and thread-card.js are the versions I ran: with both applied, the three browser summary cases and npm run test:runtime stay green.
leaf-agent
left a comment
There was a problem hiding this comment.
All three are settled at ad47815, and the first one is fixed above where I pointed it.
Rather than filtering reactions at each site — which is what my suggestion did — admission and hint generation now both read spoken_turns(thread), the list the panel already folds. That removes the second reading of a thread's messages instead of adding a filter to it. Reading it through build_threads(..., withdrawn=taken_back(events)) also makes the withdrawn case fall out of the same call rather than needing its own clause.
What the finding was actually against is now closed, not just the symptom: undo_error refuses a non-reaction message outright ("a message with words in it is said rather than unsaid"), so once a reaction cannot be an endpoint, no admissible endpoint can leave thread["msgs"] afterwards. active_summaries resolving positions against msgs is therefore safe — and it still has to, because covers must slice the full list to keep interior reactions inside the range. The admission test asserts exactly that, with the internal reaction landing in covers while a standing one and a withdrawn one are both refused as endpoints.
The geometry gate and the rail track check out as described: the read is behind a new-summary-ID test, and grid-template-columns computes to a trailing 0px when no rail renders.
What I ran at that head
tests/test_interact_session.py -k summary— 3 passed, covering endpoint admission and the reaction-skipping hint.tests/test_render_conversations.py -k "summary or summaries"— 3 passed, including the zero-geometry-reads assertion and the originals-width check.npm run test:runtime— 32 passed, including the newtests/runtime/summary-ranges.test.mjs.
The full tests/test_interact_session.py also reported three failures unrelated to this diff — test_app_server_observer_connects_over_a_private_unix_socket, test_codex_launch_owns_one_private_app_server, and test_a_reader_move_no_carrier_will_pick_up_messages_its_claude_code_session — each a PermissionError raised from socket.socket(socket.AF_UNIX). That is this sandbox refusing unix sockets; CI's test job is green on the same head.
ad47815 is the only commit since the head I reviewed, and I read it whole, so this covers the current diff.
…ontrols (#884) `ci` on `main` went red at 725fca7 (#878): [`lint` and `test` passed and the complete suite in `nightly` failed on seven cases](https://github.com/max-sixty/leaf/actions/runs/35615354769). One of them, `test_agent_status_leaves_the_margin_transcript_where_the_reader_scrolled_it`, also fails at 9b17c79 and is #879's; #883 has since landed it. The remaining six are the Web Awesome rollout's, and they share one cause: the rollout moved four packages' controls into a vendor's shadow root, and the facts Leaf had stated about the native elements it replaced stayed on the hosts those elements used to be. #878's stated validation was 177 widget browser tests and the shipped runtime tests, and neither reaches the corpus ring floor or the published site. ## What the reader sees **The band is the vendor's, not the layer's.** `theme.css` keeps the ring's thickness in one token so there is one band on the page. A vendored control's ring is painted inside its own shadow root from `--wa-focus-ring-*`, which the Leaf theme did not map, so every vendored control wore a 3px ring next to Leaf's 2px one — and the diff filter field's own rule, `.lf-diff-search:is(:focus-visible, …)`, stopped matching anything at all, because a `wa-input` host is neither the Tab stop nor the box that gets ringed. The vendor also transitions `outline-color`, so the band faded in over 75ms rather than appearing with the focus; `theme.css` states the opposite for the layer's own rules, and a transition in flight is reported as the value the property is leaving, so the band was invisible to any reading taken when it was drawn. The shared theme now states the band — `--wa-focus-ring-style`, `--wa-focus-ring-width: var(--here-ring-w)` beside the `--wa-color-focus` mapping that was already there — draws and names it on the text field's own part, since `--lf-here-ring` does not inherit, and drops `outline-color` from the two vendored controls that transition it. That is one place for every package rather than a rule per host. The diff package loses its dead filter-field rule, and the duplicate `.lf-diff-wrap:focus-visible` #878 added beside the named one — the second latent failure, which the corpus floor reached only once the first was fixed. **The chrome above the evidence grew.** `lf-visual-review` gives a focused review a laptop's height, and both rows of chrome above the evidence take their height from the tallest control in them. A vendored control sizes itself from the vendor's form-control height, eight pixels more than `.lf-btn`'s box, so the queue row and the inspector row each grew by eight and the evidence stage lost sixteen — 366px to 350px, under the 360px the workspace states. The package states those controls' height again, as it did before #878 with `.lf-vr-inspector-button { min-height: 30px }`. Measured on the rebuilt page: both rows back to 30px and the evidence back to 366px. ## What the tests were reading `test_site.py` still read a `wa-slider` through `to_have_value` and drove a `wa-select` with `select_option`; both now use the shapes #878 established in `test_render_widgets.py`. The corpus ring specimen named the `wa-input` host, which is not in sequential keyboard navigation; it now names the field the reader actually stands on, and a second specimen keeps `diff-tools` exhibited for the controls that still wear it. `test_a_copy_speaks_reader_origin_after_live_map_is_removed` is not a Web Awesome failure. It asserts the card move's optimistic paint and then closes the page — but the paint says nothing about the log, and the export opens its own page with only the log to replay from, so a send still in the wire is aborted by the close. That is the arrangement `sending()` exists for, under **State races are arrangements, not probabilities** in `tests/CLAUDE.md`; the gesture is now enclosed in it. Nothing says #878 introduced it: the two failing `main` runs before this one carry only the margin case, so this reads as a latent race that the run lost. ## Two more the floor could not reach The corpus ring floor raises inline on the first specimen it cannot stand on, so it reports one per run and fixing one uncovers the next. Behind the diff filter field, two had collected, and this branch takes both because `main`'s `nightly` stays red on that case otherwise. `lf-shot` upgrades to `wa-comparison` after presentation, and `theme.css` shows the native checkbox only while no comparison is mounted, so `lf-shot > input.lf-shotflip` — the control `RING_CASES` named — is `display: none` on every live page. The reader's stop is the comparison's own handle, which wears Leaf's band because the host maps `--wa-focus-ring` to it, and wears the `shot` name because #892's `#paint()` writes `--lf-here-ring` onto that shadow element inline — `--lf-here-ring` is registered `inherits: false`, so the host's own declaration does not reach it. The specimen moves there. That is #892's, and the same shape as the diff field: a vendored control took over and the reading stayed on the element it replaced. The summary range's expand and refold controls draw the here ring and declare no `--lf-here-ring`, which `chrome.css`'s own header forbids. That is #886's. They share one rule, so they take one name, `summary-fold`, and one specimen on the gallery's summarized thread. The walk collecting its per-specimen failures the way `test_every_base_corpus_tab_stop_has_a_visible_focus_indicator` collects its own would have shown all three in one reading. That is a change against the test rather than against this one, and nothing here makes it harder. ## Verification All six cases pass here, and so do the nightly files they live in or that the theme change could reach: `test_render_widgets.py`, `test_render_visual_review_journey.py`, `test_render_projection.py`, `test_render_controls.py`, `test_render_navigation.py`, `test_render_anchors.py`, `test_render_gate.py`, `test_site.py` — 881 passed, beside two `test_render_export.py` cases that fail in this sandbox for a reason named below and fail identically without this change. `pre-commit run --all-files` is clean, `npm run test:runtime` is 28 passed, and the Web Awesome regeneration is `scripts/vendor.py webawesome` rather than a hand edit of the bundle. That reading was taken at 4bfc53f; with `main` merged in and the two cases above taken, `tests/test_render_controls.py -k "ring or focus_indicator"` is 21 passed and `tests/test_render_conversations.py` is 96 passed, both `--run-nightly`. ## What this does not do The height fix is the visual review's own, because that is the package whose layout contract broke and where the metric was stated before. The general question — whether the shared theme should state the vendored control's box, so any vendored control matches the Leaf button beside it — is left open: taking it here would move the playground, targeting and diff geometry that #878 reviewed, with no failing case to read the result against. Nothing in this change makes that harder to do later. It does not settle what `shot` is declared by. `RING_NAMES` reads declarations off stylesheets, so that name's whole population entry stays `lf-shot:has(> input.lf-shotflip:is(:focus-visible, .lf-focus-visible))` — a rule whose control is `display: none` wherever the comparison mounts — while the credit comes from the handle's inline property. The two halves the floor compares agree on a string rather than on a rule for that one name. Putting the declaration where the paint is, `::part(handle):focus-visible` drawing and naming the band with the `#paint()` write dropped, is the repair; it is left out here because it answers for `lf-shot` the question this PR leaves open for the other vendored families, and the corpus floor reaches its end assertions either way. <details><summary>The failing cases and where each was read</summary> From [the `nightly` job at 725fca7](https://github.com/max-sixty/leaf/actions/runs/35615354769): ``` FAILED tests/test_site.py::test_the_published_notification_example_runs_its_authored_module@site AssertionError: Locator expected to have Value '2' / Error: Not an input element FAILED tests/test_site.py::test_published_visual_evidence_loads_from_its_page@site Locator.select_option: Error: Element is not a <select> element FAILED tests/test_render_controls.py::test_every_base_corpus_tab_stop_has_a_visible_focus_indicator keyboard stops with no visible indication: pr-walkthrough: input#input.control [outline none, shadow none] FAILED tests/test_render_controls.py::test_every_ring_the_layer_draws_is_shown_whole_somewhere_in_the_corpus .lf-diff-search in the page of pr-walkthrough is not in sequential keyboard navigation FAILED tests/test_render_export.py::test_a_copy_speaks_reader_origin_after_live_map_is_removed Locator expected to have attribute '1' / Actual value: None FAILED tests/test_render_projection.py::test_visual_review_gallery_gives_a_laptop_to_the_evidence assert 350.421875 >= 360 FAILED tests/test_render_margin.py::test_agent_status_leaves_the_margin_transcript_where_the_reader_scrolled_it assert {'working': [484, 980]} == {'working': [484, 959]} # #879's, landed in #883 ``` Five of the six reproduce here on `main`. The export case does not — it passed on three consecutive local runs — and was diagnosed from the arrangement rather than from a local red. The band's own reading, taken on the focused diff filter field before the transition was removed: `outline-width` 2px and `--lf-here-ring` `text-entry` from the new rule, with `outline-color` still `rgba(0, 0, 0, 0)` because the vendor's `outline-color` transition had not run. That is what made the rule look inert and is why the transition is part of this change rather than a separate one. Two cases in `test_render_export.py` fail in this sandbox — `test_the_example_preview_command_exports_a_file_that_opens_on_its_own` and `test_exporting_an_example_leaves_the_live_preview_untouched` — because a subprocess cannot launch Chrome here. Both fail identically at 9b17c79 with this change absent, and neither is in the hosted run's failure list. The everyday suite's five failures here are the same sandbox's `AF_UNIX` and umask limits, as [#883 recorded](#883). Catalog previews are not affected: the resting appearance of a vendored control is unchanged everywhere except the visual review, which the catalog does not carry, and a still has nothing focused. </details> --------- Co-authored-by: leaf-agent <[email protected]>
…htly tests around what #886, #889 and #892 moved (#903) `ci` on `main` went red at 7925553 (#892): [`lint` and `test` passed and the complete suite in `nightly` failed on eleven cases](https://github.com/max-sixty/leaf/actions/runs/35650845868). Five of them were #884's and #891's, both since merged, and the visual-review one is green again on today's `main`. This PR is the other six, which arrived together because three features landed between that run and the one before it and none of them was validated against the nightly selection. One is a fault in the layer. The other five are tests still standing where those features used to put things. **The comparison handle's lift is cast in `--shade`.** #892 gave `wa-comparison`'s handle `box-shadow: 0 1px 3px color-mix(in srgb, var(--ink) 20%, transparent)`. The layer states one shadow ink per scheme precisely because a hand-mixed colour can only be right about one ground — a drop shadow written for the light paper lifts a dark one by a fraction of what it promises — and `test_every_shadow_the_layer_lifts_a_box_with_is_cast_in_the_scheme_s_own_ink` is the reading that holds every elevation shadow to the token. The handle now spends it. **#889 made a finding say where it is; two assertions held the old wording.** `render-checks/locate.js` reads an element without an id as `<strong> in <lf-option id=c-bearer>` rather than as the host alone. That is the change #889 made on purpose, so the two nightly assertions that spelled the host move to the stated form. **#892 made the screenshot's checkbox a fallback; a test still pressed it.** `test_a_widgets_native_control_names_the_press_the_platform_makes` scrolls `lf-shot`'s transparent checkbox into view and presses Space on it. Since #892 the theme hides that checkbox the moment Web Awesome's comparison lands, so on the live page there is no control there to scroll to. The test now holds the bundle from outside the page through `primed`, which is what `tests/CLAUDE.md` asks for when the ordering matters — an arrangement rather than a race. It needed a page of its own to do it: `lf-diff` imports the same bundle at the top of its module, so holding it on the combined fixture left that widget unupgraded and the page never presented. The staged-control half of the test now runs on `DIFF_PAGE`, and `NATIVE_CONTROL_PAGE` goes with the split. **#886 added a thread to the gallery; a walk was counting presses to a different one.** `test_a_forced_inline_thread_keeps_its_control_inside_the_margin_budget` pressed `t` twice to walk from the gallery's first thread to the crowded suggestion's. #886's summary example anchors at `bg-thread-checkpoint`, which sits between them, so the second press landed there and the test went on to measure a card three thousand pixels from the cluster it names. The walk now goes to the thread it is for, gives up when it comes back round to one it has already stood on, and waits for each press's arrival before the next. **#892's upgrade arrives after the page says it has presented; a settled-page reading started before it.** `test_a_settled_page_with_a_standing_reaction_stops_rendering_its_margin` counts margin layouts across thirty frames on the gallery and allows one. The gallery carries an `lf-shot`, and moving its two frames into `wa-comparison` lays the margin out twice a few milliseconds apart, at whatever moment the module happens to resolve. The stamps `open_page` waits on do not cover an upgrade deliberately placed after them, so the page was still arriving when the count began. The test waits for the comparison first. ## Verification The six cases pass on this branch and five of them still fail on `main` without it; the sixth is the intermittent one, measured below. `tests/test_render_controls.py`, `tests/test_render_anchors.py`, `tests/test_render_projection.py`, `tests/test_render_margin.py` and `tests/test_render_commands.py` were run whole under `--run-nightly`, along with the everyday suite, `npm run test:runtime` and pre-commit on the changed files. <details><summary>Evidence, and what this leaves</summary> **The settled-page case is intermittent, and the hold is what names its cause.** Without the wait it went red on 2 of 12 local runs, with both layouts landing 6–13ms apart somewhere in the first 700ms of the window — 296/302, 191/197, 521/527. With the wait it is 8 of 8 green. Holding `**/vendor/webawesome.esm.js` from outside the page instead, changing nothing else, is 8 of 8 with no layouts counted at all, which is what identifies the shot's upgrade rather than the two-second heartbeat the test's docstring had assumed. **Attribution.** Each failure was placed by running the case at the commits between the two nightly runs: the margin walk passes at 10d61b2 and 2f8ee1b and fails at 965369b (#886), and `git show 965369b -- examples/developer/feature-gallery.html` is the added `bg-thread-checkpoint` paragraph and its thread. **Not in this PR.** One document change producing two margin layouts on adjacent frames is a doubled render in the thing that test exists to bound; this change waits for it rather than removing it, and whether the upgrade should lay out once is #892's question to answer. The wait itself is the third place a test names, by hand, a widget of its own fixture that is still arriving after the page said it presented — `test_margin_layout_batches_the_composed_page_without_refolding_controls` and `test_unchanged_margin_refresh_cost_is_bounded_by_refresh_count` each wait on `[data-interaction-frame]` carrying `data-interaction-ready`, and this adds `lf-shot wa-comparison`. That is one missing fact rather than three waits: a page-level stamp a deferring widget raises when it lands, which `open_page` could wait through, would settle every fixture at once. It is a change to make on its own terms rather than inside a CI repair, and until it is made the next widget to defer will redden some other test at a wait far from its cause. Separately, four nightly cases are red on today's `main` and are not from this run — `test_a_thread_beside_its_cluster_takes_the_room_to_the_visible_edge`, `test_the_margin_groups_meanings_at_one_destination_without_moving_the_page` and `test_a_diff_surface_keeps_the_complete_thread_lifecycle_inline` in both schemes. All four pass at 7925553 and fail at 39d9cad, so they are #895's, and the run that reaches them will be that commit's own. **Environment note.** Six everyday cases and the four browser-launch cases in `tests/test_render_commands.py` fail in this CI sandbox on a clean tree as well — no `AF_UNIX`, no installed Chrome for the subprocess gate — and all of them were green in the `test` job of the run under diagnosis. </details> Co-authored-by: leaf-agent <[email protected]>
Long conversations can now replace an older contiguous exchange with an agent-written summary in the Threads panel. The summary uses a quiet label and italic prose; readers can reveal the original messages and fold them again with a keyboard-accessible control along their right edge. The current exchange stays visible.
Leaf suggests summarization in long-thread delivery context, and
leaf conversation summarizerecords explicit first and last message IDs in the existing append-only log. Agents can replace or extend summaries as the discussion grows. Original messages remain available; edits invalidate summaries, overlapping summaries supersede earlier ones, and summaries never answer questions or resolve threads. Search, direct message links, and outstanding questions reveal covered originals.The core gallery includes a working example, and the agent reference documents the workflow. Validation after integrating
main: 1,211 everyday tests, 6 focused summary integration tests, 32 runtime tests, and pre-commit. Earlier validation covered 96 conversation browser tests, 57 browser-framework tests, light/dark visual checks, and a complete 81-page website build. API admission tests cover invalid, cross-thread, and withdrawn endpoints as well as successful projection.