Skip to content

fix(sql-editor): debounce decoration updates while typing#23

Open
xPolar wants to merge 1 commit into
masterfrom
capy/sql-editor-debounce-decoration
Open

fix(sql-editor): debounce decoration updates while typing#23
xPolar wants to merge 1 commit into
masterfrom
capy/sql-editor-debounce-decoration

Conversation

@xPolar

@xPolar xPolar commented Jun 19, 2026

Copy link
Copy Markdown

Problem

Editing large SQL queries stalls the editor because every input update resolves the active subquery immediately. That path parses the full query with the HogQL WASM parser before the browser can paint.

Fixes PostHog#60974.

Changes

  • Debounce active-query decoration work until typing or cursor movement has been idle for 150 ms.
  • Use the keyed Kea disposable for replacement and unmount cleanup.
  • Add a regression test proving rapid query updates produce one deferred decoration update.

How did you test this code?

  • Ran all 63 tests in sqlEditorLogic.test.ts.
  • Ran the frontend TypeScript check and formatting check.
  • Benchmarked 24 edits at a 50 ms key interval in Chromium against the same 16,576-byte, 250-CTE query. Keydown-to-next-paint latency fell from 391.7 ms median / 441.1 ms p95 to 21.2 ms median / 26.7 ms p95. CDP sampling attributed the baseline long tasks to the HogQL WASM parser; the final browser run retained all typed text and reduced parser long tasks from one per edit to one after the debounce settled.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Docs update

No documentation changes are needed for this editor performance fix.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Captain Capy reproduced and profiled the issue with a Playwright/Chrome DevTools benchmark. The chosen fix defers existing decoration work rather than caching parser output globally, keeping behavior scoped to each editor logic while eliminating per-keystroke parsing.


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

… on large queries

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@xPolar xPolar added the capy Generated by capy.ai label Jun 19, 2026 — with Capy AI
@capy-ai capy-ai Bot changed the title perf(sql-editor): debounce decoration updates on typing fix(sql-editor): debounce decoration updates while typing Jun 19, 2026
@capy-ai capy-ai Bot assigned xPolar Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

capy Generated by capy.ai

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Editing large SQL queries can be slow to update when typing

1 participant