Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): avoid freezing appearance font settings #5642

Closedalex73630(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/5642/headopened View on GitHub

Problem

Opening Settings > Appearance automatically enumerated every installed font when local-font access was already granted. The monospace picker then started classifying every family with synchronous canvas measurements in the renderer.

This is especially disruptive in the Electron desktop client. On the affected installation, the Electron renderer became unresponsive while the T3 server remained available through the remote feature. The web client appears less affected by the same workload.

Scope of this PR

This PR prevents the monospace check from starting merely because the Appearance page opened:

  • Start installed-font discovery only after the user focuses a font-family field.
  • Split monospace classification into time-bounded batches that yield between batches.
  • Cache the classification so multiple font pickers share one scan.
  • Show progress while the monospace list is being prepared.
  • Add focused regression coverage for deferred discovery, yielding, and result ordering.

The affected installation can now open Appearance without freezing because page navigation performs no installed-font query or monospace classification.

Known limitation

This PR does not eliminate the catalog-wide monospace check. Interacting with the monospace picker still classifies every installed family. In a real Electron test with 710 unique families, the renderer UI remained unresponsive for more than five minutes even with batching, while requests sent from a phone through the remote feature continued to work.

The underlying work is up to 32 synchronous canvas measurements per family—22,720 measurements for that catalog—plus Chromium's font-resolution cost. Electron appears substantially more affected than the web client.

Follow-up issue #5656 documents the check, the affected-system evidence, possible replacements, optimization leads, and cross-surface acceptance criteria.

Validation

  • vp test run --passWithNoTests --project unit src/appearanceFonts.test.ts — 14 tests passed.
  • vp run typecheck in apps/web.
  • Targeted lint and formatting checks for the three changed files.
  • Manual test on the affected Electron installation: Appearance opens without starting font enumeration. Interacting with the monospace picker still reproduces the remaining renderer freeze documented in #5656.

Model: GPT-5.6 Sol. Harness: Codex in T3 Code.

Note

Fix freezing UI during monospace font classification in FontFamilyPicker

  • Replaces synchronous isMonospaceFamily filtering with a new async filterFontFamiliesWithoutBlocking function that periodically yields to the main thread based on a configurable time budget, preventing UI freezes when iterating large font lists.
  • The FontFamilyPicker component now shows a "Checking installed fonts…" status while async classification runs, and only renders the filtered list once classification completes.
  • Adds a WeakMap-backed cache in FontFamilyPicker.tsx so repeated renders with the same families array skip reclassification.
  • Removes the proactive local-fonts permission probe that previously ran on mount in useFontEnumeration.
Macroscope summarized 726671d.

Note

Low Risk Settings UI and font enumeration timing only; no auth, data, or API changes.

Overview Stops Appearance from kicking off installed-font work on page load by removing the mount-time local-fonts permission probe; enumeration still starts only when a font field is focused.

For monospace pickers, synchronous isMonospaceFamily filtering over the full catalog is replaced with filterFontFamiliesWithoutBlocking, which batches canvas probes under a time budget and yields to the main thread between batches. Results are cached per families array (shared across pickers), and the UI shows “Checking installed fonts…” until classification finishes.

Adds unit coverage for yield timing and preserved filter order.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 726671d41cde30b41edf90ce54a6d4bf7d3059c0. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: be50e1af-519f-4f49-a8a9-6a93ff23558e

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. Additional reproduction details from the affected system:

      • Fontconfig reports 5,112 font faces across 3,214 distinct family-name entries. The family count is the relevant number here because the Appearance picker classifies each family.
      • To reproduce that scale deterministically, I tested with a synthetic catalog of 3,214 families. Monospace classification performs 32 canvas measurements per family, for 102,848 measurements in total.
      • Before the fix: merely opening Appearance started the complete scan synchronously. The browser's main thread remained blocked and the click did not complete before the 60-second automation timeout, which matches the apparent application freeze.
      • After the fix: Appearance opened in under one second and made zero installed-font queries. When I explicitly focused the monospace font field, the complete 3,214-family scan finished in about 15 seconds, but it ran in time-bounded batches. Timers, rendering, and browser interaction continued throughout the scan, and the picker populated when it finished.

      The total probing work is still substantial on this machine, but it no longer happens during page navigation and no longer monopolizes the UI thread.

    4. Correction and scope clarification after testing the patch on the affected Electron installation:

      The earlier synthetic automation result showed that the Appearance page no longer starts font enumeration, but it was not valid evidence that catalog-wide monospace classification remains responsive. The automation timeout also was not proof of a process deadlock.

      A real Electron test gives the more important result:

      • Opening Appearance now works because no font scan starts during page navigation.
      • Interacting with the monospace picker still starts the complete monospace scan.
      • With 710 unique families, the Electron renderer UI remained unresponsive for more than five minutes despite the batched yields.
      • The server was not blocked: requests sent from a phone through the remote feature continued to work.
      • The equivalent web-client experience appears less affected, so Electron and web need separate performance verification.

      This PR should therefore be treated as a focused fix for the page-load regression, not a complete fix for monospace font discovery. Follow-up issue #5656 documents the remaining problem and implementation options.

    5. Approvability

      Verdict: Approved 792358c

      This is a self-contained performance fix that prevents UI freezing when scanning installed fonts in appearance settings. The changes add async yielding during expensive font probes, include appropriate unit tests, and are limited to the font picker component with no security or data implications.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    6. 💡 Codex Review

      Here are some automated review suggestions for this pull request.

      Reviewed commit: 792358c91e

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

      @@ -132,3 +119,13 @@
      132119 }, []);
      133120 const listRef = useRef<LegendListRef | null>(null);
      134121 const enumeration = useFontEnumeration();
      122+ const [monospaceClassification, setMonospaceClassification] = useState<{
      123+ readonly source: readonly string[];
      124+ readonly families: readonly string[];
      125+ } | null>(null);
      126+
      127+ useEffect(() => {
      128+ if (!requireMonospace || enumeration.status !== "granted") return;
      129+ const source = enumeration.families;
      130+ let cancelled = false;
      131+ void readMonospaceFamilies(source).then((families) => {

      P1 Badge Defer monospace scanning until that picker opens

      When the user focuses the Interface or Prompt font field, discovery updates the shared enumeration state to granted, which mounts the always-present Code/Monospace picker and immediately runs this effect even though the user never opened it. On a large catalog—especially the affected Electron case—merely interacting with a proportional-font field therefore still starts the multi-minute canvas scan and freezes the renderer; gate readMonospaceFamilies on the monospace picker actually being opened rather than on global enumeration alone.

      AGENTS.md reference: AGENTS.md:L15-L17

      Useful? React with 👍 / 👎.

    7. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot).

      Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 726671d41cde30b41edf90ce54a6d4bf7d3059c0. Configure [here](https://www.cursor.com/dashboard/bugbot).
      @@ -140,5 +143,12 @@
      140143
      141144 const families = useMemo(() => {
      142145 if (enumeration.status !== "granted") return [];
      143- return requireMonospace ? enumeration.families.filter(isMonospaceFamily) : enumeration.families;
      144- }, [enumeration, requireMonospace]);
      146+ if (!requireMonospace) return enumeration.families;
      147+ return monospaceClassification?.source === enumeration.families
      148+ ? monospaceClassification.families
      149+ : [];
      150+ }, [enumeration, monospaceClassification, requireMonospace]);
      151+ const classifyingMonospaceFamilies =
      152+ requireMonospace &&
      153+ enumeration.status === "granted" &&
      154+ monospaceClassification?.source !== enumeration.families;

      Open picker lists only Default

      Medium Severity

      initialOpen opens the monospace popup while async classification still leaves families empty, so items is only the default entry (with autoHighlight). Enter or click can commit that default and clear a previously saved family during the long “Checking installed fonts…” window. Previously the sync filter finished before the popup opened, so this gap did not exist.

      Additional Locations (1)
      Fix in Cursor Fix in Web
      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 726671d41cde30b41edf90ce54a6d4bf7d3059c0. Configure [here](https://www.cursor.com/dashboard/bugbot).
    8. Note

      🤖 GPT-5.6 Sol responding on behalf of Theo

      We're closing this PR as we clean up the T3 Code backlog. Thank you for taking the time to put this together.

      We are keeping the font-picker performance fix in the open #7494, which validates a chosen font instead of scanning the full catalog. We do not need both implementations open.

      If you believe we closed this in error, please reopen the PR and leave a comment explaining what we missed.

Sign in to join this conversation.