Skip to content

fix: render Ask AI answers as markdown 📝 - #918

Merged
levin0710 merged 1 commit into
colorstackorg:mainfrom
Wisesofthemall:fix/ask-ai-markdown
Nov 8, 2026
Merged

levin0710 merged 1 commit into
colorstackorg:mainfrom
Wisesofthemall:fix/ask-ai-markdown

Conversation

@Wisesofthemall

Copy link
Copy Markdown
Contributor

Description ✏️

Closes #914

The Ask AI answer was printed as raw text, so the model's markdown showed up literally (**bold**, - and 1. lists, backticks). This PR renders it with react-markdown, so there's no parsing logic of our own. It replaces #915, #916 and #917, following the review feedback there.

  • react-markdown renders the answer, with two small official plugins:
    • remark-gfm for tables and auto-linked URLs.
    • remark-breaks so a single newline still starts a new line. The old whitespace-break-spaces rendering kept every newline, and the model often writes lines that way.
  • References: before rendering, each [ref:N] segment becomes a markdown link to #ref-N. The a override turns those links back into the existing ReferenceLink pills, so citations still work inside lists, bold text and tables. Other links open in a new tab.
  • Styling: element overrides with Tailwind classes for lists, inline code, code blocks, tables, headings and quotes. @tailwindcss/typography isn't installed, so the styles are explicit classes.
  • Safety: react-markdown doesn't render raw HTML by default, and images are disallowed, so the page never loads image URLs from the model.
  • Prompt: one added rule asks the model to format its answer in Markdown and not to use --- as a divider. --- separates the JSON block from the answer.
  • The server response shape is unchanged, so answers already cached in Redis render correctly too.

Screenshots 📸

Taken locally on /ask-ai. A sample answer was stored in Redis so the page renders it without calling the AI.

Before (main) After
Before: raw markdown After: formatted answer

Mobile (390px wide, no sideways page scroll), and the other markdown elements (headings, list styles, quote, table, code block, links):

After, on mobile Other markdown elements

Sample answer used for the before/after
Great question! Here's how most members approach **offer negotiation** [ref:1]:

**Before you negotiate**
- Get the offer **in writing** first, including base, bonus and equity [ref:2].
- Research ranges on Levels.fyi for your *exact* level and location.
- Have a **competing offer** if you can; it's the strongest leverage you have.

**During the call**
1. Thank the recruiter and show you're *excited* about the role.
2. Ask: "Is there any flexibility on the base salary?"
3. If they say no, ask about a **signing bonus** or **relocation** instead [ref:3].

Some members got an extra $5,000 to $10,000 just by asking [ref:2]. Remember, the worst they can say is *no*.

• Tip: keep notes after every call.
• Tip: never accept on the spot; ask for a day or two.

Testing 🧪

  • Ran the app locally, logged in, and loaded /ask-ai with sample answers stored in Redis (screenshots above). Checked:
    • bold, italics, both list types (including a numbered list that starts at 4), inline code, code blocks, tables, quotes and links
    • citations inside sentences, list items and table cells
    • prices like $5,000 stay as text
    • no sideways scrolling on a 390px-wide screen
  • react-router build, tsc and ESLint pass for member-profile.
  • I didn't submit live questions, because they need Anthropic, Pinecone and Slack keys. A quick question on a preview would confirm the prompt change.

Type of Change 🐞

  • Feature - A non-breaking change which adds functionality.
  • Fix - A non-breaking change which fixes an issue.
  • Refactor - A change that neither fixes a bug nor adds a feature.
  • Documentation - A change only to in-code or markdown documentation.
  • Tests - A change that adds missing unit/integration tests.
  • Chore - A change that is likely none of the above.

Checklist ✅

  • I have done a self-review of my code.
  • I have manually tested my code (if applicable).
  • I have added/updated any relevant documentation (if applicable).

🤖 Generated with Claude Code

Renders the Ask AI answer with react-markdown (plus remark-gfm for tables
and remark-breaks to keep single line breaks) instead of raw text, so
bold, lists, code and tables display properly. Thread references are
turned into "#ref-N" links and rendered as the existing reference pills.

Closes colorstackorg#914.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@levin0710 levin0710 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@levin0710
levin0710 merged commit f95bf31 into colorstackorg:main Nov 8, 2026
2 checks passed
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.

ASK AI formatting is off

2 participants