Skip to content

Unchanged selected and tabindex writes in lf-options and lf-file-editor since #6936 #6964

Done

Description

@leaf-agent

Two browser tests end with an unchanged-write finding since #6936 (9aa6fdcd2, "Drive LeafElement through the property and events a plain element gets"). In each one, a script takes a value off a widget's node and puts it back in the same task:

  • tests/browser/drafts/test_shared_drafts.py::test_one_shared_added_option_has_one_action_payload_across_tabs: unchanged write: selected on lf-option#job-mounts
  • tests/browser/test_render_files.py::test_a_reload_that_loses_a_saves_answer_keeps_the_typing_after_it: unchanged write: tabindex on div.cm-content.cm-lineWrapping in #shadow-root in lf-file-editor#notes-file

Both errors are raised in teardown by the write watch (tests/write_watch.js). It reports a write when a script leaves an attribute holding the value it started with, so a restated value fails the test.

Runs: first seen in ci run 45327285035 on 4660b588e. Both still fail locally on 77da815d6, deterministically, at the same nodes.

Bisect (git bisect run over 8bbb4ee1c..4660b588e, each test on its own): both pass at e9c4cc6bb and fail from 9aa6fdcd2 (#6936) on.

Diagnosis so far. #6936 rewired lf-options (packages/default/widgets/lf-options.js) and lf-file-editor (packages/file-editor/widgets/lf-file-editor.js) onto this.state and record(). It also changed when a LeafElement draws: it draws inside Leaf's set of state, and each update becomes a pending-task. lf-options writes selected only in #syncChoice, through toggleAttribute(…, selected). A force-toggle that matches the current state makes no mutation, so the finding means selected was taken away and put back within one script. A likely cause is two syncs in one task that read different choices: an authored or empty one first, then the logged one. Nobody has traced it yet. The file editor's tabindex flip on CodeMirror's content is unexplained too. It may be a separate mechanism, such as the editor being reconfigured editable/read-only around a redraw. Each test needs its own trace, with window.lfWrites (see the write_watch.js header) recording the stack of each write.

#6963 fixes two other tests that #6936 broke in the same run (inline test widgets missing the new reactive value declaration). It doesn't touch these two.

Cause of a failure tracked in #6960.

Activity

  1. added
    tend-ci-cause
    on Nov 24, 2026
  2. leaf-agent commented on Nov 24, 2026

    @leaf-agent
    CollaboratorAuthor

    #6973 fixes both findings. Its review, CI and landing are with the PR's own workflows. The two have separate causes.

    • tabindex in lf-file-editor: the CodeMirror view was created read-only, and a draft kept across the reload was recovered only afterwards. So the first paint in the same setup task made the file writable, and tabindex="0" was added and removed in one script. The PR recovers drafts before creating the editor and starts the editor with the read-only state the paint would give it.
    • selected in lf-options: this one comes from the test. It forges selected on #job-mounts, a selection the tab's state never held. The click's add draw put the DOM back to the state, and the pick in the same click restored it. Two syncs reading different choices is not the cause. The PR has the test drop the forged attribute once the draft generation has recorded it. The pick assertion still requires the generation's recorded choice. The widget is unchanged.

    Both tests failed on 7da7a6a71 and pass on the branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    tend-ci-cause

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions