Skip to content

fix(rig): render orphaned pyte wide-char stubs as blanks (#160) - #163

Merged
terenceponce merged 2 commits into
mainfrom
fix/rig-pyte-python
Nov 1, 2026
Merged

terenceponce merged 2 commits into
mainfrom
fix/rig-pyte-python

Conversation

@terenceponce

Copy link
Copy Markdown
Member

Fixes #160

What

The capture rig's pyte screen no longer crashes on pyte's own transient
state. pyte 0.8.2 writes a data="" stub cell after every wide (2-cell)
glyph; when one pty chunk overwrites a wide glyph's lead cell with a
narrow one and the next chunk hasn't yet rewritten the stub, the stub is
orphaned — and Screen.display's wcwidth(char[0]) raises
IndexError on the empty string if the poller reads in that window.
The rig polls display constantly outside the feed lock
(wait_for/text()/footer_span/...), so it can always land there
mid-redraw.

RigScreen(pyte.Screen) (both construction sites: live + GIF replay)
renders the orphan as the blank a real terminal shows for the leftover
continuation cell; every non-orphaned state renders byte-identically to
stock pyte 0.8.2 (verified against pyte.Screen on narrow, wide, and
end-of-row-wrap content). The venv setup line in the docstring now pins
pyte==0.8.2 wcwidth==0.9.4 pillow==13.0.0 so a fresh checkout + rig
setup gets the exact versions every lane ran on.

Non-visual change: rig/test infrastructure only — no product surface, no capture content change beyond un-crashing.

Root cause is a pyte race, not Python 3.14

The #143 lane's attribution to the interpreter doesn't hold:

  • The crash is not deterministic on 3.14 — the three red scenarios
    (attach still, attach gif, drop-image gif) passed three consecutive
    pre-fix runs on Python 3.14.8 + pyte 0.8.2 in the unmodified worktree.
  • pyte's only Python-version-sensitive input is unicodedata
    (combining classification, NFC) — the app's byte stream contains no
    combining marks, so the interpreter version cannot change what pyte
    parses or renders. Widths come from the wcwidth package's fixed
    pure-Python tables.
  • The app's own classifier agrees with wcwidth on every scenario glyph
    (📎 = 2, CJK = 2, ❯ = 1) — no layout disagreement either.
  • The race clustered on the image scenarios because their 📎 rows are
    the only content both wide and dynamically rewritten next to narrow
    text; CJK scenarios type wide text append-only and never orphan.

Disposition (ADR 0034)

  • Bump pyte — impossible: 0.8.2 (2024) is the latest release. The
    fix exists only on unreleased master, which also changed rendering
    semantics (grapheme clusters, per-cluster wcswidth) enough to shift
    the rig's asserted frames; a git-commit pin would make the venv
    fragile.
  • Pin the venv to Python 3.13 — treats a symptom the interpreter
    does not cause; the race exists on every Python and would recur under
    load.
  • Local shim (chosen) — ~12 lines, fixes the actual defect on any
    Python, and disappears into upstream's own fix whenever a pyte
    release lands (master's wcswidth(char) already survives empty
    stubs).

Evidence

Full-menu smoke on Python 3.14.8 / pyte 0.8.2 / wcwidth 0.9.4 /
pillow 13.0.0 — all 35 argparse scenario choices in primary mode (28
still, 7 gif-native) plus 6 documented secondary variants = 41/41:

PASS 01-first-run          PASS 15-picker-tail        PASS 29-reasoning-resume
PASS 02-mid-session        PASS 16-wizard-draft       PASS 30-growing-session-gif
PASS 03-ghost              PASS 17-model-tail         PASS 31-drop-image
PASS 04-growing-session    PASS 18-profile-tail       PASS 32-idle-blink
PASS 05-compact-session    PASS 19-exit-print         PASS 33-tab-complete
PASS 06-stock-compact      PASS 20-model-switch       PASS 34-reasoning-block
PASS 07-default-window     PASS 21-title-dialog       PASS 35-reasoning-scroll
PASS 08-slash-autocomplete PASS 22-title-wide         PASS 36-enter-snap
PASS 09-attach             PASS 23-breathing-gap      PASS 37-attach-gif
PASS 10-attach-refusal     PASS 24-gap-scrolled       PASS 38-slash-gif
PASS 11-attach-cjk         PASS 25-ttft-footer        PASS 39-default-gif
PASS 12-reading-session    PASS 26-scrolled-stream    PASS 40-probe
PASS 13-resume-session     PASS 27-drop-refusal       PASS 41-reading-claims
PASS 14-resume-picker      PASS 28-reasoning-stills   SMOKE RESULT: 41 passed, 0 failed
  • mix ci exit 0 — 1836 tests passed, coverage 99.2%.
  • Shim unit checks: orphaned stub → blank; wide/narrow/end-of-wrap rows
    byte-identical to stock pyte.Screen.

pyte 0.8.2's display IndexErrors on its own transient state: a stub
cell (data="") orphaned when one pty chunk overwrites a wide glyph's
lead and the next hasn't rewritten the stub yet. The rig's poller can
land in that window mid-redraw — clustered on the image scenarios'
rewritten 📎 rows, and Python-version-independent (no combining marks
in the stream; widths come from the pinned wcwidth tables). RigScreen
renders the orphan as the blank a real terminal shows; the venv setup
line now pins pyte/wcwidth/pillow exactly. ADR 0033 records why the
pyte bump (no release exists) and the 3.13 pin (wrong cause) were
rejected.
@codecov

codecov Bot commented Nov 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…aster frame-shift claim, state the deliberate-diff removal
@terenceponce
terenceponce merged commit 2a34030 into main Nov 1, 2026
5 checks passed
@terenceponce
terenceponce deleted the fix/rig-pyte-python branch November 1, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rig env: pyte 0.8.2 under Python 3.14 crashes rendering the image scenarios (attach, drop-image) — pre-existing on main

1 participant