refactor(chat): remove keyboard compatibility layer

This commit is contained in:
2026-07-16 14:36:33 +08:00
parent aec7cee9cf
commit 8b6bcab05c
9 changed files with 26 additions and 629 deletions
@@ -1,90 +0,0 @@
import { describe, expect, it } from "vitest";
import {
resolveChatKeyboardFallbackLift,
resolveChatKeyboardLift,
type ChatKeyboardViewportBaseline,
type ChatKeyboardViewportSnapshot,
} from "../chat-keyboard-geometry";
const baseline: ChatKeyboardViewportBaseline = {
layoutHeight: 800,
visualHeight: 760,
};
function makeSnapshot(
overrides: Partial<ChatKeyboardViewportSnapshot> = {},
): ChatKeyboardViewportSnapshot {
return {
layoutHeight: 800,
visualHeight: 760,
visualScale: 1,
virtualKeyboardHeight: 0,
...overrides,
};
}
describe("resolveChatKeyboardLift", () => {
it("does not add lift when the content viewport already resized", () => {
expect(
resolveChatKeyboardLift(
baseline,
makeSnapshot({ layoutHeight: 500, visualHeight: 500 }),
),
).toEqual({
keyboardVisible: true,
lift: 0,
source: "content-resize",
});
});
it("uses the visual viewport delta for an overlay keyboard", () => {
expect(
resolveChatKeyboardLift(
baseline,
makeSnapshot({ visualHeight: 460 }),
),
).toEqual({
keyboardVisible: true,
lift: 314,
source: "visual-viewport",
});
});
it("prefers Virtual Keyboard geometry when available", () => {
expect(
resolveChatKeyboardLift(
baseline,
makeSnapshot({
visualHeight: 520,
virtualKeyboardHeight: 320,
}),
),
).toEqual({
keyboardVisible: true,
lift: 334,
source: "virtual-keyboard",
});
});
it("ignores visual viewport changes caused by page zoom", () => {
expect(
resolveChatKeyboardLift(
baseline,
makeSnapshot({ visualHeight: 460, visualScale: 1.2 }),
),
).toEqual({
keyboardVisible: false,
lift: 0,
source: "none",
});
});
});
describe("resolveChatKeyboardFallbackLift", () => {
it("scales with viewport height and remains bounded", () => {
expect(resolveChatKeyboardFallbackLift(500)).toBe(260);
expect(resolveChatKeyboardFallbackLift(800)).toBe(336);
expect(resolveChatKeyboardFallbackLift(1_200)).toBe(380);
});
});