Skip to content

Make the editor respond faster on iPads and phones, and pages paint sooner - #27

Merged
The1UNeed merged 1 commit into
mainfrom
t3/improve-web-vitals
Nov 5, 2026
Merged

The1UNeed merged 1 commit into
mainfrom
t3/improve-web-vitals

Conversation

@The1UNeed

@The1UNeed The1UNeed commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

Field data (PostHog, 30 days) puts the bad INP on /app on iPads and phones. FCP is about 1.3–1.5 s everywhere.

Each change was kept only if removing it measured slower: every group was reverted in turn and re-measured with 6× and 10× CPU throttling and slow 4G.

Change What it buys (lab)
Monaco loads in small steps (monacoLocalLoader, lib/monaco/*) worst tap while the editor loads: 544 → 168 ms (6×)
Run, Create File and opening a file start after the tap paints (afterNextPaint) at 10×: Run 96 → 56 ms, switching files 176 → 128 ms
/app prerenders a title-bar skeleton; signed-out visitors don't wait for Clerk editor's first paint 376 → 128 ms (4×)
PostHog loads after the page is idle, with an event queue and early web vitals public pages: 870–903 → 542–576 KB of JS at load
experimental.inlineCss + Inter fallback-font metrics public FCP on slow 4G: about −270 ms; CLS 0
Home page holds first paint until the hero is parsed (rel="expect") stops the hero window growing after paint with inlined CSS (CLS 0.085 → 0)
Clerk middleware only on /api; locale routing as next.config rewrites pages no longer run middleware per request

Against current main (with #28), on a returning student with 60 files:

main 6× this PR 6× main 10× this PR 10×
worst tap while the editor loads 1056 ms 176 ms 1632 ms 272 ms
Run 104 ms 48 ms 144 ms 64 ms
switching files 160 ms 96 ms 264 ms 152 ms
p98 of all interactions 176 ms 136 ms 280 ms 232 ms
/app first paint 620 ms 120 ms 1000 ms 168 ms

Public pages on slow 4G: FCP 596–824 → 388–584 ms, and TBT 43–49 → 9–15 ms.

Tried and dropped because they made no measurable difference: deferring re-renders while typing, a terminal transcript class, static filtered /lessons and /practice pages, moving language registration before mount, and a font preload (that one made FCP about 100 ms worse).

Proved with production builds against main:

The Vercel preview fails for an existing reason: the Convex preview deployment lacks CLERK_JWT_ISSUER_DOMAIN.

Reviewed with sol-loop: 2 rounds with gpt-6.1-sol on high. Sol verdict: approved

🤖 Generated with Claude Code


Note

Medium Risk
Locale and middleware routing changes affect every page URL and CDN caching behavior, and workspace load timing now depends on Clerk cookie heuristics alongside deferred Run/editor paths.

Overview
This PR targets Interaction to Next Paint on /app and first paint on public pages through a mix of routing, loading, and interaction scheduling changes.

Routing and static delivery: English locale handling moves from middleware rewrites to next.config rewrites and redirects (/ → /en, bare paths → /en/..., /en/* → canonical bare URLs). Clerk middleware now runs only on /api, so page HTML can be served from the CDN without a per-request proxy hop. experimental.inlineCss inlines global CSS for initial HTML loads.

Editor and /app responsiveness: A new afterNextPaint helper defers heavy work until after the next frame—Run, create file, and Monaco mount per document—so taps paint first. Monaco loads in yielded chunks via refactored monacoLocalLoader and lib/monaco/* imports instead of one long synchronous bundle. /app shows a hydration-safe title-bar skeleton while the workspace loads, and mayHaveClerkSession (Clerk __client_uat cookie) lets signed-out visitors open an in-memory workspace without waiting for Clerk; Run also tracks the active document when deferred.

Public landing: rel="expect" blocks first paint until the hero section is parsed (pairs with inlined CSS to avoid hero layout shift). Inter Fallback metrics reduce font-swap CLS.

Analytics: PostHog moves to an idle-loaded dynamic chunk with startEarlyAnalytics (web vitals + early errors) and a bounded event queue drained when PostHog initializes.

Reviewed by Cursor Bugbot for commit 6e28d91. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel

vercel Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
pseudoeditor.dev Error Error Nov 5, 2026 2:23pm UTC

Request Review

@cursor

cursor Bot commented Nov 5, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 93934a0d-6fab-49dc-ac63-fbe6313d2f3e)

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 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-05T14:25:48.607048Z 6e28d91 New commits
ℹ️ 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.

@cursor

cursor Bot commented Nov 5, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: e9afd949-e1a7-4421-8fd3-c81a54347957)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: af2109d8dd

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

@cursor

cursor Bot commented Nov 5, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: c4dde633-7cb3-494e-8332-0ace10363622)

@cursor

cursor Bot commented Nov 5, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 2b7487d3-5b02-44ef-82e0-76eb5f81bec2)

@cursor

cursor Bot commented Nov 5, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 0c1d6db8-ca90-49f3-ae41-5a47d4df1237)

@cursor

cursor Bot commented Nov 5, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 274b00ea-d547-421b-9e0b-7eb26f715d42)

…ooner

Each change was kept only if removing it measured slower (6x and 10x CPU throttle, slow 4G):
- Monaco loads in small steps, so taps during loading stay responsive.
- Run, Create File and opening a file start after the tap has painted.
- /app prerenders its title bar; signed-out visitors don't wait for Clerk.
- PostHog loads once the page is idle; events, early errors and web vitals are held for it.
- The stylesheet is inlined into the HTML, and Inter's fallback matches its metrics.
- Clerk middleware runs only for /api; locale routing is a next.config rewrite.
- The home page holds first paint until its hero window has arrived, so it does not grow after painting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@The1UNeed
The1UNeed force-pushed the t3/improve-web-vitals branch from 162164b to 6e28d91 Compare November 5, 2026 14:22
@cursor

cursor Bot commented Nov 5, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: d762f252-c926-4ad0-8333-a5d64c91f97a)

@The1UNeed
The1UNeed merged commit 1e83043 into main Nov 5, 2026
6 of 7 checks passed

This branch had an error being deployed

1 failed deployment
Preview — 6e28d91b Deployed Nov 5, 2026 by vercel[bot]
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