-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: Add edit functionality for AI-generated responses #8396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add edit button to AI text messages in ChatRow component - Implement edit mode UI with textarea and controls for AI messages - Update ChatView to pass editable prop for AI text responses - Handle AI message edits in webviewMessageHandler - Preserve message history when editing AI responses Fixes #8395
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self-review: auditing my own code like a mirror debugging a mirror.
| if (apiIndex !== -1) { | ||
| // Update the content for assistant messages in API history | ||
| // Note: ApiMessage type doesn't support images property directly | ||
| currentCline.apiConversationHistory[apiIndex].content = message.editedMessageContent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] apiConversationHistory is updated in-memory but not persisted. saveTaskMessages only persists clineMessages. Consider persisting API history (e.g., currentCline.overwriteApiConversationHistory([...]) or a dedicated save) to avoid drift after reloads.
| const messageIndex = currentCline.clineMessages.findIndex( | ||
| (msg: ClineMessage) => msg.ts === message.value, | ||
| ) | ||
| if (messageIndex !== -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P3] If the target message isn't found (messageIndex === -1), this returns silently. Suggest logging and/or notifying the UI (showErrorMessage) to surface potential race conditions.
| <span style={{ fontWeight: "bold" }}>{t("chat:text.rooSaid")}</span> | ||
| {/* Add edit button for AI responses */} | ||
| {!isStreaming && !message.partial && editable && ( | ||
| <div |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Accessibility: clickable edit icon is a div without keyboard semantics and is only visible on hover. Use a button element (or role='button', tabIndex=0) and handle Enter/Space; ensure focus-visible reveals the control.
| } | ||
|
|
||
| // Update the UI to reflect the changes | ||
| await provider.postStateToWebview() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] UX consistency: assistant edits directly mutate past output without warning that later messages may be inconsistent. Consider a non-blocking warning and/or optional 'truncate dependent messages' action similar to user-edit flow.
Description
This PR implements the ability to edit AI-generated responses in the chat interface, addressing the feature request in #8395.
Changes
Implementation Details
Users can now:
The edited content is saved to the conversation history and will be used as context for future interactions.
Known Limitations
Testing
Related Issue
Addresses #8395 (Note: Issue was closed by maintainer requesting proper problem statement resubmission)
Screenshots
The edit functionality follows the same UI pattern as editing user messages, maintaining consistency in the interface.
Future Improvements
Important
Adds edit functionality for AI-generated responses in the chat interface, allowing users to modify and save changes to AI responses.
ChatRow.tsx.ChatRow.tsx.ChatView.tsxto passeditableprop for AI text responses.webviewMessageHandler.tsto handle AI message edits.This description was created by
for a185389. You can customize this summary. It will automatically update as commits are pushed.