fix: String() conversion for block.blockContent, avoid ES2019 methods

blockContent from QVariant needs explicit String() conversion.
Use charAt/indexOf instead of startsWith (ES6 compat).
This commit is contained in:
Levi Neely 2026-07-16 07:03:40 +02:00
parent 38df1a8e32
commit c2ff88e8e6
1 changed files with 4 additions and 4 deletions

View File

@ -622,7 +622,7 @@ ApplicationWindow {
Text {
id: callText
Layout.fillWidth: true
text: visible ? chatModel.prettyJson(block.blockContent || "") : ""
text: visible ? chatModel.prettyJson(String(block.blockContent || "")) : ""
textFormat: Text.RichText
wrapMode: Text.Wrap
font.family: "monospace"
@ -653,12 +653,12 @@ ApplicationWindow {
Layout.fillWidth: true
text: {
if (!visible) return ""
let content = block.blockContent || ""
let content = String(block.blockContent || "")
if (!content) return ""
let trimmed = content.trim()
if (trimmed.startsWith("{") || trimmed.startsWith("["))
if (trimmed.charAt(0) === '{' || trimmed.charAt(0) === '[')
return chatModel.prettyJson(content)
if (trimmed.startsWith("---") || trimmed.startsWith("diff "))
if (trimmed.indexOf("---") === 0 || trimmed.indexOf("diff ") === 0)
return chatModel.highlightedHtml(content, "diff")
return content.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g, '<br>')
}