Skip to content

feat(web): restore user prompt to composer input on revert#1282

Open
MaximIJ wants to merge 2 commits intopingdotgg:mainfrom
MaximIJ:revert-prompt-restore-clean
Open

feat(web): restore user prompt to composer input on revert#1282
MaximIJ wants to merge 2 commits intopingdotgg:mainfrom
MaximIJ:revert-prompt-restore-clean

Conversation

@MaximIJ
Copy link

@MaximIJ MaximIJ commented Mar 21, 2026

What Changed

When reverting a checkpoint, the user's original prompt text is now restored into the composer input field so they can edit and re-send without retyping.

Specifically:

  • onRevertUserMessage now looks up the reverted user message and extracts the visible prompt text using deriveDisplayedUserMessageState (strips terminal context blocks)
  • onRevertToTurnCount accepts an optional promptToRestore param and writes it back into the composer after the revert completes
  • A 300ms setTimeout defers the restore past the server state sync (throttled at ~100ms) to prevent re-renders from overwriting it
  • The composer is focused with cursor at end of text after restore

Why

When a user reverts a message, they typically want to tweak the prompt and re-send. Currently they have to retype the entire prompt from memory. Restoring it into the composer removes that friction.

This is a small, focused UX improvement — one file changed, no new dependencies, no scope expansion.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • No UI layout changes (behavior-only change, no screenshots needed)

Note

Restore user prompt to composer input after reverting to a message checkpoint

When a user reverts to a previous message, the visible prompt text of that message is now restored into the composer and focused, with the cursor placed at the end.

  • onRevertUserMessage in ChatView.tsx looks up the target message and derives its visible text via deriveDisplayedUserMessageState before passing it to onRevertToTurnCount.
  • On successful revert, onRevertToTurnCount schedules prompt restoration via setTimeout, updating promptRef, calling setPrompt, collapsing the composer cursor, and focusing the composer.

Macroscope summarized 8399fcf.

When reverting a checkpoint, the original user prompt text is now
restored into the composer input field so the user can edit and re-send
without retyping. Uses deriveDisplayedUserMessageState to extract just
the visible prompt text (stripping terminal context blocks).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Mar 21, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: aadb13a9-87f7-416a-b84f-5ecaec385104

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@github-actions github-actions bot added size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Mar 21, 2026
Skip restoring the user prompt into the composer when the checkpoint
revert fails, so users don't see their prompt return alongside an
error message.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant