Automate Program status (OSC 7501)
Write an OSC 7501 sequence to tell Paneflow what your program is doing. A build script, a deployment tool, or an agent can report that it is working, waiting for input, finished, or failed. Paneflow shows the declaration in the pane header. The sequence reports state; it does not request an action or grant permission.
This reference describes Paneflow 0.20.0 and follows the Program Status Protocol, revision 0.4.
Report a build
Save this as build-with-status.sh and run sh build-with-status.sh in a Rust
project inside a Paneflow pane. The script reports the result and preserves the
build's exit code.
printf '\033]7501;state=working:app=cargo\033\\'
if cargo build "$@"; then
printf '\033]7501;state=done:app=cargo\033\\'
else
code=$?
printf '\033]7501;state=error:app=cargo\033\\'
exit "$code"
fiWrite the sequence to the terminal, not to a redirected log. No query or heartbeat is required. Report again when the state or its details change.
Sequence format
OSC 7501;state=working:app=cargo:progress=42 STOSC stands for ESC ] (bytes 1B 5D). End the sequence with ESC \
(1B 5C) or BEL (07). The spaces around the symbolic names aren't bytes
in the sequence. Use : between key=value pairs. Unknown keys are ignored.
| Field | Value |
|---|---|
state | Required. idle, working, blocked, done, error, or clear. An unknown state discards the report. |
kind | permission, question, or auth. Used only with blocked; unknown values are ignored. |
progress | An integer from 0 to 100. Used only with working or blocked. Omit it when there is no percentage to report. |
id | Optional record path. Omit it to address the root. Use / between segments, with at most 8 segments and 128 bytes total. Each segment is 1 to 32 ASCII letters, digits, or _.+-. An empty or invalid id discards the report. |
app | Stable program identifier, such as cargo or deploy. Use 1 to 32 ASCII letters, digits, or _.+-. This is not the display title. |
title | Short label. Standard base64 of a single line of UTF-8, up to 192 bytes decoded (256 encoded). |
msg | What the program is doing or waiting for, or the result. Same encoding as title, up to 2,048 bytes decoded (2,732 encoded). |
Base64 padding is optional. Decoded title and msg must not contain control
characters, including tabs and line breaks. Keys are limited to 16 bytes. The
whole sequence is limited to 4,096 bytes with ESC \, or 4,095 with BEL.
For example, emit this before reading an answer. QXBwbHk/ decodes to Apply?:
printf '\033]7501;state=blocked:kind=permission:app=deploy:msg=QXBwbHk/\033\\'Records and lifetime
Every report replaces the entire record at its id, so repeat any app,
title, or other field you want to keep. A record without app inherits it from
the nearest ancestor that has one. state=clear:id=build removes build and
its descendants; state=clear without id removes every record in the pane.
Paneflow keeps up to 256 records per terminal and evicts the least recently
updated one when it needs room.
working, blocked, and idle clear on process exit or when a shell prompt
begins (OSC 133;A). done and error survive both until replaced, cleared,
or acknowledged by input from the attached pane. Programmatic input such as
paneflow send does not acknowledge them. A full terminal reset (RIS) clears
all records; a soft reset (DECSTR) does not.
What Paneflow shows
Paneflow shows one record per pane: the root when present, otherwise the most
recently updated record. A root in working therefore takes precedence over a
child in blocked. Use the root to report the state that should appear in the
header. idle hides the indicator, and working can show a percentage.
For programs without a recognized agent, blocked and error can put the pane
in Attention and trigger a desktop notification. Viewing a pane dismisses its
error from Attention, but the error can still show in the header. For recognized
agents, the declaration drives the agent's turn state. It does not register an
agent by app alone. See the CLI reference for send --submit and wait --idle.
Detect support
A program that can read the terminal's reply may send a query first:
Query: OSC 7501;? ST
Reply: OSC 7501;?:states=idle,working,done,blocked,error:kinds=permission,question,auth STThe reply comes back on the same terminal and uses the query's terminator. It lists supported states and kinds, not stored status. There is no OSC 7501 query that reads a record. See the session host implementation for how Paneflow stores and selects records.