fix(web): validate monospace fonts on pick instead of scanning the catalog #7494
Closedeggfriedrice24(GitHub profile, opens in a new tab)wants to merge 9 commits into
main fromrefs/pull/7494/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/web/src/appearanceFonts.ts lines 225 to 226OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -216,5 +210,17 @@216- * legitimate font.210+ * Probing a family is up to 32 measureText calls, and setting the canvas font211+ * to a new family string forces engine font matching on top. Verdicts cannot212+ * change while the page lives (the installed font list is itself cached for213+ * the session), so both passes and failures are kept, keyed by the normalized214+ * family list.217215 */218-export function isMonospaceFamily(family: string): boolean {219- const families = cssFontFamilies(family);220- if (families === null) return true;216+export function createCachedFamilyProbe(217+ probe: (families: string) => boolean,218+): (family: string) => boolean {219+ const verdicts = new Map<string, boolean>();220+ return (family) => {221+ const families = cssFontFamilies(family);222+ if (families === null) return true;223+ const cached = verdicts.get(families);224+ if (cached !== undefined) return cached;225+ const verdict = probe(families);226+ verdicts.set(families, verdict);
alex73630(GitHub profile, opens in a new tab) approved these changes
- apps/web/src/appearanceFonts.ts line 226OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -211,4 +209,18 @@209+ * kept keyed by the normalized family list. A failure always names a resolved210+ * face and is final. A pass may be the generic fallback speaking for a face211+ * that has not loaded yet, so it is only kept once the family resolves;212+ * until then every call probes again, which is what lets the terminal213+ * revalidate after a late face loads and still reject a proportional one.211214 */212-export function isMonospaceFamily(family: string): boolean {213- const families = cssFontFamilies(family);214- if (families === null) return true;215+export function createCachedFamilyProbe(216+ probe: (families: string) => boolean,217+ resolves: (families: string) => boolean,218+): (family: string) => boolean {219+ const verdicts = new Map<string, boolean>();220+ return (family) => {221+ const families = cssFontFamilies(family);222+ if (families === null) return true;223+ const cached = verdicts.get(families);224+ if (cached !== undefined) return cached;225+ const verdict = probe(families);226+ if (!verdict || resolves(families)) verdicts.set(families, verdict);
juliusmarminge closed this
Sign in to join this conversation.


Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
4ecc93fe-981b-4788-b211-cf5a9b31fcb5📥 Commits
Reviewing files that changed from the base of the PR and between 7a00e58986d2a58cc8138e6f6aef4c674ad2faec and 9113a4b101b3675300086dca615d019fe16ca736.
📒 Files selected for processing (1)
apps/web/src/components/settings/FontFamilyPicker.tsxIncluded review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Walkthrough#
The font utilities now cache resolved family probe results.
FontFamilyPickerdisplays all installed families and validates monospace requirements only after selection. Invalid selections show an error toast and are not committed.Changes#
Font validation flow
apps/web/src/appearanceFonts.ts,apps/web/src/appearanceFonts.test.tsapps/web/src/components/settings/FontFamilyPicker.tsxonSelect.Priority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Medium
Sequence Diagram(s)#
Suggested reviewers:
alex73630Merge Risk: ⚪ Minimal · up to
9113aThe picker now shows all installed font families while validating monospace compatibility only when selected, preserving the current font for invalid choices. No actionable merge-blocking risk remains.
🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)#
#5656.FontFamilyPickerlists the complete enumerated catalog and callsisMonospaceFamilyonly for a selected non-default value. Rejected v…#5656behaviors, or add those tests if that coverage is absent.✅ Passed checks (3 passed)
#5656.Full details: Linked Issues check
Explanation
The implementation matches the main coding objectives in
#5656.FontFamilyPickerlists the complete enumerated catalog and callsisMonospaceFamilyonly for a selected non-default value. Rejected values do not callonSelect, and the default path commits without probing.createCachedFamilyProbenormalizes family lists, caches resolved verdicts, and leaves unresolved verdicts uncached. The added tests cover cache normalization, unresolved families, multi-family resolution, and empty input. The available PR evidence does not establish focused coverage for proportional-selection rejection, manual-input fallback, default non-probing, or the absence of probing during open, search, scroll, and highlight interactions.✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands.