fix(tui): port upstream #22345 — strip inbound metadata blocks from user messages#322
Merged
jiulingyun merged 2 commits intomainfrom Mar 1, 2026
Merged
Conversation
…claw#22345) Co-authored-by: jiulingyun <[email protected]>
Copilot
AI
changed the title
[WIP] Port upstream commit to fork for tui module
fix(tui): port upstream #22345 — strip inbound metadata blocks from user messages
Feb 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AI-facing metadata blocks injected by
buildInboundUserContextPrefix(conversation info, sender, reply context, etc.) were leaking into user-visible chat history in the TUI and gateway message pipeline.Changes
New:
src/auto-reply/reply/strip-inbound-meta.ts— canonicalstripInboundMetadata/stripLeadingInboundMetadataimplementation; line-by-line parser that handles consecutive blocks, blank separators, and the trailingUntrusted contextsuffix; fast-path short-circuits on no sentinel match (zero alloc)src/gateway/chat-sanitize.ts— imports and appliesstripInboundMetadatainstripEnvelopeFromContentand both string-content/text branches ofstripEnvelopeFromMessagesrc/tui/tui-formatters.ts— appliesstripInboundMetadatainextractTextFromMessageforuser-role messages before returning display textsrc/gateway/chat-sanitize.test.ts— adds three regression cases: single block prefix, multiple chained blocks, and mid-text block (not just prefix position)Original prompt
This section details on the original issue you should resolve
<issue_title>upstream(tui): 移植 1 个冲突 commit (P1) — v2026.2.19→v2026.2.21</issue_title>
<issue_description>## 任务
将以下 1 个上游 commit 的修改语义化应用到本 fork。这些 commit 无法直接 cherry-pick(存在冲突),需要理解修改意图后手动应用等效变更。
上游版本范围
tui需要移植的 commit
Commit 1:
35be87b09b0c(P1)描述: fix(tui): strip inbound metadata blocks from user messages (clean rewrite) (openclaw#22345)
涉及文件:
CHANGELOG.md,src/discord/send.components.test.ts,src/gateway/chat-sanitize.test.ts,src/gateway/chat-sanitize.ts,src/gateway/server.chat.gateway-server-chat-b.e2e.test.ts,src/media-understanding/runner.auto-audio.test.ts,src/media-understanding/runner.deepgram.test.ts,src/memory/manager.async-search.test.ts,src/shared/chat-envelope.ts,src/tui/tui-formatters.ts查看上游 diff