Repository navigation
fix(ui): keep the mobile composer above the keyboard and give typing more room - #992
Conversation
…more room On iOS the composer could end up behind the software keyboard: WebKit settles visualViewport.height only after the keyboard animation, often without another resize event, and an IME candidate bar resizes the keyboard with no viewport event at all. useViewportHeight read the height once per event, so it kept the full-screen value. Scrolling down to reach the composer then fought the hook's scrollTo(0, 0), which made the composer jitter. Zoomed pages (iOS auto-zoom, pinch) were skipped entirely. - Re-read the geometry in one non-restarting settle chain after every trigger, and treat composition/input/keyup on a focused editor as triggers. - Compare the visual viewport against innerHeight / scale, with a 60px minimum so Safari toolbar shifts are not taken for a keyboard. - While the keyboard is open, mark <html data-keyboard-open> and hide the composer's controls row and the extension status shelf, and drop the bottom safe-area padding the keyboard covers. Applies to phones in portrait and landscape; tablets keep their controls. - On phones, render Send as an icon-only button (with an aria-label) and tighten the input box padding so the draft keeps the width. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Reviewed. The iOS problem is real: WebKit settles What I checked:
One tradeoff worth knowing: while the keyboard is up on a phone, the image button and model/thinking controls are hidden too, so you dismiss the keyboard to reach them. That's a reasonable price for the height, and it's easy to revisit in CSS if people miss them. Merged locally with current Generated by Claude Code |
解开 agegr#981 的 DirectoryPicker 冲突后,这一段(390e70f..f52fd84)实测 0 冲突: - agegr#992 移动端输入框停在键盘上方并给打字更多空间 - agegr#997 限制每客户端 SSE 积压 - agegr#1001 可配置发送键(Enter / Ctrl+Enter) - agegr#1006 从 pi 的 provider catalog 解析 discovery endpoint - agegr#1017 空闲关闭被禁用时回收 Stop 无法解除的运行 - agegr#1016 Stop 结束输出被幸存进程持住的命令 - agegr#1015 保留用户消息里输入的换行 - agegr#1019 在 Safari / iOS 16.2 上可加载(新增 browserslist,无新依赖)
…more room (agegr#992) On iOS the composer could end up behind the software keyboard: WebKit settles visualViewport.height only after the keyboard animation, often without another resize event, and an IME candidate bar resizes the keyboard with no viewport event at all. useViewportHeight read the height once per event, so it kept the full-screen value. Scrolling down to reach the composer then fought the hook's scrollTo(0, 0), which made the composer jitter. Zoomed pages (iOS auto-zoom, pinch) were skipped entirely. - Re-read the geometry in one non-restarting settle chain after every trigger, and treat composition/input/keyup on a focused editor as triggers. - Compare the visual viewport against innerHeight / scale, with a 60px minimum so Safari toolbar shifts are not taken for a keyboard. - While the keyboard is open, mark <html data-keyboard-open> and hide the composer's controls row and the extension status shelf, and drop the bottom safe-area padding the keyboard covers. Applies to phones in portrait and landscape; tablets keep their controls. - On phones, render Send as an icon-only button (with an aria-label) and tighten the input box padding so the draft keeps the width. Co-authored-by: miller.zeng <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
…more room (agegr#992) On iOS the composer could end up behind the software keyboard: WebKit settles visualViewport.height only after the keyboard animation, often without another resize event, and an IME candidate bar resizes the keyboard with no viewport event at all. useViewportHeight read the height once per event, so it kept the full-screen value. Scrolling down to reach the composer then fought the hook's scrollTo(0, 0), which made the composer jitter. Zoomed pages (iOS auto-zoom, pinch) were skipped entirely. - Re-read the geometry in one non-restarting settle chain after every trigger, and treat composition/input/keyup on a focused editor as triggers. - Compare the visual viewport against innerHeight / scale, with a 60px minimum so Safari toolbar shifts are not taken for a keyboard. - While the keyboard is open, mark <html data-keyboard-open> and hide the composer's controls row and the extension status shelf, and drop the bottom safe-area padding the keyboard covers. Applies to phones in portrait and landscape; tablets keep their controls. - On phones, render Send as an icon-only button (with an aria-label) and tighten the input box padding so the draft keeps the width. Co-authored-by: miller.zeng <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Problem
On iOS Safari, focusing the composer could leave it behind the software keyboard. Users had to scroll the page down to reach it, and while they scrolled the composer jittered.
Cause, in
hooks/useViewportHeight.ts:visualViewport.heightonly after the keyboard animation finishes, often without firing anotherresize(bugs.webkit.org 265578). An IME candidate bar (e.g. Chinese input) resizes the keyboard with no viewport event at all. The hook read the height once per event, so it kept the full-screen value.window.scrollTo(0, 0)pulled the page back each time, which shows up as the jitter.isUnscaledguard.Even with the composer placed correctly, only a few hundred pixels remain above the keyboard on a phone. The model/controls row and the extension status line took a large share of them.
Changes
Keyboard tracking (
hooks/useViewportHeight.ts)SETTLE_DELAYS_MS), so the layout settles on WebKit's final value rather than the mid-animation one.composition*/input/keyupevents on a focused editor also count as triggers.visualViewport.heightagainstinnerHeight / scale, so zoomed pages are handled.KEYBOARD_MIN_HEIGHT_PX) keeps Safari toolbar shifts from being taken for a keyboard.More room while typing (
app/globals.css,components/ChatInput.tsx)<html data-keyboard-open>. CSS then hides.chat-input-controlsand.extension-status-shelfand drops the bottom safe-area padding the keyboard already covers. Everything comes back when the keyboard closes.(max-width: 640px), (pointer: coarse) and (max-height: 500px). Phone landscape is included because it has the least height; tablets keep their controls.title/aria-label) and the input box padding is tighter, so the placeholder and draft keep more width.Docs and tests
AGENTS.mdsection on the mobile keyboard behaviour.MobilePwaLayout.test.mjsnow asserts that every class the keyboard rules target actually exists on its component, so a rename cannot leave a rule silently dead.Testing
tsc --noEmit,eslint, andnpm test: all 1311 tests pass.iPhone 13 emulation with a stubbed
visualViewportthat reproduces WebKit's order of events:resizefires first, then the height changes with no further event.--app-viewport-heightnot set; composer coveredChecked on an iPhone in Safari. The same logic, shipped as a local runtime patch against 0.9.3, was in daily use there before this PR.
🤖 Generated with Claude Code