diff --git a/codex-rs/core/tests/suite/snapshots/all__suite__scenarios__statusline_authoring__explicit_statusline_mention_loads_the_bundled_skill.snap b/codex-rs/core/tests/suite/snapshots/all__suite__scenarios__statusline_authoring__explicit_statusline_mention_loads_the_bundled_skill.snap index b7cdb29620..336043088c 100644 --- a/codex-rs/core/tests/suite/snapshots/all__suite__scenarios__statusline_authoring__explicit_statusline_mention_loads_the_bundled_skill.snap +++ b/codex-rs/core/tests/suite/snapshots/all__suite__scenarios__statusline_authoring__explicit_statusline_mention_loads_the_bundled_skill.snap @@ -43,13 +43,13 @@ Scenario: A user requests the bundled statusline skill by name. description: Build and enable a custom MCP statusline for the Codex CLI. Use when someone wants a provider that displays information in the terminal footer. --- - + ### Enable and verify Install the provider through an installed plugin or register the stdio command on the connected app-serv...l` on the connected app server, then restart the TUI. [hash=e0f5170a5aeda287] - Exercise `tools/list` and `resources/read` with a representative snapshot. After adding the server, star... file, restart its stdio process to load the changes. [hash=4d64fb913d86fc64] + Exercise `tools/list` and `resources/read` with a representative snapshot. After adding the server, star... file, restart its stdio process to load the changes. [hash=303220aff844fc0c] 08:configuration_update:reasoning={"effort":"low"} diff --git a/codex-rs/skills/src/assets/samples/create-statusline/SKILL.md b/codex-rs/skills/src/assets/samples/create-statusline/SKILL.md index 1c4f8e2fc3..ee7423bfc4 100644 --- a/codex-rs/skills/src/assets/samples/create-statusline/SKILL.md +++ b/codex-rs/skills/src/assets/samples/create-statusline/SKILL.md @@ -5,16 +5,46 @@ description: Build and enable a custom MCP statusline for the Codex CLI. Use whe Help the user choose what to show. Reuse an existing stdio MCP server when it already owns the data and is configured globally or supplied by an installed plugin. For a new provider, copy [the Python starter](assets/statusline.py) and edit `render`. The [TypeScript reference](references/statusline.d.ts) bundled with this skill describes the snapshot and UI tree. If those files are on a different machine from your workspace, write the provider in the workspace using the protocol below. -### Advertise and render the footer +### Advertise the footer Advertise exactly one valid statusline entrypoint per tool in `tools/list`. Use the stable server and tool names for the saved selection. Set `_meta["openai/ui"].entrypoints` to include `{"type":"statusline","resourceUri":"ui://my-statusline/footer"}`. The tool's title is the label in the picker. -Codex requests the advertised URI with `resources/read`. Read the displayed thread's snapshot from `params._meta["com.openai/codex-statusline-state"]`. Return exactly one text resource at that URI, with MIME type `application/json` and a JSON-encoded UI tree. Optional account and usage fields may be absent. A string renders literal text and `null` clears the footer. +### Available UI elements -Use a `row` with an explicit whole-number `gap` to group items. Use named theme or status colors to follow the user's theme. Codex accepts up to 64 KiB of UI tree JSON, 16 KiB of UTF-8 leaf text, 256 non-null nodes, and a depth of 16 (root at 0). Each read has one second to finish. After a successful read, Codex waits one second before reading again. An error or timeout stops polling. Reselect the provider in `/statusline` to restart it. +`row`, `col`, and `box` require a `gap`, an integer from 0 through 2^53 − 1. + +- `col`: Stack items vertically. Put each field in its own `text` or `row` element. A gap of zero puts the fields on consecutive lines, and a gap of one leaves a blank line between them. Adjacent bare strings render together. +- `row`: Group items horizontally. The gap is measured in terminal columns. Set `wrap: "wrap"` to allow items to flow onto another line, and use `justify` to position items on each line. +- `box`: Choose the axis at runtime with optional `direction`, which defaults to `col`. With `direction: "row"`, the box accepts row props and groups adjacent strings into one flex item. +- `spacer`: Put `{"type":"spacer"}` between fields in a row to push the following fields to the right. Spacers on each wrapped line share its spare width, and the row gap applies on both sides. In a content-height column, the spacer occupies a slot with the usual gaps. +- `text`: Group styled text. Set `preserveWhitespace: true` to keep indentation, repeated spaces and tabs across styled children. Set `maxLines` to an integer from 1 through 2^53 − 1 to limit the block after wrapping. Hidden lines end the visible block with an unlinked ellipsis. Clamping takes precedence over `preserveWhitespace` on the same element. +- `bold`: Render children in bold. +- `italic`: Render children in italics. +- `underline`: Underline children. +- `code`: Display commands and paths with the same children as `text`. Nest `bold` inside `code` to emphasize an argument. Code preserves spaces and line breaks across children, expands tabs at eight-column stops, and uses the terminal theme’s code colors. +- `link`: Link the children to an absolute HTTP(S) URL using `props.href`. +- `badge`: Display a short state label, for example `{"type":"badge","props":{"color":"success"},"children":["passing"]}`. A badge accepts a string, an icon, or one of each in either order. It collapses label whitespace and stays on one line. For a check before the label, use `[{"type":"icon","props":{"name":"check"}},"passing"]` as the children. Badge color defaults to `secondary` and can also be `info`, `success`, `warning`, or `danger`. +- `icon`: Render a static glyph named by `IconName` in the reference. Icons work inline in text and inherit the surrounding style. +- `list`: Use `{"type":"list","children":["build","test"]}` for bullets. Set `props.marker` to `"number"` for numbering from one or `"none"` for unmarked items. Each direct child is one item. Wrapped lines align with the item text. +- `list-item`: Group styled fragments into a single list item, for example `{"type":"list-item","children":["run ",{"type":"code","children":["tests"]}]}`. +- `string`: A bare JSON string renders as literal text. + +### General behavior + +Codex requests the advertised URI with `resources/read`. Read the displayed thread's snapshot from `params._meta["com.openai/codex-statusline-state"]`. Return exactly one text resource at that URI, with MIME type `application/json` and a JSON-encoded UI tree. Optional account and usage fields may be absent. A `null` tree clears the footer. + +Check the rendering client’s `app.cli_version` before using newer features such as `spacer` or `maxLines`. If support is unknown or absent, return a literal string for the entire tree. An unsupported tag or property invalidates the whole response. + +Use named theme or status colors to follow the user's theme. Codex accepts up to 64 KiB of UI tree JSON, 16 KiB of UTF-8 leaf text, 256 non-null nodes, and a depth of 16 (root at 0). + +#### Refresh timing and errors + +Each read has one second to finish. After a successful read, Codex waits one second before reading again. + +An error or timeout stops polling. The footer directs you to `/statusline`. Reselect the provider there to restart polling. ### Enable and verify Install the provider through an installed plugin or register the stdio command on the connected app-server host. For example, run `codex mcp add my-statusline -- python3 -u /absolute/path/to/statusline.py` there, using a path and interpreter the host can access. If the workspace is on a separate executor, give the user the provider file to copy to the host and the command to run there. Enable **Custom status line** in `/experimental` on the connected app server, then restart the TUI. -Exercise `tools/list` and `resources/read` with a representative snapshot. After adding the server, start a new conversation in its workspace to connect to it. Open `/statusline`, choose **Choose a status line provider**, and select the provider. Verify that changing threads changes the displayed inputs. F2 shows the failed attempt if the footer falls back. After editing the Python file, restart its stdio process to load the changes. +Exercise `tools/list` and `resources/read` with a representative snapshot. After adding the server, start a new conversation in its workspace to connect to it. Open `/statusline`, choose **Choose a status line provider**, and select the provider. Verify that changing threads changes the displayed inputs. If discovery fails, dismiss the provider picker before pressing F2 for inventory and server lookup warnings. If discovery completes but the provider is missing, check the entrypoint metadata in `tools/list`. After editing the Python file, restart its stdio process to load the changes. diff --git a/codex-rs/skills/src/assets/samples/create-statusline/references/statusline.d.ts b/codex-rs/skills/src/assets/samples/create-statusline/references/statusline.d.ts index cd4f3301f7..9f4b7d7845 100644 --- a/codex-rs/skills/src/assets/samples/create-statusline/references/statusline.d.ts +++ b/codex-rs/skills/src/assets/samples/create-statusline/references/statusline.d.ts @@ -150,6 +150,7 @@ export type ListElement = Extract; export type ListItemElement = Extract; export type BadgeElement = Extract; export type IconElement = Extract; +/** If spacer support is unknown or absent for app.cli_version, return a literal string for the entire tree. */ export type SpacerElement = Extract; export type CodeElement = Extract; type BoxColumnProps = ColProps & { [K in Exclude]?: never }; diff --git a/codex-rs/tui/src/chatwidget/statusline_contract_tests.rs b/codex-rs/tui/src/chatwidget/statusline_contract_tests.rs index 997c1673cf..fb90a6536d 100644 --- a/codex-rs/tui/src/chatwidget/statusline_contract_tests.rs +++ b/codex-rs/tui/src/chatwidget/statusline_contract_tests.rs @@ -82,6 +82,9 @@ fn generate_reference(output: &Path) -> color_eyre::Result { "Spacer", "Code", ] { + if name == "Spacer" { + generated.push_str("/** If spacer support is unknown or absent for app.cli_version, return a literal string for the entire tree. */\n"); + } let tag = if name == "ListItem" { "list-item".to_owned() } else {