Cap derived-quality ghost font size separately from exact#386
Open
FuJacob wants to merge 1 commit into
Open
Conversation
`resolvedGhostFontSize` treated `.exact` and `.derived` carets identically, capping both at 24pt. In hosts that emit `.derived` geometry (Slack, several web editors), the line-box height commonly inflates against the real font size, so ghost text rendered with a ~20pt cap looked oversized next to ~13pt host text — the "insanely big derived" failure mode users reported. Split the cap into three tiers keyed off `CaretGeometryQuality`: 24pt for `.exact` (measured text bounds, still trusted), 17pt for `.derived` (just above the estimated cap, since derived geometry is more reliable than estimated but still not measured), 16pt for `.estimated` (unchanged). The observed failure mode is too-large, not too-small, so biasing the derived ceiling toward the smaller end is the right tradeoff. `GhostFontSizeStabilizer` still handles per-session downward smoothing on top of this.
Comment on lines
14
to
21
| static let minimumGhostFontSize: CGFloat = 14 | ||
| static let maximumGhostFontSize: CGFloat = 24 | ||
| /// Derived caret rects come from line-box geometry rather than measured text bounds, so the | ||
| /// reported height often inflates against the host's real font size (Slack, several web | ||
| /// editors). Keep the ceiling well below the exact cap so a wrong derived reading cannot | ||
| /// render oversized ghost text — the observed failure mode is too-large, not too-small. | ||
| static let maximumDerivedGhostFontSize: CGFloat = 17 | ||
| static let maximumEstimatedGhostFontSize: CGFloat = 16 |
Contributor
There was a problem hiding this comment.
Now that all three caps are per-quality constants,
maximumGhostFontSize is the odd one out — it's the only name that doesn't signal which quality tier it governs. Renaming it to match the pattern of its siblings makes the Layout enum self-documenting and avoids any future confusion about whether the generic name applies to all qualities.
Suggested change
| static let minimumGhostFontSize: CGFloat = 14 | |
| static let maximumGhostFontSize: CGFloat = 24 | |
| /// Derived caret rects come from line-box geometry rather than measured text bounds, so the | |
| /// reported height often inflates against the host's real font size (Slack, several web | |
| /// editors). Keep the ceiling well below the exact cap so a wrong derived reading cannot | |
| /// render oversized ghost text — the observed failure mode is too-large, not too-small. | |
| static let maximumDerivedGhostFontSize: CGFloat = 17 | |
| static let maximumEstimatedGhostFontSize: CGFloat = 16 | |
| static let minimumGhostFontSize: CGFloat = 14 | |
| /// Measured text bounds from the accessibility API; trusted to scale up in larger editors. | |
| static let maximumExactGhostFontSize: CGFloat = 24 | |
| /// Derived caret rects come from line-box geometry rather than measured text bounds, so the | |
| /// reported height often inflates against the host's real font size (Slack, several web | |
| /// editors). Keep the ceiling well below the exact cap so a wrong derived reading cannot | |
| /// render oversized ghost text — the observed failure mode is too-large, not too-small. | |
| static let maximumDerivedGhostFontSize: CGFloat = 17 | |
| static let maximumEstimatedGhostFontSize: CGFloat = 16 |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Split the ghost-text font-size ceiling in
OverlayController.resolvedGhostFontSizeso.derivedcaret quality no longer shares the.exactcap. Today.exactand.derivedboth clamp at 24pt; in hosts that emit.derivedgeometry from line-box bounds (Slack, several web editors) the reported caret height inflates against the host's real font size, and ghost text renders comically oversized. The observed failure mode is too-large, not too-small.New tiers:
.exact.derived.estimatedGhostFontSizeStabilizerstill does per-focus-session downward smoothing on top of these caps, so a momentarily-better reading inside one session still narrows the ceiling.Validation
Local full-test execution hits the documented Team ID code-signing mismatch on this machine; CI runs the test target against the merge ref.
Linked issues
None filed; reported in-conversation.
Risk / rollout notes
.derivedquality, ghost text will now cap at 17pt and look slightly small. The current state is worse for affected hosts ("comically oversized") than for unaffected hosts (slightly small), so the asymmetry favors the cap..exactpaths (most native AppKit fields, Gmail/Outlook text-marker path) are unchanged.Layout.Greptile Summary
This PR splits the ghost-text font-size ceiling in
resolvedGhostFontSizeso.derivedcaret quality gets its own cap (17 pt) instead of sharing the.exactcap (24 pt), fixing oversized ghost text in hosts like Slack that inflate caret height from line-box geometry.maximumDerivedGhostFontSize = 17is added toLayout; the old binary ternary (.estimatedvs everything else) is replaced with an exhaustiveswitchover all threeCaretGeometryQualitycases..exact(24 pt) and.estimated(16 pt) caps are unchanged; only.derivedis tightened, isolating the regression risk to hosts that already report inflated derived geometry.Confidence Score: 5/5
Safe to merge — the change is pure value math on three named constants, the switch is exhaustive and compiler-enforced, and the only affected path is
.derivedquality which is currently producing the worse "comically oversized" outcome.The change is a tightly scoped constant split with an exhaustive switch. Adding
CaretGeometryQualitycases in the future would produce a compile error rather than silently falling through to the wrong cap. The.exactand.estimatedpaths are byte-for-byte identical to before, and.derivedtightening only affects hosts already exhibiting the oversized-text failure mode.No files require special attention. The single changed file is self-contained value math with no side effects outside the font-size calculation.
Important Files Changed
maximumDerivedGhostFontSize = 17and expands the binary ternary into an exhaustive switch over all threeCaretGeometryQualitycases, giving.derivedits own cap between.exact(24) and.estimated(16).Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A["resolvedGhostFontSize(caretHeight:caretQuality:)"] --> B["proposedSize = max(minFont, caretHeight × 0.78)"] B --> C{caretQuality} C -- ".exact" --> D["qualityCap = 24 pt\n(maximumGhostFontSize)"] C -- ".derived" --> E["qualityCap = 17 pt\n(maximumDerivedGhostFontSize)\n★ NEW"] C -- ".estimated" --> F["qualityCap = 16 pt\n(maximumEstimatedGhostFontSize)"] D --> G["return min(proposedSize, qualityCap)"] E --> G F --> GReviews (1): Last reviewed commit: "Cap derived-quality ghost font size sepa..." | Re-trigger Greptile