Skip to content

fix(desktop): wipe the composer's stale pixels when it empties - #819

Merged
huichen merged 2 commits into
mainfrom
fix/composer-ghost
Sep 24, 2026
Merged

huichen merged 2 commits into
mainfrom
fix/composer-ghost

Conversation

@huichen

@huichen huichen commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

Symptom

A message sent from the desktop composer (macOS 26/WKWebView) sometimes stays painted: the input box keeps the last line of the message that was just sent, with the empty-state hint drawn above it. Screenshot from the report attached below; the sent prompt was two lines and contained a /skill mention.

Diagnosis

The app state was already correct — that is what made this look like a clear-path bug but it is not:

  • The hint only renders while the editor is empty ({empty ? …}, over the empty state a MutationObserver keeps in sync), and it was up.
  • The caret sat at the start of line one — where a cleared editor's caret lands — not after the residual text.
  • Measuring the reporter's PNG: the previous first line is gone, and its whole extent lies inside the hint's box; the previous second line survives exactly in its own glyph box (x 177–1275, the same width as that line in the sent bubble above).

So the editor's DOM was empty, the hint's mount repainted its own rect, and the clear's own repaint never reached the editor. That is WKWebView on macOS 26 presenting a partially updated frame — regions of the new frame next to regions of the old, DOM and hit-testing live (tauri-apps/wry#1848) — the same family MessageBlock's will-change note already works around.

Fix

The empty-state hint now covers the editor's whole box (inset-0 plus the editor's own px-2 py-1) instead of just the text's own width (left-2 top-1). Mounting it — which always accompanies a clear — dirties every pixel of the box, so the repaint that follows wipes whatever the clear left painted; unmounting it does the same when a draft is restored. The padding keeps the hint's text exactly where a typed first line would sit, and it stays pointer-events-none now that it overlays the editor.

Also pins both constraints in a comment (and in the verification note, docs/archives/verification/composer-stale-line-20260924.md): don't shrink the hint back to the text's width, and don't give the editor a compositor layer of its own — a promoted editor stops painting into the hint's layer, which is what makes the repair work.

Verification

  • npx tsc --noEmit, npx eslint (whole desktop/src + shot + config), npx vitest run — 144 files / 1252 tests pass, including a new assertion on the hint's geometry contract.
  • Headless harness (real frontend, real Chrome): the hint's box now equals the editor's box (409,743, 750×56) and its text line is unchanged (417,748, 336.2×17); a 2× capture of the whole composer card is pixel-identical to the previous build (0 of 2,291,520 pixels differ); elementFromPoint at the bottom of the box still returns role=textbox and a click focuses the editor.

Not validated

No native WKWebView reproduction was possible from here, so this rests on the presentation defect being region-local and on the hint's mount dirtying the editor's box — which the screenshot shows working for the smaller rect, not for the whole box. If a ghost recurs in a path where the hint does not mount or unmount (a restore that replaces text with text), the next lever is a compositor promotion of the editor, paired with dirtying the editor's own layer. The verification note records that gap.

After sending a message the composer sometimes kept the last line of it
painted: the DOM was empty (the placeholder hint was up, the caret sat at
line one), yet the sent line stayed on screen — reported with a screenshot
on macOS 26.

What the screenshot shows, once the pixels are measured: the previous
first line is gone exactly where the placeholder hint's box was, and the
previous second line survives exactly in its own glyph box (x 177–1275, the
same width as that line in the message bubble above). So the clear's own
repaint never reached the editor, while the hint's mount did get repainted.
WKWebView presents partially updated frames on macOS 26 (wry#1848: "some
regions from the new frame, some from the old one" — DOM and hit-testing
live), which is the same family the hover-controls workaround in
MessageBlock already documents.

The hint is the one element whose mount is guaranteed to accompany a clear,
so widen it from the text's own box (left-2 top-1) to the editor's whole box
(inset-0 plus the editor's padding, leaving the text where a typed first
line would sit). Its mount then dirties every pixel of the editor, and the
repaint that follows wipes whatever the clear left behind; its unmount does
the same when a draft is restored.

Verified in the headless harness: the hint's box now equals the editor's box
and its text line is unchanged (417,748,336.2×17 — identical before and
after), a 2× capture of the whole composer card is pixel-identical to the
previous build (0 of 2,291,520 pixels differ), and hit-testing still reaches
the editor through the hint (elementFromPoint → role=textbox, click focuses
it).
Measure the reporter's screenshot (ink-colour bands, glyph boxes, the hint's
rect vs. the leftover line) and record what was and was not validated, so the
"do not shrink the hint / do not composite the editor" constraints in
MentionEditor.tsx have their evidence next to them. Notes that the defect is a
WKWebView presentation issue on macOS 26 (wry#1848), not app state: the DOM was
empty and the hint up while the pixels showed the sent line.
@huichen
huichen enabled auto-merge (squash) September 24, 2026 09:00
@huichen
huichen merged commit f9bb326 into main Sep 24, 2026
12 checks passed
@huichen
huichen deleted the fix/composer-ghost branch September 24, 2026 09:02
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