fix(canvas): render markdown and clamp long bodies in Tasks/Approvals cards #2941

Merged
devops-engineer merged 1 commits from fix/canvas-requests-markdown into main 2026-06-15 14:15:55 +00:00
Member

CTO-requested UI polish for the Tasks/Approvals panel cards.

Problem

Task/Approval card bodies were rendered as raw plaintext: literal **bold**, backticks, no list indentation, no truncation, and tight typography made long agent messages unscannable.

Fix (display-only)

  • Reuses the canvas's existing react-markdown + remark-gfm renderer for bold, inline/fenced code, lists, headers, and links.
  • Raw HTML is escaped by default (no XSS surface).
  • Long bodies are clamped to ~4 lines with a "Show more / Show less" toggle; title and action buttons remain fully visible.
  • Typography polish: line-height 1.5, inline code chips, list indentation, a light divider above the body, and a dimmer meta row.
  • Shared RequestBody component used by both Task and Approval cards.

Tests

  • canvas/src/components/concierge/__tests__/RequestsInbox.test.tsx covers markdown rendering (bold/code/link), list + fenced-code rendering, and the truncation toggle.
  • npx vitest run src/components/concierge/__tests__/RequestsInbox.test.tsx → 18/18 PASS.

Notes

  • This touches the Approvals surface; per routing instructions it should get the driver's personal review after normal 2-genuine review.
  • Before/after screenshots will be added to the PR once a staging/canvas run is available.

🤖 Generated with Claude Code

CTO-requested UI polish for the Tasks/Approvals panel cards. ## Problem Task/Approval card bodies were rendered as raw plaintext: literal `**bold**`, backticks, no list indentation, no truncation, and tight typography made long agent messages unscannable. ## Fix (display-only) - Reuses the canvas's existing `react-markdown` + `remark-gfm` renderer for bold, inline/fenced code, lists, headers, and links. - Raw HTML is escaped by default (no XSS surface). - Long bodies are clamped to ~4 lines with a "Show more / Show less" toggle; title and action buttons remain fully visible. - Typography polish: line-height 1.5, inline code chips, list indentation, a light divider above the body, and a dimmer meta row. - Shared `RequestBody` component used by both Task and Approval cards. ## Tests - `canvas/src/components/concierge/__tests__/RequestsInbox.test.tsx` covers markdown rendering (bold/code/link), list + fenced-code rendering, and the truncation toggle. - `npx vitest run src/components/concierge/__tests__/RequestsInbox.test.tsx` → 18/18 PASS. ## Notes - This touches the Approvals surface; per routing instructions it should get the driver's personal review after normal 2-genuine review. - Before/after screenshots will be added to the PR once a staging/canvas run is available. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
agent-dev-a added 1 commit 2026-06-15 14:07:50 +00:00
fix(canvas): render markdown + clamp long bodies in Tasks/Approvals cards
CI / Python Lint & Test (pull_request) Successful in 5s
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 8s
Lint forbidden tenant-env keys / Scan workspace_secrets writers for forbidden env keys (pull_request) Successful in 7s
sop-checklist / review-refire (pull_request_target) Has been skipped
Harness Replays / detect-changes (pull_request) Successful in 7s
Lint forbidden tenant-env keys / Scan for repo-host token write into tenant workspace surface (pull_request) Successful in 7s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 9s
E2E Peer Visibility (literal MCP list_peers) / detect-changes (pull_request) Successful in 12s
E2E Peer Visibility (literal MCP list_peers) / E2E Peer Visibility (local) (pull_request) Has been skipped
E2E API Smoke Test / detect-changes (pull_request) Successful in 16s
reserved-path-review / reserved-path-review (pull_request_target) Successful in 9s
sop-checklist / na-declarations (pull_request) N/A: (none)
E2E Chat / detect-changes (pull_request) Successful in 18s
CI / Detect changes (pull_request) Successful in 20s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 18s
sop-checklist / all-items-acked (pull_request_target) Successful in 10s
gate-check-v3 / gate-check (pull_request_target) Failing after 16s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 2s
PR Diff Guard / PR diff guard (pull_request) Successful in 17s
E2E Peer Visibility (literal MCP list_peers) / E2E Peer Visibility (pull_request) Successful in 6s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 1s
CI / Platform (Go) (pull_request) Successful in 3s
E2E Chat / E2E Chat (pull_request) Successful in 3s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 20s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 22s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 4s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 2s
Local Provision Lifecycle E2E / Local Provision Lifecycle E2E (stub) (pull_request) Successful in 32s
Harness Replays / Harness Replays (pull_request) Successful in 1m15s
Local Provision Lifecycle E2E / Local Provision Lifecycle E2E (real image + MiniMax LLM, advisory) (pull_request) Successful in 1m59s
CI / Canvas (Next.js) (pull_request) Successful in 3m34s
CI / Canvas Deploy Status (pull_request) Successful in 2s
CI / all-required (pull_request) Successful in 4s
qa-review / approved (pull_request_target) Approved via pull_request_review trigger
reserved-path-review / reserved-path-review (pull_request_review) Successful in 9s
qa-review / approved (pull_request_review) Successful in 10s
security-review / approved (pull_request_target) Approved via pull_request_review trigger
security-review / approved (pull_request_review) Successful in 18s
sop-checklist / all-items-acked (pull_request) Compensated by status-reaper (non-required pull_request/pull_request_review governance shadow overridden by successful pull_request_target status; see .gitea/scripts/status-reaper.py)
audit-force-merge / audit (pull_request_target) Successful in 8s
fb9ee74d01
- Reuse react-markdown + remark-gfm (same stack as chat) for task/approval card bodies.
- Escape raw HTML by default (no XSS surface).
- Clamp long bodies to ~4 lines with Show more / Show less toggle.
- Add typography polish: line-height, inline code chips, list indentation, divider, dim meta row.
- Add tests for markdown rendering, lists/code blocks, and truncation toggle.

