ADR 0007: Rex OSC 7501 program status, semantic prompts, and host queries¶
Status¶
Accepted. 2026-11-21.
Context¶
Modern CLI tools, build runners, and AI coding agents report structured task
progress via the Program Status protocol (OSC 7501), supported in tmux
(input.c at cce5f10)
and Ghostty / libghostty-vt
(terminal.zig at 5b0690d),
alongside FinalTerm / shell-integration prompt markers (OSC 133), ConEmu/OSC
9;4 progress bars, OSC 7 working-directory notifications, OSC 52
clipboard writes, and startup capability queries (XTVERSION, DECRQSS,
XTGETTCAP, OSC 10/11;?, ?2031 / CSI ? 996 n).
Upstream sources exhibit a concrete behavioral divergence on the OSC 7501 ; ?
capability query:
tmux(cce5f10) replies unconditionally with bare"\033]7501;?\033\\".Full Rex
OSC 7501registries advertise supported states and kinds:"\033]7501;?:states=idle,working,done,blocked,error:kinds=permission,question,auth\033\\".libghostty-vt(5b0690d) suppresses theOSC 7501 ; ?reply unless aprogram_statuseffect consumer is attached, so applications avoid sending status updates nobody observes.
Decision¶
Spec-compliant
ProgramStatusStore(libvt.status):Enforce wire payload ceiling
<= 4,096bytes before parsing.Parse colon-delimited
[a-z]{1,16}=valuepairs:state:idle | working | done | blocked | error | clear(required on non-query payloads).id: optional slash-delimited hierarchical task identifier (<= 128bytes,<= 8/segments,[A-Za-z0-9_.-]segments;""= root).kind: optionalpermission | question | auth(valid withstate=blocked).progress: optional integer0..100.app: optional[A-Za-z0-9_.+-]{1,32}, inheritingeffective_appfrom nearest ancestoridprefix when omitted on child tasks.title: optional base64-encoded UTF-8 (<= 256encoded /<= 192decoded bytes);msg: optional base64-encoded UTF-8 (<= 2,732encoded /<= 2,048decoded bytes). Reject malformed base64, invalid UTF-8, C0 controls (< 0x20except\tinmsg),DEL/C1 (0x7F..0x9F), and Unicode BiDi overrides.
state=clearremovesidand allid/*descendants (whenid == "", clears the entire store). Total active records stay bounded byLimits.max_status_records(256).Expose
term.program_status(most urgent activeProgramStatusorderedblocked > error > working > done > idle, or root record) andterm.program_statuses -> dict[str, ProgramStatus].Profile- and policy-gated
OSC 7501 ; ?reply: Reply wheneverPolicy.allow_program_status_queryisTrue(defaultTrue) andProfile.osc_7501_capabilitiesis non-empty (independent ofon_eventandrecord_eventsso pull-modeterm.program_statusinspection never changes wire negotiation), formatting the capability payload fromProfile.osc_7501_capabilities(fullstates=...:kinds=...onDEFAULT_PROFILE, bare?onTMUX_PROFILE, empty onXTERM_PROFILE) and mirroring the incomingBEL(\x07) vsST(\x1b\\) terminator.Lifecycle and
OSC 9;4fallback: MapOSC 9;4;st;proginto synthetic root status until the first nativeOSC 7501arrives (re-enabled onRIS). OnOSC 133;Aprompt start (ignoringk=ssecondary continuation prompts) orterm.notify_process_exit(), prune transientworking,blocked, andidleentries while retainingdoneanderror; surviveDECSTRsoft reset and clear all records onRIS.
Monotonic
OSC 133prompt zones and host queries (libvt.terminal):Store
PromptZone(kind: PromptKind, abs_row: int, col: int, exit_code: int | None)in acollections.dequebounded byLimits.max_prompt_zones(1,024), resolving rows on demand viaSnapshot.at_abs(abs_row)andSnapshot.viewport_row(abs_row)so scrolling never invalidates stored prompt coordinates.Support
OSC 7andOSC 9;9(term.cwd_urifor any URI,term.cwdfiltered byPolicy.osc7_hostswithout host syscalls, plusWorkingDirectoryChanged),OSC 52write (ClipboardWritewhenPolicy.allow_clipboard_write;OSC 52 ; c ; ?denied unlessPolicy.allow_clipboard_read),XTVERSION(CSI > q->DCS > | ... ST),DECRQSS(DCS $ q ... STformSGR,rDECSTBM,sDECSLRM,qDECSCUSR,"qDECSCA),XTGETTCAP(DCS + q <hex> STforTN/Co/RGB/Smulx),OSC 10;?/OSC 11;?foreground/background queries,?2031+CSI ? 996 ncolor-scheme DSR, andDCS tmux; ESC ESC ... STpassthrough envelopes (emittingPassthroughand re-feeding inner bytes only whenPolicy.allow_passthrough=True).
Alternatives considered¶
Simplified
OSC 7501;value;progressstring split: Rejected because it is wire-incompatible withtmux,Ghostty, and Rex CLI emitters.Coupling
OSC 7501 ; ?replies torecord_events/on_event: Rejected because attaching an observer must not alter wire capabilities seen by the child process, and pull-modeterm.program_statuscallers rely on the built-inProgramStatusStore.
Consequences¶
Positive¶
libvtinteroperates out of the box withtmux3.6+/3.8+,Ghostty, and CLI tools emitting RexOSC 7501,OSC 9;4, andOSC 133.Startup capability handshakes (
tmux attach, Neovim, Fish, Helix) complete immediately viadrain_replies()without 1-2 second query timeouts.
Tradeoffs¶
ProgramStatusStorevalidates base64 and UTF-8 bounds eagerly onOSC 7501frames (<= 4 KiB), dropping non-conformant fields safely.
Risks¶
Untrusted PTY output flooding
OSC 133;AorOSC 7501unique IDs. Mitigation:Limits.max_prompt_zones = 1_024(dequeFIFO) andLimits.max_status_records = 256.