Skip to content

chat: rewind through the terminal for every agent - #1577

Merged
devswha merged 1 commit into
mainfrom
chore/rewind-in-terminal-only
Oct 21, 2026
Merged

devswha merged 1 commit into
mainfrom
chore/rewind-in-terminal-only

Conversation

@devswha

@devswha devswha commented Oct 21, 2026

Copy link
Copy Markdown
Owner

User-facing change

Claude Code messages now offer Rewind in terminal, just like grok and
Antigravity. The action sends nothing, preserves the composer's draft and opens
the same pane's terminal with the existing hint to run the agent's own /rewind.
The user chooses and confirms the rewind in the terminal.

The maintainer's preview returned two HTTP 409 responses after about 3.4 seconds
on Claude Code 2.1.306, while the fixtures covered through 2.1.305. Dialog wording
changes kept breaking the screen-reading walk. This applies the maintainer's
rule: when a feature cannot work reliably from Chat, hand it to the real terminal
rather than forcing it into Chat.

Removed

  • Rewind to here, the Chat rewind/refill state and API client.
  • POST /api/pane/rewind, its shared request/response types, demo response and
    machine proxy allowlist entry. Local and machine-prefixed requests now return
    404.
  • The screen-reading walk, rewind prompt cards and responders, persisted
    artificial transcript overlay, obsolete fixtures and tests, and unused
    translations in every locale.
  • Unreleased release-note claims about automatic Chat rewind. git tag --contains
    returned no tags for the merge commits of feat(chat): rewind to an earlier message, and the chat follows #1500 (c43dffdd) and fix: close the final verification gaps of the agent command capabilities plan #1543
    (31bf25fe); both are after v0.4.12. The rewritten fragment describes only the
    terminal handoff and the retained send protection.

Kept and why

  • Native transcript branch handling: Chat still follows a conversation rewound
    in the terminal once the agent records its new branch. Claude Code records
    that branch on the next prompt or command; the bridge no longer invents an
    immediate restore based on dialog wording.
  • Rewind-dialog send guards in the composer, raw input and pending-input paths:
    these still prevent Chat text from landing in a terminal-opened rewind dialog's
    text field. Only the screen parsing and fixtures needed by those guards remain.
    Rewind screens no longer produce Chat cards.
  • Cancelled-send draft recovery and message ownership: other input paths share
    them. Their existing browser regression remains green.
  • The Claude Code command catalog now marks /rewind as terminal-only rather
    than advertising the deleted Chat dialog responder.

Scope of related issues

Refs #1189, #1483 and #1507.

This PR does not close those issues.

Validation

  • HERDR_TEST_MODE=unit bun test --timeout 60000 src/lib/rewindAction.test.ts server/conversation.test.ts server/dialogs/claude.test.ts server/dialogs/registry.test.ts server/core/claude-rewind-send.test.ts server/skills/claude.test.ts server/machines.test.ts: exit 0.
  • bun run check fast: exit 0; workflow syntax, generated types/themes,
    typecheck, production build, and 5,753 passing / 0 failing / 8 skipped
    unit tests in 411 files. Source fingerprint unchanged through the run.
  • REWIND_QA_EVIDENCE=/tmp/rewind-terminal-only-evidence bun scripts/rewind-browser-qa.ts:
    exit 0; 12 combinations (Claude Code/grok/Antigravity, 1440/390 px,
    dark/light), verifying no terminal input or HTTP mutation, the same pane's
    terminal and hint, preserved draft after returning to Chat, and no page errors.
    All 24 Chat/terminal captures were inspected. Controls, contrast, mobile
    layout, and light/dark coverage pass; the existing terminal hint is readable
    and dismissible.
  • bun scripts/restored-draft-demo-regression.ts: exit 0, all five existing
    shared draft-recovery scenarios pass.
  • TMPDIR="$(mktemp -d /tmp/rewind-contracts.XXXXXX)" bun run check run bun test --timeout 15000 server/api.contract.test.ts server/route-envelope.contract.test.ts server/pending-input.contract.test.ts:
    exit 0, 230 passing / 0 failing contracts, including local and
    machine-prefixed rewind-route 404s and the retained rewind-field send guard.
  • git diff --cached --check: exit 0.

Browser QA uses owned demo fixtures and disposable loopback servers, not a live
user session. Contract checks use bun run check run and its disposable herdr
session, config, state directory and ephemeral server ports.

