Branch conversations when editing earlier TUI prompts (#33201)

## What changed

- Fork the conversation immediately before the selected prompt instead of rolling back the current thread in place, preserving the original conversation.
- Reopen the selected prompt in the new conversation with its images, text elements, and mention bindings intact.
- Start a fresh conversation when editing the first prompt, show a dedicated continuation notice, and restore the prompt with an error if branching fails.

## Testing

- Cover branching before first and later prompts, source preservation, prompt restoration, hidden review prompts, mid-turn steering, in-progress turns, stale transcript entries, and mention bindings.

GitOrigin-RevId: 15473535b3f9733b0300711a498969e6d389db79
This commit is contained in:
Felipe Coury authored and copyberry committed 2026-07-15 01:36:44 +00:00
1 parent 72b41c55fb
commit 469ce0db51
17 files changed
+928 -549

No files matched your search

+7 -9
View File
@@ -240,6 +240,13 @@ pub(crate) enum AppEvent {
/// Fork the current session into a new thread.
ForkCurrentSession,
/// Branch before a selected prompt and reopen it in the new thread's composer.
ForkSessionForPromptEdit {
thread_id: ThreadId,
nth_user_message: usize,
prompt: UserMessage,
},
/// Request to exit the application.
///
/// Use `ShutdownFirst` for user-initiated quits so core cleanup runs and the
@@ -691,15 +698,6 @@ pub(crate) enum AppEvent {
/// finalization.
ConsolidateProposedPlan(String),
/// Apply rollback semantics to local transcript cells.
///
/// This is emitted when rollback was not initiated by the current
/// backtrack flow so trimming occurs in AppEvent queue order relative to
/// inserted history cells.
ApplyThreadRollback {
num_turns: u32,
},
StartCommitAnimation,
StopCommitAnimation,
CommitTick,