diff --git a/sdks/vscode/package.json b/sdks/vscode/package.json index a041b65223dd..12de57807ebb 100644 --- a/sdks/vscode/package.json +++ b/sdks/vscode/package.json @@ -78,7 +78,21 @@ "win": "ctrl+alt+K", "linux": "ctrl+alt+K" } - ] + ], + "configuration": { + "title": "opencode", + "properties": { + "opencode.tuiLocation": { + "type": "string", + "default": "editor", + "enum": [ + "editor", + "terminal" + ], + "description": "Where to open the opencode TUI: beside the current editor or in the terminal panel." + } + } + } }, "scripts": { "vscode:prepublish": "bun run package", diff --git a/sdks/vscode/src/extension.ts b/sdks/vscode/src/extension.ts index 105ab0293a8a..7345ccb137e3 100644 --- a/sdks/vscode/src/extension.ts +++ b/sdks/vscode/src/extension.ts @@ -40,10 +40,12 @@ export function activate(context: vscode.ExtensionContext) { } }) - context.subscriptions.push(openTerminalDisposable, addFilepathDisposable) + context.subscriptions.push(openNewTerminalDisposable, openTerminalDisposable, addFilepathDisposable) async function openTerminal() { // Create a new terminal in split screen + const config = vscode.workspace.getConfiguration("opencode") + const tuiLocation = config.get("tuiLocation", "editor") const port = Math.floor(Math.random() * (65535 - 16384 + 1)) + 16384 const terminal = vscode.window.createTerminal({ name: TERMINAL_NAME, @@ -51,10 +53,13 @@ export function activate(context: vscode.ExtensionContext) { light: vscode.Uri.file(context.asAbsolutePath("images/button-dark.svg")), dark: vscode.Uri.file(context.asAbsolutePath("images/button-light.svg")), }, - location: { - viewColumn: vscode.ViewColumn.Beside, - preserveFocus: false, - }, + location: + tuiLocation === "terminal" + ? vscode.TerminalLocation.Panel + : { + viewColumn: vscode.ViewColumn.Beside, + preserveFocus: false, + }, env: { _EXTENSION_OPENCODE_PORT: port.toString(), OPENCODE_CALLER: "vscode",