Skip to content

fix(tui): allow backtracking past /status composites to reach earlier messages - #5058

Closed
kgruiz wants to merge 8 commits into
openai:mainfrom
kgruiz:fix/backtrack-status
Closed

kgruiz wants to merge 8 commits into
openai:mainfrom
kgruiz:fix/backtrack-status

Conversation

@kgruiz

@kgruiz kgruiz commented Oct 10, 2025

Copy link
Copy Markdown
Contributor

This PR addresses #4722.

Summary

Pressing Esc to navigate back through previous messages would stop at the first /status output. Messages sent before /status became unreachable. This happened because /status output is represented as a CompositeHistoryCell, and the backtrack logic treated all composites as headers.

This PR introduces a clear distinction between header composites (true session starts) and general composites (like /status), then updates navigation to skip only real headers.

Root Cause

The backtrack function skipped everything before the last composite in the transcript, assuming all composites were headers. Because /status also created a composite, it was mistakenly treated as a boundary, preventing access to earlier user messages.

Fix Overview

  • Added a CompositeHistoryCellKind enum (Header vs General) stored inside CompositeHistoryCell.
  • Introduced new_header() and is_header() helpers to mark and identify true headers.
  • Updated all session header creation sites to use new_header(...).
  • Rewrote backtrack logic to skip only composites marked as headers while ignoring general ones like /status.

Files Changed

tui/src/history_cell.rs

  • Added the CompositeHistoryCellKind flag and helper methods.
  • Updated session header builders to tag them as Header.

tui/src/app_backtrack.rs

  • Replaced the old “last composite” logic with header-aware iteration.
  • Added regression tests verifying correct navigation behavior.

Tests

  • user_positions_skip_only_leading_composites – ensures /status no longer hides earlier user messages.
  • user_positions_reset_after_empty_composite_boundary – ensures true session headers still reset navigation.

All existing tests pass successfully.

Behavior Change

Before: backtracking stopped at /status, hiding older messages.
After: backtracking continues past /status, stopping only at real session headers.

@github-actions

github-actions Bot commented Oct 10, 2025 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@kgruiz

kgruiz commented Oct 10, 2025

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Oct 10, 2025
@etraut-openai

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. 🎉

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@etraut-openai

Copy link
Copy Markdown
Contributor

Thanks for the contribution, and apologies for the slow response. We had a big PR backlog, and it's taking us a while to get through them all.

I checked out your PR (after merging the latest changes from main) and compiled it locally. It doesn't appear to fix the bug. When I press esc twice to go into edit mode, I'm able to press esc again to get to previous prompts, but I can't go beyond a /status block.

If you still want to pursue this PR, please review it and revise as necessary. If you'd prefer not to pursue it, please close so we can have someone else work on a fix for this bug.

@etraut-openai etraut-openai added the needs-response Additional information is requested label Nov 4, 2025
@kgruiz

kgruiz commented Nov 5, 2025 •

Copy link
Copy Markdown
Contributor Author

Hi, thanks for taking a look at this.

I just tested it locally and it is working correctly for me, so I'm not sure why it doesn't seem to be working on yours?

I made sure I was using the latest remote branch then ran just codex in the codex-rs directory to ensure I was running this dev version. I was able to chat with it, then pressed esc twice to enter edit mode, and was able to go back beyond any status blocks I had.

@etraut-openai

Copy link
Copy Markdown
Contributor

I tried it again, and it works. Must have been user error on my part the first time I tried it.

@etraut-openai etraut-openai removed the needs-response Additional information is requested label Nov 6, 2025
@kgruiz

kgruiz commented Nov 6, 2025

Copy link
Copy Markdown
Contributor Author

No worries, thanks again for looking through the PR.

@etraut-openai

Copy link
Copy Markdown
Contributor

@kgruiz, after some internal discussions, we've decided to take a different approach to fix this bug. Here's the PR if you're interested in the details.

Thanks again for taking the time to submit this PR. We appreciate it!

@github-actions github-actions Bot locked and limited conversation to collaborators Nov 6, 2025
@openai openai unlocked this conversation Nov 6, 2025
nornagon-openai added a commit that referenced this pull request Nov 6, 2025
Fixes #4722

Supersedes #5058

Ideally we'd have a clearer way of separating history per-session than
by detecting a specific history cell type, but this is a fairly minimal
fix for now.
DioNanos pushed a commit to DioNanos/codex-termux that referenced this pull request Nov 10, 2025
Fixes openai#4722

Supersedes openai#5058

Ideally we'd have a clearer way of separating history per-session than
by detecting a specific history cell type, but this is a fairly minimal
fix for now.
youta7 added a commit to youta7/ta-codex that referenced this pull request Nov 10, 2025
@kgruiz
kgruiz deleted the fix/backtrack-status branch November 13, 2025 19:50
willy3087 pushed a commit to nextlw/elai_codex that referenced this pull request Nov 14, 2025
Fixes openai#4722

Supersedes openai#5058

Ideally we'd have a clearer way of separating history per-session than
by detecting a specific history cell type, but this is a fairly minimal
fix for now.
takumi-earth pushed a commit to earthlings-dev/codex that referenced this pull request Dec 2, 2025
Fixes openai#4722

Supersedes openai#5058

Ideally we'd have a clearer way of separating history per-session than
by detecting a specific history cell type, but this is a fairly minimal
fix for now.
swordfish444 pushed a commit to swordfish444/codex that referenced this pull request Feb 26, 2026
monkeycode-ai Bot pushed a commit to agogo233/Ecode that referenced this pull request Jun 8, 2026
Fixes openai/codex#4722

Supersedes openai/codex#5058

Ideally we'd have a clearer way of separating history per-session than
by detecting a specific history cell type, but this is a fairly minimal
fix for now.
AIALRA-0 pushed a commit to AIALRA-0/codex-turn-engine that referenced this pull request Jun 10, 2026
Fixes openai#4722

Supersedes openai#5058

Ideally we'd have a clearer way of separating history per-session than
by detecting a specific history cell type, but this is a fairly minimal
fix for now.
shafqatevo pushed a commit to alo-labs/kay that referenced this pull request Aug 7, 2026
Fixes openai/codex#4722

Supersedes openai/codex#5058

Ideally we'd have a clearer way of separating history per-session than
by detecting a specific history cell type, but this is a fairly minimal
fix for now.
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.

4 participants