Skip to content

refactor(tui): delete the code that the session-store removal left unused in pi-shell (plan decision 10) - #27

Merged
zy1233 merged 8 commits into
mainfrom
refactor/tui-session-store-leftovers
Oct 20, 2026
Merged

zy1233 merged 8 commits into
mainfrom
refactor/tui-session-store-leftovers

Conversation

@zy1233

@zy1233 zy1233 commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

Plan decision 10, follow-up. On 2026-10-19 the owner chose two items: delete the units that the call graph reports dead (dead_units), and do a small cleanup (small_cleanup). #26 (merged as 7d82c27) deleted the session store of pi-shell. It left code that nothing uses. This PR deletes that code:

  • 15 files that no code loads: 14 goal prompt templates and one research script. The last reference to them went away in Remove the Rust agent runtime from the TUI; keep /model via ACP config options #7.
  • The units session::worktree and session::helpers, which the call graph reports dead, and util::config::worktree, which only session::worktree used.
  • The [storage] setting (StorageConfig). It held cleanup_ttl_days, which cleaned the session files of the old Rust agent. No code reads it.
  • 10 dependencies of pi-shell that no source file names.

It also lowers three ceilings in scripts/tui_baseline.toml to the values that the gates measure.

Production behaviour does not change. One thing a user can see: a config.toml that still has a [storage] section loads as before, and the section is now reported as an unrecognized key (a warning, not an error).

Base: main (7d82c27). Not merged.

tui/crates/codegen/pi-shell/
├── src/session/templates/goal_*.md           DELETED   14 files, 449 lines
├── src/session/workflows/deep_research.rhai  DELETED   584 lines
├── src/session/helpers/                      DELETED   3 files (21 lines of code that is not a test)
├── src/session/worktree.rs                   DELETED   359 lines, 24 tests (Unix only)
├── src/util/config/worktree.rs               DELETED   62 lines: `WorktreeType`, `FromStr`, one `From`, 1 test
├── src/agent/config.rs                       `StorageConfig` and the `Config.storage` field deleted
├── src/agent/config_tests.rs                 + 1 test: a removed `[storage]` section is reported as unrecognized
└── Cargo.toml                                10 dependencies deleted
                                              (Cargo.lock: `tdigests`; THIRD-PARTY-NOTICES: 5 entries)
tui/: 28 files, +13 / -1,644 (20 files deleted, 8 changed)
.rs under tui/crates: 1,723 files, 1,007,882 lines  ->  1,718 files, 1,007,386 lines
pi-shell, code that is not a test: 31,653 -> 31,191 lines
pi-shell, units that the call graph reports dead: 9 (1,388 lines) -> 7 (1,008 lines)
pi-shell tests: 864 -> 838   (24 + 2 + 1 deleted, 1 new)
sum of `reference_passed`: 8,514 -> 8,488
packages in the dependency graph of `pi-pager-bin` (x86_64-unknown-linux-gnu): 980 -> 970
ceilings: `leader` 245 -> 243, `x.ai` 304 -> 297, graph 980 -> 970

Decision 10 has two more parts that this PR does not touch (the owner did not choose them): load_mcp_servers / util/config/mcp.rs, and pi-pager/src/recent_dirs.rs.

