Skip to content

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

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

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

Conversation

@fbartho

@fbartho fbartho commented Jul 22, 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.

Review-feedback accounting (continuation of #14026 — all 8 findings across 4 review rounds)

This PR replaces #14026, which is closed after exhausting its review-trigger budget. All eight oz-for-oss findings raised across four review rounds on #14026 are addressed as of this branch's spec tip; the table below is the full accounting.

Round Finding File:Line Resolving commit
1 Asymmetric block_padding interaction — legacy left-only shift undocumented against the new ink-edge design tech.md:27 74a882847
2 Equal-padding promise conflicted with tech.md's unchanged (left-only) block_padding residual product.md:22 0fcebacbd
2 Sub-pixel left-edge-preservation overpromise from the fixed font_size/12 padding product.md:63 0fcebacbd
2 Blast-radius scope unresolved — implementation reaches every background_color/border consumer, not just chips product.md:73 0fcebacbd
3 Arithmetic error: 2 × block_padding magnitude cited as ~1.08px, actually font_size/5 ≈ 2.6px at 13px tech.md:132 96620e117
3 Zero-ink fallback conflict between product.md (advance-edge ± pad) and tech.md's testing section tech.md:387 96620e117
4 Fallback-rules section still specified raw visible_left/visible_right for zero-ink glyphs, contradicting product.md and the implementation tech.md:254 bc345c70a
4 Left-edge delta stated as an exact 2 × block_padding figure, ignoring the first glyph's ink bearing and the new pad (glyph/font-dependent in reality) product.md:66 bc345c70a

All eight threads on #14026 have reply comments pointing at their resolving commit; the round-1–3 threads are marked resolved on GitHub. The round-4 threads (tech.md:254, product.md:66) are fixed by bc345c70a on this branch but not yet marked resolved on #14026, since #14026 is being closed in favor of this PR rather than receiving further replies.

A validation implementation exists locally (three commits, rebased onto this spec tip; not pushed, so no stable SHAs to cite — it will arrive as its own PR once this spec is approved, per the spec→implementation flow):

  • rebalance inline code chip background (ink-edge geometry, is_chip predicate, block_padding compensation)
  • equal ink-edge padding for chip-family runs
  • fix block_padding magnitude in ink-padding doc comment

Gates: cargo nextest run -p warpui_core -p warp_editor (794 passed), cargo clippy --all-targets --all-features --tests -- -D warnings (clean), cargo fmt -- --check (clean).

fbartho added 6 commits July 20, 2026 12:24
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.
…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.
… (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.
…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.
…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.
@cla-bot cla-bot Bot added the cla-signed label Jul 22, 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 22, 2026
@warp-for-oss

warp-for-oss Bot commented Jul 22, 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 reviewed this pull request and requested human review from: @vorporeal.

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 anchoring chip edges to glyph ink extents plus equal design padding, while keeping glyph layout, caret placement, selection, copy/paste, and non-chip rendering behavior unchanged.

Concerns

  • No blocking completeness, clarity, feasibility, issue-alignment, internal-consistency, or high-level security concerns found in the changed specs.
  • spec_context.md reports no approved or repository spec context for this PR, so there is no implementation/spec drift to flag.

Verdict

Found: 0 critical, 0 important, 0 suggestions

Approve

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 requested a review from vorporeal July 22, 2026 02:30
@fbartho

fbartho commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

(Just commenting as this is waiting for review).

@fbartho

fbartho commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

@vorporeal This PR is still waiting for review. (Just trying to avoid the stale-bot)

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