Skip to content

docs(specs): inline code chip ink-width background (GH13914) - #14026

Closed
fbartho wants to merge 6 commits into
warpdotdev:masterfrom
fbartho:fb/13914-code-chip-ink-width-spec
Closed

fbartho wants to merge 6 commits into
warpdotdev:masterfrom
fbartho:fb/13914-code-chip-ink-width-spec

Conversation

@fbartho

@fbartho fbartho commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Closes #13914

Adds a product spec and tech spec for the inline-code chip background asymmetry: the chip's background/border is currently painted using each glyph's advance width (which bakes in right-side bearing/spacing), so the gap between the last character's ink and the chip's right edge is consistently larger than the equivalent left-side gap — and varies with whichever glyph ends the span.

The spec's proposed design draws the chip's edges from glyph ink extents plus a font-relative design padding: [first_ink_left − pad, last_ink_right + pad] where pad is computed per run at paint time as font_size × ratio — it scales automatically with the current font size, with interior glyph positions remaining advance-based. Per-glyph ink is available cross-platform through the existing platform::FontDB::glyph_raster_bounds (already cached; macOS font-kit raster bounds and Linux swash placement have matching true-ink semantics), so the correction is exact rather than a tuned constant — this also incidentally fixes the current right edge clipping ink overshoot from italic/overhang glyphs. The tech spec documents glyph_typographic_bounds as an examined dead end (its two backends measure different things), the device→paint scale conversion, a ~1px macOS AA-fudge residual, and a zero-ink (e.g. trailing space) advance-edge fallback; it confirms the TUI Markdown renderer does not reach this paint path and is unaffected.

Remaining open questions are design-taste rather than correctness: the dimensionless padding ratio (currently 1/12 of the font size — chosen to approximate a typical monospace left-side bearing so the chip's left edge stays where today's advance-based edge sits) and visual sign-off on the macOS AA residual.

Adds product and tech specs for warpdotdev#13914: the inline code
chip's background/border is painted using per-glyph advance width
(which includes right-side bearing) rather than ink width, producing
a visually larger gap on the right edge than the left.
@cla-bot cla-bot Bot added the cla-signed label Jul 20, 2026
@github-actions github-actions Bot added the external-contributor Indicates that a PR has been opened by someone outside the Warp team. label Jul 20, 2026
@fbartho
fbartho marked this pull request as ready for review July 21, 2026 01:24
@warp-for-oss

warp-for-oss Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

@fbartho

I'm starting a first review of this spec-only pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@warp-for-oss warp-for-oss Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overview

This PR adds product and technical specs for correcting inline-code chip background geometry by deriving horizontal edges from glyph ink extents instead of glyph advances. The proposed approach is generally aligned with the issue and identifies the relevant shared text-layout path, raster-bounds API, TUI non-goal, edge cases, risks, and validation plan.

Concerns

  • The tech spec mischaracterizes the existing block_padding rectangle math as symmetric. In the current formula, visible_left - 2 * block_padding plus (visible_right - visible_left) + 2 * block_padding leaves the right edge at visible_right, so the proposed equal ink padding cannot be implemented correctly until the spec states how that compensation is replaced or adjusted.

Verdict

Found: 0 critical, 1 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread specs/GH13914/tech.md Resolved
…ompensation (GH13914)

Oz flagged that the existing paint math (visible_left - 2*block_padding, width
(visible_right - visible_left) + 2*block_padding) is asymmetric: block_padding
algebraically cancels out of the right edge and only ever shifts the left edge.
The prior spec wording claimed this was applied "symmetrically to both edges",
which was wrong.

Traced through the impl (fb/13914-code-chip-ink-width-impl,
crates/warpui_core/src/text_layout.rs:1362-1405): the ink-derived edges are
substituted as local visible_left/visible_right values immediately before this
unchanged block_padding math runs, so the fix composes with the legacy left-only
offset rather than replacing or bypassing it. The right edge ends up pure
ink-geometry (block_padding cancels), but the left edge picks up an extra
2*block_padding beyond the intended ink padding — a font_size/5 (~1px at 13px)
residual left/right imbalance that survives the fix, unrelated to the
advance-vs-ink bug this issue targets.

