VSCode Chatgpt Easy Copy Review
VSCode Chatgpt Easy Copy is a utility designed to streamline the process of copying code/text and files from Visual Studio Code (VSCode) directly into a ChatGPT tab on the Chrome browser. To utilize this tool efficiently, users need to install both the Chrome extension and the corresponding VSCode extension. The VSCode extension establishes a websocket server at port 8765, which the Chrome extension connects to. When a command is executed, selected text or file contents are transmitted via websocket to the Chrome extension, which then interacts with ChatGPT's DOM to input the data into the prompt textarea.
The core logic of the Chrome extension lies in the Service Worker, which manages the websocket connection to the VSCode extension and handles DOM manipulation for ChatGPT. To prevent the service worker from becoming inactive, a keepalive message is sent every 20 seconds. Additionally, a Content Script named Ping Server Worker ensures the service worker remains active even when VSCode is not open, by sending a ping message every 20 seconds.