From 7408fcadcc7494b35b5313f997e0b100631dedcf Mon Sep 17 00:00:00 2001
From: Maximilian Hubert <64627729+gap-editor@users.noreply.github.com>
Date: Tue, 8 Apr 2025 20:12:20 +0200
Subject: [PATCH 1/6] Update remix-ui-editor.tsx
---
.../editor/src/lib/remix-ui-editor.tsx | 59 +++++++++++++++----
1 file changed, 49 insertions(+), 10 deletions(-)
diff --git a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx
index 35b23bc5541..a2204d27c8e 100644
--- a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx
+++ b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx
@@ -648,25 +648,43 @@ export const EditorUI = (props: EditorUIProps) => {
})
editor.onDidPaste(async (e) => {
- if (!pasteCodeRef.current && e && e.range && e.range.startLineNumber >= 0 && e.range.endLineNumber >= 0 && e.range.endLineNumber - e.range.startLineNumber > 10) {
+ // Only show the modal if the user hasn't opted out
+ if (showPasteWarning && !pasteCodeRef.current && e && e.range && e.range.startLineNumber >= 0 && e.range.endLineNumber >= 0 && e.range.endLineNumber - e.range.startLineNumber > 10) {
// get the file name
const pastedCode = editor.getModel().getValueInRange(e.range)
const pastedCodePrompt = intl.formatMessage({ id: 'editor.PastedCodeSafety' }, { content:pastedCode })
+ // State for the checkbox inside this specific modal instance
+ let dontShowAgainChecked = false;
+
+ const handleClose = (askAI = false) => {
+ if (dontShowAgainChecked) {
+ try {
+ localStorage.setItem(HIDE_PASTE_WARNING_KEY, 'true');
+ setShowPasteWarning(false); // Update state to prevent future modals in this session
+ } catch (e) {
+ console.error("Failed to write to localStorage:", e);
+ }
+ }
+ if (askAI) {
+ // Proceed with the original okFn logic
+ (async () => {
+ await props.plugin.call('popupPanel', 'showPopupPanel', true)
+ setTimeout(async () => {
+ props.plugin.call('remixAI', 'chatPipe', 'vulnerability_check', pastedCodePrompt)
+ }, 500)
+ _paq.push(['trackEvent', 'ai', 'remixAI', 'vulnerability_check_pasted_code'])
+ })();
+ }
+ };
+
const modalContent: AppModal = {
id: 'newCodePasted',
title: "New code pasted",
okLabel: 'Ask RemixAI',
cancelLabel: 'Close',
- cancelFn: () => {},
- okFn: async () => {
- await props.plugin.call('popupPanel', 'showPopupPanel', true)
- setTimeout(async () => {
- props.plugin.call('remixAI', 'chatPipe', 'vulnerability_check', pastedCodePrompt)
- }, 500)
- // add matamo event
- _paq.push(['trackEvent', 'ai', 'remixAI', 'vulnerability_check_pasted_code'])
- },
+ cancelFn: () => handleClose(false), // Pass false for askAI
+ okFn: () => handleClose(true), // Pass true for askAI
message: (
{' '}
@@ -696,6 +714,18 @@ export const EditorUI = (props: EditorUIProps) => {
/>
+ {/* Added Checkbox section below */}
+
+
+
)
}
@@ -1049,6 +1079,15 @@ export const EditorUI = (props: EditorUIProps) => {
loadTypes(monacoRef.current)
}
+ const [showPasteWarning, setShowPasteWarning] = useState(() => {
+ try {
+ return localStorage.getItem(HIDE_PASTE_WARNING_KEY) !== 'true';
+ } catch (e) {
+ console.error("Failed to access localStorage:", e);
+ return true; // Default to showing the warning if localStorage fails
+ }
+ });
+
return (
From 46e9491bebca0faa661291a08705b2f21ef48f94 Mon Sep 17 00:00:00 2001
From: Maximilian Hubert <64627729+gap-editor@users.noreply.github.com>
Date: Mon, 28 Apr 2025 00:58:39 +0200
Subject: [PATCH 2/6] Update remix-ui-editor.tsx
---
libs/remix-ui/editor/src/lib/remix-ui-editor.tsx | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx
index a2204d27c8e..c24bd6a0bed 100644
--- a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx
+++ b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx
@@ -29,6 +29,9 @@ import { RemixInLineCompletionProvider } from './providers/inlineCompletionProvi
import { providers } from 'ethers'
const _paq = (window._paq = window._paq || [])
+// Key for localStorage
+const HIDE_PASTE_WARNING_KEY = 'remixide.hide_paste_warning';
+
enum MarkerSeverity {
Hint = 1,
Info = 2,
@@ -669,11 +672,11 @@ export const EditorUI = (props: EditorUIProps) => {
if (askAI) {
// Proceed with the original okFn logic
(async () => {
- await props.plugin.call('popupPanel', 'showPopupPanel', true)
- setTimeout(async () => {
- props.plugin.call('remixAI', 'chatPipe', 'vulnerability_check', pastedCodePrompt)
- }, 500)
- _paq.push(['trackEvent', 'ai', 'remixAI', 'vulnerability_check_pasted_code'])
+ await props.plugin.call('popupPanel', 'showPopupPanel', true)
+ setTimeout(async () => {
+ props.plugin.call('remixAI', 'chatPipe', 'vulnerability_check', pastedCodePrompt)
+ }, 500)
+ _paq.push(['trackEvent', 'ai', 'remixAI', 'vulnerability_check_pasted_code'])
})();
}
};
From 073a0f01e6589e77f46127c5f8f39442260b2bc7 Mon Sep 17 00:00:00 2001
From: Maximilian Hubert <64627729+gap-editor@users.noreply.github.com>
Date: Mon, 28 Apr 2025 14:57:41 +0200
Subject: [PATCH 3/6] Update remix-ui-editor.tsx
---
libs/remix-ui/editor/src/lib/remix-ui-editor.tsx | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx
index c24bd6a0bed..6213382bfc0 100644
--- a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx
+++ b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx
@@ -670,13 +670,13 @@ export const EditorUI = (props: EditorUIProps) => {
}
}
if (askAI) {
- // Proceed with the original okFn logic
+ // Proceed with the original okFn logic
(async () => {
- await props.plugin.call('popupPanel', 'showPopupPanel', true)
- setTimeout(async () => {
- props.plugin.call('remixAI', 'chatPipe', 'vulnerability_check', pastedCodePrompt)
- }, 500)
- _paq.push(['trackEvent', 'ai', 'remixAI', 'vulnerability_check_pasted_code'])
+ await props.plugin.call('popupPanel', 'showPopupPanel', true)
+ setTimeout(async () => {
+ props.plugin.call('remixAI', 'chatPipe', 'vulnerability_check', pastedCodePrompt)
+ }, 500)
+ _paq.push(['trackEvent', 'ai', 'remixAI', 'vulnerability_check_pasted_code'])
})();
}
};
@@ -687,7 +687,7 @@ export const EditorUI = (props: EditorUIProps) => {
okLabel: 'Ask RemixAI',
cancelLabel: 'Close',
cancelFn: () => handleClose(false), // Pass false for askAI
- okFn: () => handleClose(true), // Pass true for askAI
+ okFn: () => handleClose(true), // Pass true for askAI
message: (
{' '}
From 3d1988c1b03a58a5bd0be30871df670e3c23fae4 Mon Sep 17 00:00:00 2001
From: Maximilian Hubert <64627729+gap-editor@users.noreply.github.com>
Date: Wed, 7 May 2025 23:16:28 +0200
Subject: [PATCH 4/6] Update remix-ui-editor.tsx
---
.../editor/src/lib/remix-ui-editor.tsx | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx
index 3c679b86c61..534387270e4 100644
--- a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx
+++ b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx
@@ -718,15 +718,15 @@ export const EditorUI = (props: EditorUIProps) => {
{/* Added Checkbox section below */}
-
+
)
From a3e3f30cbe28e012a4cf6780cb657664502d2ae2 Mon Sep 17 00:00:00 2001
From: Maximilian Hubert <64627729+gap-editor@users.noreply.github.com>
Date: Thu, 8 May 2025 20:48:25 +0200
Subject: [PATCH 5/6] Update remix-ui-editor.tsx
From 39469fffd8072654624c97bdae0bd5fb9deebe70 Mon Sep 17 00:00:00 2001
From: STetsing <41009393+STetsing@users.noreply.github.com>
Date: Mon, 19 May 2025 11:48:44 +0200
Subject: [PATCH 6/6] Update remix-ui-editor.tsx
lint
---
libs/remix-ui/editor/src/lib/remix-ui-editor.tsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx
index 2ed9155bc15..70cedff637f 100644
--- a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx
+++ b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx
@@ -665,7 +665,7 @@ export const EditorUI = (props: EditorUIProps) => {
localStorage.setItem(HIDE_PASTE_WARNING_KEY, 'true');
setShowPasteWarning(false); // Update state to prevent future modals in this session
} catch (e) {
- console.error("Failed to write to localStorage:", e);
+ console.error("Failed to write to localStorage:", e);
}
}
if (askAI) {
@@ -686,7 +686,7 @@ export const EditorUI = (props: EditorUIProps) => {
okLabel: 'Ask RemixAI',
cancelLabel: 'Close',
cancelFn: () => handleClose(false), // Pass false for askAI
- okFn: () => handleClose(true), // Pass true for askAI
+ okFn: () => handleClose(true), // Pass true for askAI
message: (
{' '}