Skip to content

Margin card under its words moves its first message when a growing draft caps it in a short window #7511

Done

Description

@leaf-agent

In a margin card that stands under its words, a draft that grows until the card's foot meets the window's moves the card's first message and the reply up by a few pixels on the keystroke that caps the card. test_a_growing_draft_under_its_words_holds_the_editor_s_top says no keystroke should do that: the reply should keep its first line and further lines should scroll inside the editor.

The card's thread is a grid whose transcript and reply rows are both minmax(auto, max-content) (.lf-margin-thread .lf-page-thread in annotation-chrome.css). Under the card's cap, grid layout hands the room above each row's minimum out equally, so once the cap can't give the transcript its full height, the transcript shrinks too and scrolls to keep its end in view. measureThreadCard (thread-preview.js) gives the transcript a share of the cap only for a card that keeps its reply box's top, not for one that keeps its top.

It happens before #7442 too. At bfd1b7b75~1, running that test at 1000×N:

Window height Result
530 first message moves 15px
540, 550 moves 5px
560 to 640 holds

#7442 made every card 33px taller, so the test's 600px window landed in that range: the transcript went from 98px to 91px and the reply moved 7px. #7495's repair moves the test to a 628px window. A shorter window still shows the shift.

Activity

  1. leaf-agent commented on Nov 28, 2026

    @leaf-agent
    CollaboratorAuthor

    Reproduced on current main (fee455a): at the test's 600px window the capping keystroke moves the first message from 322px to 315px (7px). With the test parametrized over window heights, main also fails at 540 and 550. At 530 the card already stands at the window's foot before the first keystroke, so the test's premise fails, and over the 30 lines the first message travels 39px.

    The mechanism in the report holds. A quick experiment confirmed it: while the user writes in a card kept by its top, I pinned the transcript's min-height at its height before the card capped, in measureThreadCard. The test then passes at 540, 550, 600 and 628, with the grid's room going to the reply, so further lines scroll inside the editor. The other draft and editor tests in test_card_reply.py still pass with it (11 cases).

    I haven't opened that change as a fix, because it isn't one yet:

    • A pinned minimum keeps the transcript from yielding even when the reply can't hold its first line. A window that shrinks while the user writes, or a card that starts at the foot, as at 530, would push the reply out of the card. A real fix caps the transcript's held height at the card's cap less the reply's minimum, the way the ownLine share already computes the room left after everything else in the card.
    • The minimum needs a defined release: Send, an emptied draft, and a change of the card's side.
    • The module header says the transcript "yield[s] writing room without losing the visible lines", and the card over its words is tested to give way to its draft. The card under its words is tested to hold. The fix should state in the header that the card held by its top is the exception, so the two tests and the header agree.

    #7512 moves this test to 628px and is still open. A fix for this issue would bring the test back to a short window, parametrized over 540 to 600, once #7512 lands. That avoids editing the same test in two open PRs.

  2. leaf-agent commented on Nov 29, 2026

    @leaf-agent
    CollaboratorAuthor

    Fix opened in #7617, now that #7512 has landed. While the user writes in a card kept by its top, the transcript holds its height as a minimum. That minimum is capped at what the card's cap leaves after the reply's own minimum, and it clears once the user stops writing. The capping keystroke now takes its line from the reply, whose field scrolls, so the first message stays put. The test runs at 540, 550, 600 and 628px without the xfail. The three shorter windows fail on main and pass with the change. Review and CI are pending, and that PR's landing workflow takes it from here.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions