Changesets · Branches · Tags · Compare
| Changeset | 4af4016b5aa3fccabd3997560a63b0a10b6305e201d5feb29457e4cec4a1be63 |
|---|---|
| Author | Dallin Romney <dallinromney@gmail.com> · 2025-09-22 16:28 -07:00 |
| Committer | GitHub <noreply@github.com> · 2025-09-22 16:28 -07:00 |
| Parents | f447b1445b80 |
9 files changed
modified .vscode/launch.json +1 −1
| @@ -18,7 +18,7 @@ | ||
| 18 | 18 | ], |
| 19 | 19 | "pauseForSourceMap": false, |
| 20 | 20 | "outFiles": ["${workspaceFolder}/extensions/vscode/out/extension.js"], |
| 21 | - "preLaunchTask": "vscode-extension:build-without-watch", | |
| 21 | + "preLaunchTask": "vscode-extension:build-with-packages", | |
| 22 | 22 | "env": { |
| 23 | 23 | // "CONTROL_PLANE_ENV": "local", |
| 24 | 24 | "CONTINUE_GLOBAL_DIR": "${workspaceFolder}/extensions/.continue-debug" |
modified .vscode/tasks.json +0 −19
| @@ -174,25 +174,6 @@ | ||
| 174 | 174 | } |
| 175 | 175 | ] |
| 176 | 176 | }, |
| 177 | - { | |
| 178 | - "label": "gui:build", | |
| 179 | - "type": "shell", | |
| 180 | - "command": "npm", | |
| 181 | - "options": { | |
| 182 | - "cwd": "${workspaceFolder}/gui", | |
| 183 | - "env": { | |
| 184 | - "NODE_OPTIONS": "--max-old-space-size=4096" | |
| 185 | - } | |
| 186 | - }, | |
| 187 | - "args": ["run", "build"], | |
| 188 | - "problemMatcher": ["$tsc"], | |
| 189 | - "presentation": { | |
| 190 | - "group": "build-tasks", | |
| 191 | - "panel": "shared", | |
| 192 | - "reveal": "silent", | |
| 193 | - "close": true | |
| 194 | - } | |
| 195 | - }, | |
| 196 | 177 | { |
| 197 | 178 | "label": "binary:esbuild", |
| 198 | 179 | "type": "shell", |
modified core/protocol/ide.ts +0 −1
| @@ -51,7 +51,6 @@ | ||
| 51 | 51 | getPinnedFiles: [undefined, string[]]; |
| 52 | 52 | showLines: [{ filepath: string; startLine: number; endLine: number }, void]; |
| 53 | 53 | readRangeInFile: [{ filepath: string; range: Range }, string]; |
| 54 | - readFileAsDataUrl: [{ filepath: string }, string]; | |
| 55 | 54 | getDiff: [{ includeUnstaged: boolean }, string[]]; |
| 56 | 55 | getTerminalContents: [undefined, string]; |
| 57 | 56 | getDebugLocals: [{ threadIndex: number }, string]; |
modified extensions/vscode/src/extension/VsCodeMessenger.ts +0 −12
| @@ -295,18 +295,6 @@ | ||
| 295 | 295 | }); |
| 296 | 296 | }); |
| 297 | 297 | |
| 298 | - this.onWebviewOrCore("readFileAsDataUrl", async (msg) => { | |
| 299 | - const { filepath } = msg.data; | |
| 300 | - const fileUri = vscode.Uri.file(filepath); | |
| 301 | - const fileContents = await vscode.workspace.fs.readFile(fileUri); | |
| 302 | - const fileType = | |
| 303 | - filepath.split(".").pop() === "png" ? "image/png" : "image/jpeg"; | |
| 304 | - const dataUrl = `data:${fileType};base64,${Buffer.from( | |
| 305 | - fileContents, | |
| 306 | - ).toString("base64")}`; | |
| 307 | - return dataUrl; | |
| 308 | - }); | |
| 309 | - | |
| 310 | 298 | this.onWebviewOrCore("getIdeSettings", async (msg) => { |
| 311 | 299 | return ide.getIdeSettings(); |
| 312 | 300 | }); |
modified gui/src/components/mainInput/TipTapEditor/TipTapEditor.tsx +31 −13
| @@ -57,13 +57,10 @@ | ||
| 57 | 57 | const historyLength = useAppSelector((store) => store.session.history.length); |
| 58 | 58 | const isInEdit = useAppSelector((store) => store.session.isInEdit); |
| 59 | 59 | |
| 60 | - const [showDragOverMsg, setShowDragOverMsg] = useState(false); | |
| 61 | - | |
| 62 | 60 | const { editor, onEnterRef } = createEditorConfig({ |
| 63 | 61 | props, |
| 64 | 62 | ideMessenger, |
| 65 | 63 | dispatch, |
| 66 | - setShowDragOverMsg, | |
| 67 | 64 | }); |
| 68 | 65 | |
| 69 | 66 | // Register the main editor with the provider |
| @@ -140,6 +137,8 @@ | ||
| 140 | 137 | } |
| 141 | 138 | }, [isStreaming, props.isMainInput]); |
| 142 | 139 | |
| 140 | + const [showDragOverMsg, setShowDragOverMsg] = useState(false); | |
| 141 | + | |
| 143 | 142 | const [activeKey, setActiveKey] = useState<string | null>(null); |
| 144 | 143 | |
| 145 | 144 | const insertCharacterWithWhitespace = useCallback( |
| @@ -222,23 +221,40 @@ | ||
| 222 | 221 | if (e.shiftKey) { |
| 223 | 222 | setShowDragOverMsg(false); |
| 224 | 223 | } else { |
| 225 | - setTimeout(() => { | |
| 226 | - setShowDragOverMsg(false); | |
| 227 | - }, 2000); | |
| 224 | + setTimeout(() => setShowDragOverMsg(false), 2000); | |
| 228 | 225 | } |
| 229 | 226 | } |
| 230 | - setShowDragOverMsg(false); | |
| 231 | 227 | }} |
| 232 | 228 | onDragEnter={() => { |
| 233 | 229 | setShowDragOverMsg(true); |
| 234 | 230 | }} |
| 235 | - onDragEnd={() => { | |
| 236 | - setShowDragOverMsg(false); | |
| 237 | - }} | |
| 238 | 231 | onDrop={(event) => { |
| 239 | - // Just hide the drag overlay - ProseMirror handles the actual drop | |
| 240 | 232 | setShowDragOverMsg(false); |
| 241 | - // Let the event bubble to ProseMirror by not preventing default | |
| 233 | + if ( | |
| 234 | + !defaultModel || | |
| 235 | + !modelSupportsImages( | |
| 236 | + defaultModel.provider, | |
| 237 | + defaultModel.model, | |
| 238 | + defaultModel.title, | |
| 239 | + defaultModel.capabilities, | |
| 240 | + ) | |
| 241 | + ) { | |
| 242 | + return; | |
| 243 | + } | |
| 244 | + let file = event.dataTransfer.files[0]; | |
| 245 | + void handleImageFile(ideMessenger, file).then((result) => { | |
| 246 | + if (!editor) { | |
| 247 | + return; | |
| 248 | + } | |
| 249 | + if (result) { | |
| 250 | + const [_, dataUrl] = result; | |
| 251 | + const { schema } = editor.state; | |
| 252 | + const node = schema.nodes.image.create({ src: dataUrl }); | |
| 253 | + const tr = editor.state.tr.insert(0, node); | |
| 254 | + editor.view.dispatch(tr); | |
| 255 | + } | |
| 256 | + }); | |
| 257 | + event.preventDefault(); | |
| 242 | 258 | }} |
| 243 | 259 | > |
| 244 | 260 | <div className="px-2.5 pb-1 pt-2"> |
| @@ -283,7 +299,9 @@ | ||
| 283 | 299 | defaultModel?.model || "", |
| 284 | 300 | defaultModel?.title, |
| 285 | 301 | defaultModel?.capabilities, |
| 286 | - ) && <DragOverlay show={showDragOverMsg} />} | |
| 302 | + ) && ( | |
| 303 | + <DragOverlay show={showDragOverMsg} setShow={setShowDragOverMsg} /> | |
| 304 | + )} | |
| 287 | 305 | <div id={TIPPY_DIV_ID} className="fixed z-50" /> |
| 288 | 306 | </InputBoxDiv> |
| 289 | 307 | ); |
modified gui/src/components/mainInput/TipTapEditor/components/DragOverlay.tsx +25 −2
| @@ -1,11 +1,34 @@ | ||
| 1 | -import React from "react"; | |
| 1 | +import React, { useEffect } from "react"; | |
| 2 | 2 | import { HoverDiv, HoverTextDiv } from "./StyledComponents"; |
| 3 | 3 | |
| 4 | 4 | interface DragOverlayProps { |
| 5 | 5 | show: boolean; |
| 6 | + setShow: (show: boolean) => void; | |
| 6 | 7 | } |
| 7 | 8 | |
| 8 | -export const DragOverlay: React.FC<DragOverlayProps> = ({ show }) => { | |
| 9 | +export const DragOverlay: React.FC<DragOverlayProps> = ({ show, setShow }) => { | |
| 10 | + useEffect(() => { | |
| 11 | + const overListener = (event: DragEvent) => { | |
| 12 | + if (event.shiftKey) return; | |
| 13 | + setShow(true); | |
| 14 | + }; | |
| 15 | + window.addEventListener("dragover", overListener); | |
| 16 | + | |
| 17 | + const leaveListener = (event: DragEvent) => { | |
| 18 | + if (event.shiftKey) { | |
| 19 | + setShow(false); | |
| 20 | + } else { | |
| 21 | + setTimeout(() => setShow(false), 2000); | |
| 22 | + } | |
| 23 | + }; | |
| 24 | + window.addEventListener("dragleave", leaveListener); | |
| 25 | + | |
| 26 | + return () => { | |
| 27 | + window.removeEventListener("dragover", overListener); | |
| 28 | + window.removeEventListener("dragleave", leaveListener); | |
| 29 | + }; | |
| 30 | + }, []); | |
| 31 | + | |
| 9 | 32 | if (!show) return null; |
| 10 | 33 | |
| 11 | 34 | return ( |
modified gui/src/components/mainInput/TipTapEditor/components/StyledComponents.ts +0 −2
| @@ -56,7 +56,6 @@ | ||
| 56 | 56 | display: flex; |
| 57 | 57 | align-items: center; |
| 58 | 58 | justify-content: center; |
| 59 | - pointer-events: none; | |
| 60 | 59 | `; |
| 61 | 60 | |
| 62 | 61 | export const HoverTextDiv = styled.div` |
| @@ -69,5 +68,4 @@ | ||
| 69 | 68 | display: flex; |
| 70 | 69 | align-items: center; |
| 71 | 70 | justify-content: center; |
| 72 | - pointer-events: none; | |
| 73 | 71 | `; |
modified gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts +2 −77
| @@ -27,7 +27,7 @@ | ||
| 27 | 27 | getContextProviderDropdownOptions, |
| 28 | 28 | getSlashCommandDropdownOptions, |
| 29 | 29 | } from "./getSuggestion"; |
| 30 | -import { handleImageFile, handleVSCodeResourceFromHtml } from "./imageUtils"; | |
| 30 | +import { handleImageFile } from "./imageUtils"; | |
| 31 | 31 | |
| 32 | 32 | export function getPlaceholderText( |
| 33 | 33 | placeholder: TipTapEditorProps["placeholder"], |
| @@ -69,9 +69,8 @@ | ||
| 69 | 69 | props: TipTapEditorProps; |
| 70 | 70 | ideMessenger: IIdeMessenger; |
| 71 | 71 | dispatch: AppDispatch; |
| 72 | - setShowDragOverMsg: (show: boolean) => void; | |
| 73 | 72 | }) { |
| 74 | - const { props, ideMessenger, dispatch, setShowDragOverMsg } = options; | |
| 73 | + const { props, ideMessenger, dispatch } = options; | |
| 75 | 74 | |
| 76 | 75 | const posthog = usePostHog(); |
| 77 | 76 | |
| @@ -148,80 +147,6 @@ | ||
| 148 | 147 | const plugin = new Plugin({ |
| 149 | 148 | props: { |
| 150 | 149 | handleDOMEvents: { |
| 151 | - drop(view, event) { | |
| 152 | - // Hide drag overlay immediately when drop is handled | |
| 153 | - setShowDragOverMsg(false); | |
| 154 | - | |
| 155 | - // Get current model and check if it supports images | |
| 156 | - const model = defaultModelRef.current; | |
| 157 | - if ( | |
| 158 | - !model || | |
| 159 | - !modelSupportsImages( | |
| 160 | - model.provider, | |
| 161 | - model.model, | |
| 162 | - model.title, | |
| 163 | - model.capabilities, | |
| 164 | - ) | |
| 165 | - ) { | |
| 166 | - event.preventDefault(); | |
| 167 | - event.stopPropagation(); | |
| 168 | - return true; | |
| 169 | - } | |
| 170 | - | |
| 171 | - event.preventDefault(); | |
| 172 | - event.stopPropagation(); | |
| 173 | - | |
| 174 | - // Check if dataTransfer exists | |
| 175 | - if (!event.dataTransfer) { | |
| 176 | - return true; | |
| 177 | - } | |
| 178 | - | |
| 179 | - // Handle file drop first | |
| 180 | - if (event.dataTransfer.files.length > 0) { | |
| 181 | - const file = event.dataTransfer.files[0]; | |
| 182 | - void handleImageFile(ideMessenger, file).then((result) => { | |
| 183 | - if (result) { | |
| 184 | - const [_, dataUrl] = result; | |
| 185 | - const { schema } = view.state; | |
| 186 | - const node = schema.nodes.image.create({ | |
| 187 | - src: dataUrl, | |
| 188 | - }); | |
| 189 | - const tr = view.state.tr.insert(0, node); | |
| 190 | - view.dispatch(tr); | |
| 191 | - } | |
| 192 | - }); | |
| 193 | - return true; | |
| 194 | - } | |
| 195 | - | |
| 196 | - // Handle drop of HTML content (including VS Code resource URLs) | |
| 197 | - const html = event.dataTransfer.getData("text/html"); | |
| 198 | - if (html) { | |
| 199 | - void handleVSCodeResourceFromHtml(ideMessenger, html) | |
| 200 | - .then((dataUrl) => { | |
| 201 | - if (dataUrl) { | |
| 202 | - const { schema } = view.state; | |
| 203 | - const node = schema.nodes.image.create({ | |
| 204 | - src: dataUrl, | |
| 205 | - }); | |
| 206 | - const tr = view.state.tr.insert(0, node); | |
| 207 | - view.dispatch(tr); | |
| 208 | - } | |
| 209 | - }) | |
| 210 | - .catch((err) => | |
| 211 | - console.error( | |
| 212 | - "Failed to handle VS Code resource:", | |
| 213 | - err, | |
| 214 | - ), | |
| 215 | - ); | |
| 216 | - } | |
| 217 | - | |
| 218 | - return true; | |
| 219 | - }, | |
| 220 | - dragover(view, event) { | |
| 221 | - // Allow dragover for proper drop handling | |
| 222 | - event.preventDefault(); | |
| 223 | - return true; | |
| 224 | - }, | |
| 225 | 150 | paste(view, event) { |
| 226 | 151 | const model = defaultModelRef.current; |
| 227 | 152 | if (!model) return; |
modified gui/src/components/mainInput/TipTapEditor/utils/imageUtils.ts +0 −153
| @@ -2,159 +2,6 @@ | ||
| 2 | 2 | |
| 3 | 3 | const IMAGE_RESOLUTION = 1024; |
| 4 | 4 | |
| 5 | -/** | |
| 6 | - * Extracts the file path from a VS Code resource URL | |
| 7 | - * Example: "https://file+.vscode-resource.vscode-cdn.net/Users/path/to/file.jpg?version=123" | |
| 8 | - * Returns: "/Users/path/to/file.jpg" | |
| 9 | - */ | |
| 10 | -export function extractFilePathFromVSCodeResourceUrl( | |
| 11 | - url: string, | |
| 12 | -): string | null { | |
| 13 | - try { | |
| 14 | - const urlObj = new URL(url); | |
| 15 | - if (urlObj.hostname === "file+.vscode-resource.vscode-cdn.net") { | |
| 16 | - return decodeURIComponent(urlObj.pathname); | |
| 17 | - } | |
| 18 | - return null; | |
| 19 | - } catch (error) { | |
| 20 | - console.error("Error parsing VS Code resource URL:", error); | |
| 21 | - return null; | |
| 22 | - } | |
| 23 | -} | |
| 24 | - | |
| 25 | -/** | |
| 26 | - * Handles VS Code resource URLs by converting them to data URLs | |
| 27 | - * @param ideMessenger - The IDE messenger to communicate with VS Code | |
| 28 | - * @param vscodeResourceUrl - The VS Code resource URL | |
| 29 | - * @returns Promise with the data URL if successful, undefined otherwise | |
| 30 | - */ | |
| 31 | -export async function handleVSCodeResourceUrl( | |
| 32 | - ideMessenger: IIdeMessenger, | |
| 33 | - vscodeResourceUrl: string, | |
| 34 | -): Promise<string | undefined> { | |
| 35 | - const filepath = extractFilePathFromVSCodeResourceUrl(vscodeResourceUrl); | |
| 36 | - if (!filepath) { | |
| 37 | - console.error( | |
| 38 | - "Could not extract file path from VS Code resource URL:", | |
| 39 | - vscodeResourceUrl, | |
| 40 | - ); | |
| 41 | - return undefined; | |
| 42 | - } | |
| 43 | - | |
| 44 | - console.log("Extracted filepath:", filepath); | |
| 45 | - | |
| 46 | - try { | |
| 47 | - console.log("Requesting readFileAsDataUrl for filepath:", filepath); | |
| 48 | - console.log("About to call ideMessenger.request..."); | |
| 49 | - | |
| 50 | - // Add a timeout wrapper to prevent hanging | |
| 51 | - const timeoutPromise = new Promise((_, reject) => | |
| 52 | - setTimeout( | |
| 53 | - () => reject(new Error("Request timeout after 10 seconds")), | |
| 54 | - 10000, | |
| 55 | - ), | |
| 56 | - ); | |
| 57 | - | |
| 58 | - const requestPromise = ideMessenger.request("readFileAsDataUrl", { | |
| 59 | - filepath, | |
| 60 | - }); | |
| 61 | - | |
| 62 | - console.log("Request promise created, waiting for response..."); | |
| 63 | - | |
| 64 | - const response = await Promise.race([requestPromise, timeoutPromise]); | |
| 65 | - | |
| 66 | - console.log("Got response from ideMessenger.request:", response); | |
| 67 | - console.log("Response type:", typeof response); | |
| 68 | - | |
| 69 | - // The response should be a WebviewSingleMessage which has status and content | |
| 70 | - if (response && typeof response === "object" && "status" in response) { | |
| 71 | - const typedResponse = response as { | |
| 72 | - status: string; | |
| 73 | - error?: string; | |
| 74 | - content?: string; | |
| 75 | - }; | |
| 76 | - if (typedResponse.status === "error") { | |
| 77 | - console.error("Error reading file as data URL:", typedResponse.error); | |
| 78 | - return undefined; | |
| 79 | - } | |
| 80 | - | |
| 81 | - if (typedResponse.status === "success" && typedResponse.content) { | |
| 82 | - const dataUrl = typedResponse.content; | |
| 83 | - console.log( | |
| 84 | - "Successfully got data URL for file, content length:", | |
| 85 | - dataUrl.length, | |
| 86 | - ); | |
| 87 | - return dataUrl; | |
| 88 | - } | |
| 89 | - } | |
| 90 | - | |
| 91 | - // If response is directly a string (shouldn't happen based on protocol but just in case) | |
| 92 | - if (typeof response === "string") { | |
| 93 | - console.log("Got direct string response, length:", response.length); | |
| 94 | - return response; | |
| 95 | - } | |
| 96 | - | |
| 97 | - console.error("Unexpected response format:", response); | |
| 98 | - return undefined; | |
| 99 | - } catch (error) { | |
| 100 | - console.error("Exception caught when reading file as data URL:", error); | |
| 101 | - console.error( | |
| 102 | - "Error stack:", | |
| 103 | - error instanceof Error ? error.stack : "No stack trace", | |
| 104 | - ); | |
| 105 | - return undefined; | |
| 106 | - } | |
| 107 | -} | |
| 108 | - | |
| 109 | -/** | |
| 110 | - * Extracts VS Code resource URL from HTML content | |
| 111 | - * @param html - HTML string that may contain VS Code resource URLs | |
| 112 | - * @returns The VS Code resource URL if found, null otherwise | |
| 113 | - */ | |
| 114 | -export function extractVSCodeResourceUrlFromHtml(html: string): string | null { | |
| 115 | - try { | |
| 116 | - // Create a temporary DOM element to parse the HTML | |
| 117 | - const tempDiv = document.createElement("div"); | |
| 118 | - tempDiv.innerHTML = html; | |
| 119 | - | |
| 120 | - // Look for img tags with VS Code resource URLs | |
| 121 | - const imgTags = tempDiv.querySelectorAll("img"); | |
| 122 | - for (const img of imgTags) { | |
| 123 | - const src = img.getAttribute("src"); | |
| 124 | - if (src && src.includes("file+.vscode-resource.vscode-cdn.net")) { | |
| 125 | - return src; | |
| 126 | - } | |
| 127 | - } | |
| 128 | - | |
| 129 | - return null; | |
| 130 | - } catch (error) { | |
| 131 | - console.error("Error parsing HTML for VS Code resource URL:", error); | |
| 132 | - return null; | |
| 133 | - } | |
| 134 | -} | |
| 135 | - | |
| 136 | -/** | |
| 137 | - * Handles HTML content that contains VS Code resource URLs and converts them to usable data URLs | |
| 138 | - * @param ideMessenger - The IDE messenger to communicate with VS Code | |
| 139 | - * @param html - HTML string containing VS Code resource URLs | |
| 140 | - * @returns Promise with the data URL if successful, undefined otherwise | |
| 141 | - */ | |
| 142 | -export async function handleVSCodeResourceFromHtml( | |
| 143 | - ideMessenger: IIdeMessenger, | |
| 144 | - html: string, | |
| 145 | -): Promise<string | undefined> { | |
| 146 | - console.log("Processing HTML for VS Code resource URL:", html); | |
| 147 | - | |
| 148 | - const vscodeResourceUrl = extractVSCodeResourceUrlFromHtml(html); | |
| 149 | - if (!vscodeResourceUrl) { | |
| 150 | - console.log("No VS Code resource URL found in HTML"); | |
| 151 | - return undefined; | |
| 152 | - } | |
| 153 | - | |
| 154 | - console.log("Found VS Code resource URL:", vscodeResourceUrl); | |
| 155 | - return await handleVSCodeResourceUrl(ideMessenger, vscodeResourceUrl); | |
| 156 | -} | |
| 157 | - | |
| 158 | 5 | export function getDataUrlForFile( |
| 159 | 6 | file: File, |
| 160 | 7 | img: HTMLImageElement, |