Skip to content

Commit 3597782

Browse files
authored
fix: add no-config debug opt-out and isolate initialization failures (#1690)
* fix: isolate no-config debug workspace storage failures * fix: register no-config listeners before asynchronous setup * feat: add an opt-out for no-config debugging
1 parent 6b5e810 commit 3597782

17 files changed

Lines changed: 759 additions & 151 deletions

‎README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ debugjava -cp bin com.example.Main arg1 arg2
6060

6161
The debugger will automatically attach. See [No-Config Debug Documentation](bundled/scripts/noConfigScripts/README.md) for more details.
6262

63+
No-Config Debug is enabled by default. To disable the terminal integration and the AI `debug_java_application` tool, set `"java.debug.settings.enableNoConfigDebug": false`, reload VS Code, and recreate existing terminals. Standard Java launch/attach debugging, including F5 and Run/Debug CodeLens, remains available.
64+
6365
## AI-Assisted Debugging
6466

6567
When using GitHub Copilot Chat, you can now ask AI to help you debug Java applications! The extension provides a Language Model Tool that enables natural language debugging:
@@ -164,6 +166,7 @@ See [Language Model Tool Documentation](bundled/agents/README.md) for more detai
164166
- `auto` - Automatically apply the changes after compilation. This only works when `'java.autobuild.enabled'` is on.
165167
- `never` - Never apply the changes.
166168
- `java.debug.settings.enableRunDebugCodeLens`: enable the code lens provider for the run and debug buttons over main entry points, defaults to `true`.
169+
- `java.debug.settings.enableNoConfigDebug`: enable automatic attachment through `debugjava` and the AI `debug_java_application` tool, defaults to `true`. Can be set at user or workspace level. Changes require reloading VS Code and recreating existing terminals; standard Java launch/attach debugging is unaffected.
167170
- `java.debug.settings.forceBuildBeforeLaunch`: force building the workspace before launching java program, defaults to `true`.
168171
- `java.debug.settings.onBuildFailureProceed`: Force to proceed when build fails, defaults to false.
169172
- `java.debug.settings.console`: The specified console to launch Java program, defaults to `integratedTerminal`. If you want to customize the console for a specific debug session, please modify the 'console' config in launch.json.

‎bundled/agents/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ Make sure the Java project is properly loaded. Check that:
165165

166166
### Debug Session Won't Start
167167

168+
The `debug_java_application` tool requires `java.debug.settings.enableNoConfigDebug` (enabled by default). If you disable this setting, reload VS Code and recreate existing terminals. The launch tool then returns an explanatory message without running `debugjava`; tools that inspect or control existing debug sessions remain available.
169+
168170
Ensure:
169171
- Your project compiles successfully
170172
- No other debug session is running

‎bundled/scripts/noConfigScripts/README.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@ When you open a terminal in VS Code with this extension installed, the following
1111

1212
Note: `JAVA_TOOL_OPTIONS` is NOT set globally to avoid affecting other Java tools (javac, maven, gradle). Instead, it's set only when you run the `debugjava` command.
1313

14+
## Disabling No-Config Debug
15+
16+
No-Config Debug is enabled by default. To opt out for all workspaces or just the current workspace, add this to the corresponding VS Code settings:
17+
18+
```json
19+
"java.debug.settings.enableNoConfigDebug": false
20+
```
21+
22+
Reload VS Code and recreate existing terminals after changing this setting. The value is read once during extension activation; there is no live enable/disable switch. Existing terminal processes retain their old environment until they are recreated.
23+
24+
When disabled, the extension skips endpoint storage, file watching, Java executable detection, and wrapper permission setup, and removes this feature's cached terminal environment contributions. It does not clear the user's PATH or delete endpoint files as part of opting out. Standard Java launch/attach debugging, F5, and Run/Debug CodeLens are unaffected.
25+
26+
The AI `debug_java_application` tool requires this integration. When disabled, it returns instructions to enable the setting instead of building, launching a terminal, or stopping an existing debug session. Other AI tools for existing debug sessions remain available.
27+
1428
## Usage
1529

1630
### Basic Usage
@@ -72,8 +86,16 @@ debugjava -jar myapp.jar --spring.profiles.active=dev
7286
6. The port is written to a communication file
7387
7. VS Code's file watcher detects the file and automatically starts an attach debug session
7488

89+
The communication file is stored in the extension's workspace-specific VS Code storage directory, not its installation directory. It contains only the local debug host and port, is deleted after a successful attach, and any stale file is removed before the next registration. Its path remains stable across window reloads.
90+
7591
## Troubleshooting
7692

93+
### No-Config Debug Could Not Be Initialized
94+
95+
If the workspace storage directory or its file watcher cannot be initialized, the extension displays a warning and leaves standard Java launch/attach debugging available. No-Config Debug requires an open workspace and writable VS Code workspace storage.
96+
97+
After upgrading from a version that stored the communication file in the extension directory, recreate existing terminals to pick up the new endpoint path.
98+
7799
### Port Already in Use
78100

79101
If you see "Address already in use", another Java debug session is running. Terminate it first.

‎package.json‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,12 @@
855855
"description": "%java.debugger.configuration.enableRunDebugCodeLens.description%",
856856
"default": true
857857
},
858+
"java.debug.settings.enableNoConfigDebug": {
859+
"type": "boolean",
860+
"description": "%java.debugger.configuration.enableNoConfigDebug.description%",
861+
"default": true,
862+
"scope": "window"
863+
},
858864
"java.debug.settings.forceBuildBeforeLaunch": {
859865
"type": "boolean",
860866
"description": "%java.debugger.configuration.forceBuildBeforeLaunch%",

‎package.nls.es.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"java.debugger.configuration.numericPrecision.description": "La precisión en el formato de números reales en la vista \"Variables\" o \"Consola de Depuración\".",
5353
"java.debugger.configuration.hotCodeReplace.description": "Recargar las clases de Java modificadas durante la depuración. Asegúrate de que 'java.autobuild.enabled' no esté desactivado.",
5454
"java.debugger.configuration.enableRunDebugCodeLens.description": "Habilitar proveedores de CodeLens para la ejecución y depuración sobre los métodos principales.",
55+
"java.debugger.configuration.enableNoConfigDebug.description": "Habilitar la conexión automática del depurador mediante el comando de terminal debugjava y la herramienta de IA debug_java_application. La depuración estándar de Java no se ve afectada. Los cambios requieren recargar VS Code y volver a crear los terminales existentes.",
5556
"java.debugger.configuration.forceBuildBeforeLaunch": "Forzar la compilación del área de trabajo antes de lanzar el programa Java.",
5657
"java.debugger.configuration.onBuildFailureProceed": "Forzar continuar cuando falla la compilación.",
5758
"java.debugger.configuration.console": "La consola establecida para lanzar el programa Java. Si quieres personalizar la consola para una sesión de depuración específica, por favor modifica la configuración de la 'console' en launch.json.",

‎package.nls.it.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"java.debugger.configuration.showQualifiedNames.description": "Mostra nome completo delle classi nella scheda \"variabili\".",
77
"java.debugger.configuration.maxStringLength.description": "Lunghezza massima delle stringhe visualizzate nella scheda \"Variabili\" o \"Console di Debug\", stringhe più lunghe di questo numero verranno tagliate, se 0 nessun taglio viene eseguito.",
88
"java.debugger.configuration.enableRunDebugCodeLens.description": "Abilitare i provider di lenti di codice run e debug sui metodi principali.",
9+
"java.debugger.configuration.enableNoConfigDebug.description": "Abilita la connessione automatica del debugger tramite il comando da terminale debugjava e lo strumento IA debug_java_application. Il debug Java standard non viene modificato. Le modifiche richiedono di ricaricare VS Code e ricreare i terminali esistenti.",
910
"java.debugger.configuration.suspendAllThreads.description": "Sospende tutti i thread quando si raggiunge un punto di interruzione o ci si ferma per un'eccezione. Ha effetto solo nelle nuove sessioni di debug; le modifiche durante una sessione in esecuzione non si applicano."
1011
}

‎package.nls.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"java.debugger.configuration.numericPrecision.description": "The precision when formatting doubles in \"Variables\" or \"Debug Console\" viewlet.",
6363
"java.debugger.configuration.hotCodeReplace.description": "Reload the changed Java classes during debugging.",
6464
"java.debugger.configuration.enableRunDebugCodeLens.description": "Enable the run and debug code lens providers over main methods.",
65+
"java.debugger.configuration.enableNoConfigDebug.description": "Enable automatic attachment through the debugjava terminal command and the AI debug_java_application tool. Standard Java launch/attach debugging is unaffected. Changes require reloading VS Code and recreating existing terminals.",
6566
"java.debugger.configuration.forceBuildBeforeLaunch": "Force building the workspace before launching java program.",
6667
"java.debugger.configuration.onBuildFailureProceed": "Force to proceed when build fails",
6768
"java.debugger.configuration.console": "The specified console to launch Java program. If you want to customize the console for a specific debug session, please modify the 'console' config in launch.json.",

‎package.nls.zh-cn.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"java.debugger.configuration.maxStringLength.description": "设定“变量”或“调试控制台”视图中显示的字符串最大长度,长度超过部分将被剪掉。如果值为0,则不执行修剪。",
6161
"java.debugger.configuration.hotCodeReplace.description": "在调试期间重新加载已更改的Java类。",
6262
"java.debugger.configuration.enableRunDebugCodeLens.description": "在main方法上启用CodeLens标记。",
63+
"java.debugger.configuration.enableNoConfigDebug.description": "启用通过终端 debugjava 命令和 AI debug_java_application 工具自动附加调试器的功能。不影响标准 Java 启动和附加调试。修改后需要重新加载 VS Code 并重新创建现有终端。",
6364
"java.debugger.configuration.forceBuildBeforeLaunch": "在启动java程序之前强制编译整个工作空间。",
6465
"java.debugger.configuration.console": "指定的控制台用于启动Java程序。如果要为特定的调试会话自定义控制台,请修改launch.json中的“console”配置。",
6566
"java.debugger.configuration.exceptionBreakpoint.exceptionTypes": "指定要中断的一组异常类型,例如 java.lang.NullPointerException。可以为捕获的异常、未捕获的异常或两者都选择一个特定的异常类型及其子类。",

