Skip to content

fix(web): repair malformed strong-emphasis spacing in assistant output - #786

Open
p421098 wants to merge 1 commit into
HKUDS:devfrom
p421098:fix/web-malformed-strong-emphasis
Open

fix(web): repair malformed strong-emphasis spacing in assistant output#786
p421098 wants to merge 1 commit into
HKUDS:devfrom
p421098:fix/web-malformed-strong-emphasis

Conversation

@p421098

@p421098 p421098 commented Aug 7, 2026

Copy link
Copy Markdown

Description

Assistant responses can contain malformed strong-emphasis Markdown such as:

**發布日期: **2026 年 7 月 30 日

CommonMark does not recognize this as strong emphasis because whitespace appears immediately before the closing **, so the raw delimiters remain visible.

This PR:

  • repairs the narrow line-start/whitespace-delimited **label: **value pattern by moving the whitespace after the closing delimiter;
  • applies the repair only to ordinary text segments rendered by AssistantResponse;
  • leaves thinking segments and other user-authored Markdown surfaces unchanged;
  • protects fenced code blocks, inline code spans, and math spans;
  • keeps valid and incomplete Markdown unchanged;
  • makes the repair idempotent and supports multiple occurrences.

The example above becomes:

**發布日期:** 2026 年 7 月 30 日

Related Issues

  • None found.

Module(s) Affected

  • agents
  • api
  • config
  • core
  • knowledge
  • logging
  • services
  • tools
  • utils
  • web (Frontend)
  • docs (Documentation)
  • scripts
  • tests
  • Other: ...

Checklist

  • I have read and followed the contribution guidelines.
  • My code follows the project's coding standards.
  • I have run pre-commit run --all-files and fixed any issues.
  • I have added relevant tests for my changes.
  • Documentation is not required for this localized rendering fix.
  • My changes do not introduce any new security vulnerabilities.

Verification

  • pre-commit run --all-files: blocked by existing repository-wide formatting drift and Windows mypy errors for POSIX-only APIs outside this change
  • npm run test:node: 390 passed
  • npm run lint: 0 errors; 56 pre-existing warnings in untouched files
  • npx tsc --noEmit: passed
  • npm run build: passed
  • pre-commit run --files web/components/common/AssistantResponse.tsx web/lib/markdown-display.ts web/tests/markdown-display.test.ts: passed
  • git diff --check: passed

Additional Notes

The normalization is intentionally not added globally to normalizeMarkdownForDisplay(). Restricting it to assistant text avoids changing user notes, CoWriter content, thinking blocks, or other strict Markdown surfaces.

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.

1 participant