From 04e8aa8f108fef9fde816cfd7479d469c0d356ba Mon Sep 17 00:00:00 2001 From: yetone Date: Sat, 17 Oct 2026 19:04:45 +0800 Subject: [PATCH] library: typing with an input method no longer moves the page (#2636) In Library -> Instructions, typing Chinese through an input method made the page jump up or down while a word was composed. The cause: the textarea's autosize set height:auto to measure scrollHeight, so the page went short for a moment and the browser clamped the view's scrollTop. Putting the height back doesn't undo a clamp. app.js's scroll guard took the clamp for a scroll the reader didn't make, and its scrollIntoView({block:"nearest"}) pulled a textarea taller than the view to one of its edges. Every composition step is an input, so this happened on every keystroke. autosize (the only one in the GUI, used by a set's text, an agent's own text, a skill's description and subagent boxes) now holds the textarea's parent at its height while measuring, so the page never goes short. What was run: - New internal/gui/tests/library-ime-scroll.test.cjs covers en/zh, 980/560px, a Default set's text and Cline's own text. Chromium composes through CDP Input.imeSetComposition/insertText. WebKit gets synthetic composition events and inputs. - With the fix: 9/9 in both engines, before and after rebasing onto f191d6423. - With client.js reverted by hand: red in both engines (4 of 9), set:default in every lang/width; the page went e.g. 1000 -> 862, 1401, 1634. - extra:cline wasn't red on main: its clamp is put back before paint. It stays as a sibling guard. - library-row-open-scroll and library-instr-sets pass in both engines. - The whole GUI suite ran in both engines at concurrency 6, load ~150-300. - Chromium: 5408/5519. WebKit: 5442/5547. - Failed files were rerun at concurrency 2 and on unmodified main (c1e95f919). All are red on main too and already filed (codex-predictions #2624, segs-glide/lightweight #2683, provider-advanced-fold #2710, tray-cell-click #2686, removed-groups-menu-scroll #2172/#2211, others as filed). - WebKit plugin-moved-signin and update-release-page passed alone. removed-groups-menu-scroll went 4/4 three times. No library file stayed red. - gofmt -l: clean. go vet: darwin, and GOOS=linux and GOOS=windows with -tags nogui: clean. - go test -timeout 45m ./... under pipefail in a sandbox HOME: exit 0. Not tried: a real system input method (macOS Pinyin) in the real app. Only CDP and synthetic composition were used. --- docs/subsystems/gui-shell.md | 1 + docs/subsystems/library.md | 2 +- internal/gui/assets/plugins/library/client.js | 13 +- .../gui/tests/library-ime-scroll.test.cjs | 162 ++++++++++++++++++ 4 files changed, 176 insertions(+), 2 deletions(-) create mode 100644 internal/gui/tests/library-ime-scroll.test.cjs diff --git a/docs/subsystems/gui-shell.md b/docs/subsystems/gui-shell.md index 9a4068d04..7039c52d1 100644 --- a/docs/subsystems/gui-shell.md +++ b/docs/subsystems/gui-shell.md @@ -355,6 +355,7 @@ covers it in both engines, every language and a narrow window. - Settings' Search APIs add row has a base URL field under the key for every API (#1580): the vendor's own address is its placeholder, picking an API already added fills in its saved URL so a new key alone keeps it, and Add with no key changes only the URL. See [a search API's base URL](gateway-routing.md#a-search-apis-base-url), [`renderSearch`](../../internal/gui/assets/app.js) and `search-api.test.cjs`. - Every user-visible string has zh, zh-TW, ja and de translations with the same placeholders. `gui-zh-tw.test.cjs`, `gui-ja.test.cjs` and `gui-de.test.cjs` fail on a missing one; `gui-zh-tw.test.cjs` also fails on a zh-TW string with a Simplified character left in it. - A click never moves the page. Code scrolls a view only with the reader's event in hand (`scrollOnPurpose`); `click-scroll.test.cjs` guards this. A click is taken where the reader left the view: a scroll not theirs made just before it, whose scroll event the browser sends only at the next frame, after the click, is put back first (`backToReader` in the click guard, #1554). What was clicked is held where it was (`hold`); a view at its top when clicked stays at its top, and what comes in above the control moves it down instead (#2134, `update-auto.test.cjs`), as long as it moves less than half its own height and so stays under the pointer. Anything larger above it, as the stage a day picked on Routing brings in above the bar, is scrolled past, and the control stays where it was clicked (`routing-days-fit.test.cjs`, `routing-failed-open.test.cjs`). +- Typing never moves the page either. A textarea that grows with its text (the Library's `autosize` in plugins/library/client.js: a set's text, an agent's own text, a skill's description, a subagent's fields) is measured at height auto with what holds it kept at its height, so the page never goes short for a moment: a page gone short has its view's scroll clamped by the browser at every input, an input method's every composing step included, and the guard's putting it back pulled a textarea taller than the view to one of its edges (#2636, `library-ime-scroll.test.cjs`). - There are no native `