[BUG]: XML content sometimes disappears in the TUI terminal (and isn’t rendered in shared sessions) #2332

Closed
opened 2026-02-16 17:35:10 -05:00 by yindo · 7 comments
Owner

Originally created by @istarkov on GitHub (Oct 29, 2025).

Description

The issue is this line, it removes xml (glamour inside does not accept it)

https://github.com/sst/opencode/blob/78d6b3a9637b33f80f29ef43a54fc053e42ac1f0/packages/tui/internal/components/chat/message.go#L238

Reproduction:

Video

XML content is partially rendered and then disappears in TUI/shared session

Image

Disappear in slow mo

Image

Shared link

https://opencode.ai/s/S7sCV5Dx

(xml exists in output but considered as html (output content is not quoted in html version)

OpenCode version

0.15.23

Steps to reproduce

Without subagent

Write in opencode input, see xml will disappear

You are an agent used to receive unmodified prompt

## Output

- Your output is xml described below.
- Then return result in the following valid xml format
 ```xml
  <result prompt="{user prompt}"  base64promp="{prompt in base64}" who="{who}" />
 ```
Create result based on prompt "Hi bibro"

With subagent

---
description: Call-me agent used for testing purposes, received raw unmodified user prompt
mode: subagent
---

You are an agent used to receive unmodified prompt

## Output

- Your output is xml described below.
- Then return result in the following valid xml format
  ```xml
  <result prompt="{user prompt}"  base64promp="{prompt in base64}" who="{who}" />
 ```

Reproduce

Open opencode

@call-me hi bro

Then shift - right, see resulting xml sometimes will dissapear.

Screenshot and/or share link

https://opencode.ai/s/S7sCV5Dx

Image

Operating System

No response

Terminal

iTerm2

Originally created by @istarkov on GitHub (Oct 29, 2025). ### Description The issue is this line, it removes xml (glamour inside does not accept it) https://github.com/sst/opencode/blob/78d6b3a9637b33f80f29ef43a54fc053e42ac1f0/packages/tui/internal/components/chat/message.go#L238 ## Reproduction: ### Video XML content is partially rendered and then disappears in TUI/shared session ![Image](https://github.com/user-attachments/assets/9e1080a6-5ad9-4ee7-9df8-75be51a5aaa2) Disappear in slow mo ![Image](https://github.com/user-attachments/assets/8d35d5f4-8b76-4123-b779-90f5d356f85c) ### Shared link https://opencode.ai/s/S7sCV5Dx (xml exists in output but considered as html (output content is not quoted in html version) ### OpenCode version 0.15.23 ### Steps to reproduce #### Without subagent Write in opencode input, see xml will disappear ````markdown You are an agent used to receive unmodified prompt ## Output - Your output is xml described below. - Then return result in the following valid xml format ```xml <result prompt="{user prompt}" base64promp="{prompt in base64}" who="{who}" /> ``` Create result based on prompt "Hi bibro" ```` #### With subagent ````markdown --- description: Call-me agent used for testing purposes, received raw unmodified user prompt mode: subagent --- You are an agent used to receive unmodified prompt ## Output - Your output is xml described below. - Then return result in the following valid xml format ```xml <result prompt="{user prompt}" base64promp="{prompt in base64}" who="{who}" /> ``` ```` ### Reproduce Open `opencode` ``` @call-me hi bro ``` Then `shift - right`, see resulting xml sometimes will dissapear. ### Screenshot and/or share link https://opencode.ai/s/S7sCV5Dx ![Image](https://github.com/user-attachments/assets/9e1080a6-5ad9-4ee7-9df8-75be51a5aaa2) ### Operating System _No response_ ### Terminal iTerm2
yindo added the bug label 2026-02-16 17:35:10 -05:00
yindo closed this issue 2026-02-16 17:35:10 -05:00
Author
Owner

@istarkov commented on GitHub (Oct 29, 2025):

Video file
https://github.com/user-attachments/assets/6702b3ac-a0ad-444b-9ec5-2c4d0f8f0ad4

@istarkov commented on GitHub (Oct 29, 2025): Video file https://github.com/user-attachments/assets/6702b3ac-a0ad-444b-9ec5-2c4d0f8f0ad4
Author
Owner

@github-actions[bot] commented on GitHub (Oct 29, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #3338: Issues with navigating to subagent sessions using shift+right keybinding - directly relates to the navigation aspect mentioned in this issue
  • #3173: Subagent results not always properly handled - subagent output not being visible in parent session, requires navigating to child session to see content
  • #2645: Empty results from subagent - subagent content disappearing/not appearing in main session
  • #3312: Content rendering issues in OpenTUI where markdown/formatted content isn't properly displayed

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Oct 29, 2025): This issue might be a duplicate of existing issues. Please check: - #3338: Issues with navigating to subagent sessions using shift+right keybinding - directly relates to the navigation aspect mentioned in this issue - #3173: Subagent results not always properly handled - subagent output not being visible in parent session, requires navigating to child session to see content - #2645: Empty results from subagent - subagent content disappearing/not appearing in main session - #3312: Content rendering issues in OpenTUI where markdown/formatted content isn't properly displayed Feel free to ignore if none of these address your specific case.
Author
Owner

@istarkov commented on GitHub (Oct 29, 2025):

Fast fix idea is to use +- same regexp which is used for stripping html xml content in ts code but instead of deleting it

  • mask: Detect tags <[A-Za-z!/](?:"[^"]*"|'[^']*'|[^'"<>])*?>, replace < > on something like {{LT}} {{GT}}
  • glamour: Then convert with glamour
  • unmask: Then convert {{LT}} {{GT}} back
