Skip to content

Stand a send's landing down for a selection made behind it - #15

Merged
max-sixty merged 3 commits into
mainfrom
fix/ci-32320754646
Aug 20, 2026
Merged

max-sixty merged 3 commits into
mainfrom
fix/ci-32320754646

Conversation

@leaf-agent

@leaf-agent leaf-agent commented Aug 20, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Run 32320754646 went red on main: test_browser_and_file_captures_stop_at_the_same_widget_fences reached its fourth passage, selected it, released, and the 💬 never came up — Locator expected to be visible / Actual value: hidden, re-asked thirteen times over the full five seconds.

The button was right. A comment's send ends by handing typing to the thread it became — threadsBox.querySelector('.lf-thread[data-id=…] textarea').focus() — and a send is a round trip, so that step lands whenever the server answers. Focusing a box collapses whatever the page had selected. On a loaded runner the third passage's response landed after the fourth passage had been picked out, so by the time the mouseup's queued step read the selection there was none, and updateFab left the button down. Nothing re-decides it until the reader gestures again, which is why the failure reads as a permanent hidden rather than as a slow one.

That is not only the suite's shape: a reader who comments and then picks out their next passage on a slow connection loses the selection the same way, with no surface saying why.

Reproduction

Reproduced on this runner by throttling the page 20× through CDP (Emulation.setCPUThrottlingRate) and running the same four-case loop repeatedly. The failure lands on whichever case the previous send's response overtakes, and the page states the cause at the moment of failure:

case 4 #fence-option > lf-chip: {'sel': '', 'collapsed': True,
 'anchorParent': '<div class="lf-thread" tabindex="-1" data-id="55cffa94">…',
 'fab': 'none'}

The selection the test set in the chip is gone, collapsed into the panel thread the send had just focused. A selectionchange trace confirms the order: the test's selection, then the focus, then nothing. Across 3 × 8 throttled runs: 4 failures of that shape before the change, 0 after.

Solution

A send's focus landing stands down where the reader has a live page selection — landTyping, beside pageSelection in leaf.js. The reasoning is the one already written two lines above the composer's landing for a later edit ("A later edit is still the reader's standing gesture"); a passage picked out while the send was in the wire is the other gesture a reader can have standing, and it has less recourse than the edit, since nothing re-decides the 💬 for them.

Stated once and used at all three boxes a send can land in — the composer's new thread reply box, the general box, and a thread's reply box — because it is one fact about a send landing, not three. wireReply's own comment already says the focus landing "is the thread's and is therefore stated once"; fixing only the site CI happened to name would have left two identical steals standing.

The panel has two more post-round-trip landings, on a resolve and a reopen, and those are deliberately left alone: measured, Chrome collapses the page selection only where the landing takes a caret — a button, a select, and a checkbox all leave it standing, exactly as a tabindex="-1" div does — so a thread node takes no passage. The line is the box rather than the round trip, and landTyping's comment says so, since that is where the next reader meets the question.

This is a product fix rather than a wait added to the test: the test races nothing the runtime does not also let a reader race.

Testing

test_a_held_comment_send_leaves_the_passage_picked_out_behind_it states the race instead of running for it, per tests/CLAUDE.md's "A race this machine won't lose is stated rather than run for": the comment's POST is held in the wire with page.route, the reader picks out the next passage behind it, the hold is released, and the page is then asked as the reader would ask it — the words are still selected, and c opens the composer on them rather than on the general box.

Bug-back: with landTyping's guard removed the new test fails at the first assertion (assert '' == 'A short second passage.'), so it is not passing on the button's stale rendering.

Full suite (uv run pytest tests --run-nightly) and pre-commit run --all-files both green on this branch.