‎package.nls.zh-tw.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"java.debugger.configuration.maxStringLength.description": "設定「變數」或「偵錯主控台」視圖中顯示的字元串最大長度,長度超過部分將被剪掉。如果值為0,則不執行修剪。",
6161
"java.debugger.configuration.hotCodeReplace.description": "在偵錯期間重新載入已更改的 Java 類別。確保未停用 'java.autobuild.enabled'。",
6262
"java.debugger.configuration.enableRunDebugCodeLens.description": "在 main 方法上啟用 CodeLens 標記。",
63+
"java.debugger.configuration.enableNoConfigDebug.description": "啟用透過終端機 debugjava 命令和 AI debug_java_application 工具自動附加偵錯器的功能。不影響標準 Java 啟動和附加偵錯。修改後需要重新載入 VS Code 並重新建立現有終端機。",
6364
"java.debugger.configuration.forceBuildBeforeLaunch": "在啟動 Java 程式之前強制編譯整個工作空間。",
6465
"java.debugger.configuration.console": "指定用於啟動 Java 程式的主控台。如果要為特定的偵錯會話自訂義主控台,請修改 launch.json 中的「console」設定。",
6566
"java.debugger.configuration.exceptionBreakpoint.skipClasses": "當發生異常時,跳過指定的類別。你可以使用內建變數,如 '$JDK' 和 '$Libraries' 來跳過一組類別,或者添加一個特定的類別名表達式,如 java.*,*.Foo。",

‎src/constants.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const JAVA_LANGID: string = "java";
55
export const TELEMETRY_EVENT = "telemetry";
66
export const HCR_EVENT = "hotcodereplace";
77
export const USER_NOTIFICATION_EVENT = "usernotification";
8+
export const ENABLE_NO_CONFIG_DEBUG = "java.debug.settings.enableNoConfigDebug";
89

910
export enum ClasspathVariable {
1011
Auto = "$Auto",

0 commit comments

Comments
 (0)