From f96e7e11c616b0e75df2872ec085020cf970b189 Mon Sep 17 00:00:00 2001
From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com>
Date: Thu, 12 Feb 2026 19:29:48 +0530
Subject: [PATCH] docs: enhance report generation instructions with detailed
formatting guidelines for code examples and Mermaid diagrams
---
.../app/agents/new_chat/tools/report.py | 7 ++++
surfsense_web/components/markdown-viewer.tsx | 37 ++++---------------
2 files changed, 14 insertions(+), 30 deletions(-)
diff --git a/surfsense_backend/app/agents/new_chat/tools/report.py b/surfsense_backend/app/agents/new_chat/tools/report.py
index b06b6abe2..04ee27ef0 100644
--- a/surfsense_backend/app/agents/new_chat/tools/report.py
+++ b/surfsense_backend/app/agents/new_chat/tools/report.py
@@ -46,6 +46,13 @@ _REPORT_PROMPT = """You are an expert report writer. Generate a well-structured,
5. Be thorough and comprehensive — include all relevant information from the source content.
6. End with a conclusion or key takeaways section.
7. The report should be professional and ready to export.
+8. When including code examples, ALWAYS format them as proper fenced code blocks with the correct language identifier (e.g. ```java, ```python). Code inside code blocks MUST have proper line breaks and indentation — NEVER put multiple statements on a single line. Each statement, brace, and logical block must be on its own line with correct indentation.
+9. When including Mermaid diagrams, use ```mermaid fenced code blocks. Each Mermaid statement MUST be on its own line — NEVER use semicolons to join multiple statements on one line. For line breaks inside node labels, use
(NOT
). Example:
+ ```mermaid
+ graph TD
+ A[Source Code] --> B[Compiler]
+ B --> C[Bytecode]
+ ```
Write the report now:
"""
diff --git a/surfsense_web/components/markdown-viewer.tsx b/surfsense_web/components/markdown-viewer.tsx
index 91f97830a..bf5646107 100644
--- a/surfsense_web/components/markdown-viewer.tsx
+++ b/surfsense_web/components/markdown-viewer.tsx
@@ -9,15 +9,6 @@ interface MarkdownViewerProps {
export function MarkdownViewer({ content, className }: MarkdownViewerProps) {
const components: StreamdownProps["components"] = {
- // Define custom components for markdown elements
- callout: ({ children, ...props }) => (
-
{children} @@ -77,35 +68,21 @@ export function MarkdownViewer({ content, className }: MarkdownViewerProps) { ), th: ({ ...props }) =>
- {children}
-
- );
- }
-
- // For code blocks, let Streamdown handle syntax highlighting
- return (
-
- {children}
-
- );
- },
};
return (