fix(mobile): the phone toolbar sits on the keyboard, and the prompt's last line is no longer under it

With the on-screen keyboard up, the toolbar and the keyboard accessory bar
kept a bottom offset of --safe-area-bottom (34px on a Face ID iPhone, since
the page sets viewport-fit=cover), although the keyboard covers the
home-indicator strip that inset reserves. That left an empty band between
the toolbar and the keyboard, and put the bars 34px above the room main's
keyboard padding reserves for them (84px, the two bars only), so the bottom
of the terminal box, the last line of the prompt being typed, was painted
under the accessory bar.

With the keyboard up the bars now stack from 0 (toolbar), 40px (accessory
bar) and 84px (CJK textarea), on iOS Safari and in the home-screen app alike.
Nothing changes with the keyboard down, on a tablet or on desktop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Codeman maintainer committed 2026-11-15 14:00:34 +01:00
1 parent e99b42c387
commit e4a85fabcd
3 files changed
+176 -6

No files matched your search

+35
View File
@@ -163,6 +163,41 @@ describe('Virtual Keyboard', () => {
}
});
it('sits the bars on the keyboard with no safe-area band, and no terminal under them', async () => {
// The mock layer is the faithful iOS model: the layout viewport keeps its
// height and only the visual viewport shrinks, so KeyboardHandler lifts the
// fixed bars by translateY. Headless Chromium has no home indicator, so the
// 34px inset a Face ID iPhone reports under viewport-fit=cover is forced.
const { context, page } = await createDevicePage(device, 'about:blank', 'chromium');
try {
await setupViewportMock(page);
await page.goto(baseUrl, { waitUntil: WAIT.DOM_CONTENT_LOADED });
await page.waitForTimeout(2000);
await page.evaluate(() => document.documentElement.style.setProperty('--safe-area-bottom', '34px'));
expect(await showKeyboardViaMock(page, KEYBOARD.TYPICAL_IOS_HEIGHT)).toBe(true);
await page.waitForTimeout(WAIT.KEYBOARD_ANIMATION);
const layout = await page.evaluate(() => {
const rect = (sel: string) => (document.querySelector(sel) as HTMLElement | null)?.getBoundingClientRect();
return {
visualBottom: (window.visualViewport?.offsetTop ?? 0) + (window.visualViewport?.height ?? 0),
toolbar: rect('.toolbar'),
accessory: rect('.keyboard-accessory-bar'),
terminal: rect('#terminalContainer'),
};
});
// Flush on the keyboard: the old CSS left the toolbar 34px above it.
expect(Math.abs(layout.toolbar!.bottom - layout.visualBottom)).toBeLessThanOrEqual(1);
expect(Math.abs(layout.accessory!.bottom - layout.toolbar!.top)).toBeLessThanOrEqual(1);
// The terminal's box ends where the bars begin, so its last row (the end of
// the prompt being typed) is not painted under the accessory bar.
expect(layout.terminal!.bottom).toBeLessThanOrEqual(layout.accessory!.top + 1);
} finally {
await context.close();
}
});
it('works on Chromium', async () => {
const { context, page } = await createDevicePage(device, 'about:blank', 'chromium');
try {