-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat(ui): add ability to edit user message when reverting #2440
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
Changes from all commits
914e503
aadce42
f337913
00446a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -134,6 +134,7 @@ import { | |
| } from "../composerDraftStore"; | ||
| import { | ||
| appendTerminalContextsToPrompt, | ||
| deriveDisplayedUserMessageState, | ||
| formatTerminalContextLabel, | ||
| type TerminalContextDraft, | ||
| type TerminalContextSelection, | ||
|
|
@@ -3490,6 +3491,29 @@ export default function ChatView(props: ChatViewProps) { | |
| void onRevertToTurnCountRef.current(targetTurnCount); | ||
| }, []); | ||
|
|
||
| const onEditUserMessage = useCallback( | ||
| async (messageId: MessageId, text: string) => { | ||
| const targetTurnCount = revertTurnCountRef.current.get(messageId); | ||
| if (typeof targetTurnCount !== "number") { | ||
| return; | ||
| } | ||
|
|
||
| const displayedMessage = deriveDisplayedUserMessageState(text); | ||
| const draftText = displayedMessage.visibleText || text; | ||
| clearComposerDraftContent(composerDraftTarget); | ||
| setComposerDraftPrompt(composerDraftTarget, draftText); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 High
🤖 Copy this AI Prompt to have your agent fix this: |
||
| promptRef.current = draftText; | ||
| composerRef.current?.resetCursorState({ | ||
| cursor: draftText.length, | ||
| prompt: draftText, | ||
| detectTrigger: true, | ||
| }); | ||
| composerRef.current?.focusAtEnd(); | ||
| await onRevertToTurnCountRef.current(targetTurnCount); | ||
| }, | ||
| [clearComposerDraftContent, composerDraftTarget, composerRef, setComposerDraftPrompt], | ||
| ); | ||
|
|
||
| // Empty state: no active thread | ||
| if (!activeThread) { | ||
| return <NoActiveThreadState />; | ||
|
|
@@ -3568,6 +3592,7 @@ export default function ChatView(props: ChatViewProps) { | |
| onOpenTurnDiff={onOpenTurnDiff} | ||
| revertTurnCountByUserMessageId={revertTurnCountByUserMessageId} | ||
| onRevertUserMessage={onRevertUserMessage} | ||
| onEditUserMessage={onEditUserMessage} | ||
| isRevertingCheckpoint={isRevertingCheckpoint} | ||
| onImageExpand={onExpandTimelineImage} | ||
| markdownCwd={gitCwd ?? undefined} | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.