Repository navigation
feat(chats): carry the Pi journal into forks - #344
Conversation
A fork now reuses the source's model-side journal up to the cut, so tool results and compaction checkpoints before the forked message survive. The prefix runs through the commits that close the last copied reply's transactions and is imported into an empty journal as one path. Copied messages get fresh markers under their new ids so the next sync does not duplicate them. Without a provable boundary nothing is created and the fork rebuilds context from visible history as before. A journal error never fails the fork, and a failed chat install removes the target journal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Important
Forking an earlier inherited reply in an already-forked chat silently discards the richer journal context. The copied markers need to retain their original cut boundaries.
Reviewed changes: Reviewed the journal carryover implementation, desktop copy integration, persistence adapter, and focused behavioral coverage.
- Journal boundary selection: Reuses the active source prefix through a copied message and its closing transaction commits, with visible-history fallback when no boundary is provable.
- Import and installation: Imports a branch into a private target journal, pairs copied message identities, and cleans up dependent journals on failed installation.
- Behavioral coverage: Adds direct-fork, reopen, synchronization, fallback, and import-guard tests, registered in the compaction suite and CI registry.
Validation passed: npm run test:compaction (405 tests), the focused copy/journal/adapter tests (13 tests), npm run test:ci-policy (55 tests), and npm run type-check. A separate repeated-fork reproduction confirmed the inline finding.
gpt-6.1-sol | 𝕏
very-hermes-bot
left a comment
There was a problem hiding this comment.
Inline review — 1 finding(s) anchored to the diff. See the pinned summary comment for the overview.
| await session.importBranch(prefix); | ||
| await appendPiTransaction(session, async () => { | ||
| for (const message of input.messages) { | ||
| if (!synchronized.has(message.sourceId)) continue; | ||
| await session.appendCustomEntry(AIDEN_CHAT_MESSAGE_MARKER, { | ||
| chatMessageId: message.id, | ||
| } satisfies ChatMessageMarker); | ||
| } | ||
| }); |
There was a problem hiding this comment.
[P1 · logic] Trailing marker batch breaks journal preservation for subsequent forks from earlier turns
Confidence: 0.95
In forkChat, appending fresh message markers in a trailing transaction at the tip causes piJournalForkPrefix to return undefined on any subsequent fork from an intermediate message because non-commit markers separate the target marker from the transaction boundary.
Repair: Remap AIDEN_CHAT_MESSAGE_MARKER entries in place within prefix using input.messages before calling session.importBranch, and eliminate the trailing appendPiTransaction block.
There was a problem hiding this comment.
Fixed in 432c374: copied markers are now renamed in place inside the imported prefix, so each inherited reply keeps its original transaction boundary; the trailing marker transaction is gone. pi-journal-fork.test.ts adds a fork-of-a-fork at an earlier inherited reply after reopening the store, checks it against the same cut taken in the original chat, and checks the next sync appends only the new prompt.
Hermes Review BotConfidence: 5 Engine: SummaryCarries over the model-side Pi journal (including tool results and compaction checkpoints) up to the selected fork cut point when copying or forking a workspace chat. During Confidence Score: 5/5Fully traced and verified across 📁 Important Files Changed
FindingsNo findings. Sequence DiagramsequenceDiagram
autonumber
participant Client as Renderer / IPC
participant Handler as ChatsHandler
participant ChatStore as ChatStore
participant PiStore as PiCompactionSessionStore
participant Session as PiSessionPort
Client->>Handler: chats:copyVisibleHistory(forkAt)
Handler->>ChatStore: copyVisibleHistory(forkAt, beforeInstall)
ChatStore->>Handler: beforeInstall(copiedChat, sourceMessageIds)
Handler->>PiStore: forkChat(sourceId, targetId, messages)
PiStore->>Session: openChatIfEligible(sourceId)
PiStore->>PiStore: piJournalForkPrefix(branch, messages)
PiStore->>Session: repo.create(targetId)
PiStore->>Session: importBranch(remappedPrefix)
PiStore-->>Handler: true (journalForked)
ChatStore->>ChatStore: installNewChat(copiedChat)
ChatStore-->>Handler: copiedChat
Handler-->>Client: chatForRenderer(copiedChat)
[]
|
A fork appended every copied message marker in one trailing transaction, so an inherited reply's marker was followed by another marker before any commit. piJournalForkPrefix then refused that boundary, and forking a fork at an earlier inherited reply (or editing an earlier inherited prompt in a fork) silently fell back to visible history and lost pre-cut tool results and compaction context. Rename each copied marker in place inside the imported prefix instead, so every inherited reply keeps the transaction boundary it had in the source. The new test forks a fork at an earlier reply after reopening the store, compares it with the same cut taken in the original chat, and checks the next sync appends only the new prompt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes: Reviewed the marker-boundary fix and nested-fork regression coverage added since the previous Pullfrog review.
- Preserved inherited cuts: Remapped copied message IDs in their original journal marker entries instead of appending aliases at the tail, keeping earlier inherited replies forkable without altering transaction boundaries.
- Added nested-fork coverage: Exercised an earlier inherited cut after reopening the store, compared its context with the corresponding direct fork and exact expected messages, and verified that the next synchronization appends only the new prompt.
Validation passed at 432c3744: focused journal/copy/adapter tests (14), npm run test:compaction (406), npm run test:ci-policy (55), and npm run type-check.
gpt-6.1-sol | 𝕏

Summary
Stacked on #343 (PR 2 of
docs/plans/chat-fork-plan.md).PiSessionPort.importBranchwrites that one root-to-tip path into an empty journal. Pi's own fork doesn't fit: the branch scope needs an AgentLane, and the tree scope copies data from after the cut.chat-degradeddiagnostic and never fails the fork. A failed chat install removes the target journal unless the error requires reconciliation.Tests
main/services/pi-journal-fork.test.ts, registered intest:compactionand the CI registry. It covers:importBranchguards.chat-session-copy.test.tsnow checks the source-to-copy id pairing thatbeforeInstallreceives.type-check, eslint,test:compaction(405),test:ci-policy, and the chat copy suites.🤖 Generated with Claude Code