mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
When writing a session entry failed (ENOSPC, EBUSY, ETIMEDOUT on network drives), `SessionManager._appendEntry` had already added the entry to memory and made it the current leaf. The process kept running, and the next entry written to disk pointed to a parent that was not in the file. On resume, pi follows the history only back to that gap: everything before it disappears. In #11460 that also dropped the first system message, which declares the tools, so resume turned off every built-in tool. `_appendEntry` now undoes the in-memory append if writing fails, then rethrows. The error reaches the caller as before; later entries chain to the last entry actually on disk. Reports of this problem: - #11460: ENOSPC; resume dropped all built-in tools. - #10166: failure injected with EBUSY; the next entry on disk points to a missing parent. - #10661: ETIMEDOUT on Windows + NFS; resumed sessions showed only the last few messages. That report also describes NUL holes in the file, which this change does not address. **Testing** - Two tests in `test/session-manager/file-operations.test.ts` make writes fail with real file permissions: a read-only session file (failed append) and a read-only session directory (failed first file creation). They check that the entry is not kept, the leaf is unchanged, the next entry chains to the last written one, and the reopened session's branch contains both entries. Both fail without the change and pass with it. - `test/session-manager/` and `test/default-tools-setting.test.ts` pass (140 tests). - `npm run check` passes. Fixes #11460 Requested by @davidbrai Co-authored-by: triagent <triagent@localhost> |
||
|---|---|---|
| .. | ||
| bun | ||
| cli | ||
| core | ||
| experimental | ||
| extensions | ||
| modes | ||
| utils | ||
| cli.ts | ||
| config.ts | ||
| index.ts | ||
| main.ts | ||
| migrations.ts | ||
| package-manager-cli.ts | ||
| rpc-entry.ts | ||