diff --git a/apps/browser-extension/entrypoints/content/chatgpt.ts b/apps/browser-extension/entrypoints/content/chatgpt.ts index 73e0354f1..203087285 100644 --- a/apps/browser-extension/entrypoints/content/chatgpt.ts +++ b/apps/browser-extension/entrypoints/content/chatgpt.ts @@ -640,6 +640,16 @@ function setupChatGPTPromptCapture() { document.body.setAttribute("data-chatgpt-prompt-capture-setup", "true") const capturePromptContent = async (source: string) => { + const result = await chrome.storage.local.get([ + STORAGE_KEYS.AUTO_CAPTURE_PROMPTS_ENABLED, + ]) + const autoCapturePromptsEnabled = + result[STORAGE_KEYS.AUTO_CAPTURE_PROMPTS_ENABLED] ?? false + + if (!autoCapturePromptsEnabled) { + console.log("Auto capture prompts is disabled, skipping prompt capture") + return + } const promptTextarea = document.getElementById("prompt-textarea") let promptContent = "" diff --git a/apps/browser-extension/entrypoints/content/claude.ts b/apps/browser-extension/entrypoints/content/claude.ts index e0853d413..88874a3f1 100644 --- a/apps/browser-extension/entrypoints/content/claude.ts +++ b/apps/browser-extension/entrypoints/content/claude.ts @@ -488,6 +488,16 @@ function setupClaudePromptCapture() { } document.body.setAttribute("data-claude-prompt-capture-setup", "true") const captureClaudePromptContent = async (source: string) => { + const result = await chrome.storage.local.get([ + STORAGE_KEYS.AUTO_CAPTURE_PROMPTS_ENABLED, + ]) + const autoCapturePromptsEnabled = + result[STORAGE_KEYS.AUTO_CAPTURE_PROMPTS_ENABLED] ?? false + + if (!autoCapturePromptsEnabled) { + console.log("Auto capture prompts is disabled, skipping prompt capture") + return + } let promptContent = "" const contentEditableDiv = document.querySelector( diff --git a/apps/browser-extension/entrypoints/content/t3.ts b/apps/browser-extension/entrypoints/content/t3.ts index 4332076ed..d1229e6dc 100644 --- a/apps/browser-extension/entrypoints/content/t3.ts +++ b/apps/browser-extension/entrypoints/content/t3.ts @@ -115,32 +115,35 @@ function setupT3RouteChangeDetection() { function addSupermemoryIconToT3Input() { const targetContainers = document.querySelectorAll( - ".flex.min-w-0.items-center.gap-2.overflow-hidden", + ".flex.min-w-0.items-center.gap-2", ) - targetContainers.forEach((container) => { - if (container.hasAttribute("data-supermemory-icon-added")) { - return - } - - const existingIcon = container.querySelector( - `#${ELEMENT_IDS.T3_INPUT_BAR_ELEMENT}`, - ) - if (existingIcon) { - container.setAttribute("data-supermemory-icon-added", "true") - return - } - - const supermemoryIcon = createT3InputBarElement(async () => { - await getRelatedMemoriesForT3(POSTHOG_EVENT_KEY.T3_CHAT_MEMORIES_SEARCHED) - }) + const container = targetContainers[0] + if (!container) { + return + } - supermemoryIcon.id = `${ELEMENT_IDS.T3_INPUT_BAR_ELEMENT}-${Date.now()}-${Math.random().toString(36).substring(2, 11)}` + if (container.hasAttribute("data-supermemory-icon-added")) { + return + } + const existingIcon = container.querySelector( + `#${ELEMENT_IDS.T3_INPUT_BAR_ELEMENT}`, + ) + if (existingIcon) { container.setAttribute("data-supermemory-icon-added", "true") + return + } - container.insertBefore(supermemoryIcon, container.firstChild) + const supermemoryIcon = createT3InputBarElement(async () => { + await getRelatedMemoriesForT3(POSTHOG_EVENT_KEY.T3_CHAT_MEMORIES_SEARCHED) }) + + supermemoryIcon.id = `${ELEMENT_IDS.T3_INPUT_BAR_ELEMENT}-${Date.now()}-${Math.random().toString(36).substring(2, 11)}` + + container.setAttribute("data-supermemory-icon-added", "true") + + container.insertBefore(supermemoryIcon, container.firstChild) } async function getRelatedMemoriesForT3(actionSource: string) { @@ -150,11 +153,9 @@ async function getRelatedMemoriesForT3(actionSource: string) { const supermemoryContainer = document.querySelector( '[data-supermemory-icon-added="true"]', ) - if ( - supermemoryContainer?.parentElement?.parentElement?.previousElementSibling - ) { + if (supermemoryContainer?.parentElement?.previousElementSibling) { const textareaElement = - supermemoryContainer.parentElement.parentElement.previousElementSibling.querySelector( + supermemoryContainer.parentElement.previousElementSibling.querySelector( "textarea", ) userQuery = textareaElement?.value || "" @@ -220,12 +221,9 @@ async function getRelatedMemoriesForT3(actionSource: string) { const supermemoryContainer = document.querySelector( '[data-supermemory-icon-added="true"]', ) - if ( - supermemoryContainer?.parentElement?.parentElement - ?.previousElementSibling - ) { + if (supermemoryContainer?.parentElement?.previousElementSibling) { textareaElement = - supermemoryContainer.parentElement.parentElement.previousElementSibling.querySelector( + supermemoryContainer.parentElement.previousElementSibling.querySelector( "textarea", ) } @@ -499,6 +497,16 @@ function setupT3PromptCapture() { document.body.setAttribute("data-t3-prompt-capture-setup", "true") const captureT3PromptContent = async (source: string) => { + const result = await chrome.storage.local.get([ + STORAGE_KEYS.AUTO_CAPTURE_PROMPTS_ENABLED, + ]) + const autoCapturePromptsEnabled = + result[STORAGE_KEYS.AUTO_CAPTURE_PROMPTS_ENABLED] ?? false + + if (!autoCapturePromptsEnabled) { + console.log("Auto capture prompts is disabled, skipping prompt capture") + return + } let promptContent = "" const textarea = document.querySelector("textarea") as HTMLTextAreaElement @@ -601,6 +609,19 @@ function setupT3PromptCapture() { if (promptContent.trim()) { console.log("T3 prompt submitted via Enter key:", promptContent) + const result = await chrome.storage.local.get([ + STORAGE_KEYS.AUTO_CAPTURE_PROMPTS_ENABLED, + ]) + const autoCapturePromptsEnabled = + result[STORAGE_KEYS.AUTO_CAPTURE_PROMPTS_ENABLED] ?? false + + if (!autoCapturePromptsEnabled) { + console.log( + "Auto capture prompts is disabled, skipping prompt capture", + ) + return + } + try { await browser.runtime.sendMessage({ action: MESSAGE_TYPES.CAPTURE_PROMPT, diff --git a/apps/browser-extension/entrypoints/popup/App.tsx b/apps/browser-extension/entrypoints/popup/App.tsx index c6e8468ce..06aee4a41 100644 --- a/apps/browser-extension/entrypoints/popup/App.tsx +++ b/apps/browser-extension/entrypoints/popup/App.tsx @@ -11,6 +11,57 @@ import { } from "../../utils/query-hooks" import type { Project } from "../../utils/types" +const Tooltip = ({ + children, + content, +}: { + children: React.ReactNode + content: string +}) => { + const [isVisible, setIsVisible] = useState(false) + + return ( +
- When enabled, supermemory will search your memories as you - type in ChatGPT, Claude, and T3.chat -
+