-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Bug fix: reliably detect UserMessage boundaries via typed spans #2879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
9026a37
to
25c14d1
Compare
Update: Here’s the result video after the TUI rework(#2877). Before2025-09-03.12.40.25.movAfter2025-09-03.12.39.21.mov |
25c14d1
to
57370c7
Compare
Hi — This PR fixes a bug where |
codex-rs/tui/src/app.rs
Outdated
pub(crate) transcript_lines: Vec<Line<'static>>, | ||
// Absolute [header..end) ranges for user messages within `transcript_lines`. | ||
pub(crate) user_spans: Vec<(usize, usize)>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we try a version of this where instead of transcript_lines
we store transcript_cells
, and compute transcript_lines when we trigger transcript mode? then the transcript / backtrack view knows which cell is which and we can encapsulate this logic inside the backtrack view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. I'll start refactoring based on your suggestion.
57370c7
to
d981d44
Compare
@nornagon-openai I’ve pushed an update; could you please take another look?
Thank you! Update: Having spent additional time understanding the Overlay and Transcript code, I believe a follow-up refactor to make them cell-based is unnecessary. |
8447534
to
ab1f588
Compare
… update call sites/tests
…er_spans and let overlay handle separation; update tests
ab1f588
to
9e2fcb7
Compare
Hi @nornagon-openai — could you please take another look when you have a moment? |
No (intended) functional change. This refactors the transcript view to hold a list of HistoryCells instead of a list of Lines. This simplifies and makes much of the logic more robust, as well as laying the groundwork for future changes, e.g. live-updating history cells in the transcript. Similar to #2879 in goal. Fixes #2755.
Closing this as #3538 supersedes it. |
Fixes #2755
Replaces #2757 to fix root cause.
Summary
Root cause
Backtrack relied on rendered text parsing (“user” header join/trim), which loses type info and misidentifies boundaries.
Fix
MessageKind
(User|Other
) andMessageSpan
toHistoryCell
(default keeps existing cells unchanged).UserHistoryCell
and return it fromnew_user_prompt
(transcript rendering unchanged).transcript_lines
withtranscript_cells
in App.build_transcript_flattened()
.Before
2025-08-29.2.07.37.mov
After
2025-08-29.2.06.51.mov