An initial direct unit invocation timed out in an unrelated Devin cache test;
the documented unit mode and the final fast run both pass. A contract run using
the shared /tmp returned 229 passes and one unrelated workspace file-discovery
failure. The exact file-discovery failure also reproduces on unmodified
ee2daec0 (exit 1). The bounded file inventory in server/files.ts does not
find that test's file in this crowded shared temporary directory. No test or
product code was changed to hide it; the final contract run uses a dedicated
TMPDIR.

Independent codex exec -m gpt-6-astra review: exit 0, APPROVE, no
blocking findings. The native child reviewer could not launch because this
session is already at the harness's subagent nesting limit. The Codex reviewer
inspected six captures available at its run; the remaining 18 were subsequently
checked directly. No extra CodeRabbit review was requested.

@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: devswha/herdr-web-ui/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 945bd092-7d39-4572-b36b-9613b0f219f4
📥 Commits

Reviewing files that changed from the base of the PR and between 90b66e8 and 1b3ebb5.

📒 Files selected for processing: 60
  • DESIGN.md
  • changelog.d/chat-rewind-to-here.md
  • changelog.d/claude-rewind-2-1-305.md
  • docs/agent-commands.md
  • docs/guide.md
  • scripts/rewind-browser-qa.ts
  • server/api.contract.test.ts
  • server/conversation.test.ts
  • server/conversation.ts
  • server/dialogs/claude.test.ts
  • server/dialogs/claude.ts
  • server/dialogs/registry.test.ts
  • server/dialogs/shared.ts
  • server/fixtures/claude-rewind-2.1.304-after-never-mind-40.txt
  • server/fixtures/claude-rewind-2.1.304-confirm-apple-120.txt
  • server/fixtures/claude-rewind-2.1.304-confirm-apple-40.txt
  • server/fixtures/claude-rewind-2.1.304-confirm-apple-tip-40.txt
  • server/fixtures/claude-rewind-2.1.304-confirm-long-40.txt
  • server/fixtures/claude-rewind-2.1.304-restored-120.txt
  • server/fixtures/claude-rewind-2.1.304-restored-40.txt
  • server/fixtures/claude-rewind-2.1.304-restored-cleared-120.txt
  • server/fixtures/claude-rewind-2.1.304-restored-cleared-40.txt
  • server/fixtures/claude-rewind-2.1.304-restored-esc-120.txt
  • server/fixtures/claude-rewind-2.1.304-restored-esc-40.txt
  • server/fixtures/claude-rewind-2.1.304-select-banana-120.txt
  • server/fixtures/claude-rewind-2.1.304-select-banana-40.txt
  • server/fixtures/claude-rewind-2.1.304-select-current-120.txt
  • server/fixtures/claude-rewind-2.1.304-select-current-40.txt
  • server/fixtures/claude-rewind-2.1.304-select-long-40.txt
  • server/fixtures/claude-rewind-2.1.304-select-long-apple-40.txt
  • server/fixtures/claude-rewind-2.1.304-select-long-banana-40.txt
  • server/fixtures/claude-rewind-2.1.304-select-long-current-40.txt
  • server/fixtures/claude-rewind-2.1.305-confirm-cherry-120.txt
  • server/fixtures/claude-rewind-2.1.305-confirm-kiwi-145.txt
  • server/index.ts
  • server/machine-api.ts
  • server/machines.test.ts
  • server/outcome.ts
  • server/pane-routes.ts
  • server/prompt.ts
  • server/rewind-card-route.test.ts
  • server/rewind-never-mind.test.ts
  • server/rewind-outcomes.test.ts
  • server/rewind.test.ts
  • server/rewind.ts
  • server/route-envelope.contract.test.ts
  • server/skills/claude.test.ts
  • server/skills/claude.ts
  • shared/protocol.ts
  • site/demo/transport.ts
  • src/components/ChatView.css
  • src/components/ChatView.tsx
  • src/components/PaneTerminal.tsx
  • src/lib/api.ts
  • src/lib/i18n.ja.ts
  • src/lib/i18n.ko.ts
  • src/lib/i18n.zh.ts
  • src/lib/machineContext.tsx
  • src/lib/rewindAction.test.ts
  • src/lib/rewindAction.ts
💤 Files with no reviewable changes: 37
  • server/fixtures/claude-rewind-2.1.304-restored-cleared-40.txt
  • server/outcome.ts
  • server/fixtures/claude-rewind-2.1.304-select-long-current-40.txt
  • server/fixtures/claude-rewind-2.1.304-select-current-120.txt
  • server/fixtures/claude-rewind-2.1.304-restored-cleared-120.txt
  • server/fixtures/claude-rewind-2.1.304-select-banana-40.txt
  • server/fixtures/claude-rewind-2.1.304-select-long-banana-40.txt
  • server/fixtures/claude-rewind-2.1.304-select-long-40.txt
  • server/rewind-outcomes.test.ts
  • server/fixtures/claude-rewind-2.1.304-restored-120.txt
  • server/fixtures/claude-rewind-2.1.304-restored-esc-120.txt
  • server/rewind-card-route.test.ts
  • server/fixtures/claude-rewind-2.1.304-confirm-long-40.txt
  • server/fixtures/claude-rewind-2.1.304-confirm-apple-120.txt
  • server/fixtures/claude-rewind-2.1.305-confirm-kiwi-145.txt
  • changelog.d/claude-rewind-2-1-305.md
  • src/components/ChatView.css
  • server/fixtures/claude-rewind-2.1.304-after-never-mind-40.txt
  • server/fixtures/claude-rewind-2.1.304-select-banana-120.txt
  • server/fixtures/claude-rewind-2.1.304-restored-esc-40.txt
  • server/fixtures/claude-rewind-2.1.304-select-long-apple-40.txt
  • server/fixtures/claude-rewind-2.1.304-select-current-40.txt
  • server/fixtures/claude-rewind-2.1.304-confirm-apple-40.txt
  • server/fixtures/claude-rewind-2.1.304-restored-40.txt
  • server/dialogs/registry.test.ts
  • server/fixtures/claude-rewind-2.1.305-confirm-cherry-120.txt
  • server/rewind-never-mind.test.ts
  • site/demo/transport.ts
  • shared/protocol.ts
  • server/fixtures/claude-rewind-2.1.304-confirm-apple-tip-40.txt
  • src/lib/api.ts
  • server/rewind.test.ts
  • src/lib/i18n.zh.ts
  • src/lib/i18n.ja.ts
  • src/lib/i18n.ko.ts
  • server/dialogs/shared.ts
  • server/rewind.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

📝 Summary

Summary by CodeRabbit

  • New Features

    • Added Rewind in terminal for Claude Code, Grok, and Antigravity.
    • Rewind opens the pane terminal, sends nothing, preserves drafts, and displays guidance for running /rewind.
    • Chat follows the agent’s recorded conversation branch after rewind completion.
  • Bug Fixes

    • Rewind remains available while messages are pending and is no longer restricted by composer state.
    • Chat waits while a Claude Code rewind dialog is open, preventing accidental message submission.
  • Documentation

    • Updated feature and agent-command documentation to describe terminal-based rewind.

Chat now offers terminal-based rewind for Claude Code, Grok, and Antigravity. The action preserves drafts and sends no input. Claude transcript reads follow recorded branches. The Chat rewind API and Claude-specific in-chat rewind flow were removed.

Changes: Terminal-based rewind

