feat(tui): edit previous prompts using session forks#30504
Open
fcoury-oai wants to merge 3 commits into
Open
Conversation
1f009c6 to
569223e
Compare
167838e to
5c52903
Compare
This was referenced Jul 9, 2026
|
Fixes: #31902 |
This was referenced Jul 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Editing an earlier prompt should branch the conversation, not rewrite the thread being viewed. The TUI currently implements this with
thread/rollback, which destructively removes turns from the source thread and then reconstructs local history. That makes prompt editing depend on mutation and on inferred transcript positions.This change establishes a source-preserving boundary for prompt editing. The app server identifies canonical turns that can be used as fork points, and the TUI forks through the turn immediately before the selected prompt. The source conversation remains intact and the selected prompt is restored in the new conversation's composer.
What Changed
Turn.isForkablemetadata and propagate it through thread reads, resumes, notifications, schemas, and the app-server client.thread/forkthrough the selected prompt's predecessor; editing the first prompt starts a fresh conversation.You’re continuing from this point in a new conversation, while explicit fork flows keep their normal lineage notice.Early-interruption cancellation and safety-buffer retries deliberately retain their existing rollback behavior in this layer; the following PRs migrate those independently.
How to Test
Escto select an earlier prompt, and confirm the selection./forkand confirm it still shows the normal fork-lineage notice.Focused coverage:
just test -p codex-app-server-protocol— 256 passedjust test -p codex-tui prompt_edit— 3 passedjust test -p codex-tui backtrack— 14 passedjust test -p codex-tui cancelled_turn_edit— 2 passedjust test -p codex-tui safety_buffer— 4 passedjust test -p codex-tui— 2,978 passed; the two remaining failures are the existing Guardian feature-flag tests onmainStack