From da2e48796f68bbba8bdb149fa1d422de4486ac05 Mon Sep 17 00:00:00 2001 From: pelikhan Date: Wed, 4 Dec 2024 14:35:46 -0800 Subject: [PATCH] filter out non-file documents when launching debug session --- packages/vscode/src/fragmentcommands.ts | 25 ++++++++++++++++++------- packages/vscode/src/servermanager.ts | 8 ++++---- packages/vscode/src/state.ts | 1 + 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/packages/vscode/src/fragmentcommands.ts b/packages/vscode/src/fragmentcommands.ts index 5b83f4d8e..63094943d 100644 --- a/packages/vscode/src/fragmentcommands.ts +++ b/packages/vscode/src/fragmentcommands.ts @@ -7,8 +7,9 @@ import { GENAI_ANY_REGEX, TOOL_ID, TOOL_NAME } from "../../core/src/constants" import { NotSupportedError } from "../../core/src/error" import { promptParameterTypeToJSONSchema } from "../../core/src/parameters" import { Fragment } from "../../core/src/generation" -import { assert, dotGenaiscriptPath, groupBy } from "../../core/src/util" +import { dotGenaiscriptPath, groupBy, logInfo } from "../../core/src/util" import { resolveCli } from "./config" +import { YAMLStringify } from "../../core/src/yaml" type TemplateQuickPickItem = { template?: PromptScript @@ -193,7 +194,11 @@ export function activateFragmentCommands(state: ExtensionState) { return } files = vscode.window.visibleTextEditors - .filter((editor) => editor.document.uri.fsPath !== file.fsPath) + .filter( + (editor) => + editor.document.uri.fsPath !== file.fsPath && + editor.document.uri.scheme === "file" + ) .map((editor) => editor.document.uri) } else { template = await pickTemplate() @@ -210,22 +215,28 @@ export function activateFragmentCommands(state: ExtensionState) { ] const configuration = cliPath ? { + type: "node", name: TOOL_NAME, request: "launch", + console: "integratedTerminal", + internalConsoleOptions: "neverOpen", skipFiles: ["/**", dotGenaiscriptPath("**")], - type: "node", + args: [cliPath, ...args], - } + } satisfies vscode.DebugConfiguration : { - name: TOOL_NAME, type: "node", + name: TOOL_NAME, request: "launch", - runtimeExecutable: "npx", - runtimeArgs: [`--yes`, `${TOOL_ID}@${cliVersion}`, ...args], console: "integratedTerminal", internalConsoleOptions: "neverOpen", + skipFiles: ["/**", dotGenaiscriptPath("**")], + + runtimeExecutable: "npx", + runtimeArgs: [`--yes`, `${TOOL_ID}@${cliVersion}`, ...args], } + logInfo(`start debugging ${YAMLStringify(configuration)}`) await vscode.debug.startDebugging( vscode.workspace.workspaceFolders[0], configuration diff --git a/packages/vscode/src/servermanager.ts b/packages/vscode/src/servermanager.ts index f254738b1..d733905a6 100644 --- a/packages/vscode/src/servermanager.ts +++ b/packages/vscode/src/servermanager.ts @@ -9,7 +9,7 @@ import { TOOL_ID, } from "../../core/src/constants" import { ServerManager, host } from "../../core/src/host" -import { logError, logVerbose } from "../../core/src/util" +import { logError, logInfo, logVerbose } from "../../core/src/util" import { WebSocketClient } from "../../core/src/server/client" import { CORE_VERSION } from "../../core/src/version" import { createChatModelRunner } from "./lmaccess" @@ -42,9 +42,9 @@ export class TerminalServerManager implements ServerManager { }) ) - this.client = new WebSocketClient( - `http://localhost:${SERVER_PORT}?api-key=${encodeURIComponent(sessionApiKey)}` - ) + const url = `http://localhost:${SERVER_PORT}?api-key=${encodeURIComponent(sessionApiKey)}` + logInfo(`client url: ${url}`) + this.client = new WebSocketClient(url) this.client.chatRequest = createChatModelRunner(this.state) this.client.addEventListener(OPEN, async () => { // client connected to a rogue server diff --git a/packages/vscode/src/state.ts b/packages/vscode/src/state.ts index d8747e24c..64ef6fd3f 100644 --- a/packages/vscode/src/state.ts +++ b/packages/vscode/src/state.ts @@ -109,6 +109,7 @@ export class ExtensionState extends EventTarget { this.output = vscode.window.createOutputChannel(TOOL_NAME, { log: true, }) + this.output.info(`session api key: ${this.sessionApiKey}`) this.host = new VSCodeHost(this) this.host.addEventListener(CHANGE, this.dispatchChange.bind(this)) const { subscriptions } = context