Repository navigation
Done
Labels
bugSomething isn't working
Description
Summary
SyncToken in src/libvt/terminal.py (#13) exposes 15 public dataclass fields coupled to a process-global _GLOBAL_ROW_GEN counter in src/libvt/_grid.py, while _Row mutates wrapped and cell state across multiple direct attribute writes that rely on manual bump_row_gen() calls. Executing DCH (CSI P) at column 0 left of a DECLRMM (?69h) left margin clears scr._rows[c_row].wrapped = False without bumping content_gen, causing Terminal.changes_since() to return dirty_rows == () while snapshot()[0].wrapped flipped from True to False.
Reproduction
- Soft-wrap row
0, enableDECLRMM(?69h) with margins3..6, move to(0, 0), capturesync_token(view="working"), and feedCSI P:
uv run python -c 'from libvt import Terminal; vt = Terminal(rows=3, cols=6); vt.feed(b"ABCDEFG\x1b[?69h\x1b[3;6s\x1b[1;1H"); tok = vt.sync_token(view="working"); vt.feed(b"\x1b[P"); d = vt.changes_since(tok, view="working"); print("wrapped:", vt.snapshot()[0].wrapped, "dirty_rows:", d.dirty_rows)'
Expected
DCHleft ofDECLRMMeither leaves row0untouched (includingwrapped) or reports row0indirty_rows; aScreenDeltareplica always matchesvt.snapshot()acrosslines, cell styles, andwrappedflags.SyncTokenkeeps its watermark fields private (reprcompact and opaque, supporting==and hashing) and uses a per-Terminal(per-ScreenSet) monotonic row generation counter rather than a process-global integer shared across unrelatedTerminalinstances.- Every
_Rowmutation routes through structural write barriers on_Rowthat bumpcontent_genand invalidate cached_frozenautomatically, backed by a debug/test row-fingerprint check.
Actual
wrapped: False dirty_rows: () — incremental consumers miss the wrapped transition and diverge from Snapshot.
Environment
Versions
libvt:#2(0.1.0a0)- Python:
3.15.1 - OS: Linux
x86_64
Proposal
Invariants
The invariants below are load-bearing; everything under Intent is open.
- Callers treat
SyncTokenas an opaque value (==,hash,repr); internal watermark layout is private so internal representation upgrades remain non-breaking after0.1.0. - Two independent
Terminalinstances never contend on or advance a shared module-global row-generation counter, matching WezTermSurfaceSequenceNoatee6f3044d. - No mutation to a
_Row's characters, packed attributes, sparse extensions,used,text_used, orwrappedflag can occur without advancing that row'scontent_gen.
Intent (non-binding)
- Give each
Screen/ScreenSeta shared monotonic generation counter cell, make_Rowmutable state private behind mutator methods (set_wrapped(),clear_spacer_head(),copy_slice_from(), etc.), and guardDCHwrappedclearing behindleft <= c_col <= right. - Add a randomized sequence fuzz test verifying
ScreenDelta.apply_rows()replica equality (includingwrappedandCellattributes) againstTerminal.snapshot()after every operation.
Not doing
- Exposing internal watermark integers as public
SyncTokenattributes.
References
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity
terminal(fix[sync]): Guard _Row and SyncToken (#22)