Layer / File(s) Summary
Offer terminal rewind from Chat
src/lib/rewindAction.ts, src/components/ChatView.tsx, src/components/PaneTerminal.tsx, scripts/rewind-browser-qa.ts, docs/*, DESIGN.md, changelog.d/*, src/lib/i18n.*.ts
Chat offers terminal rewind for Claude Code, Grok, and Antigravity. The action preserves drafts, sends no input, and displays a terminal hint. Browser QA and documentation cover the updated flow.
Remove the Chat rewind API
shared/protocol.ts, src/lib/api.ts, src/lib/machineContext.tsx, server/rewind.ts, server/pane-routes.ts, server/machine-api.ts, server/index.ts, site/demo/transport.ts, server/*test.ts
The pane rewind API, client helpers, protocol types, machine proxy route, and server rewind implementation were removed. Tests verify that the removed API returns 404 and update machine route expectations.
Follow native transcript branches
server/conversation.ts, server/prompt.ts, server/dialogs/*, server/skills/claude.ts, server/fixtures/claude-rewind-*
Claude transcript handling no longer stores rewind state or uses dialog text to infer restoration. Rewind panels remain detectable for send handling. The Claude rewind dialog reader, related persistence, tests, and fixtures were removed.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Possibly related issues

  • Issue 1507 — The PR removes the Chat rewind walk and uses terminal /rewind instead.
  • Issue 1546 — The PR updates the related changelog entry and removes the former Chat rewind flow.
  • Issue 1548 — The PR removes Claude rewind parsers, responders, and related Chat surface.

Suggested reviewers: kilhyeonjun

Merge Risk: ⚪ Minimal · up to 1b3eb

Claude Code messages now open the terminal for rewind and keep the draft intact. The Chat rewind API is removed, and no remaining breakage was found, so this looks ready to merge.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 20 functions across 19 files. (4 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly describes the primary change: rewinding through the terminal. It is concise and related to the implementation, although “every agent” is broader than the documented Claude Code, grok…
Description check Passed The description explains the behavior, removed components, retained safeguards, related issues, and validation results. It does not use the template’s exact “## Change” heading or provide a direct iss…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title clearly describes the primary change: rewinding through the terminal. It is concise and related to the implementation, although “every agent” is broader than the documented Claude Code, grok, and Antigravity scope.

Full details: Description check

Explanation

The description explains the behavior, removed components, retained safeguards, related issues, and validation results. It does not use the template’s exact “## Change” heading or provide a direct issue link, but it is otherwise complete and sufficiently detailed.

Full details: Docstring Coverage

Explanation

Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 20 functions across 19 files. (4 skipped: 4 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devswha
devswha merged commit fae4558 into main Oct 21, 2026
24 of 25 checks passed
@devswha
devswha deleted the chore/rewind-in-terminal-only branch October 21, 2026 23:43
devswha added a commit that referenced this pull request Oct 24, 2026
…nd remove dead registry paths (#1890)

Fixes #1582
Fixes #1437

Two follow-ups grouped because both touch `server/prompt.ts`: one commit
per issue.

## #1582 (rewind follow-ups)
- **State file:** the server removes `claude-rewinds.json` from its
state directory on start. Only the unreleased Chat rewind (#1500) wrote
it, and nothing has read it since #1577. A failure is logged, and the
server still starts.
- **List-screen fixture:** the recorded rewind message list
(`claude-rewind-2.1.304-select-banana-40.txt`, deleted in #1577) is
back.
- `dialogs/claude.test.ts` checks it holds Chat sends without offering a
card.
- `core/claude-rewind-send.test.ts` refuses a send on it and types
nothing.
- **Comment:** `PaneTerminal.css`'s banner comment now names Claude Code
too.
- **Inlining:** `chatOwnedInput` only returned `lastChatSubmitted`, so
its two callers now call that directly.

## #1437 (dialog reader registry)
1. **Reader order is pinned.** `registry.test.ts` lists, per agent, the
order its screen is offered to the readers. Swapping two priorities now
fails a test (mutation-checked: `claude-question` priority 10 to 25
fails). The snapshot comment now cites `3df0824e`, #1435's base.
2. **The commit key comes from the chosen answer.**
`InteractionPlan.commit(answer)` and `terminalFallback(answer)` read the
chosen answer's own key sequence, so the loop executes the plan for the
answer it validated. Mutating back to `sequences[0]` fails the new test.
3. **Dead paths removed:**
   - `InteractionPlan.identity`.
- `ReaderContext.fallback`: nothing set it, so the three fallback
readers never parsed anything. They now only lend their answer behaviour
(`reread`), and `parseFallbackPrompt` still draws those cards.
- `modelListWaits`: the fallback card's model-list guard calls
`registry.waits`, the same Claude-model, Claude-effort and Codex-model
check. Tests call it directly.
4. **Parsers run less often.**
- `parsePrompt` returns at the first reader that reads the screen
instead of running every reader.
- A parser several readers share runs once per read pass, through
`onePerPass` keyed by the screen and that pass's context object:
Claude's approval, Hermes' clarify, pi's dialog and OmO's forms. The
other parsers run at most once each, because the pass stops at the first
reader that reads the screen. `ReaderContext` is readonly, so a caller
cannot change the context mid-pass and get a cached result.
5. **New interaction-plan test:** a move goes out, then the asking ends,
and nothing more is sent.
- The `picker-asking-before-commit.md` fragment from the issue comment
was already folded into 0.4.13 (#1640), so there is no fragment left to
drop.

## Verification
- `bun test` of the five changed test files: 96 pass.
`server/prompt.test.ts`, `server/dialogs`, `server/core`, `outcome`,
`pane-routes` and `conversation`: 828 pass, 0 fail.
- **Mutation checks:** each of these makes the new tests fail:
  - swapping a reader priority;
  - committing from `sequences[0]`;
  - dropping the start-up removal;
  - removing the memo's cache hit.
- `bun run typecheck`: passes on each commit.
- Code review: `omo-native-code-reviewer` approved with no HIGH or
MEDIUM findings; its readonly-context LOW is the third commit. Codex
(gpt-6.1-sol, xhigh) found no HIGH, MEDIUM or LOW: the early return
matched the old eager evaluation in 1,760 comparisons over 80 fixtures,
and `registry.waits` matched the removed condition.
- `bun run check fast` (through `dori heavy`) on c707e82: `status:
success`, with a clean tree and every step ok (typecheck, build, unit
tests, generated types and themes, workflow syntax).

---------

Co-authored-by: mp <mp@local>
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.

1 participant