feat(ui): add ability to edit user message when reverting#2440
feat(ui): add ability to edit user message when reverting#2440Githubguy132010 wants to merge 4 commits intopingdotgg:mainfrom
Conversation
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`
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
@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); |
There was a problem hiding this comment.
🟠 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.
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
Note
Add Edit button to user messages in the chat timeline to revert and prefill the composer
MessagesTimeline.tsx.📊 Macroscope summarized 914e503. 3 files reviewed, 3 issues evaluated, 0 issues filtered, 1 comment posted
🗂️ Filtered Issues