You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 9600cdf
Browse filesBrowse the repository at this point in the historyBrowse files
refactor(tui): delete the disk-reading session code (ADR1 PR 3)
The pager no longer reads session files. The last change (PR 2) resolves
--continue, --resume and --session-id through the agent, so the old readers
have no caller left. This change deletes them and adds a gate that keeps them
out.
Deleted, in the production code of pi-pager and pi-pager-bin:
- session_startup.rs: materialize_startup and its helpers (the latest session,
the id, the title and the session-id checks on disk, and the remote-restore
branch).
- cli.rs and pi-pager-bin main.rs: the pin of the resume target and the saved
sandbox profile. A resumed session takes the sandbox as a new session does
(plan decision 2).
- session_title_resolve.rs: the match against the old summaries.
select_by_title stays.
- effects/helpers.rs, effects/mod.rs, dispatch/session/load.rs: the first-prompt
reader (chat_history.jsonl) and the local-session checks before a load.
- agent_view/plan.rs: the plan.md read of the plan preview (plan decision 7).
- line_viewer.rs open_markdown(path) and test_util.rs GrokHomeFixture: no caller
is left.
Added:
- gates.session_disk_reads (scripts/tui_baseline.py and .toml): production code
of both crates must not call the readers of the session store or name the
sessions directory. The scanner finds 18 hits on main, 17 after PR 2, and 0
here. It runs in `gates`, in `check` and in pytest.
- 6 pytest cases for the gate.
27 tests go with the deleted code (26 passed, 1 ignored): pi-pager 5,675 ->
5,649. The embedded user guide (17-sessions.md) and CHANGELOG.md say what
changed for the user.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
10
10
### Changed
11
11
12
12
- **`zypi --continue`, `--resume` and `--session-id` ask the agent which session is meant (TUI)**: `zypi` used to look for the session in the session files of the old Rust agent. The Python agent writes another layout, so `--resume <title>` found no session, an unknown id failed only after the UI had started, a used `--session-id` left the UI open with `Session creation failed: Invalid params`, and `--continue` took the session that was created last (the first of the **Known issues** of 0.5.0). Now `zypi` starts the agent first and then asks it over ACP, with `session/list` (page after page) and `session/load`. It reads no session file for this. A session that does not exist ends the run before the event loop starts: the terminal is restored, the agent is stopped, the message is printed, and the exit status is 1. **Behaviour changes**: `--continue` and `--resume` without a value take the session of this directory with the latest activity (the time of its last write), not the one that was created last. `--resume <id>` finds the id in every directory and loads the session in the directory it belongs to. `--resume <title>` matches the title, which is the first message of the session, among the sessions of this directory, without regard to letter case and to spaces at the ends; two sessions with the same title are an error that lists their ids and last activity. `--session-id <id>` reads every page of the session list and refuses an id that any session has (`Session ID <id> is already in use.`, exit status 1); that costs one pass through the list (`scripts/session_list_bench.py` prints it as `walk all`), and an agent that offers no `session/list` skips the check and refuses a used id itself. The lookup stops after 30 s, the limit of the connect (`GROK_CONNECT_UI_TIMEOUT_SECS`). **Not solved**: the agent writes the file of a session when the session is created, so a run in which nobody typed a message leaves a session with the title `(no messages)`, and `--continue` takes it when it is the latest. The fix is in the Python agent (write the file at the first message). Tests: 25 unit tests of the lookup against a scripted agent, 4 of the time limit and of a cancel, 3 end-to-end tests against the real agent, and `scripts/tui_pty/resume_matrix.py --strict` (13 of 13 pass; cases 5 and 11 were known gaps, and case 8 now needs exit status 1).
13
+
-**A resumed session no longer takes the sandbox profile it was created with (TUI)**: the old Rust agent saved the sandbox profile in the files of a session. `zypi --continue` and `--resume` read it back before the sandbox was applied, so a resumed session kept its sandbox, and `--sandbox X` on a session that was saved with `Y` was refused (`cannot resume this session under sandbox profile ...`). The Python agent never saved a profile, so for its sessions nothing changes. The profile now comes from `--sandbox`, from `GROK_SANDBOX` and from the configuration, as it does for a new session. The code that read it is gone (decision 2 of the plan).
14
+
15
+
### Removed
16
+
17
+
-**The code in the TUI that read session files**: `materialize_startup` and its helpers, the pin of `--resume <title>` before the sandbox (`pin_local_resume_target`), the saved sandbox profile (`SandboxStartup`, `saved_resume_profile`), the check that a `--session-id` is free before `session/new`, the first-prompt fallback of the resume picker (it read `chat_history.jsonl`), the check of the session files in the picker's load, and the read of `<home>/sessions/.../plan.md` for the plan preview. `scripts/tui_baseline.py gates` has a new gate (`gates.session_disk_reads`): it fails when production code in `pi-pager` or `pi-pager-bin` calls the readers of the session store again.
Copy file name to clipboardExpand all lines: tui/crates/codegen/pi-pager/docs/user-guide/17-sessions.md
+11-4Lines changed: 11 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,16 +14,23 @@ To see how much disk space the home directory uses, run `zypi du`.
14
14
| --- | --- |
15
15
| Start a new session | Run `/new` (alias `/clear`), or press `Ctrl+N` twice. |
16
16
| Open the list of past sessions | Run `/resume`, or press `F3`. |
17
-
| Continue the latest session of the current directory | Run `zypi -c`. |
18
-
| Continue the latest session | Run `zypi --resume`. |
17
+
| Continue the latest session of the current directory | Run `zypi -c` or `zypi --resume`. |
19
18
| Continue a session by id or by title | Run `zypi --resume <id-or-title>`. |
20
19
| Start a new session with an id that you choose | Run `zypi --session-id <uuid>`. |
21
20
22
21
The list of sessions shows the newest session first. The title of a session is its first message.
23
22
24
-
A title that you give to `--resume` matches the titles of the sessions of the current directory. The letter case does not matter. If more than one session has the same title, `zypi`can stop with an error. A value in the form of a UUID is always an id.
23
+
When `zypi` starts, it asks the agent for the list of sessions. It does not read the session files. If the session that you name does not exist, `zypi`prints a message and stops with exit status 1. The terminal UI does not start.
25
24
26
-
A session id that you choose with `--session-id` must be a UUID. The id must not exist already. Do not use `--session-id` together with `--resume` or `-c`.
25
+
The latest session is the session with the latest activity. This is the session that the agent wrote to last. It is not always the session that you created last.
26
+
27
+
An id that you give to `--resume` is found in every directory. The agent loads the session in the directory where the session started.
28
+
29
+
A title that you give to `--resume` matches the titles of the sessions of the current directory. The letter case does not matter. Spaces at the two ends of the title do not matter. If two sessions have the same title, `zypi` stops with an error. The error lists the ids and the time of the last activity of these sessions. Use `--resume <id>` then. A value in the form of a UUID is always an id.
30
+
31
+
A session id that you choose with `--session-id` must be a UUID. No session in any directory can have this id. To check this, `zypi` reads the whole list of sessions. If a session has the id, `zypi` prints `Session ID <id> is already in use.` and stops with exit status 1. Do not use `--session-id` together with `--resume` or `-c`.
32
+
33
+
The agent writes the file of a session when the session starts. A session in which you typed nothing has the title `(no messages)`. `zypi -c` takes such a session when it is the latest one.
0 commit comments