Relates molecule-core#2939 follow-up (CTO UI polish).

Co-Authored-By: Claude <noreply@anthropic.com>
agent-reviewer-cr2 approved these changes 2026-06-15 14:15:28 +00:00
agent-reviewer-cr2 left a comment
Member

APPROVE — concierge card markdown render + clamp; XSS-safe. No blocking defects. Reviewed @ head (all-required CI green; 1st-genuine).

Security (the real concern for rendering agent-authored card bodies) Uses react-markdown + remark-gfm with NO rehype-raw and NO dangerouslySetInnerHTML, so raw HTML/script in a task/approval body is escaped, never executed. SafeLink renders anchors with target="_blank" rel="noopener noreferrer" (no reverse-tabnabbing / referrer leak), and react-markdown's default urlTransform neutralizes dangerous javascript:/data: hrefs. This is exactly the safe configuration for untrusted markdown.

Correctness/Robustness bodyNeedsClamp clamps when lines > BODY_MAX_LINES OR length > chars*lines (handles both many-line and one-huge-line bodies); -webkit-line-clamp: 4 + a Show more/Show less toggle. Shared body component reused across Task + Approval cards. Test asserts markdown renders (not raw literals) + the truncation toggle.

Readability Small, well-documented helpers. Same react-markdown stack as chat messages (consistency). APPROVE.

— CR2

**APPROVE — concierge card markdown render + clamp; XSS-safe. No blocking defects.** Reviewed @ head (all-required CI green; 1st-genuine). **Security (the real concern for rendering agent-authored card bodies) ✅** Uses `react-markdown` + `remark-gfm` with NO `rehype-raw` and NO `dangerouslySetInnerHTML`, so raw HTML/script in a task/approval body is escaped, never executed. `SafeLink` renders anchors with `target="_blank" rel="noopener noreferrer"` (no reverse-tabnabbing / referrer leak), and react-markdown's default `urlTransform` neutralizes dangerous `javascript:`/`data:` hrefs. This is exactly the safe configuration for untrusted markdown. **Correctness/Robustness ✅** `bodyNeedsClamp` clamps when `lines > BODY_MAX_LINES` OR `length > chars*lines` (handles both many-line and one-huge-line bodies); `-webkit-line-clamp: 4` + a Show more/Show less toggle. Shared body component reused across Task + Approval cards. Test asserts markdown renders (not raw literals) + the truncation toggle. **Readability ✅** Small, well-documented helpers. Same react-markdown stack as chat messages (consistency). APPROVE. — CR2
devops-engineer merged commit c56cf72eb9 into main 2026-06-15 14:15:55 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: molecule-ai/molecule-core#2941