mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 00:21:38 +00:00
fix(auto-reply): preserve newlines in stripInlineStatus and extractInlineSimpleCommand
The /\s+/g whitespace normalizer collapsed newlines along with spaces/tabs, destroying paragraph structure in multi-line messages before they reached the LLM. Use /[^\S\n]+/g to only collapse horizontal whitespace while preserving line breaks. Closes #32216 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
Peter Steinberger
parent
5b5ccb0769
commit
6200e242b2
@@ -24,7 +24,10 @@ export function extractInlineSimpleCommand(body?: string): {
|
||||
if (!command) {
|
||||
return null;
|
||||
}
|
||||
const cleaned = body.replace(match[0], " ").replace(/\s+/g, " ").trim();
|
||||
const cleaned = body
|
||||
.replace(match[0], " ")
|
||||
.replace(/[^\S\n]+/g, " ")
|
||||
.trim();
|
||||
return { command, cleaned };
|
||||
}
|
||||
|
||||
@@ -36,6 +39,11 @@ export function stripInlineStatus(body: string): {
|
||||
if (!trimmed) {
|
||||
return { cleaned: "", didStrip: false };
|
||||
}
|
||||
const cleaned = trimmed.replace(INLINE_STATUS_RE, " ").replace(/\s+/g, " ").trim();
|
||||
// Use [^\S\n]+ instead of \s+ to only collapse horizontal whitespace,
|
||||
// preserving newlines so multi-line messages keep their paragraph structure.
|
||||
const cleaned = trimmed
|
||||
.replace(INLINE_STATUS_RE, " ")
|
||||
.replace(/[^\S\n]+/g, " ")
|
||||
.trim();
|
||||
return { cleaned, didStrip: cleaned !== trimmed };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user