From 7a5be97a4c15e954f7ef489e3efcd691dfa33f9d Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Sat, 28 Nov 2026 21:21:56 +0700 Subject: [PATCH] fix(gpui): report a fine pointer on GPUI so controls take pointer sizes pointer-capabilities answers touch-primary for every non-web build, so the GPUI desktop client took iOS touch sizes: 44 pt controls and rows instead of 28 and 36. GPUI reports every pointer as a mouse, so its branch answers fine pointer, no touch screen. iOS, Android and web resolve the same file as before. --- packages/app/gpui/metro-resolution.test.ts | 8 +++++++ packages/app/gpui/native.test.ts | 10 +++++++++ .../src/hooks/pointer-capabilities.gpui.ts | 21 +++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 packages/app/src/hooks/pointer-capabilities.gpui.ts diff --git a/packages/app/gpui/metro-resolution.test.ts b/packages/app/gpui/metro-resolution.test.ts index ca3e4c3e33..99aa1ff511 100644 --- a/packages/app/gpui/metro-resolution.test.ts +++ b/packages/app/gpui/metro-resolution.test.ts @@ -130,6 +130,14 @@ const CASES = [ native: path.join(APP_DIR, "modules/paseo-press-feedback/src/ui/feedback.native.tsx"), web: path.join(APP_DIR, "modules/paseo-press-feedback/src/ui/feedback.tsx"), }, + { + label: "pointer capabilities", + origin: path.join(APP_DIR, "src/components/ui/control-sizing.ts"), + specifier: "@/hooks/pointer-capabilities", + gpui: path.join(APP_DIR, "src/hooks/pointer-capabilities.gpui.ts"), + native: path.join(APP_DIR, "src/hooks/pointer-capabilities.ts"), + web: path.join(APP_DIR, "src/hooks/pointer-capabilities.ts"), + }, ]; afterEach(() => { diff --git a/packages/app/gpui/native.test.ts b/packages/app/gpui/native.test.ts index 25523124ce..89e3b822f3 100644 --- a/packages/app/gpui/native.test.ts +++ b/packages/app/gpui/native.test.ts @@ -123,6 +123,16 @@ test.skipIf(!endpoint || appearanceFixture)( 45_000, ); +test.skipIf(!endpoint || appearanceFixture)( + "real Paseo sizes controls for a pointer, not for touch", + async () => { + // Regression: GPUI took the native touch answer, so a 28 pt pointer control rendered at 44. + const settings = await nodeWithId("sidebar-settings"); + expect(settings.frame?.[3]).toBe(28); + }, + 20_000, +); + test.skipIf(!endpoint || appearanceFixture)( "real Paseo opens History", async () => { diff --git a/packages/app/src/hooks/pointer-capabilities.gpui.ts b/packages/app/src/hooks/pointer-capabilities.gpui.ts new file mode 100644 index 0000000000..f965166b00 --- /dev/null +++ b/packages/app/src/hooks/pointer-capabilities.gpui.ts @@ -0,0 +1,21 @@ +import type { PointerCapabilities, PointerCapabilitiesSource } from "./pointer-capabilities"; + +export type { PointerCapabilities, PointerCapabilitiesSource }; + +// The GPUI desktop client runs in a macOS, Linux, or Windows window. The runtime reports +// every pointer as a mouse, so a fine pointer drives the UI and the answer never changes. +const GPUI_POINTER_CAPABILITIES: PointerCapabilities = { finePointer: true, touchScreen: false }; + +export function usePointerCapabilities(): PointerCapabilities { + return GPUI_POINTER_CAPABILITIES; +} + +/** True when a mouse-like pointer drives the UI, read at call time. */ +export function hasFinePointer(): boolean { + return true; +} + +/** True when touch is the primary input, read at call time. */ +export function hasTouchPrimaryPointer(): boolean { + return false; +}