From 6f8579dd817106bc31c626ea94d48e7bd130bbac Mon Sep 17 00:00:00 2001 From: JonathanLab Date: Mon, 26 Jan 2026 18:20:51 +0100 Subject: [PATCH] fix: Strip ANSI escape codes from command output in chat ANSI codes were being displayed as raw text (e.g. [32m) instead of being rendered or stripped. This strips them so command output displays as clean plain text. Closes #441 --- .../sessions/components/session-update/ExecuteToolView.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/twig/src/renderer/features/sessions/components/session-update/ExecuteToolView.tsx b/apps/twig/src/renderer/features/sessions/components/session-update/ExecuteToolView.tsx index 6ddbe8c74..728b032d3 100644 --- a/apps/twig/src/renderer/features/sessions/components/session-update/ExecuteToolView.tsx +++ b/apps/twig/src/renderer/features/sessions/components/session-update/ExecuteToolView.tsx @@ -8,6 +8,8 @@ import { import { Box, Flex, IconButton, Text } from "@radix-ui/themes"; import { useState } from "react"; +const ANSI_REGEX = new RegExp(`${String.fromCharCode(0x1b)}\\[[0-9;]*m`, "g"); + interface ExecuteToolViewProps { toolCall: ToolCall; turnCancelled?: boolean; @@ -45,7 +47,7 @@ export function ExecuteToolView({ const isIncomplete = status === "pending" || status === "in_progress"; const isLoading = isIncomplete && !turnCancelled; - const output = getOutputFromContent(content) ?? ""; + const output = (getOutputFromContent(content) ?? "").replace(ANSI_REGEX, ""); const hasOutput = output.trim().length > 0; const outputLines = output.split("\n"); const isCollapsible = outputLines.length > COLLAPSED_LINE_COUNT;