Skip to content

Commit 52031a5

Browse files
author
Eric Wheeler
committed
fix: persist edit warning dialog preference during session
This change fixes the issue where the edit warning dialog appears on every edit, even after the user has already seen it once. The solution: 1. Uses a React ref to store the preference in memory during the session 2. Bypasses the dialog if the user has already seen it 3. Adds double-click functionality to user messages for quick editing The preference is reset when the VS Code window is reloaded, ensuring users are reminded of the warning after a restart. Fixes: #6058 Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
1 parent 2f4d833 commit 52031a5

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

webview-ui/src/App.tsx

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ const App = () => {
9191
messageTs: 0,
9292
})
9393

94+
// Track if the user has seen the edit warning - using ref to persist across renders
95+
const hasSeenEditWarningRef = useRef<boolean>(false)
96+
9497
const [editMessageDialogState, setEditMessageDialogState] = useState<EditMessageDialogState>({
9598
isOpen: false,
9699
messageTs: 0,
@@ -158,12 +161,23 @@ const App = () => {
158161
}
159162

160163
if (message.type === "showEditMessageDialog" && message.messageTs && message.text) {
161-
setEditMessageDialogState({
162-
isOpen: true,
163-
messageTs: message.messageTs,
164-
text: message.text,
165-
images: message.images || [],
166-
})
164+
// If the user has already seen the warning, skip the dialog and directly edit
165+
if (hasSeenEditWarningRef.current) {
166+
vscode.postMessage({
167+
type: "editMessageConfirm",
168+
messageTs: message.messageTs,
169+
text: message.text,
170+
images: message.images || [],
171+
})
172+
} else {
173+
// Show the warning dialog for the first time
174+
setEditMessageDialogState({
175+
isOpen: true,
176+
messageTs: message.messageTs,
177+
text: message.text,
178+
images: message.images || [],
179+
})
180+
}
167181
}
168182

169183
if (message.type === "acceptInput") {
@@ -267,6 +281,8 @@ const App = () => {
267281
open={editMessageDialogState.isOpen}
268282
onOpenChange={(open) => setEditMessageDialogState((prev) => ({ ...prev, isOpen: open }))}
269283
onConfirm={() => {
284+
// Mark that the user has seen the edit warning
285+
hasSeenEditWarningRef.current = true
270286
vscode.postMessage({
271287
type: "editMessageConfirm",
272288
messageTs: editMessageDialogState.messageTs,

webview-ui/src/components/chat/ChatRow.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,12 @@ export const ChatRowContent = ({
10821082
</div>
10831083
) : (
10841084
<div className="flex justify-between">
1085-
<div className="flex-grow px-2 py-1 wrap-anywhere">
1085+
<div
1086+
className="flex-grow px-2 py-1 wrap-anywhere"
1087+
onDoubleClick={(e) => {
1088+
e.stopPropagation()
1089+
handleEditClick()
1090+
}}>
10861091
<Mention text={message.text} withShadow />
10871092
</div>
10881093
<div className="flex">

0 commit comments

Comments
 (0)