Skip to content

Studio: restore WebKitGTK offscreen code fences in batches and on any pointer release - #16919

Merged
danielhanchen merged 2 commits into
mainfrom
studio-fence-webkitgtk-followup
Nov 6, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
studio-fence-webkitgtk-followup

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Follow-up to #16854. Two review findings on the WebKitGTK (Linux desktop) code fence paths; Chromium (Windows) and macOS never enable these paths, so nothing changes there.

Problems

  1. Scrolling back to a dense code fence below the 240-line window cap remounted every highlighted token in one commit. When the fence goes offscreen it is parked as plain text and FenceLines unmounts, but useFenceHighlightLimit stays mounted with finished progress, so coming back skipped the 512-token batches. A 120-line fence with 64 tokens per line came back as 7,680 spans in a single render.
  2. A fence that came into view while a finger was down stayed unhighlighted after the finger lifted. The restore is deferred while a pointer is held and retried on release, but releasePointer() returned early unless a mouse press had been recorded. Touch never records one, and neither does a mouse press that began before the listeners attached.

Fix

  • useFenceHighlightLimit takes the parked state. Parking restarts the batched progress and pauses the queue, so returning remounts one batch at a time. The reset only runs when the parked state changes, so it is idempotent.
  • releasePointer() always clears the held pointer and schedules the retry when a restore was deferred. Repeated calls coalesce into one frame.

Tests

  • New studio/frontend/tests/code-fence-offscreen-restore.test.ts runs the real hook and listener code extracted from code-fence-defer.tsx:
    • a dense fence that is parked and restored returns at most one 512-token batch per commit, and does no highlight work while parked;
    • touch release, normal mouse release, and a mouse press that began before the listeners attached all restore the fence.
  • Each test fails without its fix (3 of 4 fail on main; the normal mouse case already worked).
  • desktop-webkit-paths.test.ts updated for the new releasePointer body.
  • 108 of 108 tests in the 13 files that read code-fence-defer.tsx pass; tsc -p tsconfig.app.json is clean.

…ter release

A dense under-cap fence parked as plain text kept its completed highlight
progress, so scrolling back remounted every highlighted span in one commit.
Restart the quiet-work batches while the fence is parked.

releasePointer returned early unless a mouse press had been recorded, so a
touch release (or a mouse press that predates the listeners) never retried
the offscreen-text restore that a held pointer had deferred. Retry on every
release once a held frame was marked.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T14:28:51.959747Z a1faa1c Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: a1faa1c732

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 07a9c87 into main Nov 6, 2026
@danielhanchen
danielhanchen deleted the studio-fence-webkitgtk-followup branch November 6, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant