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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix(cos): resolve infinite loop in markdown parser crashing agents page
Adam Eivyf8832734033e
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex deb5c35e2f..ff3b78528d 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -1,3 +1,5 @@## Fixed- Submodule status API (`/api/git/submodules/status`) always returned empty array — `stdout.trim()` was stripping the leading space status character from `git submodule status` output, causing the regex parser to fail+- CoS agents page crash: pipe characters (`|`) in task descriptions triggered infinite loop in markdown parser — non-table pipes now treated as normal text with safety fallback+- CoS agents API returned full output arrays (600KB+) for all agents in listing — output now stripped from listing response and loaded on demanddiff --git a/client/src/components/cos/MarkdownOutput.jsx b/client/src/components/cos/MarkdownOutput.jsxindex 8a4ad6854a..b35f02bee9 100644--- a/client/src/components/cos/MarkdownOutput.jsx+++ b/client/src/components/cos/MarkdownOutput.jsx@@ -32,6 +32,9 @@ function parseInline(text) {return parts;}+const RE_STRUCTURAL = /^(#{1,6} |```|---+$|> |[-*+] |\d+\. )/;+const RE_TABLE_SEP = /^[\s|:-]+$/;+const H_STYLES = ['text-base font-bold text-white mt-3 mb-1','text-sm font-bold text-white mt-3 mb-1',@@ -97,7 +100,8 @@ function parseBlocks(md) {}// Table: header row followed by separator- if (line.includes('|') && lines[i + 1]?.match(/^[\s|:-]+$/)) {+ const isTableStart = line.includes('|') && RE_TABLE_SEP.test(lines[i + 1] || '');+ if (isTableStart) {const headers = line.split('|').map(c => c.trim()).filter(Boolean);i += 2;const rows = [];@@ -116,12 +120,14 @@ function parseBlocks(md) {// Empty lineif (!line.trim()) { i++; continue; }- // Paragraph: collect consecutive non-structural lines+ // Paragraph: collect consecutive non-structural lines (pipes without table separators are normal text)const para = [];- while (i < lines.length && lines[i].trim() && !/^(#{1,6} |```|---+$|> |[-*+] |\d+\. )/.test(lines[i]) && !lines[i].includes('|')) {+ while (i < lines.length && lines[i].trim() && !RE_STRUCTURAL.test(lines[i])) {+ 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(' '))}</p>);+ if (para.length === 0) i++; // skip unconsumed line to prevent infinite loop}return blocks;diff --git a/server/routes/cosAgentRoutes.js b/server/routes/cosAgentRoutes.jsindex e8c8f7045a..ee07a5096a 100644--- a/server/routes/cosAgentRoutes.js+++ b/server/routes/cosAgentRoutes.js@@ -21,10 +21,11 @@ router.post('/health/check', asyncHandler(async (req, res) => {}));// GET /api/cos/agents - Get state-resident agents (running + recently completed, auto-cleans zombies)+// Strips output arrays from listing — output is loaded on demand via GET /agents/:idrouter.get('/agents', asyncHandler(async (req, res) => {await cos.cleanupZombieAgents();const agents = await cos.getAgents();- res.json(agents);+ res.json(agents.map(({ output, ...rest }) => rest));}));// GET /api/cos/agents/history - Get available date buckets with counts