Skip to content

feat(ui): add ability to edit user message when reverting#2440

Closed
Githubguy132010 wants to merge 4 commits intopingdotgg:mainfrom
Githubguy132010:session/agent_e8ef51f9-999b-4912-9fc5-f9a251cdbdb8
Closed

feat(ui): add ability to edit user message when reverting#2440
Githubguy132010 wants to merge 4 commits intopingdotgg:mainfrom
Githubguy132010:session/agent_e8ef51f9-999b-4912-9fc5-f9a251cdbdb8

Conversation

@Githubguy132010
Copy link
Copy Markdown

@Githubguy132010 Githubguy132010 commented May 1, 2026

Fixes #2438

What Changed

Added an edit button to eligible user messages in the chat timeline. Clicking it rolls the thread back to the checkpoint before that message’s agent work, restores the user message text into the composer, and focuses the composer so the prompt can be corrected and resent.

Why

This supports the common “fix my previous prompt and restart from there” workflow without manually copying text and reverting separately. It reuses the existing checkpoint revert mechanism instead of introducing a new rollback path, keeping the behavior consistent with current thread state handling.

UI Changes

Adds a small edit icon button next to the existing revert action on user messages that have a restorable checkpoint.

Before: user messages exposed copy/revert actions only.
After: user messages expose copy/edit/revert actions, with edit pre-filling the composer after rollback.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Add Edit button to user messages in the chat timeline to revert and prefill the composer

  • Adds an Edit button (alongside the existing Revert button) to eligible user message rows in MessagesTimeline.tsx.
  • Clicking Edit reverts the conversation to that message's turn count and prefills the composer with the derived visible text, moves the cursor to the end, and focuses the input.
  • The Edit button is disabled while a checkpoint revert or work is in progress.
📊 Macroscope summarized 914e503. 3 files reviewed, 3 issues evaluated, 0 issues filtered, 1 comment posted

🗂️ Filtered Issues

Implement `onEditUserMessage` in `ChatView` to allow users to modify a message's text and revert the conversation to that specific point. This updates the composer draft and resets the cursor state to the end of the text.

- Add `onEditUserMessage` handler to `ChatView`
- Update `MessagesTimeline` to include an edit button (SquarePenIcon) next to the revert button
- Update corresponding types and test mocks for `MessagesTimeline`
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 1, 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: 7e0378d4-f95a-44ef-8f28-52f67427702b

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:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels May 1, 2026
Comment thread apps/web/src/components/ChatView.tsx
@vercel
Copy link
Copy Markdown

vercel Bot commented May 4, 2026

@Githubguy132010 is attempting to deploy a commit to the Ping Labs Team on Vercel.

A member of the Team first needs to authorize it.

const displayedMessage = deriveDisplayedUserMessageState(text);
const draftText = displayedMessage.visibleText || text;
clearComposerDraftContent(composerDraftTarget);
setComposerDraftPrompt(composerDraftTarget, draftText);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High components/ChatView.tsx:3504

onEditUserMessage clears the composer draft and replaces it with the edited message text before onRevertToTurnCountRef.current runs. If the revert bails out (user cancels confirmation dialog, isRevertingCheckpoint already true, environment unavailable, or turn running), the original composer content (prompt, images, terminal contexts) is already destroyed and cannot be recovered.

🤖 Copy this AI Prompt to have your agent fix this:
In file apps/web/src/components/ChatView.tsx around line 3504:

`onEditUserMessage` clears the composer draft and replaces it with the edited message text before `onRevertToTurnCountRef.current` runs. If the revert bails out (user cancels confirmation dialog, `isRevertingCheckpoint` already true, environment unavailable, or turn running), the original composer content (prompt, images, terminal contexts) is already destroyed and cannot be recovered.

Evidence trail:
ChatView.tsx lines 3494-3516: onEditUserMessage clears composer then awaits revert. ChatView.tsx lines 2552-2605: onRevertToTurnCount has multiple early-return bail-out paths (isRevertingCheckpoint, environment unavailable, phase running, user cancels dialog). composerDraftStore.ts lines 2863-2890: clearComposerContent destroys prompt, images, terminalContexts, persistedAttachments.

@Githubguy132010 Githubguy132010 deleted the session/agent_e8ef51f9-999b-4912-9fc5-f9a251cdbdb8 branch May 4, 2026 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 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.

[Feature]: Edit button on user messages (similar to t3chat)

1 participant