Registry Mirror
Skip to content

Conversation

@backnotprop

@backnotprop backnotprop commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Asked for by the Workspaces perf program: a warm document open spent most of its mount task in forced layouts, and two of them were in @plannotator/ui. This removes both and prepares @plannotator/ui 0.53.1 (not published; Plannotator's app versions are unchanged).

What changed

  • useVimSelection: the reset when vim is off (state, focus, HUD, and the selection inside the viewer through window.getSelection()) now runs only when vim goes from on to off. A mount where vim was never on reads no selection. The enable path is unchanged. One behaviour change a host may notice: with vim off, a selection already inside the viewer is no longer cleared when the document mounts or its content changes (useVimSelection.selectionScope.test.tsx updated to say so). Turning vim off still clears it.
  • AnnotationToolstrip: the buttons no longer read offsetWidth in a layout effect. A hidden copy of the label sits in a one-column grid whose column animates 0fr to 1fr, so the width comes from layout; the side padding animates 7 to 10 px as before. The visible label is positioned beside the icon and clipped by the button, as before. (Drawing the label inside the grid track itself reveals it more slowly than the button grows, since a track laid out at a fraction of its width is narrower again, and WebKit does not animate the width at all unless the item clips its overflow; so the track holds a hidden copy.)
  • Version 0.53.1 in packages/ui/package.json and bun.lock; HANDOFF.md has a section on the two changes; the README and HANDOFF entries labelled "after 0.53.0 / unreleased" now say 0.53.1.

Numbers

Chromium trace, a harness that renders Viewer with the toolstrip header (a 120-section document), the open clicked after three warm-up opens, median of 25 runs:

Mount task Forced style + layout in the open Layouts in the open
main 18.7 ms 2 events, 9.4 ms (toolstrip offsetWidth) 2
toolstrip fix only 15.0 ms 2 events, 9.4 ms (now clearSelectionWithin) 1
this PR 5.9 ms 0 1

The layout itself still happens once, in the frame, so total layout time is about the same; what goes away is the synchronous layout inside the mount task. Fixing only the toolstrip just moves the forced layout to the vim reset, so both are needed.

In Plannotator's own annotate app the count does not drop: other readers in the same commit (a visual-viewport read, a measuring component, the sticky lane's offsetTop) take the forced layout over (13 vs 12 forced layouts on a full page load in an earlier run). The gain is for hosts like Workspaces where these were the readers.

Checked

  • Look and motion, before and after, in Chromium, WebKit and Firefox (Playwright, collapsed / hovered / active / compact / icon-only screenshots, and every frame of a hover's expand and collapse sampled): expand curves equal within frame timing (largest difference 0.01 of the width in WebKit), icon and label positions within 0.1 px, opacity within 0.02. An expanded button is now its exact subpixel width, up to 0.5 px wider than the rounded offsetWidth it used. Reduced motion behaves as before (the toolstrip never had its own rule).
  • tests/e2e/toolstrip-stacking.spec.ts on a compiled binary: 2 passed. New tests/e2e/toolstrip-rtl.spec.ts, run by the existing chromium project and a new webkit project in playwright.config.ts (that spec only, launched without the Chromium flags): every expanded button's label sits after its icon, left to right and under dir="rtl", in both engines. The label is placed with inset-inline-start; the first version used a physical left and covered the icon right to left, which this spec catches.
  • DOM tests: useVimSelection (new: no getSelection call on a never-enabled mount; turning vim off after it was on still clears, and only then), useVimDocumentFocus, AnnotationToolstrip, Viewer.documentHeader, StickyHeaderLane; bun test packages/ui.
  • bun run typecheck (strict consumer included). The guides.show viewer manifest does not change.

🤖 Generated with Claude Code

backnotprop and others added 6 commits October 20, 2026 17:51
useVimSelection resets only when vim goes from on to off, so a mount with
vim never on calls no window.getSelection(). AnnotationToolstrip's buttons
take their expanded width from layout (a 0fr -> 1fr grid column holding a
hidden copy of the label) instead of reading offsetWidth in a layout effect.

Co-Authored-By: Claude <noreply@anthropic.com>
…he icon right to left

The label was placed with a physical left, so under dir="rtl" it covered the
icon. The label, the side padding and the sizer's gap now use logical
properties. toolstrip-stacking.spec.ts checks in Chromium and WebKit that every
expanded button's label sits after its icon, left to right and right to left.

Co-Authored-By: Claude <noreply@anthropic.com>
…a hand launch

The check launched WebKit inside the Chromium run, which inherited the
config's Chromium flags and failed on the CI runner. It now lives in
toolstrip-rtl.spec.ts, which the chromium project runs with every spec and a
webkit project (that spec only, launched with no Chromium flags) runs in
WebKit.

Co-Authored-By: Claude <noreply@anthropic.com>
# Conflicts:
#	tests/e2e/playwright.config.ts
…rt for the remote-mode update test

toolstrip-stacking: on CI's Chromium the pointer can still read as (0, 0) on
the new document, on the sidebar peek's edge strip, so the peek opened over
the page (over the thread beside a file on main too) and, at full screen,
over the strip. The peek closes only when the pointer leaves it: enter it and
leave, then require it closed before the strip is probed.

update-advert: the remote-mode case picked a random port in 30000-50000,
inside Linux's ephemeral range, and CI hit "Port … in use after 5 retries"
twice. It now takes a port the OS reports free.

Co-Authored-By: Claude <noreply@anthropic.com>
# Conflicts:
#	tests/e2e/playwright.config.ts
@backnotprop
backnotprop merged commit 576a43a into main Oct 21, 2026
32 checks passed
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.

1 participant