Skip to content

Studio: browser pane opens without per-frame thread work on long chats - #17282

Merged
danielhanchen merged 4 commits into
mainfrom
studio-browser-pane-open
Nov 9, 2026
Merged

danielhanchen merged 4 commits into
mainfrom
studio-browser-pane-open

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Problem

Opening or closing the browser pane in a long chat still cost far more than in a short one, worst on macOS WebKit (Round 11 real runners: open 460 to 562 ms at 150 turns against 144 to 165 ms at 1 turn). #16986 already keeps distant rows out of layout; this PR removes the per-frame work that remained.

Causes

  • The pane's open and close slide the chat column's width over 260 ms, and every frame of the slide re-wraps every row still inside the layout reach around the reading position. Turning only the slide off cut slow-frame time on macOS WebKit from 401 to 549 ms to 312 to 354 ms.
  • The side-panel inset lookup in chat-page.tsx used root.querySelectorAll(":scope > [data-side-panel-inset]"), which matches against every node below the root (about 57,000 elements in a 150-turn chat), and the resize observer ran it on every frame of the slide: the largest single per-open cost in the Chromium profile (about 25 ms).
  • dismiss-click-streak.ts ran a descendant selector for an open menu against the whole document on every press anywhere: about 10 ms per click at 150 turns.

Change

  • The inset lookup reads the root's direct children.
  • The press check first looks for a Radix popper wrapper and only runs the menu selector when one exists; the result is identical.
  • A chat taller than the layout reach (viewport plus 2x rowReachPx, about 4,500 px on a 900 px window) takes the pane's new width in one step (data-artifact-layout-instant); shorter chats keep the slide. The attribute is set or cleared on every open and close.

Look

In long chats only, the chat column snaps to its new width instead of sliding when the pane opens or closes. The pane's own entrance is unchanged, and the end state is the same. The Linux desktop app already resized in one step and is untouched. Reading position through open and close (Chromium, 150 turns): at the bottom it stays at the bottom, as on main; mid-chat the top message moves 5 px (146 px on main).

Results

Real runners, 1 vs 150 turns, main measured twice (A/A), interleaved:

150 turns main main (A/A) this PR 1 turn
macOS WebKit, slow-frame time on open 332 ms 288 ms 150 ms 0 ms
macOS WebKit, longest frame on open 92 ms 80 ms 98 ms 43 ms
macOS Chromium, open layout / style 20 / 23 ms 18 / 26 ms 10 / 15 ms 7-9 / 16-20 ms
Windows Edge, open layout / style 45 / 55 ms 47 / 56 ms 28 / 33 ms 22 / 40 ms
Windows Edge, close layout 32-40 ms 39-49 ms 9-16 ms

The Windows result held on two runners; the macOS result is one runner with three interleaved reps (the head's worst rep, 291 ms, overlaps the A/A range). The longest single frame is within noise.

Not addressed: the first pane open of a session on macOS WebKit still costs about 350 to 560 ms; it is not code loading or row layout (prefetching and hiding every row did not remove it), most likely garbage collection over a long chat's heap.

Tests

  • New tests/dismiss-click-streak.test.ts case (fails on main) and tests/browser-pane-open-cost.test.ts source checks for the inset lookup and the one-step rule.
  • Frontend node suite 15,326 pass, tsc --noEmit clean; the long-chat gate passes.

- Side-panel insets are read from the chat root's children; the :scope query matched every
  node of the thread on each resize-observer tick of the pane's slide.
- The dismiss-click guard looks for a popper wrapper before running its descendant menu
  query, which walked the whole chat on every press (about 10 ms at 150 turns).
- A chat taller than the rows kept in reach of the reader takes the pane's width in one step:
  the slide re-wrapped those rows on every frame (about 200 ms of slow frames on macOS WebKit).
  Shorter chats keep the slide.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T20:03:49.943315Z a88481a 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 4c515c75bc

ℹ️ 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".

@NilayYadav

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: a88481a89a

ℹ️ 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 ab9845e into main Nov 9, 2026
@danielhanchen
danielhanchen deleted the studio-browser-pane-open branch November 9, 2026 20:24
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.

2 participants