Skip to content

feat(tui): edit previous prompts using session forks#30504

Open
fcoury-oai wants to merge 3 commits into
mainfrom
codex/tui-remove-thread-rollback
Open

feat(tui): edit previous prompts using session forks#30504
fcoury-oai wants to merge 3 commits into
mainfrom
codex/tui-remove-thread-rollback

Conversation

@fcoury-oai

@fcoury-oai fcoury-oai commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

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

  • Add additive v2 Turn.isForkable metadata and propagate it through thread reads, resumes, notifications, schemas, and the app-server client.
  • Anchor replayed and live user transcript cells to canonical turn IDs, excluding synthetic or in-progress history from prompt-edit targets.
  • Replace transcript prompt-edit rollback with thread/fork through the selected prompt's predecessor; editing the first prompt starts a fresh conversation.
  • Replay retained history before showing You’re continuing from this point in a new conversation, while explicit fork flows keep their normal lineage notice.
  • Preserve prompt text, text elements, and local or remote image attachments when moving the selected prompt into the new composer.

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

  1. Start the TUI and complete at least two turns.
  2. Open the transcript, press Esc to select an earlier prompt, and confirm the selection.
  3. Confirm a new conversation opens with history only through the preceding turn and the selected prompt restored, but not submitted, in the composer.
  4. Resume the source conversation and confirm its history is unchanged.
  5. Repeat with the first prompt and confirm a fresh conversation opens with the prompt restored.
  6. Run an explicit /fork and confirm it still shows the normal fork-lineage notice.

Focused coverage:

  • just test -p codex-app-server-protocol — 256 passed
  • just test -p codex-tui prompt_edit — 3 passed
  • just test -p codex-tui backtrack — 14 passed
  • just test -p codex-tui cancelled_turn_edit — 2 passed
  • just test -p codex-tui safety_buffer — 4 passed
  • just test -p codex-tui — 2,978 passed; the two remaining failures are the existing Guardian feature-flag tests on main

Stack

  1. Prompt editing via session forks (this PR)
  2. Safety-buffer retries via session forks
  3. Durable early interruption and rollback cleanup

@fcoury-oai fcoury-oai requested a review from a team as a code owner June 29, 2026 02:15
@fcoury-oai fcoury-oai force-pushed the codex/tui-remove-thread-rollback branch 4 times, most recently from 1f009c6 to 569223e Compare July 9, 2026 18:38
@fcoury-oai fcoury-oai force-pushed the codex/tui-remove-thread-rollback branch from 167838e to 5c52903 Compare July 9, 2026 22:14
@fcoury-oai fcoury-oai changed the title feat(tui): replace rollback with session forks feat(tui): edit previous prompts using session forks Jul 9, 2026
@aktasumut34

Copy link
Copy Markdown

Fixes: #31902

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants