Skip to content

fix(pty): silence Windows seam dead-code warnings without API changes - #29

Merged
Xuepoo merged 1 commit into
mainfrom
ctx-0018/fix-pty-seam-warnings
Aug 26, 2026
Merged

Xuepoo merged 1 commit into
mainfrom
ctx-0018/fix-pty-seam-warnings

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Resolves dead-code warnings on cfg(windows) seam types in crates/bitty-pty (platform/windows.rs and builder.rs) that were left non-blocking after CTX-0013.

CarryCtx: CTX-0018

Changes (strictly crates/bitty-pty/**, no API changes)

  • builder.rs: SpawnConfig now #[cfg_attr(windows, allow(dead_code))] with documenting comment referencing the Tier-1 Windows follow-up slice (ADR-0002). Seam remains exercisable via platform::windows::open_pty_and_spawn.
  • platform/windows.rs: Master/Child marked #[allow(dead_code)] with seam comment; open_pty_and_spawn now takes config: &SpawnConfig and touches all fields (program, args, env, cwd, cols, rows) so they are considered read on cfg(windows) — honest exercisability instead of masking.
  • error.rs: flatten_upstream now #[cfg_attr(windows, allow(dead_code))] with comment (fully exercised on Unix via platform::unix, unused on Windows until Tier-1 slice).

Verification

Closes CarryCtx CTX-0018 — stops at IN_REVIEW, handoff to opencode.

Branch: ctx-0018/fix-pty-seam-warnings at 0959c32, worktree .worktrees/ctx-0018-fix-pty-seam-warnings

CTX-0018: make the Windows ConPTY seam exercisable and add targeted allow(dead_code)

- builder.rs: SpawnConfig now cfg_attr(windows, allow(dead_code)) with comment referencing ADR-0002 Tier-1 Windows follow-up slice

- platform/windows.rs: Master/Child marked allow(dead_code) with seam comment; open_pty_and_spawn now touches SpawnConfig fields so they are considered read on cfg(windows) instead of dead

- error.rs: flatten_upstream now cfg_attr(windows, allow(dead_code)) with comment (exercised on Unix, unused until Tier-1 Windows slice)

- verified zero warnings: cargo check --workspace --all-targets and cargo check --workspace --all-targets --target x86_64-pc-windows-gnu (just check green)
@Xuepoo
Xuepoo merged commit 450ac7a into main Aug 26, 2026
17 checks passed
@Xuepoo
Xuepoo deleted the ctx-0018/fix-pty-seam-warnings branch August 26, 2026 17:06
@Xuepoo Xuepoo added the fix Bug fix label Aug 29, 2026
@Xuepoo Xuepoo added this to the v0.0.1 milestone Aug 29, 2026
@Xuepoo Xuepoo added area:pty Area: PTY area:platform Area: platform / windowing labels Aug 29, 2026
Xuepoo added a commit that referenced this pull request Oct 27, 2026
… Width tables (#2734)

* [CTX-1609] feat(term-state): make grapheme clusters one layout unit

Authoritative UCD 18.0.0 East_Asian_Width and Extended_Pictographic tables
(generated, checked in with provenance), cluster-accurate cell widths
(ZWJ families, flags, skin tones, keycaps, VS16), and a bounded cluster-tail
print path so one cluster occupies one cell plus its wide spacer.

- Width: the generated table covers W/F/A/N/Na/H; controls stay one cell and
  zero-width marks win before EAW. Canonical hash v13 adds the ambiguous
  width policy because it changes later layout.
- Clusters: print joins GB6-GB13 scalars onto the preceding cell, grows a
  one-cell cluster to two when the spacer fits, and degrades over-cap tails
  deterministically (marks dropped, printable continuations start a cell).
- Segmentation: Prepend (GB9b), ZWNJ-as-Extend, the full InCB linker set and
  linker state across Extend; the full UCD GraphemeBreakTest 18.0.0 passes.
- Render: run formation keeps the cluster in one cell, the unshaped fallback
  paints the lead, and the cluster goldens are re-recorded.

Material change: text containing newly authoritative Wide scalars reflows one
column wider on upgrade; ambiguous scalars are unchanged under the default
narrow policy.

* [CTX-1609] feat(config): add terminal.ambiguous_width

Adopt `terminal.ambiguous_width = "narrow" | "wide"` (default narrow)
through the Lua -> plan -> merge -> effective -> runtime -> terminal-state
chain, with fail-closed validation at every layer.

- bitty-lua extracts the raw closed-enum string; bitty-config parses,
  validates, merges as a scalar-replace leaf, classifies reloads as
  restart-required, and exposes the default in `inspect config` and the
  profile schema/table writer.
- bitty-runtime carries the policy in RuntimeConfig, seeds the primary
  terminal and every spawned pane, and the app maps the effective value by
  value.
- The policy never re-measures cells already on the grid, hence the
  restart-required reload class and the `State::set_ambiguous_width`
  creation-time contract.

* [CTX-1609] test(term-state): pin cluster presentation widths

Cover the cluster-width matrix at the grapheme boundary: regional-indicator
pair, skin-tone modifier, VS16 emoji presentation, keycap, VS15 text
presentation, lone zero-width cluster, and ambiguous policy.

* [CTX-1609] fix(term): paint full grapheme clusters and complete the UAX #29 tables

Review follow-ups for bitty#1767 (comment 6423156515).

Paint (bitty-render):
- One paint group is now one extended grapheme cluster of the run text, not
  one shaper byte offset: `क्ष` shapes its second consonant at its own offset,
  and grouping by offset alone dropped it. Every drawable member of a group
  paints, advanced by the shaper's pen, so Indic matras and conjuncts, Thai
  floating marks, decomposed Hangul jamo, and both flag indicators reach the
  frame. A cluster wider than its committed cells overhangs like any glyph
  bitmap; the next cluster keeps its own column.
- Classic crossfont stays the documented degraded fallback (no shaper: the
  lead glyph plus zero-width marks), stated in the crate text-stack docs, the
  grid module docs, and `Runtime::is_crossfont`.
- Shaped and fallback span math measures text under the resolved
  `terminal.ambiguous_width` policy (`cells_for_range_in`), and GridRenderer
  carries the policy the runtime installs, so a wide ambiguous scalar no
  longer shifts the following glyph one column early.

Unicode (bitty-term-state):
- `scripts/generate-unicode-tables.py` emits the full UAX #29 property set
  from UCD 18.0.0: GCB=Extend (2274 scalars), SpacingMark (381), Prepend (27),
  and InCB Linker/Consonant/Extend, with SHA-256 provenance for every input
  and the Unicode License v3 notice. The generated module is now
  `unicode_tables.rs`.
- All 27 Prepend scalars are zero-width through the same generated table, so
  GB9b can no longer hide the base behind a spacer.
- GB9c follows the Unicode 18.0.0 rule shape
  `InCB=Linker InCB=Extend* × InCB=Consonant` (UAX #29 revision 49), so
  `क्१` and a virama followed by ZWNJ break while real conjuncts still join.
- All 853 GraphemeBreakTest samples stay green; unit tests pin the table
  counts, Prepend width, conjunct boundaries, spacing marks outside the old
  curated subset, and cluster presentation.

Tests: a real GridRenderer capture covers `कि`, `क्ष`, `กำ`, `কে`, `🇫🇷`,
`🇫🇮`, and decomposed `가` (painted glyphs 1/2/1/1/1/1/1 before and
2/3/2/2/2/1/1 after; the two flags composite to different pixels), plus the
config reload class, last-column cluster, lone regional indicator, wide
ambiguous, and prepend+base cases.
Xuepoo added a commit that referenced this pull request Oct 27, 2026
… prepends safely (#2738)

Second review of the grapheme rework (bitty#1767); rebased onto the merged
first round (bitty#2734), so this commit is the follow-up only.

Render (must-fix 1):
- A paint group with more than one shaped member is one committed layout
  unit; its entries advance inside that unit (`कि`: 4.16 px + 13.81 px for
  one cell), so the per-cell advance gate must not read them as a cell
  advance. The gate now skips multi-member groups, and entries sharing a
  byte offset are excluded from the median that serves as its reference.
  Deterministic FakeShaper cases (`कि`, `क्ष`, a flag pair without a
  ligature, a ZWJ family, a wide ambiguous scalar) pin every member painting
  without host fonts.
- The gate measures the shaper's own (narrow) cell count, so a wide East
  Asian ambiguous cluster stays shaped under
  `terminal.ambiguous_width = "wide"` instead of degrading because the
  policy span is two cells.

Terminal truth (must-fix 2):
- `restore_scrollback_text` selects the first non-zero-width scalar as
  `Cell::glyph`, so a leading `Prepend` (`"\u{0600}1"`) can no longer hide
  its base. Leading zero-width scalars attach to the preceding cell's tail
  (stepping back over a wide spacer) exactly like `print`, and a
  line-leading one is dropped.
- Tail overflow mirrors print: zero-width scalars past the bound drop, a
  printable scalar starts a fresh cell instead of truncating the line.
- Restore tests cover `"\u{0600}1"`, `"a\u{0600}1"`, and a nine-scalar
  printable cluster.

Follow-ups:
- The generated UAX #29 tables now carry the full
  `Grapheme_Cluster_Break=Control` class (19 ranges, 3893 scalars),
  replacing the curated GB4/GB5 list that missed soft hyphen, the Mongolian
  vowel separator, the bidi isolates, the interlinear/musical/shorthand and
  Egyptian format scalars, and the tag-plane ranges. CR/LF stay included
  explicitly per GB4/GB5. The measured over-join cases are pinned.
- `InCB=Linker` doc count corrected to 23.
- The generator formats its output with the pinned `rustfmt`, so regeneration
  is byte-identical without a manual `cargo fmt` step.
- The prepend test documents that only a first-row lead is dropped; a
  later-row lead attaches to the previous row's last cell.
- Drive-by: two pre-existing private intra-doc links broke the rustdoc gate on
  main (`SwashSingle` -> `system_db`, `commit_profile_rename` ->
  `PROFILE_RENAME_OVERRIDE`). Both are code spans now; the identical one-line
  fixes ride in #2737, so on a rebase after it lands these hunks are no-ops.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:platform Area: platform / windowing area:pty Area: PTY fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant