fix(tui): keep /copy aligned with rollback#18739
Merged
fcoury-oai merged 2 commits intomainfrom Apr 20, 2026
Merged
Conversation
Track a bounded set of copyable agent responses by visible user turn so `/copy` follows the transcript after backtracking. When rewind goes past the retained copy window, report the 32-response limit instead of copying stale text. Update rollback handling to trim the copy cache alongside transcript cells and cover both surviving-response and over-limit rewind cases.
etraut-openai
approved these changes
Apr 20, 2026
Collaborator
etraut-openai
left a comment
There was a problem hiding this comment.
Code looks good. I verified the bug before the change and the correct behavior after the change.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
Fixes #18718.
After rewinding a thread,
/copycould still copy the latest assistant response from before the rewind. The transcript cells were rolled back, but the copy source was a singlelast_agent_markdowncache that was not synchronized with backtracking, so the visible conversation and copied content could diverge.What changed
ChatWidgetnow keeps a bounded copy history for the most recent 32 assistant responses, keyed by the visible user-turn count. When local rollback trims transcript cells, the copy cache is trimmed to the same surviving user-turn count so/copyuses the latest visible assistant response.If the user rewinds past the retained copy window,
/copynow reports:The change also adds coverage for copying the latest surviving response after rollback and for the over-limit rewind message.
Verification
/copycopied the surviving response./copyshowed the 32-response limit message.cargo test -p codex-tui slash_copyjust fix -p codex-tuicargo insta pending-snapshotsNote:
cargo test -p codex-tuicurrently fails on unrelated model catalog and snapshot drift around the default model changing togpt-5.4; the focused/copytests pass after fixing the new test setup.