fix(session): skip display_kind timeline rows in undo/retry turn targets - #73396
Merged
kshitijk4poor merged 2 commits intoJul 28, 2026
Merged
Conversation
list_recent_user_messages and the in-memory /retry + session.undo walkers treated every role=user row as a real user turn. Timeline bookkeeping (model_switch, async_delegation_complete, auto_continue, hidden) is stored that way, so /undo soft-deleted from a marker and /retry re-sent opaque bookkeeping text. Exclude display_kind the same way CLI resume counting and the prompt.submit ordinal path do.
…llback.restore Phase 2 review found two sibling sites with the same bug class: - truncate_before_user_ordinal in prompt.submit counted display_kind timeline rows as user turns, shifting the truncation target - rollback.restore used the old pop-loop pattern that would pop a display_kind marker instead of the last real exchange Both now use the same predicate (role==user and not display_kind) matching list_recent_user_messages, /undo, /retry, and CLI resume. Added tests for both paths.
kshitijk4poor
enabled auto-merge (rebase)
July 28, 2026 13:56
Collaborator
Duplicate of #72820: the current patch is byte-for-byte identical across the same six files, including the regression coverage. |
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.
Summary
/undoand/retrynow skipdisplay_kindtimeline rows (model_switch, async_delegation_complete, auto_continue, hidden) when finding the target user turn — matching the predicate already used in CLI resume turn counting (cli_agent_setup_mixin.py:518,cli_commands_mixin.py:1017).Problem
Timeline bookkeeping rows are durable
role='user'in state.db but no client counts them as user turns. When a session ends with a trailing marker:/undosoft-deleted only the marker, leaving the last real Q/A intact — user thinks they undid, but didn't/retryre-sent the opaque marker text and truncated only the marker instead of the failed exchangeSame bug class as #72695 (prompt.submit ordinal). This PR does NOT touch that path.
Changes
hermes_state.py—list_recent_user_messagesSQL: addAND (display_kind IS NULL OR display_kind = '')cli.py—retry_last/undo_lastin-memory walkers: addnot msg.get("display_kind")gateway/slash_commands.py— gateway/retrywalker: same predicatetui_gateway/server.py—/retryandsession.undowalkers: same predicate/retryhistory walkValidation
Closes #72820