What each deletion rests on

  • The 15 files. For each template, a search of the whole tree at 7d82c27 for the file name without its extension finds nothing outside the template directory. Nothing in tui/ names deep_research. (The Python package pi-dynamic-workflows has a workflow with the same name. It builds its script in Python and does not read this file.) The last commit that changed how often these names appear is 455527c (Remove the Rust agent runtime from the TUI; keep /model via ACP config options #7). rustc cannot see a file that no include_str! names, so it gives no warning. This is a text search.
  • session::worktree and session::helpers. scripts/tui_callgraph.py units --crate pi-shell --live pi-pager-bin pi-pager-minimal pi-update reports them dead. rustc gives no warning: they hold pub(crate) items and one re-export. The two tests resolve_worktree_by_id_or_path_* in session::worktree are the two that showed the race in refactor(tui): delete the session store of pi-shell (plan decision 10) #26. They are gone. The cause of that race (a named serial key does not exclude the default key) is not fixed by this. See "Not verified". The 24 tests of the module tested items of pi_workspace::worktree through the re-export pub(crate) use pi_workspace::worktree::* (request and response types, build_candidate_list, BackgroundCopyGuard, resolve_worktree_by_id_or_path). Those items stay in pi-workspace. After this change, no file in tui/ names pi_workspace::worktree.
  • util::config::worktree. The first check run (on the commit that deletes the two units) gave one warning: an unused import of worktree::* in util/config/mod.rs. The only user of that module was session::worktree. The next commit deletes the module. After it, the warning count is 0.
  • [storage]. [storage] cleanup_ttl_days has no reader. The new test a_removed_storage_section_is_reported_as_unrecognized shows that a config with the section still loads and that the section is reported as an unrecognized key. I did not remove Config.storage_mode and the hidden --storage-mode flag: they are another setting.
  • The 10 dependencies. A text search of src/, tests/ and build.rs of pi-shell for each name, not counting // comments (the search of refactor(tui): delete the session store of pi-shell (plan decision 10) #26 counted comments, so it missed base64). The compiler checks each result: after the removal, check and cargo check --workspace --tests pass. On 7d82c27 the search finds 8 names (urlencoding, base64, pi-compaction-transcript, pi-workflow, tdigests, nix, pretty_assertions, pi-test-utils). After the two dead units go, 2 more (pi-fast-worktree, tokio-util) have no user. Ten packages leave the dependency graph: pi-workflow (a crate of this workspace) and nine registry packages (tdigests, rhai, rhai_codegen, smartstring, thin-vec, const-random, const-random-macro, crunchy, tiny-keccak).

Evidence

  • Before: 7d82c27 (main). TUI CI: 8,514 passed, 0 failed, 21 ignored; 980 packages in the graph; leader 243 of 245, x.ai 297 of 304.
    After: scripts/tui_baseline.py check (WSL2). First run on the commit that deletes the two units (5 m 03 s): 1 warning, the unused import above. Second run on the source of the dependency commit (3 m 27 s): passes. The consumer build has 0 warnings, --workspace --tests has 0 errors, the graph has 970 packages, leader is 243 and x.ai is 297, and the pager reads no session file. scripts/tui_notices.py check: 984 of 984. After the removal of the dependencies and before update --write, it reported 5 stale entries (rhai, rhai_codegen, smartstring, tdigests, thin-vec).
  • The whole manifest (scripts/tui_baseline.py test, WSL2, 23 m 56 s, incremental build) on the dependency commit 8b146e7: 8,487 passed, 1 known failure (the tmux probe of pi-pager-render, counted as passed by the manifest), 21 ignored. pi-shell 838, pi-pager 5,649, the other suites equal their reference_passed. The later commits change only the manifest and documents. The test count adds up: 864 - 24 (session::worktree, Unix only) - 2 (session::helpers) - 1 (util::config::worktree) + 1 (the new test) = 838.
  • Real zypi under a pseudo-terminal (mock model): resume_matrix.py --strict 16 PASS / 0 GAP / 0 FAIL, smoke.py 23/23, exit_matrix.py 12/12, print_exit.py, mode_probe.py, status_line_probe.py 4/4, net_audit.py --mock 13/13. The binary was built from the same source as 8b146e7. refactor(tui): delete the session store of pi-shell (plan decision 10) #26 did not run these again, because its production code did not change. This PR deletes modules and one config field, so they ran again.
  • Mutation check of the new test: I put StorageConfig and the Config.storage field back (the reverse of the config.rs part of 6118888) and ran a_removed_storage_section_is_reported_as_unrecognized. It fails (got: []: [storage] is a known section again, so nothing reports it). It passes on the clean tree. Only this one change was tried.
  • Python: full pytest (real_llm deselected) on 1a8abee, the same counts as before this PR (it adds no Python test): Windows 2,559 passed, 39 skipped, 31 deselected; Linux (WSL2, rg on PATH) 2,568 passed, 30 skipped, 31 deselected. ruff check . and ruff format --check . pass.
  • CI (on 6bd7db5, all green): CI (run 39193752450): Ruff, and pytest on Python 3.11, 3.12 and 3.13. TUI CI (run 39193752451): 8,488 passed, 0 failed, 21 ignored; 970 packages in the graph; leader 243, x.ai 297; 0 warnings. The numbers are the ones this PR expected. The runner has 4 vCPU and runs 4 test threads, so a green TUI CI says nothing about the races that show only at more threads (see "Not verified").
  • Not verified: Windows and macOS builds of zypi (the Rust and PTY runs are Linux only). Whether pi-workspace has its own tests for the cases that the 24 deleted session::worktree tests covered (they compiled on Unix only). Other places with the same pattern as the race of refactor(tui): delete the session store of pi-shell (plan decision 10) #26 (serial(GROK_HOME) in pi-pager; the named keys force_dark_wake_env, attribution_emit_count and heap_profile_hooks in pi-shell; tests that read GROK_HOME and have no serial at all) were not checked. A separate test-only PR will do that. Whether xai_grok_pager__*.snap files and the other files below are really unused is not verified.

Not in this PR (found, not deleted)

A text scan found more code and files that nothing seems to use. They are candidates for plan D.8. Nothing was deleted, and nothing was compiled without them.

  • 7 units that the call graph still reports dead (1,008 lines): auth::flow, config::reloader, session::events (591 lines; it has an impl for GoalClassifierVerdictTelemetry, so check it first), session::telemetry, session::unified_list, upload, upload::turn.
  • The crate pi-workflow: 9 files, 3,570 lines. tui/Cargo.toml lists it as a member. No Cargo.toml depends on it.
  • Config.storage_mode and the hidden --storage-mode flag: the flag goes into StorageMode::resolve, and no .rs file reads the result.
  • About 88 files that no code loads: pi-pager/tests/scenarios/ (43 files, 70,628 B), pi-pager/npm/ (24 files, 73,368 B; this is plan D.7), pi-pager/scripts/install-enterprise.ps1 (12,460 B), 9 of the 11 logo files (10,147 B), 11 snapshots with the old crate name xai_grok_pager__*.snap (2,737 B).

Merge Danger

Door: two-way

The change deletes code and files that nothing uses, one config field that nothing reads, and 10 dependencies that no source file names. A revert brings all of them back. No data and no wire format change.

Blast Radius: the tui/ tree of pi-shell, Cargo.lock, the baseline manifest; people who build on pi_shell

  • Code outside this repository that uses pi_shell::session::{worktree, helpers}, pi_shell::util::config::WorktreeType or the field Config.storage stops compiling. Nothing in this repository does: the consumer build and cargo check --workspace --tests pass with 0 warnings.
  • A config.toml with [storage] keeps loading. The section is reported as an unrecognized key at start. A user who set cleanup_ttl_days sees that warning and nothing else, because nothing read the value.
  • Cargo.lock loses one package (tdigests) and 10 dependency lines. THIRD-PARTY-NOTICES loses 5 entries. The other 9 registry packages stay in the lock file because pi-workflow is still a workspace member. The size of the release binary was not measured.
  • The ceilings in the manifest now equal the measured values (graph 970, leader 243, x.ai 297, pi-shell 838 tests). A later change that adds a package, a warning or a leader / x.ai line fails the gate at once. That is what the ratchet is for.
  • The 24 tests of session::worktree are gone (they ran on Unix only). The items they tested are still in pi-workspace. I did not compare these cases with the tests inside pi-workspace.
  • No other open PR is needed first: the base is main.

…pt that nothing loads

Nothing in the tree names these 15 files any more (git grep by file name: no hit).
The last code that loaded them was removed with the Rust agent runtime in
455527c (#7); the files stayed, and rustc cannot see a file that no `include_str!`
names, so no warning reported them.

pi-shell/src/session/templates/ (14 Markdown prompt templates for the goal
mode) and pi-shell/src/session/workflows/deep_research.rhai (584 lines).
15 files, 1,033 lines. No Rust code changes.
…elpers of pi-shell

The call graph (scripts/tui_callgraph.py units) reports both as dead: nothing in the
consumer build (pi-pager-bin, pi-pager-minimal, pi-update) reaches them. rustc does not
warn, because what they hold is `pub(crate)` or a re-export.

session::worktree (359 lines): a glob re-export of pi_workspace::worktree, two `From`
impls between the shell's WorktreeType and the workspace's (nothing calls them), and 24
tests of types and functions that live in pi-workspace (serde shapes, build_candidate_list,
BackgroundCopyContext, resolve_worktree_by_id_or_path).

session::helpers (3 files, 61 lines): comments, and two tests of string shapes.

The two `resolve_worktree_by_id_or_path` tests were the ones that opened worktrees.db in
whatever GROK_HOME held; they are gone with the unit. pi-shell tests: 864 -> 838.

pi_workspace::worktree has no user left in pi-shell after this; that is left for plan D.8.
`[storage] cleanup_ttl_days` set how long old session files were kept. The code that
read it went with the session store (#26), and the pager keeps no session file now.
`StorageConfig` and the `storage` field of `Config` are deleted.

A config file that still has the section loads. The section is reported as
unrecognized, like any other unknown section: a new test pins that, and the
"valid config" test no longer lists the section.

`storage_mode` (the `--storage-mode` flag and `Config.storage_mode`) is a different
setting. This change does not touch it.
`util::config::worktree` holds a `WorktreeType` enum (with `FromStr` and a `From` impl for
`CreationMode`). Its one user was `session::worktree`, which the previous commit deletes. The
baseline `check` shows it: the glob re-export of the module is an unused import (1 warning;
the ceiling is 0).

`pi-workspace` and `pi-workspace-types` have their own `WorktreeType` and do not use this
one. The module has one test, `test_worktree_type_fromstr`; it goes with it. `pi-shell` has
no other reference to `pi_fast_worktree` now, so that dependency goes in the next commit.
…e names

Ten dependencies of `pi-shell` are not named in any source file of the crate outside comments
(a text scan of `src/`, `tests/` and `build.rs`; the compiler has the last word):

- `[dependencies]`: `urlencoding`, `base64`, `pi-fast-worktree`, `pi-compaction-transcript`,
  `pi-workflow`, `tdigests`, and `nix` (unix only).
- `[dev-dependencies]`: `pretty_assertions`, `pi-test-utils`, `tokio-util`.

Eight lost their last user in #26 (the session store). `pi-fast-worktree` lost its last users in
`session::worktree` and `util::config::worktree` (this branch), and `tokio-util` in the tests of
`session::worktree`.

The dependency graph of `pi-pager-bin` goes from 980 to 970 packages on Linux: `pi-workflow` (a
crate of this workspace; no other crate depends on it now) and nine packages from the registry
(`tdigests`, `rhai`, `rhai_codegen`, `smartstring`, `thin-vec`, `const-random`,
`const-random-macro`, `crunchy`, `tiny-keccak`). `Cargo.lock` loses `tdigests` and ten
dependency lines. The other packages stay in the lock file, because `pi-workflow` is still a
member of the workspace. `THIRD-PARTY-NOTICES` loses 5 entries (it lists the packages that ship on
any platform; `tui_notices.py check`: 984 of 984).
…i-shell

- `[gates.residue]`: `leader` 245 -> 243 and `x.ai` 304 -> 297. The deletions of #26 removed
  those lines; `check` has said "lower the ceiling" since then.
- `[graph.max_nodes]`: 980 -> 970 packages on Linux (the dependency commit of this branch).
- `pi-shell` `reference_passed`: 864 -> 838. The tests of `session::worktree` (24, Unix only),
  `session::helpers` (2) and `util::config::worktree` (1) are gone, and one test is new (a
  `[storage]` section is reported as unrecognized). The ten references add up to 8,488 (8,514
  before).

A local run on Linux (WSL2) gives: `check` with 0 warnings, 970 packages, `leader` 243 and `x.ai`
297; the ten test suites 8,487 passed and 1 failed (the known `tmux_probe` test of
`pi-pager-render`); `tui_notices.py check` 984 of 984.
… store left in pi-shell)

- CHANGELOG.md: the entry for the third cleanup of pi-shell (15 files, three modules, the
  [storage] setting, 10 dependencies). It also says that the earlier entry left
  `[storage] cleanup_ttl_days` for this one.
- docs/baselines/tui.md: current baseline r16 (tests 8,488, graph 970, `leader` 243, `x.ai` 297)
  and a column r16 in the table of sizes. The numbers are from local runs (WSL2); the CI numbers
  of PR #27 follow in a later commit.
- docs/baselines/archive/tui-history.md: the r16 paragraph, with the CI numbers of `7d82c27`.
- docs/baselines/tui-support.md: made again (`pi-shell` has 7 dead units, 1,008 lines, not 9 and
  1,388).
- Plan: status r16, next steps, decision 10, D.2, D.8 (new candidates: 7 dead units, the crate
  `pi-workflow`, `Config.storage_mode`, about 88 files that no code loads), D.9, a new open item
  "races between tests", the index and the revision list.
- Execution log: section 10.19, B.11 (how to repeat the checks) and the r16 revision entry.
…lines

`CI` (run 39193752450) and `TUI CI` (run 39193752451) pass on 6bd7db5.
`TUI CI`: 8,488 passed, 0 failed, 21 ignored; 970 packages in the graph;
`leader` 243, `x.ai` 297; 0 warnings. These are the numbers that section
10.19 of the execution log expected, so only the "to be added" line and
the timing bullet change, plus one sentence in each r16 entry.

The cargo test job took 17 m 34 s and the gates job 4 m 24 s. The tests
themselves took about 54 s of that time.
@zy1233
zy1233 added this pull request to stack #32 October 20, 2026 06:16
@zy1233
zy1233 merged commit 7542062 into main Oct 20, 2026
7 checks passed
@zy1233
zy1233 deleted the refactor/tui-session-store-leftovers branch October 20, 2026 06:19
zy1233 added a commit that referenced this pull request Oct 25, 2026
…to #31 (plan r19) (#33)

The owner asked for three things: merge the five open PRs (#27 to #31) into main with
`gh stack`, set the V0.6 milestone from the present state, and pause development for
1 to 2 days.

The merge is done (stack #32, `gh stack merge 32 --yes --squash`). main goes from
7d82c27 to b33017a with five squash commits. The tree of each commit is the tree of its
PR head. CI and TUI CI pass on b33017a (8,490 passed, 0 failed, 22 skipped).

The plan gets a new section "发布里程碑 V0.6": the scope (the 10 commits on main after
v0.5.0), six exit conditions with their state, the known issues (two are new), and what
is not in V0.6. It also gets the r19 status, the pause, and the fixed status of the
places that still said "waiting for merge" for #25 to #28. The execution log gets
section 10.22: the install of `gh stack` (the first download was cut short), the merge,
the check of the trees, CI on main, the milestone, the pause, and what is not verified.

The GitHub milestone v0.6.0 (#2) is created. It has no due date and no PRs, as v0.5.0.
No condition is met yet. Only documents change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant