Skip to content

Consolidate SetQA AI Q&A renderer onto shared MarkdownView pipeline (DRY + mermaid parity) #71

@cgbarlow

Description

@cgbarlow

Background

SetQA.svelte maintains its own divergent local renderMarkdown (lines 618-624, used at lines 771 and 847 for completed and streaming AI answers). This duplicates the canonical pipeline in frontend/src/lib/components/markdownHelpers.ts and violates protocol #13 (DRY) in docs/protocols.md.

After v5.7.0 (ADR-149) the canonical MarkdownView pipeline gains Mermaid diagram rendering. The AI Q&A panel does not inherit that automatically because of the duplication.

Behavioural differences today

Capability Shared MarkdownView SetQA local
iris:// link click-through Yes No
Image rendering with src allowlist Yes No
URL-scheme allowlist Default + iris: Whitelist-based tag allowlist
Mermaid diagrams (post-v5.7.0) Yes No

Proposed change

Replace SetQA's local renderMarkdown with an import from markdownHelpers.ts and wire runMermaidIn(answerEl, currentTheme) after each {@html} injection (both completed and streaming answer containers). Verify streaming-partial mermaid degrades gracefully (incomplete fence renders as the small error placeholder until the closing fence arrives).

Acceptance criteria

  • AI Q&A answers render mermaid diagrams (parity with /views/[id] Text views).
  • AI Q&A answers honour iris:// link clicks (jump to diagram/element).
  • AI Q&A answers respect the canonical image-src allowlist.
  • No regression in existing AI Q&A rendering tests; new test asserts identical HTML between SetQA answer and MarkdownView for the same source.
  • Streaming answers handle in-progress mermaid fences without crashing the panel.

References

  • ADR-137 (text diagram + shared markdown renderer)
  • ADR-149 (mermaid in markdown — v5.7.0)
  • Protocol feat: Collections, multi-set AI context (v2.7.4) #13 (DRY) in docs/protocols.md
  • frontend/src/lib/components/SetQA.svelte lines 618-624, 771, 847
  • frontend/src/lib/components/markdownHelpers.ts

Out of scope for this issue

This issue covers the renderer fold only. Further AI-answer-specific UX (e.g. mermaid-block copy-to-clipboard, diagram fullscreen) belongs in its own follow-up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions