feat(tui): let injected text parts opt into markdown rendering - #43319
Open
Zaldaryon wants to merge 3 commits into
Open
feat(tui): let injected text parts opt into markdown rendering#43319Zaldaryon wants to merge 3 commits into
Zaldaryon wants to merge 3 commits into
Conversation
Contributor
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
A user message renders its text through a plain text node, so a part that a plugin or a tool injects with session.prompt shows its markup literally. The assistant path already renders through the markdown component. Text parts can now set metadata.render to "markdown" to pick the markdown component instead. Anything a person typed keeps rendering literally, so a prompt containing markdown syntax is still echoed back as it was entered. TextPartInput already carries metadata and resolvePart spreads the input part into the stored part, so no schema or server change is needed.
Zaldaryon
force-pushed
the
feat/opt-in-markdown-for-injected-user-parts
branch
from
August 19, 2026 09:13
2988083 to
f89cadd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #43318
Type of change
What does this PR do?
A user message renders its visible text through a plain
<text>node, while the assistant path renders through<markdown>:That split is right for text a person typed and wrong for text a plugin injects. Anything sent through
session.promptbecomes a text part on a user message, so a plugin reporting status back into the session can only show raw markup. The case I hit is a background agent plugin posting its completion notice into the parent session, which lands as literal headings, asterisks and backticks.A text part can now set
metadata.renderto"markdown"and get the markdown component. Parts without the flag render as before, so a typed prompt containing markdown syntax is still echoed back the way it was entered. That keeps the behavior a maintainer called intentional on #5675 while giving programmatic senders a way to ask.Why it needs no schema or server work:
TextPartInputalready carriesmetadata, andresolvePartatpackages/opencode/src/session/prompt.ts:992returns[{ ...part, messageID, sessionID }], so the flag already survives the trip from the plugin to the stored part. The TUI was the only place that had to learn to read it.The splitting logic sits in
packages/tui/src/routes/session/user-message-text.tsso it can be tested without standing up the route.How did you verify your code works?
Five new cases cover typed text staying literal, an opted-in part reaching the markdown body, one message mixing both kinds, synthetic and empty parts staying hidden, and an unrecognized
rendervalue falling back to literal text.I also ran the suite on the base commit to confirm the counts move by exactly the five tests added, and that the one flaky
flockENOENT I saw on a first run is unrelated and does not reproduce.Screenshots / recordings
A terminal screenshot would carry the color attributes, so this is the character frame from the TUI test renderer instead, same content through each path at width 64. The markup characters are what the frame can show:
Say the word if you want a recording of the real TUI and I will attach one.
Writer side
The first caller is ready on the other side of the wire: code-yeongyu/oh-my-openagent#7042 tags its background task notifications with the same hint. Neither change depends on the other landing first. A client that ignores
metadatakeeps its current behavior, and a part without the flag renders the way it does today.Checklist