// pseudo code
var tagRe = regexp.MustCompile(`(?is)<[A-Za-z!/](?:"[^"]*"|'[^']*'|[^'"<>])*?>`)

func renderPreservingHTML(md string) (string, error) {
	// 1) Pre: mask angles *only inside tags*
	masked := tagRe.ReplaceAllStringFunc(md, func(s string) string {
		return strings.NewReplacer("<", "{{LT}}", ">", "{{GT}}").Replace(s)
	})

	// 2) Glamour render
	r := ToMarkdown(masked)

	// 3) Post: unmask back to literal <...>
	out = strings.ReplaceAll(out, "{{LT}}", "<")
	out = strings.ReplaceAll(out, "{{GT}}", ">")
	return out, nil
}

regexp playground

https://regex101.com/r/sf64K8/1

I will do if it's ok

@istarkov commented on GitHub (Oct 29, 2025): Fast fix idea is to use +- same regexp which is used for stripping html xml content in ts code but instead of deleting it - mask: Detect tags `<[A-Za-z!/](?:"[^"]*"|'[^']*'|[^'"<>])*?>`, replace `<` `>` on something like `{{LT}}` `{{GT}}` - glamour: Then convert with glamour - unmask: Then convert {{LT}} {{GT}} back ```go // pseudo code var tagRe = regexp.MustCompile(`(?is)<[A-Za-z!/](?:"[^"]*"|'[^']*'|[^'"<>])*?>`) func renderPreservingHTML(md string) (string, error) { // 1) Pre: mask angles *only inside tags* masked := tagRe.ReplaceAllStringFunc(md, func(s string) string { return strings.NewReplacer("<", "{{LT}}", ">", "{{GT}}").Replace(s) }) // 2) Glamour render r := ToMarkdown(masked) // 3) Post: unmask back to literal <...> out = strings.ReplaceAll(out, "{{LT}}", "<") out = strings.ReplaceAll(out, "{{GT}}", ">") return out, nil } ``` regexp playground https://regex101.com/r/sf64K8/1 I will do if it's ok
Author
Owner

@rekram1-node commented on GitHub (Oct 29, 2025):

We are about to ship a full rewrite of the tui that will have a different markdown renderer, may be better to address this once that ships unless XML is a big blocker for u

@rekram1-node commented on GitHub (Oct 29, 2025): We are about to ship a full rewrite of the tui that will have a different markdown renderer, may be better to address this once that ships unless XML is a big blocker for u
Author
Owner

@istarkov commented on GitHub (Oct 29, 2025):

https://github.com/sst/opencode/tree/opentui ? here?

@istarkov commented on GitHub (Oct 29, 2025): https://github.com/sst/opencode/tree/opentui ? here?
Author
Owner

@rekram1-node commented on GitHub (Oct 29, 2025):

@istarkov yes! I bet this issue still exists there too tbh but if you were interested in making a fix, branching off that would probably be best.

One note is the markdown renderer is about to be updated today or tmr probs so id hold off until that gets merged

@rekram1-node commented on GitHub (Oct 29, 2025): @istarkov yes! I bet this issue still exists there too tbh but if you were interested in making a fix, branching off that would probably be best. One note is the markdown renderer is about to be updated today or tmr probs so id hold off until that gets merged
Author
Owner

@istarkov commented on GitHub (Oct 29, 2025):

Thank you! Amazing tool!

@istarkov commented on GitHub (Oct 29, 2025): Thank you! Amazing tool!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2332