Skip to content

Commit

Permalink
filter out non-file documents when launching debug session
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Dec 4, 2024
1 parent 5d6e068 commit da2e487
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
25 changes: 18 additions & 7 deletions packages/vscode/src/fragmentcommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -210,22 +215,28 @@ export function activateFragmentCommands(state: ExtensionState) {
]
const configuration = cliPath
? <vscode.DebugConfiguration>{
type: "node",
name: TOOL_NAME,
request: "launch",
console: "integratedTerminal",
internalConsoleOptions: "neverOpen",
skipFiles: ["<node_internals>/**", dotGenaiscriptPath("**")],
type: "node",

args: [cliPath, ...args],
}
} satisfies vscode.DebugConfiguration
: <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: ["<node_internals>/**", dotGenaiscriptPath("**")],

runtimeExecutable: "npx",
runtimeArgs: [`--yes`, `${TOOL_ID}@${cliVersion}`, ...args],
}

logInfo(`start debugging ${YAMLStringify(configuration)}`)
await vscode.debug.startDebugging(
vscode.workspace.workspaceFolders[0],
configuration
Expand Down
8 changes: 4 additions & 4 deletions packages/vscode/src/servermanager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions packages/vscode/src/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit da2e487

Please sign in to comment.