[Critical Bug] UI Deadlock & Persistent VS Code Crash when pasting ANSI escape codes (Terminal logs) into the input box
What version of the IDE extension are you using?
v26.602.71036
What subscription do you have?
it doesn't matter
Which IDE are you using?
VS Code
What platform is your computer?
Microsoft Windows NT 10.0.26200.0 x64
What issue are you seeing?
Title: [Critical Bug] UI Deadlock & Persistent VS Code Crash when pasting ANSI escape codes (Terminal logs) into the input box
Description:
Pasting text containing terminal ANSI color escape sequences (e.g., logs from llama.cpp) into the extension's chat input box triggers a catastrophic React infinite loop. This completely locks up the Webview UI thread, ultimately causing the entire VS Code window to become unresponsive.
Worse, because the input draft is automatically saved to VS Code's global state, the extension becomes permanently "bricked" across restarts until the global state database is physically deleted.
Environment:
OS: Windows 11 (X64)
VS Code: 1.124.0
Extension: openai.chatgpt (Codex)
Steps to Reproduce:
Open the Codex extension chat panel.
Copy the following raw terminal log output (which contains ANSI escape codes like [34m and [0m):
code
Text
& $cfg.llamaCpp.serverExe `
>> -m $cfg.model.filePath `
>> --host 127.0.0.1 `
>> --port 8081 `
>> --threads $cfg.launch.threads `
>> --ctx-size $cfg.launch.ctxSize `
>> --n-gpu-layers 0
[34m0.00.637.077 [0m [32mI [0mlog_info: verbosity = 3 (adjust with the `-lv N` CLI arg)
[34m0.00.637.084 [0m [32mI [0mdevice_info:
[34m0.00.758.078 [0m [32mI [0m - CUDA0 : NVIDIA GeForce GTX 1050 Ti (4095 MiB, 3358 MiB free)
[34m0.00.758.130 [0m [32mI [0m - CPU : Intel(R) Core(TM) i5-7300HQ CPU @ 2.50GHz (16259 MiB, 8056 MiB free)
[34m0.00.758.246 [0m [32mI [0msystem_info: n_threads = 4 (n_threads_batch = 4) / 4 | CUDA : ARCHS = 750,800,860,890,900,1200,1210 | USE_GRAPHS = 1 | PEER_MAX_BATCH_SIZE = 128 | CPU : SSE3 = 1 | SSSE3 = 1 | AVX = 1 | AVX2 = 1 | F16C = 1 | FMA = 1 | BMI2 = 1 | LLAMAFILE = 1 | OPENMP = 1 | REPACK = 1 |
[34m0.00.758.279 [0m [32mI [0msrv llama_server: n_parallel is set to auto, using n_parallel = 4 and kv_unified = true
[34m0.00.758.345 [0m [32mI [0msrv init: running without SSL
[34m0.00.758.379 [0m [32mI [0msrv init: using 8 threads for HTTP server
[34m0.00.758.706 [0m [32mI [0msrv start: binding port with default address family
[34m0.00.776.198 [0m [32mI [0msrv llama_server: loading model
[34m0.00.776.249 [0m [32mI [0msrv load_model: loading model 'C:\Users\LENOVO\AppData\Local\LocalAI\models\Qwen3-4B-Q4_K_M.gguf'
[34m0.00.776.379 [0m [32mI [0mcommon_init_result: fitting params to device memory ...
[34m0.00.776.380 [0m [32mI [0mcommon_init_result: (for bugs during this step try to reproduce them with -fit off, or provide --verbose logs if the bug only occurs with -fit on)
[34m0.02.232.226 [0m [35mW load: control-looking token: 128247 '</s>' was not control-type; this is probably a bug in the model. its type will be overridden
[0m [34m0.02.470.183 [0m [35mW llama_context: n_ctx_seq (4096) < n_ctx_train (40960) -- the full capacity of the model will not be utilized
[0m [34m0.02.681.919 [0m [32mI [0mcommon_init_from_params: warming up the model with an empty run - please wait ... (--no-warmup to disable)
[34m0.02.689.825 [0m [31mE CUDA error: no kernel image is available for execution on the device
[0m [34m0.02.689.842 [0m [31mE current device: 0, in function ggml_cuda_kernel_can_use_pdl at D:\a\llama.cpp\llama.cpp\ggml\src\ggml-cuda\common.cuh:1602
D:\a\llama.cpp\llama.cpp\ggml\src\ggml-cuda\ggml-cuda.cu:103: CUDA error
Paste it directly into the chat input box.
Actual Behavior / Symptoms:
The input box immediately freezes.
The Webview Developer Tools console floods with an infinite React render loop (repeating componentDidCatch calls from thread-side-panel-tabs-xxx.js).
Due to main thread starvation, all subsequent local asset requests via vscode-resource-base-authority fail with 408 Request Timeout.
The entire VS Code host crashes with the "The window is not responding" dialog.
Persistency: Restarting VS Code or reinstalling the extension does not fix it. The extension reads the "poisonous draft" from VS Code's global state upon initialization, resulting in an instant crash every time it is opened.
Expected Behavior:
The frontend text parser/highlighter should safely escape or strip invalid ANSI control characters without crashing the React component lifecycle.
Temporary Workaround for Affected Users:
To unbrick the extension, users must force-kill VS Code and rename/delete the global state database:
Navigate to %APPDATA%\Code\User\globalStorage
Rename or delete state.vscdb (e.g., to state.vscdb.bak)
Restart VS Code.
⚠️ Warning: This workaround comes at a high cost, as it wipes out all chat histories and global states for other extensions as well.
Root Cause Analysis:
The input box or its markdown renderer lacks boundary checks or sanitization for raw terminal ANSI escape characters. When attempting to parse them, it triggers a catastrophic setState loop in the React Error Boundary, pegging the CPU at 100% and starving the Service Worker.
Could you please add ANSI sanitization to the input field and fix the infinite loop in the error boundary? Thanks!
What steps can reproduce the bug?
- Open the Codex extension chat panel.
- Copy the following raw terminal log output (which contains ANSI escape codes like [34m and [0m):
- need to paste all
& $cfg.llamaCpp.serverExe `
>> -m $cfg.model.filePath `
>> --host 127.0.0.1 `
>> --port 8081 `
>> --threads $cfg.launch.threads `
>> --ctx-size $cfg.launch.ctxSize `
>> --n-gpu-layers 0
^[[34m0.00.637.077^[[0m ^[[32mI ^[[0mlog_info: verbosity = 3 (adjust with the `-lv N` CLI arg)
^[[34m0.00.637.084^[[0m ^[[32mI ^[[0mdevice_info:
^[[34m0.00.758.078^[[0m ^[[32mI ^[[0m - CUDA0 : NVIDIA GeForce GTX 1050 Ti (4095 MiB, 3358 MiB free)
^[[34m0.00.758.130^[[0m ^[[32mI ^[[0m - CPU : Intel(R) Core(TM) i5-7300HQ CPU @ 2.50GHz (16259 MiB, 8056 MiB free)
^[[34m0.00.758.246^[[0m ^[[32mI ^[[0msystem_info: n_threads = 4 (n_threads_batch = 4) / 4 | CUDA : ARCHS = 750,800,860,890,900,1200,1210 | USE_GRAPHS = 1 | PEER_MAX_BATCH_SIZE = 128 | CPU : SSE3 = 1 | SSSE3 = 1 | AVX = 1 | AVX2 = 1 | F16C = 1 | FMA = 1 | BMI2 = 1 | LLAMAFILE = 1 | OPENMP = 1 | REPACK = 1 |
^[[34m0.00.758.279^[[0m ^[[32mI ^[[0msrv llama_server: n_parallel is set to auto, using n_parallel = 4 and kv_unified = true
^[[34m0.00.758.345^[[0m ^[[32mI ^[[0msrv init: running without SSL
^[[34m0.00.758.379^[[0m ^[[32mI ^[[0msrv init: using 8 threads for HTTP server
^[[34m0.00.758.706^[[0m ^[[32mI ^[[0msrv start: binding port with default address family
^[[34m0.00.776.198^[[0m ^[[32mI ^[[0msrv llama_server: loading model
^[[34m0.00.776.249^[[0m ^[[32mI ^[[0msrv load_model: loading model 'C:\Users\LENOVO\AppData\Local\LocalAI\models\Qwen3-4B-Q4_K_M.gguf'
^[[34m0.00.776.379^[[0m ^[[32mI ^[[0mcommon_init_result: fitting params to device memory ...
^[[34m0.00.776.380^[[0m ^[[32mI ^[[0mcommon_init_result: (for bugs during this step try to reproduce them with -fit off, or provide --verbose logs if the bug only occurs with -fit on)
^[[34m0.02.232.226^[[0m ^[[35mW load: control-looking token: 128247 '</s>' was not control-type; this is probably a bug in the model. its type will be overridden
^[[0m^[[34m0.02.470.183^[[0m ^[[35mW llama_context: n_ctx_seq (4096) < n_ctx_train (40960) -- the full capacity of the model will not be utilized
^[[0m^[[34m0.02.681.919^[[0m ^[[32mI ^[[0mcommon_init_from_params: warming up the model with an empty run - please wait ... (--no-warmup to disable)
^[[34m0.02.689.825^[[0m ^[[31mE CUDA error: no kernel image is available for execution on the device
^[[0m^[[34m0.02.689.842^[[0m ^[[31mE current device: 0, in function ggml_cuda_kernel_can_use_pdl at D:\a\llama.cpp\llama.cpp\ggml\src\ggml-cuda\common.cuh:1602
D:\a\llama.cpp\llama.cpp\ggml\src\ggml-cuda\ggml-cuda.cu:103: CUDA error
Paste it directly into the chat input box.
What is the expected behavior?
Actual Behavior / Symptoms:
The input box immediately freezes.
The Webview Developer Tools console floods with an infinite React render loop (repeating componentDidCatch calls from thread-side-panel-tabs-xxx.js).
Due to main thread starvation, all subsequent local asset requests via vscode-resource-base-authority fail with 408 Request Timeout.
The entire VS Code host crashes with the "The window is not responding" dialog.
Persistency: Restarting VS Code or reinstalling the extension does not fix it. The extension reads the "poisonous draft" from VS Code's global state upon initialization, resulting in an instant crash every time it is opened.
Expected Behavior:
The frontend text parser/highlighter should safely escape or strip invalid ANSI control characters without crashing the React component lifecycle.
Temporary Workaround for Affected Users:
To unbrick the extension, users must force-kill VS Code and rename/delete the global state database:
Navigate to %APPDATA%\Code\User\globalStorage
Rename or delete state.vscdb (e.g., to state.vscdb.bak)
Restart VS Code.
⚠️ Warning: This workaround comes at a high cost, as it wipes out all chat histories and global states for other extensions as well.
Additional information
Root Cause Analysis:
The input box or its markdown renderer lacks boundary checks or sanitization for raw terminal ANSI escape characters. When attempting to parse them, it triggers a catastrophic setState loop in the React Error Boundary, pegging the CPU at 100% and starving the Service Worker.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