Repository navigation
Done
Labels
enhancementNew feature or request
Description
Summary
Wave 1 leaf slice of #34: convert Event from a closed type Event = ... union into an open nominal class Event base (kw_only=True, match_args=False) with an opt-in type KnownEvent = ... union, consolidate title and working-directory variants, and normalize OSC 133 plus VS Code OSC 633 shell-integration sequences. Landing the open Event base in Wave 1 unblocks ClipboardReadRequested in Wave 2 and notification events in #31 without breaking downstream match exhaustiveness.
Motivation
src/libvt/events.pydefinestype Event = ...as a closed union with no shared base class, so adding any new protocol event breaks downstream callers that annotateEventalongsidetyping.assert_never, and positional dataclass matching becomes brittle whenever an existing event gains an optional field.TerminalemitsOSC 133prompt marks (PromptMark), whereas shells running under VS Code, Ghostty, and Kitty integrations emitOSC 633(A/B/C/Dzones,E;<command>[;<nonce>]with\xAB/\\escaping, andP;Cwd=...), often pairingOSC 133andOSC 633on the exact same(abs_row, col)cell.
Proposal
- Define
@dataclass(frozen=True, slots=True, kw_only=True, match_args=False) class Event:insrc/libvt/events.pyas the nominal base of all concrete event dataclasses, changeTerminal.drain_events()to returntuple[Event, ...], and exporttype KnownEvent = ...insrc/libvt/events.pyfor callers that explicitly opt into exhaustive union checking. - Consolidate overlapping variants by adding a
targetenum field onTitleChanged(window, icon, or tmuxESC krename) and asourceenum field onWorkingDirectoryChanged(OSC 7vsOSC 633 ; P ; Cwd=...). - Normalize
OSC 133andOSC 633A/B/C/DintoPromptZone(exit_code: int | NoneonCOMMAND_END), parseOSC 633 ; E ; <cmd>[;<nonce>]intoShellCommandReportedby splitting;before unescaping\xAB(0x00–0x20,0x3b) and\\, route633;P;Cwd=...toWorkingDirectoryChangedand otherKey=Valuepairs toShellPropertyChanged, deduplicate same-(abs_row, col, kind)133+633marks, and keep633;Eand633;Pout ofStopOn.PROMPT_MARK.
Alternatives
- Keeping
type Event = ...as the default return annotation ofdrain_events(): rejected because every minor release that adds a VT sequence event (such asClipboardReadRequestedor Emit typed notification events forOSC 9, KittyOSC 99, andOSC 777#31 desktop notifications) would trigger type-checker regressions in downstream consumers.
References
- Design specification, roadmap, and downstream consumer: Move
tmuxtolibvt.contrib.tmuxand harden pre-0.1core APIs #34,0.0.xto0.1.0and beyond Roadmap #35, Emit typed notification events forOSC 9, KittyOSC 99, andOSC 777#31 - Files touched at 6c33073:
src/libvt/events.py,src/libvt/terminal.py - Specification: VS Code shell integration (
OSC 633)
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Type
Projects
- StatusShow more project fieldsDone
Activity
0.1.0API waves aroundterminal.pyserialization #36OSC 52Policycontrols inlibvt#40libvt.__all__behind PEP 562 and gatepytest11imports #43OSC 9, KittyOSC 99, andOSC 777#31