Skip to content

perf: keystroke path does a full AppKit hit-test per event + heavy forceRefresh after input #183

Description

@arzafran

From the gpt-5.6-sol codebase eval (P0). This touches the sacred typing-latency path, so it needs careful, measured work in its own session, not a rushed batch.

Two hot-path costs on every keystroke:

  • NSWindow.programa_sendEvent computes a hit view for every event before checking its type (Sources/WindowSwizzles.swift:231 -> themeFrame.hitTest at :614); WindowTerminalHostView still calls recursive super.hitTest even though it skips pointer routing for keyboard events (Sources/WindowTerminalHostView.swift:126).
  • After text input, forceRefresh builds interpolated diagnostic state and checks the layer outside #if DEBUG, then does geometry/display reconciliation before the refresh (Sources/TerminalSurface.swift:1430, called from Sources/GhosttyTerminalView+Keyboard.swift:918).

First step: return a nil hit context for non-pointer events and rely on first-responder context; add a minimal requestRedrawAfterInput() that only calls ghostty_surface_refresh, keeping forceRefresh for topology changes. MEASURE p95 keystroke latency before/after with the existing lag harness — do not merge on eyeball.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions