Skip to content

Commit fdbf51d

Browse files
committed
vscode-extension: refactor options
1 parent ec38293 commit fdbf51d

File tree

8 files changed

+37
-50
lines changed

8 files changed

+37
-50
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
2-
"temporal.replayerEntrypoint": "main.go",
32
"temporal.debugLanguage": "go",
43
"temporal.debugger.backgroundProcess.command": "tdlv",
5-
"temporal.debugger.backgroundProcess.args": ["--lang=go"]
4+
"temporal.debugger.backgroundProcess.args": ["--lang=go", "--install", "--quiet"]
65
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "msedge",
9+
"request": "launch",
10+
"name": "Launch Edge against localhost",
11+
"url": "http://localhost:8080",
12+
"webRoot": "${workspaceFolder}"
13+
}
14+
]
15+
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
2-
"temporal.replayerEntrypoint": "main.go",
32
"temporal.debugLanguage": "go",
43
"temporal.debugger.backgroundProcess.command": "tdlv",
5-
"temporal.debugger.backgroundProcess.args": ["lang=go"]
4+
"temporal.debugger.backgroundProcess.args": ["--lang=go", "--install", "--quiet"]
65
}

example/js/.vscode/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"temporal.replayerEntrypoint": "vscode-replayer.ts",
2+
"temporal.typescriptReplayerEntrypoint": "vscode-replayer.ts",
33
"temporal.debugLanguage": "typescript",
44
"temporal.debugger.backgroundProcess.command": "tdlv",
5-
"temporal.debugger.backgroundProcess.args": ["--lang=js"]
5+
"temporal.debugger.backgroundProcess.args": ["--lang=js", "--install", "--quiet"]
66
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
2-
"temporal.replayerEntrypoint": "vscode-replay.py",
32
"temporal.debugLanguage": "python",
4-
"temporal.debugger.backgroundProcess.command": "../../tdlv.build",
5-
"temporal.debugger.backgroundProcess.args": ["--lang=python", "--entrypoint=vscode-replay.py"]
3+
"temporal.debugger.backgroundProcess.command": "tdlv",
4+
"temporal.debugger.backgroundProcess.args": ["--lang=python", "--entrypoint=vscode-replay.py", "--install", "--quiet"]
65
}

vscode-debugger-extension/extension/src/extension.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as vscode from "vscode"
22
import { HistoryDebuggerPanel } from "./panel"
33

