How pi's BranchSummary navigates session-tree branches
A technical note examines pi's BranchSummary and the /tree command, explaining that they navigate to another node in a SessionTree while remaining in the same session file, rather than switching Git branches. The note says users can select most entries, including a point after a specific tool call, and choose no summary, a standard summary, or a summary with a custom prompt. It compares this behavior with Claude Code's /rewind, noting that /rewind is based on user-query checkpoints that can restore both conversation and code state. The note also traces how entries from the abandoned path are collected for summarization and how a BranchSummaryEntry is appended.
The analysis clarifies that BranchSummary is a session-context navigation mechanism for returning to earlier conversation states. It also distinguishes pi's entry-level selection and optional summarization from Claude Code's checkpoint-based approach, which can include code restoration.
看到 BranchSummary 或者pi中对应的命令 /tree,总让人联想到git worktree,或者在git上切换分支之后摘要的感觉。但是实际上和git没有一毛钱关系。
看了一眼方法签名, 好吧原来是在 SessionTree 上面切换node。
// =========================================================================
// Tree Navigation
// =========================================================================
/**
* Navigate to a different node in the session tree.
* Unlike fork() which creates a new session file, this stays in the same file.
*
* @param targetId The entry ID to navigate to
* @param options.summarize Whether user wants to summarize abandoned branch
* @param options.customInstructions Custom instructions for summarizer
* @param options.replaceInstructions If true, customInstructions replaces the default prompt
* @param options.label Label to attach to the branch summary entry
* @returns Result with editorText (if user message) and cancelled status
*/
async navigateTree(
targetId: string,
options: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string } = {},
): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }>