Skip to content

fix(session): skip display_kind timeline rows in undo/retry turn targets - #73396

Merged
kshitijk4poor merged 2 commits into
NousResearch:mainfrom
kshitijk4poor:salvage/72820-display-kind-undo-retry
Jul 28, 2026
Merged

fix(session): skip display_kind timeline rows in undo/retry turn targets#73396
kshitijk4poor merged 2 commits into
NousResearch:mainfrom
kshitijk4poor:salvage/72820-display-kind-undo-retry

Conversation

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Summary

/undo and /retry now skip display_kind timeline 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:

  • /undo soft-deleted only the marker, leaving the last real Q/A intact — user thinks they undid, but didn't
  • /retry re-sent the opaque marker text and truncated only the marker instead of the failed exchange

Same bug class as #72695 (prompt.submit ordinal). This PR does NOT touch that path.

Changes

  • hermes_state.pylist_recent_user_messages SQL: add AND (display_kind IS NULL OR display_kind = '')
  • cli.pyretry_last / undo_last in-memory walkers: add not msg.get("display_kind")
  • gateway/slash_commands.py — gateway /retry walker: same predicate
  • tui_gateway/server.py/retry and session.undo walkers: same predicate
  • Tests for TUI undo soft-delete path and /retry history walk

Validation

Closes #72820

necoweb3 and others added 2 commits July 28, 2026 18:51
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
kshitijk4poor enabled auto-merge (rebase) July 28, 2026 13:56
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery comp/tui Terminal UI (ui-tui/ + tui_gateway/) area/sessions Session lifecycle, resume, persistence, history duplicate This issue or pull request already exists sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Jul 28, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #72820: the current patch is byte-for-byte identical across the same six files, including the regression coverage.

@kshitijk4poor
kshitijk4poor merged commit cf258b6 into NousResearch:main Jul 28, 2026
40 checks passed
@kshitijk4poor
kshitijk4poor deleted the salvage/72820-display-kind-undo-retry branch August 5, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/sessions Session lifecycle, resume, persistence, history comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery comp/tui Terminal UI (ui-tui/ + tui_gateway/) duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants