ggtui 0.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ggtui-0.5.0/.claude/agents/bug-hunter.md +25 -0
- ggtui-0.5.0/.github/workflows/release.yml +65 -0
- ggtui-0.5.0/.gitignore +9 -0
- ggtui-0.5.0/.python-version +1 -0
- ggtui-0.5.0/AGENTS.md +88 -0
- ggtui-0.5.0/CHANGELOG.md +24 -0
- ggtui-0.5.0/LICENSE +21 -0
- ggtui-0.5.0/Makefile +15 -0
- ggtui-0.5.0/PKG-INFO +77 -0
- ggtui-0.5.0/README.md +54 -0
- ggtui-0.5.0/docs/guide.md +197 -0
- ggtui-0.5.0/memory/README.md +6 -0
- ggtui-0.5.0/memory/textual_workspace_traps.md +29 -0
- ggtui-0.5.0/notes/README.md +9 -0
- ggtui-0.5.0/notes/plans/workspace-app.md +476 -0
- ggtui-0.5.0/notes/plans/workspace-split.md +172 -0
- ggtui-0.5.0/pyproject.toml +69 -0
- ggtui-0.5.0/src/ggtui/__init__.py +18 -0
- ggtui-0.5.0/src/ggtui/__main__.py +5 -0
- ggtui-0.5.0/src/ggtui/app.py +1691 -0
- ggtui-0.5.0/src/ggtui/cli.py +89 -0
- ggtui-0.5.0/src/ggtui/completion.py +607 -0
- ggtui-0.5.0/src/ggtui/editor.py +604 -0
- ggtui-0.5.0/src/ggtui/errors.py +59 -0
- ggtui-0.5.0/src/ggtui/half_blocks.py +190 -0
- ggtui-0.5.0/src/ggtui/hover.py +423 -0
- ggtui-0.5.0/src/ggtui/kernel.py +220 -0
- ggtui-0.5.0/src/ggtui/kitty_image.py +250 -0
- ggtui-0.5.0/src/ggtui/pane_pages.py +477 -0
- ggtui-0.5.0/src/ggtui/protocol.py +70 -0
- ggtui-0.5.0/src/ggtui/quick_plots.py +134 -0
- ggtui-0.5.0/src/ggtui/script.py +350 -0
- ggtui-0.5.0/src/ggtui/session.py +348 -0
- ggtui-0.5.0/src/ggtui/style.py +88 -0
- ggtui-0.5.0/src/ggtui/terminal.py +168 -0
- ggtui-0.5.0/src/ggtui/text.py +42 -0
- ggtui-0.5.0/src/ggtui/variables.py +220 -0
- ggtui-0.5.0/src/ggtui/views.py +620 -0
- ggtui-0.5.0/src/ggtui/worker.py +993 -0
- ggtui-0.5.0/tests/pinned/README.md +11 -0
- ggtui-0.5.0/tests/pinned/ggrust.js +2282 -0
- ggtui-0.5.0/tests/test_workspace_app.py +1539 -0
- ggtui-0.5.0/tests/test_workspace_boundary.py +127 -0
- ggtui-0.5.0/tests/test_workspace_hover_parity.py +223 -0
- ggtui-0.5.0/uv.lock +516 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bug-hunter
|
|
3
|
+
description: Bug-hunting reviewer for ggtui (AGENTS.md rule 5). Assumes the recently implemented step is faulty, finds concrete bugs, confirms them with tests or repro scripts, and reports back. Does not edit source files.
|
|
4
|
+
model: sonnet
|
|
5
|
+
tools: Read, Grep, Glob, Bash
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
You are a bug hunter for ggtui, a Textual terminal workspace for ggrust plots.
|
|
9
|
+
|
|
10
|
+
Assume the code under review is wrong. Your job is to prove it.
|
|
11
|
+
|
|
12
|
+
- Read `AGENTS.md` and `memory/README.md` first; the memory entries list known traps.
|
|
13
|
+
- Focus on the area named in your brief. Use `git diff` / `git log` to see what changed.
|
|
14
|
+
- Look for concrete failures: wrong output, crashes on user input, a kernel or app
|
|
15
|
+
that hangs, state that never clears, edge cases (empty data, nulls, huge counts,
|
|
16
|
+
odd terminal sizes).
|
|
17
|
+
- Confirm each bug with `uv run pytest`, a Textual pilot test or a small repro
|
|
18
|
+
script. Keep scratch files outside `src/` and `tests/`.
|
|
19
|
+
- Keep every repro under about 1 GB of memory. Never kill a process you did not start.
|
|
20
|
+
- Do not edit source or test files. Do not commit.
|
|
21
|
+
|
|
22
|
+
Report only confirmed or strongly plausible bugs, most severe first. For each one:
|
|
23
|
+
file:line, the triggering input, expected vs actual behaviour, how you confirmed it,
|
|
24
|
+
and whether it is CONFIRMED (reproduced) or PLAUSIBLE (reasoned, not reproduced).
|
|
25
|
+
If you find nothing, say so plainly.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Runs the checks, builds the wheel and sdist, smoke-tests the wheel, and publishes to
|
|
2
|
+
# PyPI when a `v*` tag is pushed (trusted publishing: no stored token). Manual runs
|
|
3
|
+
# and pull requests that touch packaging only check and build, they never publish.
|
|
4
|
+
name: Release
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
tags: ["v*"]
|
|
9
|
+
pull_request:
|
|
10
|
+
paths:
|
|
11
|
+
- ".github/workflows/release.yml"
|
|
12
|
+
- "pyproject.toml"
|
|
13
|
+
- "uv.lock"
|
|
14
|
+
workflow_dispatch:
|
|
15
|
+
|
|
16
|
+
permissions:
|
|
17
|
+
contents: read
|
|
18
|
+
|
|
19
|
+
jobs:
|
|
20
|
+
build:
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
- uses: astral-sh/setup-uv@v6
|
|
25
|
+
with:
|
|
26
|
+
python-version: "3.11"
|
|
27
|
+
- uses: actions/setup-node@v4 # the hover parity tests run ggrust.js in node
|
|
28
|
+
with:
|
|
29
|
+
node-version: "22"
|
|
30
|
+
- name: Check
|
|
31
|
+
run: make check
|
|
32
|
+
- name: Build
|
|
33
|
+
run: uv build
|
|
34
|
+
- name: Smoke-test the wheel in a clean environment
|
|
35
|
+
run: |
|
|
36
|
+
uv venv /tmp/smoke
|
|
37
|
+
uv pip install --python /tmp/smoke/bin/python dist/*.whl
|
|
38
|
+
/tmp/smoke/bin/ggtui --version
|
|
39
|
+
/tmp/smoke/bin/python -c "import ggtui, ggrust; assert hasattr(ggrust, 'to_png_with_tooltips')"
|
|
40
|
+
- uses: actions/upload-artifact@v4
|
|
41
|
+
with:
|
|
42
|
+
name: dist
|
|
43
|
+
path: dist/
|
|
44
|
+
|
|
45
|
+
publish:
|
|
46
|
+
name: Publish to PyPI
|
|
47
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
48
|
+
needs: [build]
|
|
49
|
+
runs-on: ubuntu-latest
|
|
50
|
+
environment: pypi
|
|
51
|
+
permissions:
|
|
52
|
+
id-token: write # PyPI trusted publishing, no stored token
|
|
53
|
+
steps:
|
|
54
|
+
- uses: actions/download-artifact@v4
|
|
55
|
+
with:
|
|
56
|
+
name: dist
|
|
57
|
+
path: dist
|
|
58
|
+
- name: Check the tag matches the package version
|
|
59
|
+
run: |
|
|
60
|
+
version="${GITHUB_REF_NAME#v}"
|
|
61
|
+
test -f "dist/ggtui-${version}.tar.gz" || {
|
|
62
|
+
echo "tag ${GITHUB_REF_NAME} does not match the built version: $(ls dist)"; exit 1; }
|
|
63
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
64
|
+
with:
|
|
65
|
+
packages-dir: dist/
|
ggtui-0.5.0/.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.14
|
ggtui-0.5.0/AGENTS.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
Read this file before touching the code. It is the contract for every agent (human or
|
|
4
|
+
AI) working on **ggtui**. Lessons learned live in [memory/](memory/README.md): read
|
|
5
|
+
its index before starting work.
|
|
6
|
+
|
|
7
|
+
## What ggtui is
|
|
8
|
+
|
|
9
|
+
A terminal workspace for [ggrust](https://github.com/datavil/ggrust) plots, in the
|
|
10
|
+
spirit of RStudio: a Textual app with a console, Plots (Kitty graphics, hover
|
|
11
|
+
tooltips), Data, Help and Variables tabs, and a script editor. Pure Python.
|
|
12
|
+
|
|
13
|
+
- **ggrust is a dependency, used through its public API only.** Plots render through
|
|
14
|
+
`ggrust.to_png_with_tooltips` and the other frozen names in ggrust's
|
|
15
|
+
`docs/guide/stability.md`. Never import a private `ggrust._*` name:
|
|
16
|
+
`tests/test_workspace_boundary.py` fails on one. If ggtui needs something ggrust
|
|
17
|
+
does not expose, ask the user; it becomes a ggrust change of its own.
|
|
18
|
+
- **Hover mirrors ggrust's HTML runtime.** `src/ggtui/hover.py` is a Python copy of
|
|
19
|
+
`lookup` in ggrust's `js/ggrust.js`, pinned in `tests/pinned/` with the ggrust
|
|
20
|
+
version it came from. The parity test skips when the installed ggrust is newer;
|
|
21
|
+
re-pin then (`tests/pinned/README.md`).
|
|
22
|
+
- ggtui is not bound by ggrust's lets-plot parity or golden-image rules.
|
|
23
|
+
|
|
24
|
+
## Layout
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
src/ggtui/ app (Textual app), editor, completion, views (tabs), kitty_image,
|
|
28
|
+
half_blocks, terminal (probe), kernel (app side) and worker (the
|
|
29
|
+
kernel process), protocol, hover, session, script, variables,
|
|
30
|
+
quick_plots, pane_pages, style, text, errors, cli (the command)
|
|
31
|
+
tests/ pytest, including Textual pilot tests and the hover parity test
|
|
32
|
+
docs/guide.md the user guide
|
|
33
|
+
notes/ plans, indexed in notes/README.md
|
|
34
|
+
memory/ lessons learned, indexed in memory/README.md
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The kernel (`worker.py`) runs in its own process and must not import Textual.
|
|
38
|
+
|
|
39
|
+
## Golden rules
|
|
40
|
+
|
|
41
|
+
1. **Test everything before handing over, not just smoke tests.** Run `make check`,
|
|
42
|
+
start `ggtui` (a pty is fine headless) and look at what it draws. Textual's pilot
|
|
43
|
+
and `app.save_screenshot()` let you see layouts without a terminal.
|
|
44
|
+
2. **Be surgical.** Do exactly what was asked. If you must touch anything outside
|
|
45
|
+
it, ask the user first.
|
|
46
|
+
3. **Simple beats clever.** Small modules, one concept each, no hidden global state.
|
|
47
|
+
4. **Ask the user** when unsure about a design decision or a new key, command or
|
|
48
|
+
behavior. Do not guess.
|
|
49
|
+
5. **Bug-hunting sub agents.** After a step, spin up a sub agent (on a cheaper model)
|
|
50
|
+
whose job is to assume the code is faulty, find the bug and report back with a
|
|
51
|
+
repro. Its repros stay under about 1 GB of memory, and it never kills processes it
|
|
52
|
+
did not start. Fix what it confirms, surgically, and re-verify.
|
|
53
|
+
6. **Record critical lessons** as a file in `memory/` with a line in its index.
|
|
54
|
+
7. **Commit only when the user says so.** Run `make format` and `make check` first;
|
|
55
|
+
tests pass at every commit.
|
|
56
|
+
|
|
57
|
+
## Naming and style
|
|
58
|
+
|
|
59
|
+
- Full words, no abbreviations (`group_index`, not `grp_idx`; `frame`, not `df`).
|
|
60
|
+
Well-known terms are fine (`n`, `x`, `y`, `png`, `rgb`).
|
|
61
|
+
- Ruff formatting and import sorting; polars over pandas. Functions return one type.
|
|
62
|
+
- Type hints are **comprehensive**: every function, parameter and return value, with
|
|
63
|
+
precise types (`Literal[...]`, `X | None`, typed containers), not `Any` unless
|
|
64
|
+
truly unavoidable. Checked with `ty` (`uv run ty check src`).
|
|
65
|
+
- Docstrings are **NumPy style** on every public function and class: summary,
|
|
66
|
+
`Parameters` (`type, default=...`), `Returns`, `Raises`, `Examples` where useful.
|
|
67
|
+
- Every module starts with a docstring: what it does and what it does not.
|
|
68
|
+
- No `_`-prefixed (or other) attribute on a Textual `App`/`Widget` subclass without
|
|
69
|
+
grepping `textual/` for that name first (see memory).
|
|
70
|
+
- No em dashes in code, docs or comments.
|
|
71
|
+
|
|
72
|
+
## Errors
|
|
73
|
+
|
|
74
|
+
Errors say **what** was wrong, **where** (which command, argument, file or line),
|
|
75
|
+
**what is accepted** and **how to fix it**. Use the specific classes in
|
|
76
|
+
`src/ggtui/errors.py` (each subclasses the matching builtin and has a docstring),
|
|
77
|
+
never a bare `Exception`. Code typed in the console must never take the app down:
|
|
78
|
+
the kernel reports its errors as tracebacks in the console. Tests assert on the error
|
|
79
|
+
type and the key parts of the message.
|
|
80
|
+
|
|
81
|
+
## Commands
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
uv sync # dev env (ggrust from PyPI)
|
|
85
|
+
make format # ruff format + ruff check --fix
|
|
86
|
+
make check # ruff, ty, pytest (run before every commit)
|
|
87
|
+
uv run ggtui --demo
|
|
88
|
+
```
|
ggtui-0.5.0/CHANGELOG.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.5.0 (unreleased)
|
|
4
|
+
|
|
5
|
+
First release as its own package. Until now the workspace lived in ggrust's
|
|
6
|
+
`prototype/terminal-graphics` branch as the `ggrust` command (workspace 0.4.0); its
|
|
7
|
+
history came along.
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- The package is `ggtui` and the command is `ggtui` (`ggtui --demo`,
|
|
12
|
+
`ggtui run script.py [--watch]`, `ggtui --version`).
|
|
13
|
+
- Plots and hover targets come from ggrust's public `to_png_with_tooltips` (ggrust
|
|
14
|
+
1.2), so ggtui uses no private ggrust name; a test guards that.
|
|
15
|
+
- The session folder is `~/Library/Application Support/ggtui` (macOS) or
|
|
16
|
+
`$XDG_DATA_HOME/ggtui` (Linux), and `GGTUI_DATA` replaces `GGRUST_WORKSPACE_DATA`.
|
|
17
|
+
Sessions of the 0.4.0 prototype are not carried over.
|
|
18
|
+
- Plots drawn from more than 200,000 data rows render without hover tooltips, which
|
|
19
|
+
would take hundreds of MB for such plots.
|
|
20
|
+
|
|
21
|
+
### Removed
|
|
22
|
+
|
|
23
|
+
- The classic Ghostty workspace (`ggrust --classic`, `ggrust pane`) and its inline
|
|
24
|
+
Kitty `show()`. The Textual app replaces them; they remain in the git history.
|
ggtui-0.5.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Zaf4
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
ggtui-0.5.0/Makefile
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
.PHONY: format lint check test
|
|
2
|
+
|
|
3
|
+
format:
|
|
4
|
+
uv run ruff format src tests
|
|
5
|
+
uv run ruff check --fix src tests
|
|
6
|
+
|
|
7
|
+
lint:
|
|
8
|
+
uv run ruff format --check src tests
|
|
9
|
+
uv run ruff check src tests
|
|
10
|
+
uv run ty check src
|
|
11
|
+
|
|
12
|
+
test:
|
|
13
|
+
uv run pytest -q
|
|
14
|
+
|
|
15
|
+
check: lint test
|
ggtui-0.5.0/PKG-INFO
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: ggtui
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: A terminal workspace for ggrust plots: console, plots with hover, data and help in one TUI
|
|
5
|
+
Project-URL: Repository, https://github.com/datavil/ggtui
|
|
6
|
+
Author-email: Zaf4 <zafermolbio@gmail.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Environment :: Console :: Curses
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: Operating System :: MacOS
|
|
13
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
16
|
+
Classifier: Typing :: Typed
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Requires-Dist: ggrust<1.3,>=1.2
|
|
19
|
+
Requires-Dist: textual>=8.2
|
|
20
|
+
Requires-Dist: tree-sitter-python>=0.23
|
|
21
|
+
Requires-Dist: tree-sitter>=0.25
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# ggtui
|
|
25
|
+
|
|
26
|
+
A terminal workspace for [ggrust](https://github.com/datavil/ggrust) plots, in the
|
|
27
|
+
spirit of RStudio: a Python console on the left, and Plots, Data, Help and Variables
|
|
28
|
+
tabs on the right, in one full-screen app in your terminal. Every plot you type is
|
|
29
|
+
drawn in the Plots tab at its size, with hover tooltips as in ggrust's HTML output.
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
ggplot(mpg, aes("displ", "hwy", color="class")) + geom_point()
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Install
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
uv tool install ggtui
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
or `pipx install ggtui`, or `pip install ggtui` in a project. ggtui needs macOS or
|
|
42
|
+
Linux, and is best in a terminal with Kitty graphics (Ghostty, Kitty, WezTerm); other
|
|
43
|
+
terminals get a coarse half-block preview of each plot.
|
|
44
|
+
|
|
45
|
+
## Use
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
ggtui # open the workspace
|
|
49
|
+
ggtui --demo # with a few example plots
|
|
50
|
+
ggtui run analysis.py --watch # run a script, again on every save
|
|
51
|
+
ggtui --help
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The console starts with `from ggrust import *` and `from ggrust.data import *`. Console
|
|
55
|
+
commands: `show(x)`, `help(x)`, `last()`, `save(...)`, `style(...)`, `clear()`,
|
|
56
|
+
`edit(path)`, `browse()`. Keys: F1 help, F2/F3 plots, F4 zoom, F5 restart the kernel,
|
|
57
|
+
F6 plot look, F7 compare, F8 script/console, Ctrl-Q quit. The full guide is in
|
|
58
|
+
[docs/guide.md](docs/guide.md).
|
|
59
|
+
|
|
60
|
+
Plots drawn from more than 200,000 data rows show no hover (their tooltips would take
|
|
61
|
+
hundreds of MB); everything else works as usual.
|
|
62
|
+
|
|
63
|
+
## Develop
|
|
64
|
+
|
|
65
|
+
ggtui needs ggrust 1.2 or later (`ggrust.to_png_with_tooltips`), installed from PyPI
|
|
66
|
+
by `uv sync`.
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
uv sync
|
|
70
|
+
make check # ruff, ty, pytest (Textual pilot tests included)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
See [AGENTS.md](AGENTS.md) for the rules of the repo.
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
MIT
|
ggtui-0.5.0/README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# ggtui
|
|
2
|
+
|
|
3
|
+
A terminal workspace for [ggrust](https://github.com/datavil/ggrust) plots, in the
|
|
4
|
+
spirit of RStudio: a Python console on the left, and Plots, Data, Help and Variables
|
|
5
|
+
tabs on the right, in one full-screen app in your terminal. Every plot you type is
|
|
6
|
+
drawn in the Plots tab at its size, with hover tooltips as in ggrust's HTML output.
|
|
7
|
+
|
|
8
|
+
```python
|
|
9
|
+
ggplot(mpg, aes("displ", "hwy", color="class")) + geom_point()
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
uv tool install ggtui
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
or `pipx install ggtui`, or `pip install ggtui` in a project. ggtui needs macOS or
|
|
19
|
+
Linux, and is best in a terminal with Kitty graphics (Ghostty, Kitty, WezTerm); other
|
|
20
|
+
terminals get a coarse half-block preview of each plot.
|
|
21
|
+
|
|
22
|
+
## Use
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
ggtui # open the workspace
|
|
26
|
+
ggtui --demo # with a few example plots
|
|
27
|
+
ggtui run analysis.py --watch # run a script, again on every save
|
|
28
|
+
ggtui --help
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The console starts with `from ggrust import *` and `from ggrust.data import *`. Console
|
|
32
|
+
commands: `show(x)`, `help(x)`, `last()`, `save(...)`, `style(...)`, `clear()`,
|
|
33
|
+
`edit(path)`, `browse()`. Keys: F1 help, F2/F3 plots, F4 zoom, F5 restart the kernel,
|
|
34
|
+
F6 plot look, F7 compare, F8 script/console, Ctrl-Q quit. The full guide is in
|
|
35
|
+
[docs/guide.md](docs/guide.md).
|
|
36
|
+
|
|
37
|
+
Plots drawn from more than 200,000 data rows show no hover (their tooltips would take
|
|
38
|
+
hundreds of MB); everything else works as usual.
|
|
39
|
+
|
|
40
|
+
## Develop
|
|
41
|
+
|
|
42
|
+
ggtui needs ggrust 1.2 or later (`ggrust.to_png_with_tooltips`), installed from PyPI
|
|
43
|
+
by `uv sync`.
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
uv sync
|
|
47
|
+
make check # ruff, ty, pytest (Textual pilot tests included)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
See [AGENTS.md](AGENTS.md) for the rules of the repo.
|
|
51
|
+
|
|
52
|
+
## License
|
|
53
|
+
|
|
54
|
+
MIT
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# ggtui guide
|
|
2
|
+
|
|
3
|
+
The `ggtui` command opens a workspace in the terminal you run it in: a Python
|
|
4
|
+
console on the left, and Plots, Data, Help and Variables tabs on the right. Every
|
|
5
|
+
plot you type is drawn in the Plots tab at its size, and drawn again when the tab
|
|
6
|
+
changes size.
|
|
7
|
+
|
|
8
|
+
> **0.x.** ggtui is young: its commands and keys may change in any 0.x release
|
|
9
|
+
> (`ggtui --version` shows the version).
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
- **macOS or Linux.** On Windows the `ggtui` command exits with a message.
|
|
14
|
+
- **ggtui installed** with ggrust, [Textual](https://textual.textualize.io) and
|
|
15
|
+
tree-sitter (for syntax highlighting) as its dependencies (see the README).
|
|
16
|
+
- **A terminal with Kitty graphics**, such as [Ghostty](https://ghostty.org), Kitty or
|
|
17
|
+
WezTerm, to see plots sharp. In other terminals the Plots tab shows a coarse
|
|
18
|
+
preview in colored half blocks, and `browse()` (or `browser` under the plot) opens
|
|
19
|
+
the plot in the web browser; `save` works everywhere.
|
|
20
|
+
|
|
21
|
+
## Start it
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
ggtui
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`ggtui --demo` starts with a few example plots. The console starts with
|
|
28
|
+
`from ggrust import *` and `from ggrust.data import *` already run, so the example
|
|
29
|
+
datasets (`mpg`, `penguins`, `iris`, `economics`) are there:
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
ggplot(mpg, aes("displ", "hwy", color="class")) + geom_point()
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The plot shows in the Plots tab, and the console says `↳ plot 1`. Every plot of a
|
|
36
|
+
block is drawn, not only the last one.
|
|
37
|
+
|
|
38
|
+
### Run a script, again on every save
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
ggtui run analysis.py --watch
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
opens the workspace with `analysis.py` run in its console. With `--watch`, every
|
|
45
|
+
save (from any editor: vim, Zed, VS Code beside the workspace) runs it again, and its
|
|
46
|
+
new plots replace those of its last run; a run that fails keeps the last plots on
|
|
47
|
+
screen and shows the traceback with the script's line numbers. The script runs in
|
|
48
|
+
the console's namespace, so its names are in the Variables tab and the console can
|
|
49
|
+
work with them. Without `--watch`, the script runs once.
|
|
50
|
+
|
|
51
|
+
### Your session is kept
|
|
52
|
+
|
|
53
|
+
The input history and the plot list survive quitting: the next `ggtui` starts with
|
|
54
|
+
the last session's history (↑, Ctrl-R) and plots (F2/F3). Kept plots are drawn again
|
|
55
|
+
at the tab's size by the new kernel, and `last()` works on them once they are shown.
|
|
56
|
+
Up to 1,000 history entries and 50 plots (200 MB) are kept, the oldest dropped first,
|
|
57
|
+
in `~/Library/Application Support/ggtui` on macOS and
|
|
58
|
+
`~/.local/share/ggtui` on Linux (`$XDG_DATA_HOME`); set
|
|
59
|
+
`GGTUI_DATA` to use another folder. `clear()` deletes the kept plots too.
|
|
60
|
+
To redraw a plot, the workspace keeps a copy of it, data included (plots over 8 MB
|
|
61
|
+
keep only their image).
|
|
62
|
+
|
|
63
|
+
## The console
|
|
64
|
+
|
|
65
|
+
Type code in the editor at the bottom; the output log is above it. The editor
|
|
66
|
+
highlights Python and the bracket matching the one at the cursor.
|
|
67
|
+
|
|
68
|
+
| Key | What it does |
|
|
69
|
+
|---|---|
|
|
70
|
+
| Enter | Run the block when it is complete, as in Python's REPL; otherwise add a line, indented like the one before (one level more after a `:`). Inside an indented block, an empty line runs it. |
|
|
71
|
+
| Backspace | In a line's indentation, go back one level. |
|
|
72
|
+
| Tab | Complete: keyword arguments of the call being typed (`geom_point(si` gives `size=` and `size_unit=`), aesthetics in `aes()`, `geom_*()` and `stat_*()`, names (`geom_po`), the names you made in the console (`my_fr` gives `my_frame`, with its shape), and their methods when their type is a library's (`my_frame.fil` gives `filter(`). Each candidate shows its line of documentation. One candidate is inserted at once; several open a menu (↑ ↓ to pick, Tab or Enter to take, Esc to close). Tab in a line's indentation indents. |
|
|
73
|
+
| ↑ ↓ | On the first (last) line: the previous (next) block from the history; past the newest comes back what you were typing. |
|
|
74
|
+
| Ctrl-R | Search the history: type part of a block; Ctrl-R again for an older match, Enter to take it, Esc to cancel. |
|
|
75
|
+
| F1 | The help of the name under the cursor, in the Help tab. |
|
|
76
|
+
| Ctrl-C | Interrupt the running block; when nothing runs, copy the selection or empty the editor. |
|
|
77
|
+
| Ctrl-L | Empty the output log. |
|
|
78
|
+
|
|
79
|
+
A pasted block runs as one block, and a block that shares an indent (copied from
|
|
80
|
+
inside a function, say) has it removed first. Completion learns the console's names
|
|
81
|
+
after each block runs; it never waits for a running block.
|
|
82
|
+
|
|
83
|
+
## Console commands
|
|
84
|
+
|
|
85
|
+
The console has these names, also as methods of `pane` (type `pane` to list them).
|
|
86
|
+
They exist only in the workspace console; `from ggrust import *` does not add them.
|
|
87
|
+
|
|
88
|
+
| Command | What it does |
|
|
89
|
+
|---|---|
|
|
90
|
+
| `show(x)` | Show a data frame (polars or pandas) as a table in the Data tab, or a plot in the Plots tab. |
|
|
91
|
+
| `help(x)` | Show the help of a function or class, formatted, in the Help tab. |
|
|
92
|
+
| `last()` | Return the plot on screen, to build on: `last() + theme_bw()`. |
|
|
93
|
+
| `save(filename, w=None, h=None)` | Save the plot on screen at the tab's size (or `w` x `h` pixels); the extension picks the format, as in `ggsave`. |
|
|
94
|
+
| `style(name)` | How plots with no flavor of their own look: `"dark"`, `"light"` or `"none"`. |
|
|
95
|
+
| `clear()` | Empty the plot history. |
|
|
96
|
+
| `edit(path)` | Open a script in the Script editor above the console (a new file is written on the first Ctrl-S). |
|
|
97
|
+
| `browse()` | Open the plot on screen in the web browser, interactive (tooltips, zoom), at the tab's size. Over SSH, where no browser opens, it prints the page's path. |
|
|
98
|
+
|
|
99
|
+
`input()` cannot read in the console (the kernel has no stdin) and raises
|
|
100
|
+
`WorkspaceError`.
|
|
101
|
+
|
|
102
|
+
## The tabs
|
|
103
|
+
|
|
104
|
+
The workspace draws in the terminal's own colors on its own background, every
|
|
105
|
+
region in a thin dim frame with its name in the top edge (the frame with the focus
|
|
106
|
+
is a little brighter).
|
|
107
|
+
|
|
108
|
+
**Plots** shows the plot on screen in a frame titled `plot 3/5 · <its title>`. The
|
|
109
|
+
words in the frame's bottom edge are clickable: ◀ ▶ through the history, `save`,
|
|
110
|
+
`zoom`, `compare`, `browser` and the plot look (dark, light, none). Plots that set no flavor get `flavor_high_contrast_dark()` (or
|
|
111
|
+
the light one, when the terminal background is light) and `flavor_transparent()`, so
|
|
112
|
+
they sit on the terminal's background; their theme's own text colors give way to the
|
|
113
|
+
flavor's, so text a library colors near-black stays readable. `save` writes the plot
|
|
114
|
+
as you made it, without that look. The workspace keeps the images of the last 12
|
|
115
|
+
plots seen; older ones are drawn again when you go back to them.
|
|
116
|
+
|
|
117
|
+
**Hover**: move the mouse over a plot to see its tooltips, as in the HTML output: the
|
|
118
|
+
same lines (`layer_tooltips()`, or the default ones), the marker color, and the axis
|
|
119
|
+
values on the panel's edges; bars and lines show every series at the cursor's x.
|
|
120
|
+
`tooltips="none"` turns them off. Terminals that report the mouse in pixels (Ghostty,
|
|
121
|
+
Kitty, WezTerm) place it to the pixel; others to the cell. The kernel builds the
|
|
122
|
+
targets with the plot; the first hover over a plot fetches and indexes them (about 0.1 s for
|
|
123
|
+
100,000 points, later while a block runs), and after that a hover answers in a few
|
|
124
|
+
milliseconds. Plots drawn from more than 200,000 data rows (all their frames
|
|
125
|
+
together) show no hover: their tooltips would take hundreds of MB to build.
|
|
126
|
+
|
|
127
|
+
**Compare** (F7 or `compare` under the plot) pins the plot on screen on the left and
|
|
128
|
+
shows the others beside it, both at half the tab's width: F2/F3 change the right
|
|
129
|
+
one, new plots appear on the right. F7 again shows one plot. Needs Kitty graphics.
|
|
130
|
+
|
|
131
|
+
**Data** shows `show(frame)` as a scrollable table: the frame's name, its row and
|
|
132
|
+
column count, and each column's type and null count in the header (in yellow when
|
|
133
|
+
it has nulls). Up to 10,000 rows are shown; a LazyFrame collects only those.
|
|
134
|
+
|
|
135
|
+
In the table, the cursor picks a column. Quick plots write their ggrust code into
|
|
136
|
+
the console and run it, so you see the grammar (and ↑ brings the code back to
|
|
137
|
+
edit):
|
|
138
|
+
|
|
139
|
+
| Key | Plot |
|
|
140
|
+
|---|---|
|
|
141
|
+
| h | A histogram of a numeric column: `ggplot(mpg, aes("hwy")) + geom_histogram()`. |
|
|
142
|
+
| d | A density of a numeric column. |
|
|
143
|
+
| b | A bar chart of a text, categorical, boolean or integer column (on its side with more than 8 levels). |
|
|
144
|
+
| s | A scatter: `s` on the x column, then `s` on the y column (Esc forgets x). |
|
|
145
|
+
|
|
146
|
+
Quick plots need a frame with a name in the console (`show(cars)`, not
|
|
147
|
+
`show(mpg.head())`), and say which key to press when a column does not suit the plot.
|
|
148
|
+
|
|
149
|
+
**Help** shows `help(x)` and F1: the signature, then the docstring with its
|
|
150
|
+
sections, parameters and examples set apart.
|
|
151
|
+
|
|
152
|
+
**Variables** lists the names you made in the console after every block: frames
|
|
153
|
+
with their shape, plots with their geoms, functions with their signature, and other
|
|
154
|
+
values with their type and a short value. Enter on a name opens it: a frame in the
|
|
155
|
+
Data tab, a plot in the Plots tab, the help of a function, class or module, and the
|
|
156
|
+
value of anything else (each runs its code in the console: `show(cars)`).
|
|
157
|
+
|
|
158
|
+
## The script editor
|
|
159
|
+
|
|
160
|
+
`edit("analysis.py")` opens a script above the console, with line numbers and Python
|
|
161
|
+
highlighting, as RStudio's source pane:
|
|
162
|
+
|
|
163
|
+
| Key | What it does |
|
|
164
|
+
|---|---|
|
|
165
|
+
| Ctrl-Enter (or F9) | Run the selection, or else the whole statement under the cursor (a `for` line runs its block, a decorator its function) in the console, then move to the next statement. The code goes to the history too. |
|
|
166
|
+
| Ctrl-S | Save the script (the title shows `●` while there are unsaved changes). |
|
|
167
|
+
| F8 | Move between the script and the console. |
|
|
168
|
+
| Ctrl-W | Close the script; with unsaved changes, a second Ctrl-W drops them. |
|
|
169
|
+
|
|
170
|
+
Ctrl-Q with unsaved changes in the script only warns; a second Ctrl-Q quits. Files
|
|
171
|
+
over 5 MB or not in UTF-8 are not opened (`ScriptError` in the console).
|
|
172
|
+
|
|
173
|
+
## Keys
|
|
174
|
+
|
|
175
|
+
| Key | What it does |
|
|
176
|
+
|---|---|
|
|
177
|
+
| F1 | Help on the name under the cursor. |
|
|
178
|
+
| F2 / F3 | Previous / next plot. |
|
|
179
|
+
| F4 | Zoom: the tabs take the whole screen (the plot is drawn again at that size); F4 again gives the console back. |
|
|
180
|
+
| F5 | Restart the kernel. |
|
|
181
|
+
| F6 | Next plot look: dark, light, none. |
|
|
182
|
+
| F7 | Compare: pin the plot on screen beside the others; again to stop. |
|
|
183
|
+
| F8 | Move between the script editor and the console. |
|
|
184
|
+
| Ctrl-S | Save the plot on screen as `ggrust-plot-<n>.png` (runs `save(...)` in the console); in the script editor, save the script. |
|
|
185
|
+
| Ctrl-P | Command palette, with the same actions. |
|
|
186
|
+
| Ctrl-Q | Quit. |
|
|
187
|
+
|
|
188
|
+
## The kernel
|
|
189
|
+
|
|
190
|
+
Code runs in a separate process, the kernel, so a long or stuck computation never
|
|
191
|
+
freezes the workspace. The status line shows whether it is idle or busy, its memory
|
|
192
|
+
and the app's, and the last run time. Ctrl-C interrupts a running block with a
|
|
193
|
+
`KeyboardInterrupt`. F5 restarts the kernel: its names are gone, and plots made
|
|
194
|
+
before stay viewable; with the session kept (the default), the new kernel draws them
|
|
195
|
+
again at a new size and `last()` works on them. A kernel that dies (a crash, `os._exit`) is restarted on its own; one that
|
|
196
|
+
dies three times in a row while starting is left stopped, with its error output in
|
|
197
|
+
the console, until F5.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Memory index
|
|
2
|
+
|
|
3
|
+
Critical lessons: approaches that work, or that break things. One file per lesson.
|
|
4
|
+
Add a line here for every new file. Format: `- [Title](file.md): one-line hook`.
|
|
5
|
+
|
|
6
|
+
- [Textual traps in the workspace app](textual_workspace_traps.md): never shadow Textual's private or public names on App/Widget subclasses (`_resize_timer`, `history`, `watch`); `priority=True` for global keys; drop answered entries from "asked" sets.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Textual traps in the workspace app
|
|
2
|
+
|
|
3
|
+
**Broke (W1, 2026-11-30):** the app stored its own resize debounce in `self._resize_timer`.
|
|
4
|
+
Textual's `App` uses that private name for its own resize handling, so after the first
|
|
5
|
+
terminal resize the layout never followed again (pilot: screen 180x50, `#main` still
|
|
6
|
+
120x38). Nothing raised. **Rule:** no `_`-prefixed attributes on `App`/`Widget` subclasses
|
|
7
|
+
unless grepped against `textual/` first (`grep -rn "self\._name\b" .venv/.../textual`);
|
|
8
|
+
prefer a descriptive public name (`_plot_resize_timer` now).
|
|
9
|
+
|
|
10
|
+
**Broke:** F6 did nothing while the editor had focus: `TextArea` binds `f6` (select line).
|
|
11
|
+
App-level keys that must work everywhere need `priority=True`.
|
|
12
|
+
|
|
13
|
+
**Also:** `TextArea.history` is its undo history (`checkpoint()`): never name an attribute
|
|
14
|
+
`history` on a `TextArea` subclass. Textual dispatches `on_mount` (and other handlers) up
|
|
15
|
+
the MRO, so a subclass's `on_mount` does not replace the base one. Use pilot +
|
|
16
|
+
`app.save_screenshot()` and render the SVG with Chrome (Playwright `channel="chrome"`, drop
|
|
17
|
+
`@font-face`) to look at layouts headlessly.
|
|
18
|
+
|
|
19
|
+
**Also (W2):** `DOMNode.watch` is a Textual method (reactive watchers, `watch_<name>`
|
|
20
|
+
too): name a flag `script_watched`, not `watch`. Before adding any attribute to an
|
|
21
|
+
`App`/`Widget` subclass, grep `textual/` for `def <name>` as well as `self.<name>`.
|
|
22
|
+
|
|
23
|
+
**Also (W3):** Textual already enables SGR-Pixels mouse (1016) when the terminal
|
|
24
|
+
answers the in-band resize query (2048): `MouseMove.pointer_x/y` are then sub-cell
|
|
25
|
+
floats; do not parse mouse escapes yourself. Any "asked for, waiting" set (renders,
|
|
26
|
+
tooltips) must drop an entry when its answer comes, or a later identical request is
|
|
27
|
+
skipped forever (hover went dead after F6 cycled back to the first look). Textual's
|
|
28
|
+
`export_screenshot` sizes runs by code points, so Kitty placeholder cells (3 code
|
|
29
|
+
points, 1 cell) look stretched in the SVG: an export artifact, not a layout bug.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Notes
|
|
2
|
+
|
|
3
|
+
Plans and decisions behind ggtui. Each file has a status.
|
|
4
|
+
|
|
5
|
+
- [plans/workspace-app.md](plans/workspace-app.md): done. The plan of the workspace app
|
|
6
|
+
(W0 to W3) while it lived in ggrust's `prototype/terminal-graphics` branch.
|
|
7
|
+
- [plans/workspace-split.md](plans/workspace-split.md): live. How the workspace moved
|
|
8
|
+
out of ggrust into ggtui (stages 1 to 4), and the open idea of a plot-renderer hook
|
|
9
|
+
for matplotlib, plotnine and lets-plot.
|