diff options
| author | Frank <[email protected]> | 2025-07-22 15:36:55 -0400 |
|---|---|---|
| committer | Frank <[email protected]> | 2025-07-22 15:36:55 -0400 |
| commit | 13def91e9ae967e6ee2c14ae259260149c2d7e1f (patch) | |
| tree | 0068a00f606b8910edfd55f9dbce11e9d03a1745 | |
| parent | 26a40610ddbb9eaf77c8df4eaf4466a3e04bfa0e (diff) | |
| download | opencode-13def91e9ae967e6ee2c14ae259260149c2d7e1f.tar.gz opencode-13def91e9ae967e6ee2c14ae259260149c2d7e1f.zip | |
wip: vscode extension
| -rw-r--r-- | sdks/vscode/src/extension.ts | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/sdks/vscode/src/extension.ts b/sdks/vscode/src/extension.ts index de10db54d..49a05f641 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 opencode let openTerminalDisposable = vscode.commands.registerCommand("opencode.openTerminal", async () => { // Create a new terminal in split screen const port = Math.floor(Math.random() * (65535 - 16384 + 1)) + 16384 const 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 terminal if (connected) { await appendPrompt(port, `In ${fileRef}`) + terminal.show() } }) @@ -57,12 +60,12 @@ export function activate(context: vscode.ExtensionContext) { const terminal = vscode.window.activeTerminal if (!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) |
