From bba935f93dc1dfed19fea9724a0b97adf53dbc27 Mon Sep 17 00:00:00 2001 From: David Montero Crespo Date: Fri, 8 May 2026 16:32:59 -0300 Subject: [PATCH] fix(serial-monitor): strip ANSI escape sequences from board output Beta testers saw raw `[0;32m` and `[0m` text mixed into the serial monitor for several ESP32 examples. Those are ANSI SGR escapes the ESP-IDF logger emits to color INFO/WARN lines on a real terminal. Our
 renders them literally because there was no ANSI handling in
the path.

Strip the SGR sequences (`\x1b\[[0-9;]*m`) before the IP-linkifier so
the user only sees plain text. Combined with the sdkconfig change that
drops the default log level to WARN, the ESP32 output is now as clean
as the AVR output.

Co-Authored-By: Claude Opus 4.7 (1M context) 
---
 frontend/src/components/simulator/SerialMonitor.tsx | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/frontend/src/components/simulator/SerialMonitor.tsx b/frontend/src/components/simulator/SerialMonitor.tsx
index 235e2405..7158854d 100644
--- a/frontend/src/components/simulator/SerialMonitor.tsx
+++ b/frontend/src/components/simulator/SerialMonitor.tsx
@@ -247,7 +247,12 @@ export const SerialMonitor: React.FC = () => {
       
         {activeBoard?.serialOutput
           ? (() => {
-              const text = activeBoard.serialOutput;
+              // ESP-IDF and many other firmwares emit ANSI SGR escapes
+              // (`\x1b[0;32m...`). The 
 renders them literally, so
+              // users saw raw `[0;32m` mixed into their Serial.print output.
+              // Strip them before any further processing — color isn't
+              // worth a full parser here.
+              const text = activeBoard.serialOutput.replace(/\x1b\[[0-9;]*m/g, '');
               const ipRegex = /http:\/\/192\.168\.4\.(\d+)(\/[^\s]*)?/g;
               const matches = [...text.matchAll(ipRegex)];