Repository navigation
Commit 9058ab3
authored
feat(tui): the status row is drawn from what the client knows (#19)
## Summary
`[ui.status_line]` drew nothing with the Python agent. The row waited for a `session_status` message that only the old Rust agent sent. Now `zypi` builds the row from what it already knows. There is no change on the wire and no change in Python. This is plan decision 15, option (b). Option (a), a new message from the Python agent, was chosen first and did not pass the review below.
```text
shell_status_context()
start from the status the agent sent # it wins; empty if none
fill the empty fields from ClientOwnedFields:
cwd, session id, model id and name, version
session name: always the client's, because a rename happens here
fill_from_clocks:
cost.total_duration_ms = time since the session was attached
turn.started_at_ms = start of the running turn
left empty: context, the rest of cost, branch, repo # nobody on this side can know them
```
```diff
the row is built again when
the source agent changes
+ cwd, session id, session name, model, or "a turn runs" changes # ClientOwnedFields
a forced or due refresh arrives
```
The flag "a turn runs" is the reason for the last line. A command row runs on every tick of a turn and on no tick after it. Without the flag, the last run would keep the turn in its payload, and a timer would stay on a built-in row after the turn.
**Why not option (a).** DESIGN section 8.5 lists five points for a `pi/` extension; one failed point is enough to refuse it. Two failed: (1) what the Python agent could truthfully send is known to `zypi` already, or has a standard place in ACP (`agentInfo.version`, `usage_update`); the agent itself knows neither the context window nor a price. (4) The message type would live in `pi-shell`, an old runtime crate. The user then chose (b).
## Evidence
- **Before:** `status_line_probe.py` (r11, plan section 10.14): 4 runs, the row was not drawn with the Python agent and a command script did not run.
**After:** 4/4 runs pass on a real debug `zypi` (WSL2, 23 s). Without a status from the agent: the row is on the screen; a script runs and gets session id, cwd, model, version, `workspace.current_dir`; `context_window` is an empty object and `cost` has only `total_duration_ms` (no `used_percentage`, `context_tokens`, `context_window_size`, `total_cost_usd`). With a status from the agent (the stand-in `status_proxy_agent.py`): the row shows what the agent sent.
- **Tests:** 16 new unit tests: 9 in `status_line_tests.rs` (what `zypi` fills in, what an agent status keeps, the two clocks) and 7 in `dispatch/tests/status_line.rs` (when the row is built again, what a script is given). 2 tests rewritten (they said the row waits for the agent). 1 adjusted: `only_a_row_that_can_change_mid_turn_holds_the_loop_awake_for_one`. The start of a turn now makes the row stale once, on purpose; the old test looked for ticks right after the turn start and failed. It now lets that one rebuild happen first. A built-in row still asks for no tick; a command row still asks for one.
- **Checks that ran locally** (WSL2, debug build; on the code of the final commit, the last edits are documentation only): the `pi-pager` suite of the manifest (`--lib`, `settings_e2e`, `grok_home_paths`, `selection_model_public_api`, `python_agent_e2e`, with the manifest environment): 5,624 passed, 0 failed, 13 ignored (the reference is 5,608; the 16 new tests are the difference). `tui_baseline.py check` exit 0: warnings 0, residue words unchanged, graph 980 = ceiling, `cargo check --workspace --tests` 0 errors. `ruff check` and `ruff format --check` pass. `pytest`: Windows 2,519 passed, 39 skipped, 31 deselected; WSL 2,542 passed, 16 skipped, 31 deselected.
- **A failure that this change did not cause:** my first run of the suite had 1 failure, `pin_ambiguous_title_errors_before_sandbox`. `main` and #18 fail the same way on my machine when the whole `--lib` suite runs, and the test passes alone. The cause is a leftover directory in my real `~/.pi-python/sessions`, from an earlier run that did not finish. The test uses fixed session ids. In a whole-suite run, another test pins `grok_home()` to the real home first, so the test writes there. An id that exists in two directories cannot be found by title (`duplicate_legacy_id_is_not_title_addressable` tests this), so the call returns `Ok` where the test wants an error. With an empty `HOME` the whole `--lib` suite passes (5,340 passed, 0 failed); with only `sessions/` copied in, it fails; with only `config.toml` and `trusted_folders.toml` copied in, it passes. After I removed the directory, the suite passed (above). CI runners are clean, so CI does not see it. I did not change the fixture.
- **CI** (on `bfd5425`: [TUI CI run](https://github.com/zy1233/pi-python/actions/runs/38348219064), [CI run](https://github.com/zy1233/pi-python/actions/runs/38348219013)): every job passes. `Ruff`. `pytest` 3.11, 3.12 and 3.13. `Gates + cargo check`: warnings 0, `leader` 245 of 245, `x.ai` 304 of 304, graph 980 of 980. `cargo test`: 8,681 passed, 0 failed, 22 ignored (`pi-pager`: 5,624 passed, 13 ignored, the same as my rerun). `Release build baseline` is manual and was skipped.
- **CI after merging `main`** (on `1fa18cf`, where #18 is merged into this branch; [TUI CI run 38353039701](https://github.com/zy1233/pi-python/actions/runs/38353039701), [CI run 38353039688](https://github.com/zy1233/pi-python/actions/runs/38353039688)): every job passes. `Gates + cargo check`: warnings 0, `leader` 245 of 245, `x.ai` 304 of 304, graph 980 of 980. `cargo test`: 8,700 passed, 0 failed, 22 ignored (`pi-pager`: 5,643 passed, 13 ignored). That is the base of 8,665 plus the 19 tests of #18 and the 16 tests of this PR.
- **Not verified:** Windows and macOS (the probe runs on Linux only). A real model (the agent is a mock; the data in the row does not depend on the model). A real agent that sends `session_status` (only the stand-in does).
## Merge Danger
**Door:** two-way
No data format, no wire message and no Python code changes. A revert brings back the old state: no row with the Python agent.
**Blast Radius:** status row
Only a user who sets `[ui.status_line]` sees a difference. The row now appears where it did not. `context` and `cost` items stay empty with the Python agent; the guide page says so. The row is built once more at the start of a turn and once more at its end: one more build for a built-in row, one more run of the script for a command row. The agent status still wins when an agent sends one.
Merged on the owner's order, after #18, into V0.5 (`v0.5.0`). #18 and this PR changed the same documentation lines (`CHANGELOG.md`, the plan, the execution log), so the branch has one merge of `main` (`1fa18cf`); the code did not conflict. A documentation PR that follows moves both CHANGELOG entries from `[Unreleased]` to `[0.5.0]` and narrows the `[ui.status_line]` known issue (the `context` and `cost` items stay empty). `tui/` changed, so the release build and the binary size are checked again on this tree (release dry run [run 38353038777](https://github.com/zy1233/pi-python/actions/runs/38353038777), `release_baseline` [run 38353042677](https://github.com/zy1233/pi-python/actions/runs/38353042677); both started on `1fa18cf`).1 parent ec7d455 commit 9058ab3
14 files changed
Lines changed: 747 additions & 97 deletions
File tree
- docs
- PLAN
- archive
- baselines
- scripts
- tests
- tui_pty
- tui/crates/codegen/pi-pager
- docs/user-guide
- src/app
- agent_view
- dispatch/tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| |||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
| 116 | + | |
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
702 | 702 | | |
703 | 703 | | |
704 | 704 | | |
705 | | - | |
| 705 | + | |
706 | 706 | | |
707 | 707 | | |
708 | 708 | | |
709 | 709 | | |
710 | 710 | | |
711 | 711 | | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
712 | 717 | | |
713 | 718 | | |
714 | 719 | | |
| |||
724 | 729 | | |
725 | 730 | | |
726 | 731 | | |
727 | | - | |
728 | | - | |
729 | | - | |
730 | | - | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
731 | 737 | | |
732 | 738 | | |
733 | 739 | | |
734 | 740 | | |
735 | 741 | | |
736 | 742 | | |
737 | 743 | | |
738 | | - | |
| 744 | + | |
739 | 745 | | |
740 | 746 | | |
741 | 747 | | |
742 | | - | |
743 | | - | |
744 | | - | |
745 | | - | |
746 | | - | |
747 | | - | |
748 | | - | |
749 | | - | |
750 | | - | |
751 | | - | |
752 | | - | |
753 | | - | |
754 | | - | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
755 | 759 | | |
756 | 760 | | |
757 | 761 | | |
758 | 762 | | |
759 | 763 | | |
760 | 764 | | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
761 | 809 | | |
762 | 810 | | |
763 | 811 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
0 commit comments