#23073: fix(ui): strip reply directive tags from assistant messages in WebChat [AI-assisted]
app: web-ui
size: XS
Cluster:
Model Reasoning Fixes
## Summary
Fixes #23053
The `[[reply_to_current]]` tag was appearing in WebChat messages after finalization, even though it was correctly stripped during streaming.
## Root Cause
The frontend's `extractText()` function in `ui/src/ui/chat/message-extract.ts` was only stripping `<thinking>` tags from assistant messages, but NOT directive tags like `[[reply_to_current]]` or `[[audio_inline:...]]`.
While the server-side `chat.history` endpoint correctly strips these tags via `stripInlineDirectiveTagsForDisplay()`, the UI's text extraction was processing messages without this step.
## Fix
Import and apply `stripInlineDirectiveTagsForDisplay()` to assistant message text extraction (3 code paths in `extractText()`).
## Testing
- [x] Verified via tsx import that tags are stripped
- [x] `pnpm check` passes (format + lint)
- [ ] Full test suite (browser tests require display)
## AI Disclosure 🤖
This PR was created with AI assistance (Claude/OpenClaw). The fix was:
- **Identified** by tracing the data flow from server to UI rendering
- **Implemented** by following the existing pattern for tag stripping
- **Tested** via tsx import verification
I understand what the code does: it adds the same tag-stripping function used server-side to the frontend's text extraction for assistant messages, ensuring consistency between streaming and finalized message display.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Added `stripInlineDirectiveTagsForDisplay()` to frontend's `extractText()` function to remove directive tags like `[[reply_to_current]]` and `[[audio_as_voice]]` from assistant messages. Previously only `<thinking>` tags were stripped on the frontend, while the server-side chat history endpoint correctly removed directive tags, causing inconsistency between streaming and finalized message display.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The change is a straightforward bug fix that adds consistent tag-stripping behavior already used server-side. The implementation correctly applies the same function in all three code paths for assistant messages, follows existing patterns, and addresses a clear display inconsistency issue without introducing new functionality or complexity.
- No files require special attention
<sub>Last reviewed commit: e945350</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#23144: fix(ui): strip reply directive tags from assistant messages in WebC...
by echoVic · 2026-02-22
91.7%
#20164: fix(webchat): strip reply directive tags before rendering assistant...
by Limitless2023 · 2026-02-18
91.1%
#16733: fix(ui): avoid injected newlines when tool output is hidden
by jp117 · 2026-02-15
85.2%
#22832: fix: strip [[reply_to_current]] directive from chat history
by willkriski · 2026-02-21
82.4%
#4495: Fix: emit final assistant event when reply tags hide stream
by ukeate · 2026-01-30
82.2%
#23370: fix: strip [[reply_to_current]] tags from WebChat + validate invoke...
by alexmelges · 2026-02-22
82.0%
#3721: fix(ui): webchat not displaying chat responses
by maxmaxrouge-rgb · 2026-01-29
81.8%
#17244: fix: strip TTS tags from agent replies before delivery (#14652)
by robbyczgw-cla · 2026-02-15
81.7%
#22808: test(ui): split baseline browser-test fixes from webchat feature
by opnsec · 2026-02-21
79.9%
#20231: fix: strip untrusted metadata blocks from chat history
by MisterGuy420 · 2026-02-18
79.3%