44
export async function activate(context: vscode.ExtensionContext): Promise<void> {
5-
// const debugAdapterTrackerFactory: vscode.Disposable = registerDebugAdapterTrackerFactory()
65
const openCommand: vscode.Disposable = vscode.commands.registerCommand(
76
"temporal.debugger-extension.open-panel",
87
async () => {

vscode-debugger-extension/extension/src/panel.ts

Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -491,36 +491,26 @@ export class HistoryDebuggerPanel {
491491
})
492492
}
493493

494-
private async getReplayerEndpoint() {
494+
private async getTypescriptReplayerEndpoint() {
495495
const config = vscode.workspace.getConfiguration("temporal")
496-
let replayerEntrypoint = config.get("replayerEntrypoint") as string
496+
let typeScriptReplayerEntrypoint = config.get("typeScriptReplayerEntrypoint") as string
497497
const language = getCurrentLanguage()
498498
const workspace = vscode.workspace.workspaceFolders?.[0]
499499
const workspaceFolder = workspace?.uri
500500

501501
// Debug logging
502502
console.log("Debug configuration:")
503503
console.log("- Language:", language)
504-
console.log("- Configured replayerEntrypoint:", replayerEntrypoint)
505504
console.log("- Workspace folder:", workspaceFolder?.fsPath)
506505
console.log("- All temporal config:", config)
507506

508-
const configuredAbsolutePath = path.isAbsolute(replayerEntrypoint)
507+
const configuredAbsolutePath = path.isAbsolute(typeScriptReplayerEntrypoint)
509508

510509
// Provide language-specific defaults if not configured
511-
if (!replayerEntrypoint) {
510+
if (!typeScriptReplayerEntrypoint) {
512511
switch (language) {
513512
case "typescript":
514-
replayerEntrypoint = "src/debug-replayer.ts"
515-
break
516-
case "go":
517-
replayerEntrypoint = "." // Use current directory for Go package
518-
break
519-
case "java":
520-
replayerEntrypoint = "src/main/java/TemporalReplayer.java"
521-
break
522-
case "python":
523-
replayerEntrypoint = "replayer.py"
513+
typeScriptReplayerEntrypoint = "src/debug-replayer.ts"
524514
break
525515
default:
526516
throw new Error(`No default replayer endpoint for language: ${language}`)
@@ -531,36 +521,36 @@ export class HistoryDebuggerPanel {
531521
if (workspaceFolder === undefined) {
532522
throw new Error("temporal.replayerEndpoint not configured, cannot use default without a workspace folder")
533523
} else {
534-
replayerEntrypoint = vscode.Uri.joinPath(workspaceFolder, replayerEntrypoint).fsPath
524+
typeScriptReplayerEntrypoint = vscode.Uri.joinPath(workspaceFolder, typeScriptReplayerEntrypoint).fsPath
535525
}
536526
}
537527

538528
try {
539-
const stat: vscode.FileStat = await vscode.workspace.fs.stat(vscode.Uri.file(replayerEntrypoint))
529+
const stat: vscode.FileStat = await vscode.workspace.fs.stat(vscode.Uri.file(typeScriptReplayerEntrypoint))
540530
const { type } = stat
541531
if (type === vscode.FileType.Directory) {
542532
throw new Error(
543-
`Configured temporal.replayerEndpoint (${replayerEntrypoint}) is a folder, please provide a file instead`,
533+
`Configured temporal.replayerEndpoint (${typeScriptReplayerEntrypoint}) is a folder, please provide a file instead`,
544534
)
545535
}
546536
if (type === vscode.FileType.Unknown) {
547537
throw new Error(
548-
`Configured temporal.replayerEndpoint (${replayerEntrypoint}) is of unknown type, please provide a file instead`,
538+
`Configured temporal.replayerEndpoint (${typeScriptReplayerEntrypoint}) is of unknown type, please provide a file instead`,
549539
)
550540
}
551541
} catch (err: any) {
552542
if (err?.code === vscode.FileSystemError.FileNotFound.name) {
553543
if (!configuredAbsolutePath && (vscode.workspace.workspaceFolders?.length ?? 0) > 1) {
554544
throw new Error(
555-
`Configured temporal.replayerEndpoint (${replayerEntrypoint}) not found (multiple workspace folders found, consider using an absolute path to disambiguate)`,
545+
`Configured temporal.replayerEndpoint (${typeScriptReplayerEntrypoint}) not found (multiple workspace folders found, consider using an absolute path to disambiguate)`,
556546
)
557547
}
558-
throw new Error(`Configured temporal.replayerEndpoint (${replayerEntrypoint}) not found`)
548+
throw new Error(`Configured temporal.replayerEndpoint (${typeScriptReplayerEntrypoint}) not found`)
559549
}
560550
throw err
561551
}
562552

563-
return replayerEntrypoint
553+
return typeScriptReplayerEntrypoint
564554
}
565555

566556
private getLanguageRequirements(language: string): string {
@@ -599,7 +589,6 @@ export class HistoryDebuggerPanel {
599589
// Still send protobuf bytes to webview for UI processing
600590
const bytes = new Uint8Array(temporal.api.history.v1.History.encode(history).finish())
601591
const workspace = vscode.workspace.workspaceFolders?.[0]
602-
const replayerEndpoint = await this.getReplayerEndpoint()
603592
const language = getCurrentLanguage()
604593

605594
await this.panel.webview.postMessage({ type: "historyProcessed", history: bytes })
@@ -639,6 +628,7 @@ export class HistoryDebuggerPanel {
639628

640629
switch (language) {
641630
case "typescript":
631+
const typescriptReplayerEndpoint = await this.getTypescriptReplayerEndpoint()
642632
// TypeScript-specific configuration
643633
if (process.env.TEMPORAL_DEBUGGER_EXTENSION_DEV_MODE) {
644634
baseConfig.skipFiles?.push("${workspaceFolder}/packages/worker/src/**")
@@ -648,7 +638,7 @@ export class HistoryDebuggerPanel {
648638
const pathPrefix = process.env.NODE_PATH ? `${process.env.NODE_PATH ?? ""}${delim}` : ""
649639
debugConfig = {
650640
...baseConfig,
651-
args: [replayerEndpoint],
641+
args: [typescriptReplayerEndpoint],
652642
env: {
653643
TEMPORAL_DEBUGGER_PLUGIN_URL: this.server.url,
654644
NODE_PATH: `${pathPrefix}${path.join(__dirname, "../../node_modules")}`,
@@ -657,20 +647,8 @@ export class HistoryDebuggerPanel {
657647
break
658648

659649
case "go":
660-
// For Go, ensure we have a valid program path
661-
let goProgram = replayerEndpoint
662-
if (goProgram.endsWith(".go")) {
663-
// If it's a .go file, use it directly
664-
goProgram = replayerEndpoint
665-
} else {
666-
// If it's a directory, use the directory path
667-
goProgram = path.dirname(replayerEndpoint)
668-
}
669-
console.log("Go program path:", goProgram)
670-
671650
debugConfig = {
672651
...baseConfig,
673-
program: goProgram,
674652
env: {
675653
TEMPORAL_DEBUGGER_PLUGIN_URL: this.server.url,
676654
},
@@ -680,7 +658,6 @@ export class HistoryDebuggerPanel {
680658
case "java":
681659
debugConfig = {
682660
...baseConfig,
683-
args: [replayerEndpoint],
684661
env: {
685662
TEMPORAL_DEBUGGER_PLUGIN_URL: this.server.url,
686663
},
@@ -690,7 +667,6 @@ export class HistoryDebuggerPanel {
690667
case "python":
691668
debugConfig = {
692669
...baseConfig,
693-
args: [replayerEndpoint],
694670
env: {
695671
TEMPORAL_DEBUGGER_PLUGIN_URL: this.server.url,
696672
},

vscode-debugger-extension/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"configuration": {
4343
"title": "Temporal debugger",
4444
"properties": {
45-
"temporal.replayerEntrypoint": {
45+
"temporal.typeScriptReplayerEntrypoint": {
4646
"type": "string",
4747
"default": "src/debug-replayer.ts",
4848
"description": "Specifies which file will be used to start a replayer process."
@@ -182,4 +182,4 @@
182182
"vscode": "^1.89.0"
183183
},
184184
"icon": "logo.png"
185-
}
185+
}

0 commit comments

Comments
 (0)