sqlite: also emit an ASCII table so the TUI shows columns
The OpenCode TUI renders tool output through a literal <text> node (packages/tui/.../session/index.tsx, GenericTool), so a GFM table becomes a wall of pipes. The web/desktop client passes the same output through the markdown renderer and draws a proper grid, so a GFM table is the most compact form there. The previous fix emitted a markdown table and assumed the TUI would render it. It does not. The fix: ship both. The ASCII table is space- padded, word-wraps long cells, and stays aligned even when the TUI shows only its collapsed 3-line preview; the markdown table follows and is what the web/desktop client renders with a proper grid. - New rowsToAsciiTable: cellToAscii, truncateForCell, wrapCell, visibleWidth, padRight. NULL -> <null>, BLOB -> <BLOB nB>, Date -> ISO, BigInt -> string. Cell width capped at 40 chars by default (configurable). Single words longer than the cap are hard-wrapped. - sqlite_query's format=table path now emits the ASCII table first and the markdown table second, with a blank line between. - README explains why the duplication and how to read both. End-to-end verified via Code Mode (no model in the loop) after opencode service restart picked up the new transform.
This commit is contained in:
@@ -220,6 +220,53 @@ Error: SQLite error SQLITE_CONSTRAINT_UNIQUE: UNIQUE constraint failed: users.em
|
||||
The model should be told (or already knows) that this prefix means "the
|
||||
operation failed; do not pretend it succeeded."
|
||||
|
||||
### Output on the TUI vs the web client
|
||||
|
||||
The OpenCode web and desktop clients pass tool output through the
|
||||
markdown renderer, but the TUI renders tool output as a literal
|
||||
`<text>` node (see `packages/tui/.../session/index.tsx` — the
|
||||
`GenericTool` component). A GFM table in the TUI therefore shows up as a
|
||||
wall of `|` characters and is hard to scan in the TUI's collapsed
|
||||
3-line preview.
|
||||
|
||||
To make the data legible in both clients, `sqlite_query` with
|
||||
`format: "table"` (the default) ships the result twice:
|
||||
|
||||
1. **First, a plain ASCII table** with space-padded columns. The TUI's
|
||||
`<text>` shows this as a real aligned table; web/desktop show the
|
||||
same lines too (it is plain text, not markdown).
|
||||
2. **Then, a fenced GFM table** in markdown form. The web/desktop
|
||||
clients render this with a proper grid; the TUI ignores the markdown
|
||||
syntax and shows the pipes as-is. Discard visually in the TUI; it is
|
||||
still parseable markdown for any downstream tool that reads the
|
||||
transcript.
|
||||
|
||||
So a `SELECT * FROM users` in the TUI looks like:
|
||||
|
||||
```text
|
||||
SQL: SELECT * FROM users ORDER BY id params: []
|
||||
Returned 3 row(s). Bytes used: 96.
|
||||
|
||||
id name age
|
||||
-- ------- ---
|
||||
1 Alice 30
|
||||
2 Bob 25
|
||||
3 Charlie 35
|
||||
|
||||
| id | name | age |
|
||||
| --- | --- | --- |
|
||||
| 1 | Alice | 30 |
|
||||
| ...
|
||||
```
|
||||
|
||||
The same call in the web client draws the second block as a bordered
|
||||
grid and the first block as preformatted text.
|
||||
|
||||
**TUI visibility tip:** the TUI also hides generic tool output by
|
||||
default (`generic_tool_output_visibility` is `false`). Toggle it on with
|
||||
the `session.toggle.generic_tool_output` keybind if you do not see the
|
||||
output at all.
|
||||
|
||||
## File layout
|
||||
|
||||
This plugin is a single directory:
|
||||
|
||||
Reference in New Issue
Block a user