Skip to content

fix(auto-reply): preserve newlines in stripInlineStatus and extractInlineSimpleCommand#32224

Merged
steipete merged 2 commits intoopenclaw:mainfrom
scoootscooob:fix/strip-inline-status-preserve-newlines
Mar 2, 2026
Merged

fix(auto-reply): preserve newlines in stripInlineStatus and extractInlineSimpleCommand#32224
steipete merged 2 commits intoopenclaw:mainfrom
scoootscooob:fix/strip-inline-status-preserve-newlines

Conversation

@scoootscooob
Copy link
Contributor

Summary

  • stripInlineStatus() and extractInlineSimpleCommand() used /\s+/g to normalize whitespace, which collapsed newlines along with spaces/tabs. This destroyed paragraph structure in multi-line messages from Discord (Shift+Enter) and other channels.
  • Replaced with /[^\S\n]+/g to only collapse horizontal whitespace while preserving line breaks.

Closes #32216

Test plan

  • New test suite with 8 tests covering both functions
  • Verified newlines preserved in multi-line messages (no /status)
  • Verified newlines preserved when stripping /status directive
  • Verified horizontal whitespace still collapsed correctly
  • Verified /help command extraction preserves newlines

🤖 Generated with Claude Code

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 2, 2026

Greptile Summary

Fixed a bug where stripInlineStatus() and extractInlineSimpleCommand() were collapsing newlines along with other whitespace using /\s+/g, destroying paragraph structure in multi-line messages. The fix replaces the regex with /[^\S\n]+/g to only collapse horizontal whitespace (spaces, tabs) while preserving line breaks (\n).

Key Changes

  • Updated regex pattern in both functions to preserve newlines
  • Added comprehensive test suite with 8 tests covering newline preservation, whitespace collapsing, command extraction, and edge cases
  • Added inline comment explaining the regex choice for future maintainability

The implementation is correct and well-tested. The regex pattern /[^\S\n]+/g is a standard idiom for matching horizontal whitespace.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The change is a focused bug fix with clear intent, using a well-established regex pattern. Comprehensive test coverage (8 new tests) validates the fix works as intended. The code is simple, well-documented, and addresses a specific issue (GitHub stripInlineStatus collapses newlines in all incoming messages #32216) without introducing new complexity.
  • No files require special attention

Last reviewed commit: 2c42930

scoootscooob and others added 2 commits March 2, 2026 22:42
…lineSimpleCommand

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 openclaw#32216

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@steipete steipete force-pushed the fix/strip-inline-status-preserve-newlines branch from 2c42930 to 825d5aa Compare March 2, 2026 22:43
@steipete steipete merged commit 319b7c6 into openclaw:main Mar 2, 2026
@steipete
Copy link
Contributor

steipete commented Mar 2, 2026

Landed via temp rebase onto main.

  • Gate: pnpm -s vitest run src/auto-reply/reply/reply-inline.test.ts
  • Land commit: 825d5aa
  • Merge commit: 319b7c6

Thanks @scoootscooob!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stripInlineStatus collapses newlines in all incoming messages

2 participants