New request
#2144: feat: MEDIA: inline image rendering missing from React Markdown.tsx (SessionsPage)
We'll provision a sandbox, run an agent against the issue, and open a draft PR. You can pull the branch and iterate from there.
Summary
The static/ui.js renderer already supports MEDIA: token inline rendering (merged in v0.50.41 via PR #459), but the React-based web/src/components/Markdown.tsx used by SessionsPage.tsx does not parse MEDIA: tokens — they fall through as plain text, appearing as a raw path string instead of an inline image.
Current behavior
When viewing session history (SessionsPage), assistant messages containing MEDIA:/path/to/image.jpg render the raw text path rather than an <img> element.
Expected behavior
MEDIA: tokens should be parsed and rendered as inline images via the existing /api/media?path=... endpoint, matching the behavior of static/ui.js.
Reproduction
- Have agent respond with
MEDIA:/root/workspace/image_001.jpg - View the message in ChatPage (PTY terminal) → renders correctly via
ui.js - Navigate to SessionsPage and open that session →
MEDIA:token shown as plain text
Root cause
Markdown.tsx parseInline() regex (line ~245) does not include MEDIA: pattern matching:
const pattern =
/(`[^`]+`)|(\[([^\]]+)\]\(([^)]+)\))|(\*\*([^*]+)\*\*)|(\*([^*]+)\*)|(\bhttps?:\/\/[^\s<>)\]]+)|(\n)/g;
The TUI's markdown.tsx correctly handles this via MEDIA_LINE_RE (line 83).
Proposed fix
Add MEDIA: token type to InlineNode union and parse pattern:
// New node type
| { type: "media"; path: string }
// Regex addition (before bare URL):
|(MEDIA:(\S+))
// Render case:
case "media": {
const src = node.path.startsWith('/')
? `/api/media?path=${encodeURIComponent(node.path)}`
: node.path;
return <img key={i} src={src} alt="media" className="max-w-full rounded-lg" />;
}
Affected files
web/src/components/Markdown.tsx— addMEDIA:parsing and<img>rendering
Well-scoped renderer parity fix adding MEDIA: token parsing to a single React component.
- web/src/components/Markdown.tsx
- web/src/components/SessionsPage.tsx