Skip to content

Strip leaked <cite> tags from chat output#22

Merged
philosophercode merged 1 commit into
mainfrom
philosophercode/fix-chat-cite-tags
May 29, 2026
Merged

Strip leaked <cite> tags from chat output#22
philosophercode merged 1 commit into
mainfrom
philosophercode/fix-chat-cite-tags

Conversation

@philosophercode

Copy link
Copy Markdown
Owner

Problem

The MakerLab Assistant grounds answers with inline source markup like
<cite index="1-9">…</cite>. The chat renders assistant text with
react-markdown, which has no raw-HTML plugin, so the tags showed up as
literal text (e.g. <cite index="1-9">) in grounded answers.

Fix

Add a small stripCitations() helper in ChatFab.tsx that removes the
opening/closing <cite> tags while keeping the cited prose, and apply it to
assistant message text before it reaches react-markdown.

Scoped to assistant rendering only; no behavior change for user messages or
markdown formatting.

Notes

  • Surfaced while preparing screenshots for the ISAM 2026 demo abstract.
  • Could not run npm run lint locally (eslint not installed in this
    workspace); relying on CI.

🤖 Generated with Claude Code

The assistant grounds answers with inline source markup like
<cite index="1-9">…</cite>. react-markdown has no raw-HTML plugin, so these
tags rendered as literal text in the chat. Strip the tags (keeping the cited
prose) before rendering assistant messages.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 29, 2026 19:21
@vercel

vercel Bot commented May 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
makerlab-tools Error Error May 29, 2026 7:21pm
makerlab-tools-g4gb Ready Ready Preview, Comment May 29, 2026 7:21pm

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes grounded assistant responses rendering literal <cite …> / </cite> markup in the chat UI by stripping citation wrapper tags before content is passed to react-markdown.

Changes:

  • Added a stripCitations() helper to remove inline <cite> markup while preserving the cited text.
  • Applied citation stripping to assistant message rendering only (user messages unchanged).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +35 to +37
function stripCitations(text: string): string {
return text.replace(/<cite\b[^>]*>/gi, "").replace(/<\/cite>/gi, "");
}
@philosophercode philosophercode merged commit 18f33a2 into main May 29, 2026
3 of 4 checks passed
@philosophercode philosophercode deleted the philosophercode/fix-chat-cite-tags branch May 29, 2026 19:31
philosophercode added a commit that referenced this pull request Jun 2, 2026
Fills test gaps from PRs that merged before the suite branch was cut, and
documents v5 for agents:

- ChatFab tests for <cite> tag stripping (#22): tags removed, cited prose
  kept, multi-tag and no-tag cases. Plus pending tool-call status labels
  (get_unit_details / report_issue / generic) and the photo-upload flow
  (upload → removable preview → [Attached photos: …] hint on send, and the
  upload-error path). ChatFab statement coverage 54% → 81%; overall 87.5% → 92%.
- Dark-mode E2E (#23): tool-detail page resolves the dark design tokens when
  the dark theme is active, and the choice persists across reload.
- v5/AGENTS.md: scoped agent guide (stack, Notion data layer, key files,
  conventions, how to run the test suite) with an explicit note that the root
  CLAUDE.md is v4/AirTable and does not apply to v5.
- Install @vitest/coverage-v8 so `npm run test:coverage` works (the config
  referenced the provider but it was never added).

test:all green: 232 Vitest + 17 Playwright, lint + tsc clean.

Co-authored-by: Isaac S <philosophercode@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants