Optimize scrolling checkpoint

This commit is contained in:
jacob314
2026-04-24 17:11:18 -07:00
parent c597c2b64b
commit c612957caf
18 changed files with 422 additions and 92 deletions
@@ -12,6 +12,7 @@ import {
type MouseEvent,
type MouseEventName,
} from '../contexts/MouseContext.js';
import { debugLogger } from '@google/gemini-cli-core';
export const useMouseClick = (
containerRef: React.RefObject<DOMElement | null>,
@@ -30,6 +31,10 @@ export const useMouseClick = (
(event: MouseEvent) => {
const eventName =
name ?? (button === 'left' ? 'left-press' : 'right-release');
debugLogger.log(
`[useMouseClick] received event=${event.name} expected=${eventName} hasContainer=${!!containerRef.current}`,
);
if (event.name === eventName && containerRef.current) {
const { x, y, width, height } = getBoundingBox(containerRef.current);
// Terminal mouse events are 1-based, Ink layout is 0-based.
@@ -39,12 +44,17 @@ export const useMouseClick = (
const relativeX = mouseX - x;
const relativeY = mouseY - y;
debugLogger.log(
`[useMouseClick] bounds x=${x} y=${y} w=${width} h=${height} mouseX=${mouseX} mouseY=${mouseY} relX=${relativeX} relY=${relativeY}`,
);
if (
relativeX >= 0 &&
relativeX < width &&
relativeY >= 0 &&
relativeY < height
) {
debugLogger.log(`[useMouseClick] Triggering handler!`);
handlerRef.current(event, relativeX, relativeY);
}
}