diff --git a/sdks/vscode/src/extension.ts b/sdks/vscode/src/extension.ts index 693e7267e50..e51ab0c8705 100644 --- a/sdks/vscode/src/extension.ts +++ b/sdks/vscode/src/extension.ts @@ -33,9 +33,7 @@ export function activate(context: vscode.ExtensionContext) { } if (terminal.name === TERMINAL_NAME) { - // @ts-ignore - const port = terminal.creationOptions.env?.["_EXTENSION_OPENCODE_PORT"] - port ? await appendPrompt(parseInt(port), fileRef) : terminal.sendText(fileRef, false) + terminal.sendText(fileRef, false) terminal.show() } }) @@ -44,7 +42,6 @@ export function activate(context: vscode.ExtensionContext) { async function openTerminal() { // Create a new terminal in split screen - const port = Math.floor(Math.random() * (65535 - 16384 + 1)) + 16384 const terminal = vscode.window.createTerminal({ name: TERMINAL_NAME, iconPath: { @@ -56,48 +53,12 @@ export function activate(context: vscode.ExtensionContext) { preserveFocus: false, }, env: { - _EXTENSION_OPENCODE_PORT: port.toString(), OPENCODE_CALLER: "vscode", }, }) terminal.show() - terminal.sendText(`opencode --port ${port}`) - - const fileRef = getActiveFile() - if (!fileRef) { - return - } - - // Wait for the terminal to be ready - let tries = 10 - let connected = false - do { - await new Promise((resolve) => setTimeout(resolve, 200)) - try { - await fetch(`http://localhost:${port}/app`) - connected = true - break - } catch {} - - tries-- - } while (tries > 0) - - // If connected, append the prompt to the terminal - if (connected) { - await appendPrompt(port, `In ${fileRef}`) - terminal.show() - } - } - - async function appendPrompt(port: number, text: string) { - await fetch(`http://localhost:${port}/tui/append-prompt`, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ text }), - }) + terminal.sendText("opencode") } function getActiveFile() {