Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix: support double liner (#61631)

Alex V28c1513b17a8
diff --git a/products/conversations/backend/api/tests/test_formatting.py b/products/conversations/backend/api/tests/test_formatting.py
index 111d2d56f451..77b3f0a4f895 100644
--- a/products/conversations/backend/api/tests/test_formatting.py
+++ b/products/conversations/backend/api/tests/test_formatting.py
@@ -154,9 +154,36 @@ class TestSlackFormatting(SimpleTestCase):
slack_text, slack_blocks = rich_content_to_slack_payload(rich_content, "")
content, parsed_rich_content = slack_to_content_and_rich_content(slack_text, slack_blocks)
- assert content == "line1 \nline2\n\nline3"
+ assert content == "line1 \nline2\n\n \n\n\nline3"
assert parsed_rich_content is not None
- assert len(parsed_rich_content["content"]) == 2
+ # 3 paragraphs: original 2 + spacer section between them
+ assert len(parsed_rich_content["content"]) == 3
+
+ @parameterized.expand(
+ [
+ ("single_paragraph", 1, 1),
+ ("two_paragraphs", 2, 3),
+ ("three_paragraphs", 3, 5),
+ ]
+ )
+ def test_outbound_paragraph_spacer_sections(self, _name: str, para_count: int, expected_elements: int) -> None:
+ rich_content = {
+ "type": "doc",
+ "content": [
+ {"type": "paragraph", "content": [{"type": "text", "text": f"para{i + 1}"}]} for i in range(para_count)
+ ],
+ }
+
+ _, slack_blocks = rich_content_to_slack_payload(rich_content, "")
+ assert slack_blocks is not None
+
+ elements = slack_blocks[0]["elements"]
+ assert len(elements) == expected_elements
+ for i, el in enumerate(elements):
+ if i % 2 == 0:
+ assert el["elements"][0]["text"] == f"para{i // 2 + 1}"
+ else:
+ assert el["elements"][0]["text"] == "\n"
def test_outbound_excludes_images_from_text_when_requested(self) -> None:
rich_content = {
diff --git a/products/conversations/backend/formatting.py b/products/conversations/backend/formatting.py
index 65201feef818..dc7da840b757 100644
--- a/products/conversations/backend/formatting.py
+++ b/products/conversations/backend/formatting.py
@@ -511,6 +511,10 @@ def rich_content_to_slack_blocks(rich_content: JSON | None, include_images: bool
section_elements.append({"type": "link", "url": src, "text": alt})
if section_elements:
+ if rich_text_elements:
+ rich_text_elements.append(
+ {"type": "rich_text_section", "elements": [{"type": "text", "text": "\n"}]}
+ )
rich_text_elements.append({"type": "rich_text_section", "elements": section_elements})
continue