pi-mono/packages/coding-agent/test/session-manager
Julien Barbay 2b768ba42c
feat(coding-agent): ingest external entries in in-memory sessions (#8980)
* feat(coding-agent): ingest external entries in in-memory sessions

SessionManager.inMemory() takes the entries to start from, so a session
held outside the filesystem can be resumed as it was stored.

Replaying through appendMessage/appendCompaction cannot do this: ids are
minted fresh, so every stored firstKeptEntryId, targetId and fromId has to
be remapped, timestamps are rewritten, and parentId always comes from the
current leaf, so a branched tree needs the original branch() choreography
reproduced call by call.

The entry-adoption half of _setSessionFile becomes _loadEntries, which the
constructor also uses when there are entries but no file. Entries carrying
a session header keep it; without one, the header comes from the options
and the entries become its body.

* fix(coding-agent): carry the stored version through restored entries

inMemory() took SessionEntry[], which excludes SessionHeader, so an
external store could not pass the header it saved and the header branch of
_loadEntries was unreachable through the public API. A restore therefore
always synthesised a current-version header, and the migration that ran
next read that header and skipped: a v2 session kept its hookMessage roles
forever.

Widening to FileEntry[] lets the stored header through, version included.
Migration moves inside the header branch, where a version exists to compare
against; without a header the entries are adopted as current-version, which
is the only thing they can mean.
2026-09-03 10:49:41 +02:00
..
build-context.test.ts fix(coding-agent): add entry renderers for session entries 2026-07-01 11:30:26 +02:00
custom-session-id.test.ts fix(coding-agent): allow session id for no-session runs 2026-06-25 14:44:44 +02:00
file-operations.test.ts fix(coding-agent): repair unterminated session files 2026-08-26 12:07:30 +02:00
labels.test.ts fix(coding-agent): rechain fork paths without labels 2026-06-12 18:50:31 +02:00
load-entries.test.ts feat(coding-agent): ingest external entries in in-memory sessions (#8980) 2026-09-03 10:49:41 +02:00
migration.test.ts chore: pin dependencies and use native TypeScript 2026-05-20 12:46:17 +02:00
save-entry.test.ts chore: pin dependencies and use native TypeScript 2026-05-20 12:46:17 +02:00
tree-traversal.test.ts fix(coding-agent): preserve branch summary source leaf 2026-08-19 12:02:37 +02:00