Two other tests went red on neighbouring runs and are not this: the draft-staleness cluster (#6, merged) and test_a_page_nobody_has_touched_scrolls_from_the_keyboard (#13).


Automated fix for failed run

A comment's send ends by handing typing to the thread it became, and a
send is a round trip, so that step lands whenever the server answers.
Focusing a box collapses whatever the page had selected, so a reader who
picked out their next passage while the send was in the wire had it taken
back — and nothing re-decides the 💬 until they gesture again, so the words
in front of them simply stopped being something to comment on, with no
surface saying why. On a loaded runner that is what a red main looked like:
the fence-capture test selected its fourth passage, released, and waited out
five seconds for a button the runtime had already decided against.

`landTyping` is that step with the reader's standing gesture read first —
the same reading the composer already makes of a later edit two lines above
it. Stated once and used at all three boxes a send can land in, because it
is one fact about a send landing rather than three; `wireReply` had already
written that the focus landing is stated once.

The new test states the race rather than running for it: the POST is held in
the wire, the next passage is picked out behind it, and after the release the
page is asked as the reader would ask it — the words are still selected, and
`c` opens the composer on them.

@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 guard reads right and sits in the right place: openComposer ends with composerInput.focus(), so an ordinary send still lands with the page selection collapsed and the three existing landing assertions (.lf-thread textarea focused after a design-mode comment, and the general box's two) keep meaning what they meant. The held-send test follows the page.route recipe correctly — _until counts the request out before the held[0] reach, per the norm that reach is written under — and it bug-backs on both assertions, since with the guard gone the c press would type into a focused reply box rather than open the composer.

One question on the PR's own terms, inline.

Comment thread plugins/leaf/skills/leaf/assets/leaf.js Resolved
A review on the branch counted five post-round-trip focus landings and
asked after the two `landTyping` leaves alone. Measured: Chrome collapses
the page selection for a form control and leaves it standing for a
`tabindex="-1"` div, so a resolve and a reopen land the reader on a thread
node without taking the passage they had picked out. The line is a box, not
a round trip, which is what the name was already saying — now written where
the next reader meets it.

@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 comment lands the right claim in the right place — the two thread-node landings are now answered where the next reader meets the question, and the description's "three of five" is narrowed to match. One correction inline: the measured mechanism is narrower than the sentence that carries it.

I re-measured in Chrome (channel="chrome", same build the suite uses) with a paragraph selected, focusing each target with focus({preventScroll: true}):

landing selection after
<div tabindex="-1"> stands
<button> stands
<select> stands
<input type="checkbox"> stands
<textarea> collapsed
<input type="text"> collapsed
<div contenteditable> collapsed

So "form control" is the wrong cut — three of the four form controls leave the selection standing. What collapses it is a landing that takes a caret. That matters here because the sentence is the one defending the function's name: landTyping is named for typing, and typing is the mechanism, so writing the cause as form-control-ness makes the name read as a near-miss for it rather than as exactly it.

The same phrasing is in the PR description's Solution paragraph ("focus lands on a form control") and in the resolved thread above — worth the same narrowing in the description, since that is the other place this gets re-derived from.

Comment thread plugins/leaf/skills/leaf/assets/leaf.js Resolved
The comment gave form-control-ness as what collapses the page selection,
which is wider than the measurement behind it: re-measured in the suite's
Chrome, a button, a select, and a checkbox all leave a selected paragraph
standing, exactly as the `tabindex="-1"` thread node does. Only a landing
that takes a caret — textarea, text input, contenteditable — collapses it.

The narrower reading is also the one the sentence is there to defend:
`landTyping` is named for typing, and typing is the mechanism.
@max-sixty
max-sixty merged commit 2a1ec4a into main Aug 20, 2026
7 checks passed
@max-sixty
max-sixty deleted the fix/ci-32320754646 branch August 20, 2026 08:05
max-sixty pushed a commit that referenced this pull request Sep 18, 2026
`notes/workspace-followups.md` has been presenting finished work as the
plan since 9 September. It opens with "Start #2, #3 and #4 as one
coordinated contract batch; run the review-queue simplification #8
alongside it" — all four of those shipped that week — and carries
thirteen briefs, each with a live "Next task" and "Done when", for work
`TODO.md` dropped as complete. This removes them and leaves the six
`TODO.md` still links: #11, #14, #19, #20, #22 and #23.

The trim follows the convention #666 set and the reason `CLAUDE.md`
gives for it: a note is never a second specification for shipped
behavior. #666 removed #6, #7, #16 and #17 the same way, rewriting the
two `Owner / dependencies` lines in surviving briefs that named them; it
simply did not reach the rest.

Each removal is evidenced by the commit that took the item out of
`TODO.md`, not by a reading of the current code:

| Brief | Removed from `TODO.md` by |
| --- | --- |
| #1, #3, #5 |
[`0f7f06a6`](0f7f06a)
— "Completed workspace items #1, #3, and #5 are removed from `TODO.md`"
|
| #2, #4, #8, #9 |
[`28b5da99`](28b5da9)
— "the completed #2, #4, #6, #8, #9, and #17 backlog entries are removed
while preserving the deferred evaluation work" |
| #13, #15 |
[`6df40353`](6df4035)
— "closes three bounded workspace follow-ups" |
| #10, #12 |
[`c9eaa2c6`](c9eaa2c)
— the continuation cue and the adaptive Threads placement |
| #18, #21 |
[`e46c8b93`](e46c8b9)
— the monitoring workspace and its package-owned root |

Alongside the briefs, three group headings are now empty and go; the
`Suggested work packages` table loses the rows whose whole scope landed;
and four cross-references that named a removed ID are rewritten — #14's
dependency on the Threads-placement experiment, #20's ordering behind
#8, and the two sentences in `Reproduction record` and `Browser
evidence` that pointed at briefs no longer here.

#14 needed more than a rewritten pointer. The experiment it waited on
was settled in two steps, and only the first removed an ID: [PR
#520](#520) kept the adaptive
placement and deferred the modal-focus work to #24, which landed in [PR
#536](#536) as inertness, dialog
semantics and focus containment for a covering workspace. That is the
surface #14 exists to verify, so its `Done when` — "Avoid imposing a
modal focus trap on a nonmodal panel" — described the containment #536
shipped as the defect to avoid. It now states the containment the
shipped modality requires, and the dependency line names both
settlements.

The dated evidence sections themselves stay. They are the record of what
was read in a browser on 8 September, not a plan, and the note's own
header scopes them to that date.

No test covers `notes/`, and this changes no behavior, so there is
nothing to regress. `pre-commit` passes on the file; the `TODO.md` →
note anchors all still resolve, and no surviving text references a
removed ID.

---------

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Sep 24, 2026
…a Rust sort film example (#1134)

Closes #15.

`lf-code` can now quote an excerpt of a longer file under that file's
own line numbers. The new `lines` attribute uses the range grammar `hi`
already uses (`lines="1505-1507,1520-1527"`):

- The gutter shows those numbers, and a gap between ranges draws an
elided row ("⋮ 12 lines").
- `hi`, a note's `at`, and another widget's indication key all name
lines by those numbers. A range may span a gap.
- Without `lines`, the body is lines 1..N, so quick snippets are
unchanged.
- The gutter numbers and the elided rows are painted by CSS from data
attributes. They never enter the clipboard, and no anchor can land on
them.
- The gutter widens to fit the largest number. `--lf-code-gutter` is a
registered `<length>`, so a note beside the code stays aligned with it.

**Validation.** A new registry key, `x-numbering`, names the attribute
that numbers a data body. `version check` refuses:

- a numbering whose count differs from the body's line count;
- ranges that are backwards or not ascending;
- a line 0;
- any `x-lines` reference to a line the excerpt does not show.

**Named lines, not added.** A line is addressed only by its number. A
driver that wants readable names keeps a name→number table in its own
code. The worked example does this.

**New example.** `examples/rust-sort.html` explains Rust's 2016 merge
sort. The sort film plays beside three `lf-code` excerpts of `slice.rs`.
Each step calls `indicate()` with the source line it runs, and the
matching excerpt lights that line. The example is in the catalog, and
the preview stills are refreshed. `feature-gallery.html` now uses
`lines` too.

> _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.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Nov 6, 2026
…are found by one automaton; an inline edge is no gap between words

The draft (#12). Placement tracked what a posted thread's anchor depends on and nothing
of the draft's, so on a page with no threads yet a script that rewrote the paragraph
around a sentence the user was commenting on took the draft's mark off the sentence
until the next presentation, and `pendingAt()` returned the passage in the old, now
disconnected node. The draft's anchor now stands among the threads' under a key no
thread bears: its quote in the index, its section among the ids, its text nodes among
those a rewrite settles at once. Placement tells those who hear it whether the draft
moved, and the anchor paint repaints the draft's mark from `pendingAt()`.

Ids in staged trees (#13). The watcher read the ids a change added or removed with a
light-tree `querySelectorAll`, so a widget whose shadow stage held a section, replaced
by one staged with the same section before it was put in place, left a section-only
thread on the disconnected old element. Ids are now read in the light tree and the
declared shadow trees an id is looked for in (`shadowRootsIn`, as `elementById` does).

One automaton (#14). The index found copies by hashing each quote's first 16 letters
and then its whole length, so at each place the first hash matched it tried every
length the quotes sharing it came in: 800 quotes of growing length sharing a run of x's
took 4.3 s in Chromium and 9.6 s in Firefox, about 8x per doubling. An Aho–Corasick
automaton over the quotes' letters (`automatonOf`) now finds every copy of every quote
in one pass, in time with the text, the quotes' total length and the copies found; the
matcher reads each copy's words against the page and keeps the fence and context rules
on top. No maintained dependency fits: the automaton is 70 lines and runs over a window
of the page's letters that a dependency's string API doesn't take. The hash keys,
their buckets and `keyStarts` go. `findEach`, Chromium then Firefox:
- #9's shape, 1,600 quotes alike but for a number: 14.2 to 12.1 ms, 36 to 12 ms;
- #14's shape, 400 and 800 quotes: 515 and 4,258 to 2.5 and 8.3 ms; 1,193 and 9,620 to 2
  and 8 ms.
The 1,600-mark page is unchanged: presentation 38.9 to 38.5 ms, edit 292 to 290 ms,
startup presented at 1,281 to 1,238 ms. The 1,600-section page's edit varied 6.5-11.9 ms
on de675ba and 6.5-13 ms here over three runs each; its move 1.2-1.8 against 1.4-1.8.

Word gaps (#15). The raw reading held an edge between any two text nodes and a quote's
gap matched one, so `one two`, rewritten as `<span>one</span><span>two</span>`, which
reads `onetwo`, stayed marked in both browsers while the file's reading detaches it. The
raw reading now holds a space wherever the reading reads one (a line break, a block's
end: `readSegments`' rule), an edge only between inline elements, and a gap must hold
whitespace: an edge may stand in a gap or inside a word, never be one. A quote across
two blocks no longer runs their words together (`boldtext` over `bold` and `text`
blocks), as in the file. Page search takes the same gap. tests/quote_cases.json gains
both cases, a line break, and an inline-edge word. Of the gaps the review named, a
line break and a block's end are spaces in both readings; `display: contents` and
generated content are style, which neither reading reads. On the 25 example pages,
7,055 quotes captured across each pair of adjacent text nodes all resolve to their own
words, or are repeated.

Tests, each failing on de675ba in Chromium and Firefox:
- test_a_draft_s_passage_keeps_its_mark_when_a_script_rewrites_around_it (#12), read
  once;
- test_a_section_staged_again_in_a_new_widget_keeps_its_thread (#13);
- test_words_a_script_sets_in_elements_of_their_own_run_together (#15).
Runtime, each failing on de675ba: the seeded check now runs pages holding only a
draft and stages filled before they are put in place, and checks the draft's placement
and section-only threads after every change; two quote cases; and a `findEach` test
that counts the automaton's lookups against the text and the strings' total length for
both shapes. The raw-reading test now expects a space at a block's end.
max-sixty added a commit that referenced this pull request Nov 6, 2026
…dings

Neither "always joined" nor "always apart" is what a reader sees where two inline
elements meet with nothing between them: only the page's CSS says whether
`<strong>Status</strong><span>Ready</span>` shows one word or two, and the file's
reading can't see CSS. A survey of 657 retained pages found 2,918 pairs of words drawn
apart, on another line or with a gap, that the reading joined, on 183 pages, more than
half of them written by Leaf's own widgets (lf-option's chips and title, lf-trace,
lf-timeline). So, reversing round 13's call on #15, a quote and a search now match
across such an edge with or without a space, in both readings, as main's browser did:
"alphabeta" and "alpha beta" both find `<span>alpha</span><span>beta</span>`, and
"recommended Drop" finds an option's chip and title. The end of an element outside
`$passages.phrasing` (a text block, a list item, a table cell, a widget not declared
`x-inline`) and a `<br>` stay real gaps, which a quote can't run across.

The browser's reading is spelled as before, an edge between two runs of words read in
one element and a space between runs read in two; `scan` finds a quote's letters with
one automaton and holds each copy to its quote's spaces (a space or an edge where the
quote has a space, nothing or an edge where it has none), and page search joins its
words across whitespace or an edge. The file's reading records where two runs meet in
one block (`Passages.edges`), and `occurrences` finds the same copies on a letters view
of its text, returning each copy's span, since a copy's length is no longer its
quote's: `resolve_quote` and `capture_anchor` read spans, and the clerk, which places
an edit by its offsets, takes only a copy spelled as the edit's words.

What this makes unnecessary goes: `$passages.apart` and its reasons, and the rule that
read a said value apart from its element's words, in both readings. `$passages.phrasing`
stays, since it decides which elements' ends are real gaps, in both readings now
(`why-phrasing` says so), and link's run-in rule reads it.

tests/quote_cases.json flips two cases, an inline element's edge and two spans outside
a text block, and adds a flex row's label and value and an option's chip and title,
read both ways; both runtimes answer all 31. test_words_a_script_sets_in_elements_of_
their_own_run_together becomes ..._keep_their_thread: two words a script sets in spans
of their own keep the thread that quotes them.

Measured against 0c623e9 and main (62cb54f):
- 267 quote anchors in the logs of 113 retained pages: in the file's reading and in
  Chromium's, each attaches to the same words, or stays detached, on all three; none
  is newly detached, newly attached or moved (128 attached, 139 detached).
- The survey's 2,918 pairs, searched with a space between: 228 found on 0c623e9,
  every one here.
- 179,571 quotes of one to four words sampled from 652 retained pages: 6 gain a copy,
  5 of them from one copy to two ("7 On" also finds a counter's "7On"); none loses one.

Tests, each failing on 0c623e9 in Chromium and Firefox:
- test_page_search_finds_words_css_draws_apart_with_nothing_between_them, a flex row
  and an option's chip and title;
- the four new or flipped shared cases, in both runtimes.
max-sixty added a commit that referenced this pull request Nov 26, 2026
…age data on first visits

Codex's review of the previous commit found faults in it, numbered as its findings
are:

- #1: the door refused a comment a reader genuinely drew. A revision digests a
  value alone, so the same value republished under another contract read as a
  contract the seat never drew. The door now refuses only a current reading that
  holds an error; an input of another contract is left to `page check`.
- #3: on Linux two writes can share a change time, so the separate change-time
  stat still missed a same-size rewrite with the old modification time (35 of
  100 cache trials, 86 of 100 news trials), and the hosted publisher's
  fingerprint (`record_reading`) ignored it. `file_stamp` takes `changed`, which
  adds the change time from the same stat and settles on the later of the two
  times, and every reader of a bound file (news, the hosted fingerprint, the
  source's cache and run) stamps it that way.
- #10: comments keep the file's own revision, but the previous commit made the
  served state's tail resend a publication's unchanged value on every rerun (one
  256 KiB rerun grew the answer from 362 bytes to 262 KB), and a validation
  cached by the file's revision went stale when the label moved. A bound file's
  whole value now has its own digest, kept with its reading, which the tail
  compares (`data.value_key`) and validation keys on; the tail's rerun test is
  back as it was.
- #12: the first-visit state dropped a publication only a thread's widget binds,
  and advertised the version of all data while sending part of it, so a tab
  naming that version never got the rest. It now holds every source a document
  or message of the page binds, and the version of exactly those
  (`page_data.bound_data`), in place of the export's filter, which leaves
  messages out.
- #13 (part): a widget's construction in `leaf page state` said an input of
  another contract had its value available. It now says it has none, with why.
  `page check` still finds a file bound under another contract only in the
  page's own markup, not in a sample's or a message's.
- #14: a read failure whose cause the file's stamp doesn't name, such as a
  symlink in its path, stayed cached after its cause cleared. A source holding
  an error is now read again each time.
- #15: looking up one source for the door read every bound file. It now reads
  the one it names.
max-sixty added a commit that referenced this pull request Nov 26, 2026
… and leave drafts off first visits

Codex's review of the previous commit confirmed #3 fixed on Linux and macOS and
found these still open:

- #10: two overlapping state requests could lose a relabel, since a reading the
  file cache no longer held fell back to the file's revision, which leaves the
  label out. `data.value_key` now takes the digest kept with that exact reading,
  and digests any other reading of a bound file afresh; a publication still
  stands in by its revision, so a rerun sends no value.
- #12: first visits held every binding `working_data_bindings` knows, the
  unpublished source's among them, so a binding only `index.html` holds put its
  file in the public state. `bound_data` now reads the published revisions and
  the messages, and not the draft.
- #14: a symlink put in a bound file's path and taken out again moved neither the
  news nor the run, and a file holding bad bytes was read again on every state
  read. A bound file's observation (`file_bindings.observed`), which the news,
  the hosted fingerprint and the source's cache all read, now also says whether
  its path names it without a symlink, so every reading, an error's included, is
  kept under it.
- #15: admission read every publication to learn whether a source was supplied.
  It now asks for the one source first, and reads the others only where that
  source holds nothing.

Still open, and reported: #1's comment on a file an input of another contract
binds after its page was checked, and a contract that pins the file's name,
which a new label then breaks; #13's file-contract check, which reaches the
page's own markup and not a sample's or a message's; and the copy of a file
source into a live sample, which takes a publication's revision.
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