@dyyz1993/pi-coding-agent 0.74.36 → 0.74.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2528,18 +2528,20 @@ export class AgentSession {
2528
2528
  // Non-user message: leaf = selected node
2529
2529
  newLeafId = targetId;
2530
2530
  }
2531
- // Safety guard: reject navigation that would eliminate ALL user messages.
2532
- // The new leaf path is root → ... → newLeafId (or null for root reset).
2533
- // If a summary is provided, it will be a child of newLeafId, so the effective
2534
- // leaf path includes newLeafId's ancestors. Check both cases.
2535
- const effectiveLeafId = summaryText ? newLeafId : newLeafId;
2536
- const userMsgCount = this.sessionManager.countUserMessagesOnPath(effectiveLeafId);
2537
- if (userMsgCount === 0) {
2538
- return {
2539
- cancelled: true,
2540
- editorText: undefined,
2541
- reason: `Navigation to "${targetId}" would remove all user messages from the active path. This likely means the target is before the first user message. Use file-level rollback (snapshot.rollback) instead.`,
2542
- };
2531
+ // Safety guard: reject navigation that would eliminate ALL user messages
2532
+ // ONLY when file rollback is involved (skipFiles !== true).
2533
+ // When skipFiles=true (message-only rollback), going back to empty is valid
2534
+ // the user wants to undo their mistaken message.
2535
+ if (options.skipFiles !== true) {
2536
+ const effectiveLeafId = summaryText ? newLeafId : newLeafId;
2537
+ const userMsgCount = this.sessionManager.countUserMessagesOnPath(effectiveLeafId);
2538
+ if (userMsgCount === 0) {
2539
+ return {
2540
+ cancelled: true,
2541
+ editorText: undefined,
2542
+ reason: `Navigation to "${targetId}" would remove all user messages and restore files to their pre-session state. Use message-only rollback (skipFiles: true) to undo without file changes.`,
2543
+ };
2544
+ }
2543
2545
  }
2544
2546
  // Switch leaf (with or without summary)
2545
2547
  // Summary is attached at the navigation target position (newLeafId), not the old branch