diff --git a/extension/app/background.ts b/extension/app/background.ts index 0319dfb9bd20..234bb1996811 100644 --- a/extension/app/background.ts +++ b/extension/app/background.ts @@ -88,6 +88,36 @@ chrome.runtime.onConnect.addListener((port) => { } }); +chrome.runtime.onMessageExternal.addListener((request) => { + console.log("Message received:", request); + if (request.action === "openSidePanel" && request.conversationId) { + chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => { + console.log("Active tab:", tabs[0]); + if (tabs[0]) { + void chrome.sidePanel + .open({ + windowId: tabs[0].windowId, + }) + .then(() => { + // Set a timeout to ensure it's loaded. Ugly but works. + setTimeout(() => { + const params = JSON.stringify({ + conversationId: request.conversationId, + }); + void chrome.runtime.sendMessage({ + type: "EXT_ROUTE_CHANGE", + pathname: "/run", + search: `?${params}`, + }); + }, 1000); + }) + .catch((err) => console.error("Error opening side panel:", err)); + } + }); + } + return true; +}); + const getActionHandler = (menuItemId: string | number) => { switch (menuItemId) { case "ask_dust": diff --git a/extension/app/src/pages/RunPage.tsx b/extension/app/src/pages/RunPage.tsx index 7ccece04a7ec..ae1dbd76d3b0 100644 --- a/extension/app/src/pages/RunPage.tsx +++ b/extension/app/src/pages/RunPage.tsx @@ -16,6 +16,11 @@ export const RunPage = () => { const run = async () => { const params = JSON.parse(decodeURI(location.search.substr(1))); + if (params.conversationId) { + await navigate(`/conversations/${params.conversationId}`); + return; + } + const files = await fileUploaderService.uploadContentTab({ includeContent: params.includeContent, includeCapture: params.includeCapture, diff --git a/extension/manifest.json b/extension/manifest.json index b47e03c5386e..4b993c503414 100644 --- a/extension/manifest.json +++ b/extension/manifest.json @@ -35,5 +35,8 @@ "contextMenus" ], "host_permissions": [""], + "externally_connectable": { + "matches": ["http://localhost:3000/*"] + }, "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu2kn2r/3emY/9AwPzAH0qb1KskhZCqLp4PE3o1PqD1hyLTf9fJ+VC0CPyy3F6bep/6mjVZaN+Ufw7bTn3XFoj3TW+Xg5e/KLg+qUn2pUS973j68IyhyIamydfx90ZZajCU1XwB666+8dFwgB6sy4sGe86WNKu0Be+EDhhVFCFVI2D7CyJjlmQXUXTYDr6U41MsdI1DlDK6jrv6N9IkHKhvq1o06GN0W8CpoPJ554iBHWcw5UYNHi6ySxA+u7OoV58tDkTyVOS9sQ8WGIge3hDmhc2jcUhsJTzkeAS3ijShKVdYC0i+5n5g6SnQ4N7y2xehEYsms0ARqkUkF/QPwmTQIDAQAB" } diff --git a/front/components/UserMenu.tsx b/front/components/UserMenu.tsx index 1cee8476854f..2cd58731f25d 100644 --- a/front/components/UserMenu.tsx +++ b/front/components/UserMenu.tsx @@ -106,6 +106,25 @@ export function UserMenu({ }} /> )} + { + if (typeof window !== "undefined" && window.chrome?.runtime) { + chrome.runtime.sendMessage( + "okjldflokifdjecnhbmkdanjjbnmlihg", + { + action: "openSidePanel", + workspaceId: owner.sId, + conversationId: "M1wNSpqgq9", + }, + (response) => { + console.log("Message sent:", response); + } + ); + } + }} + /> )} diff --git a/front/package-lock.json b/front/package-lock.json index fe208e1d9d4d..ef956d731297 100644 --- a/front/package-lock.json +++ b/front/package-lock.json @@ -33,6 +33,7 @@ "@tiptap/pm": "^2.1.13", "@tiptap/react": "^2.1.13", "@tiptap/starter-kit": "^2.1.13", + "@types/chrome": "^0.0.287", "@uiw/react-textarea-code-editor": "^3.0.2", "auth0": "^4.3.1", "blake3": "^2.1.7", @@ -18354,6 +18355,15 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/chrome": { + "version": "0.0.287", + "resolved": "https://registry.npmjs.org/@types/chrome/-/chrome-0.0.287.tgz", + "integrity": "sha512-wWhBNPNXZHwycHKNYnexUcpSbrihVZu++0rdp6GEk5ZgAglenLx+RwdEouh6FrHS0XQiOxSd62yaujM1OoQlZQ==", + "dependencies": { + "@types/filesystem": "*", + "@types/har-format": "*" + } + }, "node_modules/@types/connect": { "version": "3.4.38", "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz", @@ -18427,6 +18437,19 @@ "@types/send": "*" } }, + "node_modules/@types/filesystem": { + "version": "0.0.36", + "resolved": "https://registry.npmjs.org/@types/filesystem/-/filesystem-0.0.36.tgz", + "integrity": "sha512-vPDXOZuannb9FZdxgHnqSwAG/jvdGM8Wq+6N4D/d80z+D4HWH+bItqsZaVRQykAn6WEVeEkLm2oQigyHtgb0RA==", + "dependencies": { + "@types/filewriter": "*" + } + }, + "node_modules/@types/filewriter": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/@types/filewriter/-/filewriter-0.0.33.tgz", + "integrity": "sha512-xFU8ZXTw4gd358lb2jw25nxY9QAgqn2+bKKjKOYfNCzN4DKCFetK7sPtrlpg66Ywe3vWY9FNxprZawAh9wfJ3g==" + }, "node_modules/@types/formidable": { "version": "3.4.3", "dev": true, @@ -18461,6 +18484,11 @@ "@types/node": "*" } }, + "node_modules/@types/har-format": { + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@types/har-format/-/har-format-1.2.16.tgz", + "integrity": "sha512-fluxdy7ryD3MV6h8pTfTYpy/xQzCFC7m89nOH9y94cNqJ1mDIDPut7MnRHI3F6qRmh/cT2fUjG1MLdCNb4hE9A==" + }, "node_modules/@types/hast": { "version": "2.3.6", "license": "MIT", diff --git a/front/package.json b/front/package.json index 061926a49b0e..2edf5a8bd4f7 100644 --- a/front/package.json +++ b/front/package.json @@ -46,6 +46,7 @@ "@tiptap/pm": "^2.1.13", "@tiptap/react": "^2.1.13", "@tiptap/starter-kit": "^2.1.13", + "@types/chrome": "^0.0.287", "@uiw/react-textarea-code-editor": "^3.0.2", "auth0": "^4.3.1", "blake3": "^2.1.7",