pi-codex-style-table0.1.2
Codex-style tables and Markdown selection copying for Pi assistant messages
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
Codex-style tables for Pi
Render tables in Pi assistant messages with a Codex-style layout: aligned columns and horizontal separators, without outer or vertical borders.
Item Value
━━━━━━━━━ ━━━━━━━━━━
Status Ready
───────── ──────────
Command npm test
Pi handles inline formatting inside cells, including bold text, code, links, and math. User messages, tool output, thinking blocks, code blocks, and Markdown outside tables keep their existing rendering. Stored conversations and model inputs are unchanged.
Usage
Requires Pi 1.4.0 or later and Node.js 22.19 or later. On older Pi versions or when required internal APIs are incompatible, the extension displays a warning and leaves the default renderer in place.
Try it for one session:
pi -e npm:pi-codex-style-table
Install it for future sessions:
pi install npm:pi-codex-style-table
Run /reload in an active session after installation. To uninstall, run the following command and then /reload:
pi remove npm:pi-codex-style-table
If you already load this extension from a local path, remove that registration first to avoid loading it twice.
Codex-style layout
Based on OpenAI Codex 6c0db39b94.
- Two terminal cells between columns and one cell of horizontal padding on each side of a cell.
- Bold headers in the current theme's accent color,
━below headers, and─between body rows. - Left, center, and right alignment from
:---,:---:, and---:. - Column widths based on visible terminal width, excluding ANSI styling and hyperlink control sequences.
- Width reduction prioritizes columns containing long paths or URLs, then narrative text, then compact values.
- Narrative and long-token columns preferentially retain 16 cells, with a general minimum column width of 3.
- Key/value records replace the grid when the screen is too narrow or wrapping would make too many rows difficult to read.
- Record labels and values appear side by side when space permits, or on separate lines on narrower screens.
- The full table is laid out again during streaming and terminal resizing.
- Trailing prose accidentally parsed as table rows is separated from the table where possible.
Colors follow the current Pi theme rather than reproducing Codex's palette. Markdown parsing, inline formatting, word wrapping, Unicode width calculations, and clickable links use Pi's implementation. Line breaks can therefore differ from Codex for some inputs.
Copying selected table content
Selections managed by Pi's fullscreen mode are copied as Markdown.
pi --tui-mode fullscreen -e npm:pi-codex-style-table
- Selecting a whole table reconstructs a pipe table, preserving column alignment, bold, italic, strikethrough, code, and links.
- Partial selections copy only the selected characters. When several cells are copied, unselected headers and cells remain empty.
- A selection within one cell is copied without a table wrapper. For example, selecting
lphfrom boldalphaproduces**lph**. Selecting only inline code copies the literal code characters. - Lines split by display wrapping are joined, and repeated headers in key/value records are deduplicated.
- Pi's existing copy-on-select setting and selection-copy shortcut continue to work.
/copystill copies the original full assistant response.
Selections handled by the terminal itself, including regular-mode dragging, copy the visible screen text. The extension cannot intercept that path. It produces Markdown text, not an additional HTML clipboard format. Content selected outside tables follows Pi's existing screen-text copying behavior.
If rendered coordinates cannot be mapped reliably to cells, the entire selection falls back to visible text. This can happen with Unicode width differences across ANSI formatting boundaries, layouts modified by other extensions, or identical tables repeated inside nested blocks. Wide characters clipped out of an extremely narrow display are not restored.
Implementation
src/table-layout.ts: column classification, width allocation, alignment, record layouts, and cell-position metadata.src/pi-adapter.ts: table rendering scoped to assistant-bodyMarkdowninstances.src/table-copy.ts: selected cell fragments merged into Markdown.src/copy-adapter.ts: rendered positions mapped to fullscreen selection coordinates.src/styles.ts: header accent color and bold styling restored after inline code and links.src/index.ts: installation and cleanup during the TUI session lifecycle.
Pi does not expose a public table-renderer replacement API. registerMarkdownTransformer() changes text before rendering, so it cannot accurately measure visible width after inline formatting. This extension wraps AssistantMessageComponent.render and rendering methods on individual assistant-body Markdown instances. Selection copying hooks into TuiAltScreen.getActiveSelectionText. Cell-position metadata is stored separately, without inserting hidden control sequences into the output or modifying installed Pi files.
The adapter checks the Pi version and internal methods, invalidates caches, and restores only the methods it still owns during cleanup. Wrappers retained by other extensions become inactive and delegate to the original behavior. Markdown instances are tracked through weak references. Compatibility with other rendering extensions should be checked separately.
License
Apache-2.0. See LICENSE and NOTICE for licensing and attribution of the Codex-derived implementation and reference fixtures.