github →

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.

Issue
enhancementrenderer

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

  1. Have agent respond with MEDIA:/root/workspace/image_001.jpg
  2. View the message in ChatPage (PTY terminal) → renders correctly via ui.js
  3. 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 — add MEDIA: parsing and <img> rendering
Assessmentadvisory
feature easy95% confidence

Well-scoped renderer parity fix adding MEDIA: token parsing to a single React component.

Likely files
  • web/src/components/Markdown.tsx
  • web/src/components/SessionsPage.tsx
Create the request

This opens a fresh agent run and a draft PR for issue #2144.

Cancel