Skip to content

Put comparison watchers and lf-diff's inline patch on the one return rule - #2568

Merged
max-sixty merged 3 commits into
mainfrom
agent-aa1de8ec6e2c469da
Oct 12, 2026
Merged

max-sixty merged 3 commits into
mainfrom
agent-aa1de8ec6e2c469da

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

The last two places that kept their own return rule now paint through readingPaint, the one rule #2565 settled: on return, a paint draws again only when its reading changed while away, or when the departure cut a paint short. These are items 66 and 67 of the Lit survey follow-up review, numbered in that review rather than as GitHub issues.

Behaviour that changed

  • Item 66: a comparison watcher survives a throw. watchComparison (version.js) read on every return inside whileConnected's start. A callback that threw there made watchOwner retire the subscription for good, so a tab's or settled ask's Δ marks stopped following the comparison. Comparisons now carry a generation, advanced by announceComparison() at each of the two places the comparison changes. watchComparison keys readingPaint on it: each lf-comparison event reads at once, and a connection reads on the following microtask, outside the connection. A return to an unchanged comparison reads nothing. A throw is reported once and the next comparison change reads again. module-authoring.md "Reading version changes" says so.
  • Item 67: lf-diff's inline patch uses the shared rule. readingPaint is now exported from widget-api.js and documented under "Connection lifetimes". lf-diff's inline patch paints through it, keyed by the patch text, and its settled flag from Keep a failed widget failed when it returns, and make whileConnected/frameFor the one widget lifetime API #2503 is gone. No other package or example widget keeps a copy of the rule. lf-file-editor re-reads its file on each connection, but that is an external re-read with no reading key, not a copy.

Measured

Hand-written source excludes tests and Markdown.

Item Source Tests
66 version.js +23 / −11 +50 / −0
67 widget-api.js +8 / −1, lf-diff.js +12 / −6 0
Total +43 / −18 +50 / −0

Validation

  • test_a_comparison_mark_that_failed_on_return_keeps_following_the_comparison fails on main: the decision tab's mark stays empty after a later comparison. It passes here, and checks the throw is reported once.
  • These pass: all of test_render_options_settled.py and test_render_diff_controls.py, including Keep a failed widget failed when it returns, and make whileConnected/frameFor the one widget lifetime API #2503's test_a_patch_that_failed_stays_failed_when_its_diff_returns; the diff or tab selection of test_render_widgets.py (66 tests); the margin comparison test and two comparison-selection tests in test_render_anchors.py; and pnpm run test:runtime.

This was written by Claude Code on behalf of max-sixty

max-sixty and others added 3 commits October 12, 2026 02:58
…rule

A comparison watcher whose callback threw on its owner's return used to lose its
listener for good, so a tab's or settled ask's Δ marks stopped following the
comparison. `watchComparison` now paints through `readingPaint`, keyed by a
comparison generation that each announced change advances. A return reads again
only when the comparison changed while away, and the connection's read runs on the
microtask after it, so a throw is reported once and the next change paints again.

`readingPaint` is now part of the package API (`widget-api.js`), documented in
module-authoring.md "Connection lifetimes". lf-diff's inline patch paints through
it, keyed by its text, and its hand-made `settled` copy of the rule is gone. No
other package keeps a copy.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…-authoring.md

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 1ace63b into main Oct 12, 2026
3 checks passed
@max-sixty
max-sixty deleted the agent-aa1de8ec6e2c469da branch October 12, 2026 10:19
max-sixty added a commit that referenced this pull request Oct 12, 2026
version.js conflicted only in its imports: this branch's rendering and
arrivals imports for continuity, and #2568's readingPaint for comparison
watchers. Both kept; the rest merged cleanly.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 12, 2026
… subscription (#2575)

`readingPaint` (presence.js) now holds the one failure rule for every
paint that goes through it, whether a call, `refresh()` or a clock
repaint started the draw. A draw that throws or rejects while its owner
stands is reported once, as a page error naming its owner. The failure
never reaches the caller as a throw, so no subscription ends on it, and
the next changed reading draws again. A draw that the owner's departure
cut short is not reported, because the return draws it again. Before
this, each caller handled a failed draw its own way, and `watchData`
ended its subscription for good. This closes issue 71 of the Lit
follow-up review (that review's numbering, not a GitHub issue).

## Behaviour that changed

- **A data widget recovers from a callback that failed on its return.**
If a source changed while its widget was away and the `watchData`
callback threw on the return, `stop()` ended the subscription for good,
and the widget never drew a later source. The failure is now reported
once and the next reading draws. Removed from data.js: its
catch-and-report, `updateSafely`, the `mounting` flag, the stop-on-mount
path, and the comment that recorded the permanent stop as deliberate.
The new contract replaces that comment. Reports now read `paint failed
for lf-feed#id` in place of `data subscriber failed for … input … source
…`.
- **A projection reading that rejects is reported.** Before,
`readingPaint`'s settle handler swallowed the rejection, so an async
`watchProjection` / `watchQuestions` / `watchReports` / `watchHistory`
failure never reached the agent. It is now reported like a throw. A
throw also no longer escapes the microtask as an uncaught exception.
- **`watchComparison` reads synchronously on connection again.** #2568
added a microtask so that a throw could not fail the connection. A throw
can no longer escape the paint, so that step is gone.
- **Widget controller: one report and one box, as before.** A failed
`renderState` is reported by its paint. The region falls back to the
same fail-soft box, `failSoftUnreported`. The presentation coordinator
now reports through `reportCarried`, so a failure the paint already
reported is not reported again as `Presentation failed`. A failure no
paint saw is still reported under that heading. The report's text
changes to `paint failed for lf-local#id: <lf-local> renderState threw:
…`.

- **Clock repaints follow the same rule.** A reading paint's clock
repaint now goes through that guard. `tickClock` reports through
`reportCarried`, so it reports only failures no paint has already
reported, such as a plain `clocked` paint's. Those still read `clock
paint failed`.

`module-authoring.md` now describes the rule in "Connection lifetimes",
in the `watchData` readiness paragraph, and in the `watchComparison`
entry.

## Measured

Hand-written source covers the runtime JS. Tests and Markdown are
excluded.

| | Added | Removed |
|---|---|---|
| Source | 111 | 88 |
| Tests | 114 | 34 |

## Validation

- `test_a_subscriber_that_failed_on_return_draws_the_next_reading` fails
on `main`: the drawn readings stop at `changed-away`. It passes here and
checks for exactly one report.
-
`test_a_returning_projection_subscriber_reads_again_only_where_its_departure_cut_the_paint`
now includes a rejecting reader (`watchHistory`). On `main` that reader
is never reported.
- New cases in `arrivals.test.mjs` fail on the first version of this
change and pass here. One is a clock repaint that throws, which is now
reported once and names its owner. The other is a paint abandoned on
departure, including one a later draw had already overtaken. That paint
is drawn again on return and not reported.
- These pass: the runtime suite (`node --test tests/runtime/*.test.mjs`,
368 tests); `test_render_startup.py`, `test_render_anchors.py` and
`test_render_projection.py` selected on data, projection, subscriber,
watch, comparison and clock (207 tests); the controller and coordinator
failure tests in `test_render_application_boundary.py`,
`test_render_outbox.py`, `test_render_threads.py`,
`test_render_widgets.py`, `test_render_controls.py` and
`test_render_navigation.py`; and the lf-diff, lf-tabs, lf-text-document
and options-settled cases (90 tests).

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 12, 2026
…parison paint to one report (#2588)

`main`'s push `ci` has not completed green since #2568. The last two
completed runs
([38235572771](https://github.com/max-sixty/leaf/actions/runs/38235572771)
on 1ace63b,
[38244446941](https://github.com/max-sixty/leaf/actions/runs/38244446941)
on e5aca3e) failed three `main`-tier tests. Two are already fixed on
`main`; this PR fixes the third and tightens one of the fixed ones.

## Behaviour that changed

- **`test_an_export_keeps_its_quiet_words_off_screen` runs again.**
#2555 removed the `x-paints` key and the `state` property from
`declared_reading_package`, but this test still wrote `<lf-reading
state="done">`, so `page check` refused the page before the export ran
(`Additional properties are not allowed ('state' was unexpected)`). The
test is `main`-tier and lives in a file #2555 did not edit, so
`--changed-since` never selected it. It now takes its quiet word from a
highlighted `lf-code` line, which the default package draws, and drops
the fixture. With `.lf-quiet`'s clip removed from the theme, the test
fails, as it did before.
- **A failed comparison paint must be reported exactly once.**
`test_a_comparison_mark_that_failed_on_return_keeps_following_the_comparison`
counted only `leaf:` reports, and its comment expected a second,
uncaught record of the throw. Since #2575, `readingPaint` reports the
failure once and nothing escapes. On current `main` the page records one
error, `leaf: paint failed for lf-tabs#views: …`. The test now requires
exactly that error. A paint that also rethrows from a microtask fails
it.

The other two failures need nothing more.
`test_a_reaction_on_a_visual_part_names_that_part` was fixed by #2582,
and the comparison test's arrangement by #2581.

## Evidence

- On `main` 4f81e81, the export test fails with the refusal above.
With this change it passes.
- `leaf-dev flake` (18 copies, six at a time) passed 18/18 for the
export test, the comparison test and the reaction test. A flake run of
`tests/test_render_words_watch.py` also passed 18/18 for every test.
That file's `TypeError: Cannot read properties of null (reading
'present')` did not reproduce on `main` and is not in either failed
run's log.
- The other two `declared_reading_package` tests still pass
(`test_the_render_gate_catches_a_declared_word_that_never_reached_the_page`,
`test_a_word_the_revision_adds_to_a_surviving_element_is_said`).

Hand-written source delta: 0 lines. Test delta: +10 −12
(`tests/test_render_export.py` +8 −10,
`tests/test_render_options_settled.py` +2 −2).

> _This was written by Claude Code on behalf of max-sixty_

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 12, 2026
Main exported readingPaint from presence.js (#2568), which lf-diff imports and
module-authoring.md documents, so it stays an authoring export; this branch's removal
of renderRetired and textNodesUnder stands. Main also split a margin control's
receipts out of presentContributionEntry into presentContributionReceipts (#2522), so
the reference documents both.

Co-Authored-By: Claude Opus 5.5 (1M context) <[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