Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: keep line breaks in CoS agent output summaries

Adam Eivyf261e74db568
diff --git a/client/src/components/cos/MarkdownOutput.jsx b/client/src/components/cos/MarkdownOutput.jsx
index 6afb590bd3..7393115ea0 100644
--- a/client/src/components/cos/MarkdownOutput.jsx
+++ b/client/src/components/cos/MarkdownOutput.jsx
@@ -85,7 +85,7 @@ const H_STYLES = [
'text-xs font-semibold text-gray-300 mt-2 mb-0.5',
];
-function parseBlocks(md, baseLevel, linkifyText) {
+function parseBlocks(md, baseLevel, linkifyText, preserveLineBreaks) {
const lines = (md || '').split('\n');
const blocks = [];
let i = 0;
@@ -169,7 +169,14 @@ function parseBlocks(md, baseLevel, linkifyText) {
if (lines[i].includes('|') && RE_TABLE_SEP.test(lines[i + 1] || '')) break;
para.push(lines[i]); i++;
}
- if (para.length) blocks.push(<p key={`p${i}`} className="text-xs text-gray-300 my-0.5">{parseInline(para.join(' '), linkifyText)}</p>);
+ if (para.length) {
+ // Line-oriented sources (agent output) keep each source line on its own
+ // row; prose sources fold soft-wrapped lines into one paragraph.
+ const body = preserveLineBreaks
+ ? para.flatMap((l, j) => (j ? [<br key={`br${j}`} />, ...parseInline(l, linkifyText)] : parseInline(l, linkifyText)))
+ : parseInline(para.join(' '), linkifyText);
+ blocks.push(<p key={`p${i}`} className="text-xs text-gray-300 my-0.5">{body}</p>);
+ }
if (para.length === 0) i++; // skip unconsumed line to prevent infinite loop
}
@@ -180,10 +187,10 @@ function parseBlocks(md, baseLevel, linkifyText) {
// literal text into links — how a CoS run card resolves the bare `#7640` an
// agent wrote in its summary against that run's own tracker. Omit it and the
// text renders exactly as before.
-export default function MarkdownOutput({ content, baseLevel = 3, linkifyText = null }) {
+export default function MarkdownOutput({ content, baseLevel = 3, linkifyText = null, preserveLineBreaks = false }) {
return (
<div className="markdown-output min-w-0 overflow-hidden break-words">
- {parseBlocks(content, baseLevel, linkifyText)}
+ {parseBlocks(content, baseLevel, linkifyText, preserveLineBreaks)}
</div>
);
}
diff --git a/client/src/components/cos/MarkdownOutput.test.jsx b/client/src/components/cos/MarkdownOutput.test.jsx
index 0ce7cf90d5..6ad12527dd 100644
--- a/client/src/components/cos/MarkdownOutput.test.jsx
+++ b/client/src/components/cos/MarkdownOutput.test.jsx
@@ -118,3 +118,16 @@ it('refuses a resolver destination that would not pass as a markdown link href',
expect(screen.queryByRole('link')).toBeNull();
expect(screen.getByText('click me')).toBeInTheDocument();
});
+
+describe('preserveLineBreaks', () => {
+ const src = 'first line\nsecond line';
+ it('folds soft-wrapped lines into one row by default', () => {
+ const { container } = render(<MarkdownOutput content={src} />);
+ expect(container.querySelector('br')).toBeNull();
+ });
+ it('keeps each source line on its own row when asked', () => {
+ const { container } = render(<MarkdownOutput content={src} preserveLineBreaks />);
+ expect(container.querySelectorAll('br')).toHaveLength(1);
+ expect(container.querySelector('p').textContent).toBe('first linesecond line');
+ });
+});
diff --git a/client/src/components/cos/OutputBlocks.jsx b/client/src/components/cos/OutputBlocks.jsx
index 1ee0bc6d69..166ae0e1a0 100644
--- a/client/src/components/cos/OutputBlocks.jsx
+++ b/client/src/components/cos/OutputBlocks.jsx
@@ -33,7 +33,7 @@ function renderBlock(block, i, linkifyText) {
if (block.type === 'lifecycle') {
return <div key={i} className="py-0.5 text-xs text-gray-400 break-words">{block.line}</div>;
}
- return <MarkdownOutput key={i} content={block.content} linkifyText={linkifyText} />;
+ return <MarkdownOutput key={i} content={block.content} linkifyText={linkifyText} preserveLineBreaks />;
}
// `linkifyText` is forwarded to MarkdownOutput so a caller that knows the