Skip to content

Commit 40bbb5a

Browse files
committed
pi: make /drop transparent to /fold so fold summarizes across drops
1 parent 84b9f08 commit 40bbb5a

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

dotfiles/pi/.pi/agent/extensions/drop.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
* using the last message as the branch summary instead of
77
* generating one with the LLM.
88
*
9-
* This is a fast, zero-cost alternative to /fold. Compatible with fold's
10-
* anchor system (uses the same "fold" label).
9+
* This is a fast, zero-cost alternative to /fold. Does not create a fold
10+
* marker, so the next /fold will reach back past the drop point and include
11+
* the drop's branch summary in its summarization.
1112
*
1213
* Usage:
1314
* /drop
@@ -94,7 +95,6 @@ export default function (pi: ExtensionAPI) {
9495
// Navigate tree back to anchor with the last message as summary
9596
const navResult = await ctx.navigateTree(anchorId, {
9697
summarize: true,
97-
label: "fold",
9898
});
9999

100100
if (navResult.cancelled) {

dotfiles/pi/.pi/agent/extensions/fold.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,23 @@ export default function (pi: ExtensionAPI) {
8888
// Gather messages after anchor for summarization
8989
const anchorIndex = branch.findIndex((e) => e.id === anchorId);
9090
const entriesAfterAnchor = branch.slice(anchorIndex + 1);
91-
const messages = entriesAfterAnchor
92-
.filter((entry): entry is SessionEntry & { type: "message" } => entry.type === "message")
93-
.map((entry) => entry.message);
91+
const messages: Parameters<typeof convertToLlm>[0] = [];
92+
for (const entry of entriesAfterAnchor) {
93+
if (entry.type === "message") {
94+
messages.push(entry.message);
95+
} else if (entry.type === "branch_summary") {
96+
// Include drop summaries (unlabeled) but skip fold summaries (labeled "fold")
97+
const label = ctx.sessionManager.getLabel(entry.id);
98+
if (label !== "fold") {
99+
messages.push({
100+
role: "branchSummary" as const,
101+
summary: entry.summary,
102+
fromId: entry.fromId,
103+
timestamp: Date.parse(entry.timestamp),
104+
});
105+
}
106+
}
107+
}
94108

95109
if (messages.length === 0) {
96110
ctx.ui.notify("No conversation to fold", "error");

0 commit comments

Comments
 (0)