The open source coding agent.
TypeScript
wip: vscode extension
Frank13def91e9ae9
diff --git a/sdks/vscode/src/extension.ts b/sdks/vscode/src/extension.tsindex de10db54d57..49a05f641f1 100644--- a/sdks/vscode/src/extension.ts+++ b/sdks/vscode/src/extension.ts@@ -4,12 +4,14 @@ export function deactivate() {}import * as vscode from "vscode"export function activate(context: vscode.ExtensionContext) {+ const TERMINAL_NAME = "opencode"+// Register command to open terminal in split screen and run opencodelet openTerminalDisposable = vscode.commands.registerCommand("opencode.openTerminal", async () => {// Create a new terminal in split screenconst port = Math.floor(Math.random() * (65535 - 16384 + 1)) + 16384const terminal = vscode.window.createTerminal({- name: "opencode",+ name: TERMINAL_NAME,iconPath: {light: vscode.Uri.file(context.asAbsolutePath("images/button-dark.svg")),dark: vscode.Uri.file(context.asAbsolutePath("images/button-light.svg")),@@ -23,7 +25,7 @@ export function activate(context: vscode.ExtensionContext) {},})- terminal.show(false)+ terminal.show()terminal.sendText(`OPENCODE_THEME=system OPENCODE_CALLER=vscode opencode --port ${port}`)const fileRef = getActiveFile()@@ -46,6 +48,7 @@ export function activate(context: vscode.ExtensionContext) {// If connected, append the prompt to the terminalif (connected) {await appendPrompt(port, `In ${fileRef}`)+ terminal.show()}})@@ -57,12 +60,12 @@ export function activate(context: vscode.ExtensionContext) {const terminal = vscode.window.activeTerminalif (!terminal) return- // @ts-ignore- const port = terminal.creationOptions.env?.["_EXTENSION_OPENCODE_PORT"]- if (!port) return-- await appendPrompt(parseInt(port), fileRef)- terminal.show()+ if (terminal.name === TERMINAL_NAME) {+ // @ts-ignore+ const port = terminal.creationOptions.env?.["_EXTENSION_OPENCODE_PORT"]+ port ? await appendPrompt(parseInt(port), fileRef) : terminal.sendText(fileRef)+ terminal.show()+ }})context.subscriptions.push(openTerminalDisposable, addFilepathDisposable)