Documents this precisely in tech.md (new "Interaction with the legacy
block_padding offset" section + Follow-up), and softens product.md's Success
Criterion 1 / adds Open Question warpdotdev#4 so the spec doesn't overclaim full left/right
padding equality.
@fbartho

fbartho commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

/oz-review

@warp-for-oss

warp-for-oss Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

@fbartho

I'm re-reviewing this spec-only pull request in response to a review request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@warp-for-oss warp-for-oss Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overview

This PR adds product and tech specs for deriving inline-code chip backgrounds from glyph ink extents instead of advance widths. The overall approach is feasible and the security pass found no new security surface, but the current spec still has unresolved product/tech mismatches around the accepted padding geometry and the implementation blast radius.

Concerns

  • The product spec promises equal ink padding, while the tech spec explicitly preserves the existing left-only block_padding offset and says equal padding is not fully achieved.
  • The success criterion that the left edge stays within a sub-pixel for any code span is stronger than the fixed font_size / 12 padding design can guarantee.
  • The spec leaves the shared-path blast radius as an open question even though the tech design applies to every TextStyle::background_color/TextStyle::border consumer.

Verdict

Found: 0 critical, 3 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread specs/GH13914/product.md Resolved
Comment thread specs/GH13914/product.md Resolved
Comment thread specs/GH13914/product.md Resolved
… (GH13914)

Round-2 review resolutions on PR warpdotdev#14026:

- Bring the block_padding correction in scope for chips: compensate out the
  legacy left-only 2*block_padding shift so chip edges are equal ink padding on
  both sides, literally. Non-chip runs keep the legacy math. The composes-section
  becomes replaced-for-chips; the algebra stays as evidence.
- Rewrite the success criterion honestly: equal ink padding is the promise; the
  left edge tightens ~1px as an intended consequence, not preservation. The
  font_size/12 padding is a design value for air, no longer doing left-edge duty.
- Make the scope explicit and intentional: the ink-edge geometry applies to the
  chip family (inline-code chips today, kbd keycaps per PR warpdotdev#13916 once landed) via
  a named TextStyle::is_chip predicate. All other border/background consumers are
  unchanged.
@fbartho

fbartho commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

/oz-review

@warp-for-oss

warp-for-oss Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

@fbartho

I'm re-reviewing this spec-only pull request in response to a review request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@warp-for-oss warp-for-oss Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overview

This spec PR adds product and tech specs for deriving inline-code chip background geometry from glyph ink extents instead of advance widths.

Concerns

  • The specs contain inconsistent numeric guidance for the intended left-edge shift: 2 * block_padding = font_size / 5 is described as roughly 1px at a 13px font, but that computes to about 2.6px.
  • The zero-ink fallback rule is internally inconsistent: the fallback section says to use the raw advance edge, while the testing section expects advance-edge ± pad.
  • No security findings: this is a paint-time text-layout geometry change and does not introduce new external inputs, auth boundaries, sensitive data handling, secrets, or automation surfaces.

Verdict

Found: 0 critical, 2 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread specs/GH13914/tech.md Resolved
Comment thread specs/GH13914/tech.md Resolved
…g (GH13914)

Round-3 review findings:
- tech.md:132 understated 2*block_padding as ~1.08px; it is font_size/5,
  ~2.6px at a 13px font (a clearly visible shift, not sub-pixel). Propagate
  the corrected magnitude everywhere it's cited: tech.md's block_padding
  interaction section, testing/manual-verification criteria, and
  product.md's goals/success-criteria/open-questions.
- product.md:55's zero-ink fallback description dropped the padding term
  ("advance-based edge" only), conflicting with tech.md's own fallback-rules
  section and the actual implementation, both of which apply
  advance-edge ± pad. Align product.md to state the same rule.
@fbartho

fbartho commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

/oz-review

@warp-for-oss

warp-for-oss Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

@fbartho

I'm re-reviewing this spec-only pull request in response to a review request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@warp-for-oss warp-for-oss Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overview

This PR adds product and tech specs for fixing inline code chip background geometry by deriving chip edges from glyph ink extents rather than advance widths, scoped to chip-family runs and covered by unit/manual validation.

Concerns

  • The zero-ink fallback is inconsistent: the product spec requires advance-edge fallback with the fixed padding preserved, while the tech spec says to fall back to raw advance bounds.
  • The success criteria require an exact 2 × block_padding left-edge tightening, but the new-vs-old edge delta also depends on the first glyph's ink bearing and the chosen pad.

Verdict

Found: 0 critical, 2 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread specs/GH13914/tech.md Resolved
Comment thread specs/GH13914/product.md Resolved
…a claims (GH13914)

tech.md's fallback-rules section still specified raw visible_left/visible_right
for zero-ink edge glyphs, contradicting product.md's advance-edge ± pad rule
(already correct) and the implementation (pinned by
test_run_background_falls_back_to_advance_for_zero_ink_glyph). Align tech.md
to advance-edge ± pad.

Separately, every "left edge tightens by 2 × block_padding (≈2.6px)" claim
framed as a verification criterion or precise new-vs-old delta ignored that
the left edge also switches from advance-anchored to ink-anchored, making the
true delta glyph/font-dependent. Reframe these as: the typical magnitude of
the removed block_padding residual (still exact in isolation), not a fixed
verification target. product.md Success Criterion 2 now asserts the
literally-pinned properties (zero block_padding residual, ink-edge-minus-pad
formula) instead of an exact pixel figure.
@fbartho

fbartho commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of #14122 — same spec carried forward with the final round's findings addressed; the feedback-accounting table there maps all eight findings across the four review rounds to their fix commits.

@fbartho fbartho closed this Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed external-contributor Indicates that a PR has been opened by someone outside the Warp team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inline code chip background extends past glyph ink on the right (advance width vs ink width)

1 participant