Skip to content

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

Closed

Description

@istarkov

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

Activity

  1. istarkov commented on Oct 29, 2025

    @istarkov
    ContributorAuthor
  2. github-actions commented on Oct 29, 2025

    @github-actions
    Contributor

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

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

  3. istarkov commented on Oct 29, 2025

    @istarkov
    ContributorAuthor

    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

  4. rekram1-node commented on Oct 29, 2025

    @rekram1-node
    Collaborator

    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

  5. istarkov commented on Oct 29, 2025

    @istarkov
    ContributorAuthor
  6. rekram1-node commented on Oct 29, 2025

    @rekram1-node
    Collaborator

    @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

  7. istarkov commented on Oct 29, 2025

    @istarkov
    ContributorAuthor

    Thank you! Amazing tool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions