Repository navigation
core(refactor): Split views, snapshot, dispatch, recorder, target, and aio (#203) - #204
Merged
Merged
Conversation
why: Break the screen-to-terminal import cycle and separate low-level buffer helpers, views, reflow, formatting, and snapshots into acyclic modules. what: - Extract _util.py with hardened _byte_view and ASCII integer parsers - Extract views.py with Cursor, ScrollRegion, RowView, and RegionView - Extract _reflow.py for primary-screen soft-wrap reflow - Extract format.py and snapshot.py, keeping terminal/screen re-exports - Make screen.py acyclic with lazy graphics initialization
why: Bound Terminal memory with __slots__, move CSI/OSC/ESC/DCS dispatch out of terminal.py, add a typed recorder seam without monkey-patching, and centralize donor state transfer in replace_from. what: - Extract recorder.py with TerminalRecorder, FlightRecorder, CompositeRecorder, and find_flight_recorder - Extract _vt_dispatch.py for CSI/OSC/ESC/DCS handling - Add single-truth private mode support helpers in modes.py - Add Terminal.__slots__, _attach_recorder, _attach_reply_sink, _resize_internal, batched feed_until recording, and replace_from - Switch tmux control adoption to Terminal.replace_from
why: Remove libvt.testing's runtime dependency on contrib.tmux and eliminate unsafe blind `.snapshot()` probing on arbitrary objects. what: - Add SupportsVtTarget (__vt_target__) guarded against class objects in testing.py and remove contrib.tmux imports and blind `.snapshot()` - Implement __vt_target__ on TmuxCaptureResult, AsyncTerminalStream, and PtySession - Widen pytest_plugin recorder annotations to TerminalRecorder | None - Update docs/api/testing.md, migrate test_syrupy _SnapHolder, and widen live tmux capture polling iterations in test_testing.py
why: Deduplicate session sync-timer, input-encoding, reply-sink, and wait_for logic across streams and PTYs while isolating POSIX PTY code into its own module. what: - Replace aio.py with aio/__init__.py, _core.py, _stream.py, and _pty.py using relative imports and shared _SessionCore inheritance - Preserve _FrameWaits, shared foreground stream reads, Linux pidfd process groups, cancel-safe close, and PTY fd cleanup on failure - Document inherited members in docs/api/aio.md, update aio package loading in tests/test_aio.py, and record #203 in CHANGES
tony
force-pushed
the
refactor/203-structural-split
branch
from
December 5, 2026 14:39
e0cebb6 to
fa5e1d2
Compare
tony
added a commit
that referenced
this pull request
Dec 5, 2026
why: Decouple terminal views, formatting, snapshots, VT dispatch,
recorders, testing targets, and asyncio transports so stacked
extensions do not collide on monolithic modules or private fields.
what:
- Extract views, format, and snapshot modules from screen and terminal
- Add Terminal.__slots__, _vt_dispatch, TerminalRecorder, and
Terminal.replace_from()
- Introduce SupportsVtTarget for testing target extraction
- Split libvt.aio into a package sharing _SessionCore
- core(refactor): Extract views, format, snapshot
- terminal(refactor): Add slots, dispatch, recorder
- testing(refactor): Decouple SupportsVtTarget
- aio(refactor): Split package with _SessionCore
Closes #203
This was referenced Dec 5, 2026
tony
added a commit
that referenced
this pull request
Dec 5, 2026
why: Give every public module and split package its own API reference
page after #204 and earlier contrib splits while preserving existing
docs URLs through Sphinx rediraffe redirects.
what:
- Break docs/api/aio.md into docs/api/aio/{index,core,stream,pty}.md
- Break docs/api/contrib_tmux.md and contrib_syrupy.md into
docs/api/contrib/{index,syrupy}.md and
docs/api/contrib/tmux/{index,profile,capture,window,control}.md
- Add dedicated pages for views, snapshot, format, and recorder
- Scope screen.md and terminal.md to owned symbols and canonicalize
cross-references across docs, docstrings, CHANGES, and MIGRATION
- Update docs/redirects.txt for moved API paths and add
test_every_public_module_has_api_doc_page()
Refs #203
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #203
Summary
Structural module split and protocol decoupling across core rendering, terminal state, testing target extraction, and asyncio transport layers — preserving all existing public imports and runtime compatibility while creating clean extension points for stacked concept PRs.
Atomic commits
core(refactor): Extract views, format, snapshotRowView/RegionViewintolibvt.views,Formatter/render/_render_vtintolibvt.format, andSnapshot/SnapshotDictintolibvt.snapshot, re-exported fromlibvt.screenandlibvt.terminal.is_private_mode_supported()inlibvt.modes.terminal(refactor): Add slots, dispatch, recorderTerminalto__slots__(78 slots, zero__dict__), splits VT handler tables intolibvt._vt_dispatch, and addsTerminalRecorderprotocol (libvt.recorder),Terminal._attach_recorder(),Terminal.replace_from(), and batchedfeed_until().contrib/tmux/control.pyoff private terminal attribute mutation ontoTerminal.replace_from().testing(refactor): Decouple SupportsVtTargetSupportsVtTarget(__vt_target__) inlibvt.testingand implements it onAsyncTerminalStream,PtySession, andTmuxCaptureResult, eliminating duck-typed_extract_target()chains.test_live_tmux_server_vs_pure_terminal_snapshot_parityreadiness wait loop to eliminate busy-runner startup timeout flakes.aio(refactor): Split package with _SessionCorelibvt.aiointo a package (aio/{__init__,_core,_stream,_pty}.py) sharing_SessionCoreacrossAsyncTerminalStreamandPtySessionwith zero runtime import cycles.Verification
ruff check .andruff format --check .(131 files)ty check --python-version 3.12andty check --python-version 3.15pytest -q(1234 passed, 2 skipped)sphinx-build -b html -W --keep-going docs(0 warnings)