From 40413c9e8c640d0aed7720ca8fbf78dba8dfbc7d Mon Sep 17 00:00:00 2001 From: ryanmelt-agent Date: Thu, 14 May 2026 19:12:03 +0000 Subject: [PATCH] Fix display of newline characters in telemetry string values In packet viewer and other single-line value displays, embedded newlines in telemetry strings are now shown as visible \n escape sequences rather than silently truncating the display. \r and \t are similarly escaped. In TEXTBOX screen widgets, actual newlines are preserved so the v-textarea renders them as real line breaks, splitting the value across multiple rows. The opt-out is a data property (escapeSpecialCharacters: false) on the widget, keeping FormatValueBase generic for future multi-line widgets. Fixes #154 Co-Authored-By: Paperclip --- .../openc3-vue-common/src/widgets/FormatValueBase.js | 9 ++++++++- .../openc3-vue-common/src/widgets/TextboxWidget.vue | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/openc3-cosmos-init/plugins/packages/openc3-vue-common/src/widgets/FormatValueBase.js b/openc3-cosmos-init/plugins/packages/openc3-vue-common/src/widgets/FormatValueBase.js index 35bc4c2664..d819808695 100644 --- a/openc3-cosmos-init/plugins/packages/openc3-vue-common/src/widgets/FormatValueBase.js +++ b/openc3-cosmos-init/plugins/packages/openc3-vue-common/src/widgets/FormatValueBase.js @@ -37,7 +37,14 @@ export default { if (value === null || value === undefined) { return 'null' } - return String(value) + const str = String(value) + // Escape special whitespace so they display visibly in single-line widgets. + // Widgets that support multi-line display (e.g. TextboxWidget) set + // escapeSpecialCharacters: false in their data() to opt out. + if (this.escapeSpecialCharacters !== false) { + return str.replace(/\r\n/g, '\\r\\n').replace(/\r/g, '\\r').replace(/\n/g, '\\n').replace(/\t/g, '\\t') + } + return str }, // sprintf-js doesn't support BigInt values so we handle common // integer format specifiers manually to preserve full precision diff --git a/openc3-cosmos-init/plugins/packages/openc3-vue-common/src/widgets/TextboxWidget.vue b/openc3-cosmos-init/plugins/packages/openc3-vue-common/src/widgets/TextboxWidget.vue index a9d02a3153..caa0ff8a56 100644 --- a/openc3-cosmos-init/plugins/packages/openc3-vue-common/src/widgets/TextboxWidget.vue +++ b/openc3-cosmos-init/plugins/packages/openc3-vue-common/src/widgets/TextboxWidget.vue @@ -66,6 +66,8 @@ export default { return { width: 200, height: 200, + // Allow actual newlines to render as line breaks in v-textarea + escapeSpecialCharacters: false, } }, computed: {