feat(gateway): bring /undo [N] to messaging platforms (parity with CLI/TUI)#36699
Merged
Conversation
…I/TUI)
Gateway /undo was wired into every platform but still ran the old
single-turn hard-truncate. Now it matches the CLI/TUI: /undo [N] backs
up N user turns (default 1, clamps to oldest), soft-deletes the
truncated rows on disk (active=0, kept for audit, hidden from re-prompts
and search) via SessionDB.rewind_to_message, evicts the cached agent so
the next turn rebuilds from the active-only transcript (the gateway's
equivalent of the CLI's in-place history surgery + memory invalidation),
and echoes the backed-up message text so the user can copy/edit and
resend — platforms have no editable composer to prefill.
- gateway/session.py: SessionStore.rewind_session(session_id, n) wraps
the soft-delete primitive; load_transcript already returns active-only
- gateway/run.py: _handle_undo_command parses [N], calls rewind_session,
evicts the agent, echoes target text; confirm-prompt detail is count-aware
- locales: undo.removed gains {turns}; new undo.invalid_count, all 16 langs
- tests: tests/gateway/test_undo_rewind_session.py (6 cases)
Contributor
🔎 Lint report:
|
| Rule | Count |
|---|---|
unresolved-import |
1 |
First entries
tests/gateway/test_undo_rewind_session.py:13: [unresolved-import] unresolved-import: Cannot resolve imported module `pytest`
✅ Fixed issues: none
Unchanged: 4962 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
JoeKowal
pushed a commit
to JoeKowal/hermes-agent
that referenced
this pull request
Jun 4, 2026
…I/TUI) (NousResearch#36699) Gateway /undo was wired into every platform but still ran the old single-turn hard-truncate. Now it matches the CLI/TUI: /undo [N] backs up N user turns (default 1, clamps to oldest), soft-deletes the truncated rows on disk (active=0, kept for audit, hidden from re-prompts and search) via SessionDB.rewind_to_message, evicts the cached agent so the next turn rebuilds from the active-only transcript (the gateway's equivalent of the CLI's in-place history surgery + memory invalidation), and echoes the backed-up message text so the user can copy/edit and resend — platforms have no editable composer to prefill. - gateway/session.py: SessionStore.rewind_session(session_id, n) wraps the soft-delete primitive; load_transcript already returns active-only - gateway/run.py: _handle_undo_command parses [N], calls rewind_session, evicts the agent, echoes target text; confirm-prompt detail is count-aware - locales: undo.removed gains {turns}; new undo.invalid_count, all 16 langs - tests: tests/gateway/test_undo_rewind_session.py (6 cases)
1 task
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
/undo [N]now works the same on every messaging platform as it does in the CLI/TUI. The gateway command was wired into all platforms but still ran the old single-turn hard-truncate — this brings it to parity.Changes
SessionStore.rewind_session(session_id, n)wrapsSessionDB.rewind_to_message— soft-deletes the truncated rows (active=0, kept for audit, hidden from re-prompts and search) instead of hard-rewriting the transcript.load_transcriptalready returns the active-only view._handle_undo_commandparses[N], callsrewind_session, evicts the cached agent (so the next turn rebuilds from the truncated transcript and memory caches refresh — the gateway's equivalent of the CLI's in-place history surgery), and echoes the backed-up message text so the user can copy/edit and resend. The destructive-confirm detail is count-aware.undo.removedgains{turns}; newundo.invalid_count— all 16 languages.tests/gateway/test_undo_rewind_session.py(6 cases).Why echo instead of prefill
Messaging platforms have no editable composer to pre-fill (unlike CLI/TUI), so the gateway echoes the backed-up message text in its reply with "Copy/edit the text above and send it to re-prompt from here." Same soft-delete + N-turn semantics, platform-appropriate UX.
Behavior
/undo/undo 3/undo 99/undo abcValidation
rewind_sessiontests + 261 across the full related suites (test_undo_command,test_hermes_state,test_memory_session_switch,test_i18n).removed+invalid_count(no format errors, all placeholders resolve).Follow-up to the merged CLI/TUI
/undo [N]work (#21910).Infographic