Skip to content

fix(bots): render Markdown in saved answers to item questions - #51002

Merged
nwparker merged 1 commit into
stablyai:mainfrom
lafraia:fix/historical-bot-item-answer-markdown
Nov 27, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
lafraia:fix/historical-bot-item-answer-markdown

Conversation

@lafraia

@lafraia lafraia commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When you answer a bot's question on an item in your own words, and later look back at that item, your answer now shows formatting (bold, code, links) and bot mentions the same way a normal item comment does, instead of raw ** and [Bot: ...](bot:...) text.

What Changed

  • Before: a closed item question folds its saved answer into a muted "Question → answer" line. That line printed the answer as plain text, so Markdown punctuation and the bot ID inside a mention were visible.
  • After: free-text answers on that line are drawn with BotItemMarkdown, the same memoized renderer item comments use. The first paragraph runs on after the arrow. Picked quick replies stay plain text, written as their chip wrote them, so a label like 1. Merge it does not become a numbered list.
  • Mechanism: botItemAnswer (in src/shared/bots/bot-item-answer-lines.ts) now returns { words, picked } instead of only the words. Picks are read from the line's own answer instead of a rebuilt comment. A sent line collapses runs of spaces, so a label like The *lead* is also matched against its space-collapsed form and still counts as a pick. botItemAnswerWords stays as a wrapper with the same output for existing callers, including mobile and older clients. BotItemAnswerLine renders a <div> (Markdown blocks cannot sit inside a <p>), and a plain answer keeps its line breaks.

Why

Saved free-text answers should look the same whether they show as a comment or folded into the question. Reusing the item comment renderer gives the same sanitizing, mention chips and link handling, with no second Markdown path. Quick replies stay plain because those words are fixed labels, not something the owner wrote.

Linked Issue

Fixes #50996

Original fix by @lafraia in #51002; final version reworked during the bug bash.

Visual Proof

N/A for new captures. No proof artifacts were recorded for the reworked version, and GUI runs are not allowed on the build machine for this landing. The contributor's original before/after captures of the same component, from the first version of this PR, show the user-facing change:

The answeredInWords fixture in BotItemCommentCard.fixture.tsx renders the after state.

Testing

  • Repro: an item question answered in free text with **bold**, inline code and a [Bot: Name](bot:id) mention showed the raw syntax on the closed question line.
  • Automated tests added/updated: BotItemQuestionLines.test.tsx (Markdown and mention chip drawn, no nested <p>, quick replies including 1. ... and space-run labels stay literal, plain line breaks kept) and bot-item-answer-lines.test.ts (picks matched against space-collapsed labels per question).
  • vitest run across src/renderer/src/components/bots/items and src/shared/bots/bot-item-answer-lines.test.ts: 12 files, 85 tests pass. oxfmt, oxlint, anti-slop oxlint, native code-quality oxlint, ast-grep and the changed-code quality gate are clean on the touched files.
  • Platforms: macOS (unit tests). The renderer path does not depend on platform.

Performance

None that matters. The parsing runs per answered question line when an item card renders, not on a terminal, polling or startup path. Measured botItemAnswerWords old vs new (µs per card, 2000 runs): typical pick 0.55 → 0.59, typical free text 0.80 → 0.82–0.89, a 19 KB free-text answer 1.72 → 1.65–1.70, an adversarial 8 questions × 10 space-run labels 1.89 → 1.87–1.92. All within noise. The space-collapsed matching only runs when a label has a run of spaces. Free-text answers now go through the memoized BotItemMarkdown, the same cost as the matching comment. The work is per card, with no shared store or selector change, so updating one item does not recompute any other.

Risk

Level: Low. The riskiest part is how a saved free-text answer wraps and displays on its question line. If it broke, users would see formatting or spacing problems in historical answers. Saved data, sends and the shared botItemAnswerWords output are unchanged. Back out with a plain revert.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance. Markdown goes through the existing chat sanitizer and mention handling. No platform, SSH or remote-specific code. Mobile and older clients keep using botItemAnswerWords, whose output is unchanged.

Reported by @lafraia

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Answer content now distinguishes picked replies from free-text answers. Bot question answer lines render free-text answers with Markdown, including bot mentions. Picked replies and other plain-text answers retain plain-text rendering. Answer-line normalization supports option labels with different whitespace and removes sent-image prompt markers from answer text.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to de6b4

Free-text answers to bot questions now render Markdown and bot mentions in the item activity, and picked replies stay literal. No merge-blocking risk remains.

Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Description check Warning The description covers most template sections with substantive content: ELI5, What Changed (before/after and mechanism), Why, Linked Issue (Fixes #50996), Performance, Risk with a level, and Testing w… 1. Replace the Visual Proof N/A with a before/after capture of the reworked version, or with a working tabbed before/after comparison. Attach it through the PR's attachment flow, not through committed files. Remove the N/A text. 2. Confirm …
Passed Passed checks: 3 passed

Check name Status Explanation
Linked Issues check Passed [#50996] requires saved free-text answers to bot item questions to render Markdown and bot mentions like item comments, in the item activity after the question is answered. Objective status: Addressed…
Out of Scope Changes check Passed All listed changed files relate to the [#50996] objective. BotItemMarkdown.tsx gains an optional className prop that lets BotItemAnswerLine style the rendered answer. BotItemQuestionLines.tsx and BotI…
Title check Passed The title names the main change: Markdown rendering in saved answers to bot item questions. It uses the conventional commit form and is specific. It matches the changeset, which renders free-text answ…
Full details: Linked Issues check

Explanation

[#50996] requires saved free-text answers to bot item questions to render Markdown and bot mentions like item comments, in the item activity after the question is answered. Objective status: Addressed, from the whole-PR summary and one focused read. BotItemQuestionLines.tsx derives the answer kind through botItemAnswer and passes a markdown flag to BotItemAnswerLine. BotItemQuestionStep.tsx renders BotItemMarkdown when markdown is true. Predefined option answers keep the plain-text path, which the issue does not require to change. Read of BotItemMarkdown.tsx at the reviewed head confirms it is the item comment renderer. It wraps NativeChatMarkdown with the item density styling and an optional className, so the answer line uses the same renderer as item comments. Parser regressions in bot-item-answer-lines.test.ts cover collapsed option labels and attachment markers. Renderer tests in BotItemQuestionLines.test.tsx assert formatted text and mention chips. Limits: the diff between the previous reviewed head and the current head could not be read because changed blobs are missing from the checkout. The current head therefore relies on the supplied whole-PR summary, which describes the same behavior as the previous assessment. The mention chip output was not confirmed in source, and the rendered check ran on macOS only. The issue has no non-coding acceptance criteria.

Full details: Out of Scope Changes check

Explanation

All listed changed files relate to the [#50996] objective. BotItemMarkdown.tsx gains an optional className prop that lets BotItemAnswerLine style the rendered answer. BotItemQuestionLines.tsx and BotItemQuestionStep.tsx choose between plain text and Markdown for answer lines. bot-item-answer-lines.ts adds botItemAnswer, which returns the answer kind and words used for that choice. Its whitespace fallback and attachment-marker stripping support the parser regressions named in the PR. BotItemCommentCard.fixture.tsx adds a fixture for the new behavior. The test files cover the same objective. No listed change alters saved data, authorization, or unrelated item behavior. Limit: the incremental diff from the previous reviewed head could not be read, so this conclusion covers the supplied whole-PR summary and the file read above.

Full details: Title check

Explanation

The title names the main change: Markdown rendering in saved answers to bot item questions. It uses the conventional commit form and is specific. It matches the changeset, which renders free-text answers through BotItemMarkdown on the closed question line.

Full details: Description check

Explanation

The description covers most template sections with substantive content: ELI5, What Changed (before/after and mechanism), Why, Linked Issue (Fixes #50996), Performance, Risk with a level, and Testing with automated test details. Two required items are not met. First, Visual Proof is marked N/A, but the template requires a before/after for UI behavior changes. The author cites external attachment links from the first version of the PR and states that no proof was recorded for the reworked version. The rendered change is user-visible, so the N/A exemption does not apply. Second, the Testing checklist has an unchecked item: the author did not state that the change was manually tested locally, and the Repro line is only partly tied to this version. The 'Every added test fails without this change' checkbox is also not explicitly confirmed. The AI Disclosure, Review, and Agent skill upstream boundary sections are left as template text or are unaddressed. The Checklist is not filled in. These gaps are not critical to the change's intent, but the missing UI proof is a required item.

Resolution

  1. Replace the Visual Proof N/A with a before/after capture of the reworked version, or with a working tabbed before/after comparison. Attach it through the PR's attachment flow, not through committed files. Remove the N/A text. 2. Confirm the Testing checklist. State whether the change was tested manually on the reworked version, and confirm that the new tests fail without the change. 3. Fill in or remove the AI Disclosure section, and complete the Agent skill upstream boundary checkbox. 4. Tick the Checklist items that apply, or explain any that do not.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e7b24e52-0825-4de8-ba0d-4f1ae5c8eddf
Commits

Reviewing files that changed from the base of the PR and between dda68f1 and de6b40a.

Files selected for processing: 6

  • src/renderer/src/components/bots/items/BotItemCommentCard.fixture.tsx
  • src/renderer/src/components/bots/items/BotItemQuestionLines.test.tsx
  • src/renderer/src/components/bots/items/BotItemQuestionLines.tsx
  • src/renderer/src/components/bots/items/BotItemQuestionStep.tsx
  • src/shared/bots/bot-item-answer-lines.test.ts
  • src/shared/bots/bot-item-answer-lines.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

A free-text answer to a closed bot item question showed its raw Markdown
and bot mention syntax on the folded "Question → answer" line. The line
now draws the owner's own words with the item's Markdown renderer, so
formatting and mentions look as they do in a regular item comment.
Picked quick replies, including labels whose runs of spaces were
collapsed when sent, stay plain text as their chip wrote them.

Fixes stablyai#50996

Co-authored-by: Daniel Lafraia <[email protected]>
@nwparker
nwparker force-pushed the fix/historical-bot-item-answer-markdown branch from dda68f1 to de6b40a Compare November 27, 2026 17:23
@nwparker nwparker changed the title fix(bots): render Markdown in historical item answers fix(bots): render Markdown in saved answers to item questions Nov 27, 2026
@nwparker
nwparker merged commit f6b15b0 into stablyai:main Nov 27, 2026
57 of 59 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.

[Bug]: Historical answers to bot item questions display raw Markdown

2 participants