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([issue-3282]): stop the card-body flatten from rewriting stack traces and UA strings
[._.]/ Adam Eivy178cb7ad3ed7
diff --git a/client/src/components/ui/CollapsibleText.jsx b/client/src/components/ui/CollapsibleText.jsxindex e61b503f6e..2219b1fb12 100644--- a/client/src/components/ui/CollapsibleText.jsx+++ b/client/src/components/ui/CollapsibleText.jsx@@ -24,6 +24,13 @@ const CLAMP_CLASS = {* clamp works and foreign headings stay out of the page outline) but renders* the real markdown on expand. When omitted, expanding just unclamps `text`.*+ * `forceToggle` shows the toggle even when the preview fits. It exists for the+ * `expandedContent` case: there, the toggle is the ONLY route to the rich+ * content, so gating it purely on overflow strands a short-but-lossy body —+ * a one-line description holding a link or an image would render as inert+ * flattened text with no way to reach the real markup. Callers pass it when+ * the preview is lossy, not merely when it is truncated.+ ** The overflow measurement runs against the *clamped* element, so the toggle* only appears when the text actually spills. It is recomputed on the collapsed* path when the text changes, so an edit that shortens the text clears a stale@@ -49,7 +56,8 @@ export default function CollapsibleText({className = '',lines = 2,expandedContent = null,- expandedClassName = ''+ expandedClassName = '',+ forceToggle = false}) {const [expanded, setExpanded] = useState(false);const [isOverflowing, setIsOverflowing] = useState(false);@@ -82,7 +90,7 @@ export default function CollapsibleText({{text}</p>)}- {(isOverflowing || expanded) && (+ {(isOverflowing || expanded || forceToggle) && (<buttontype="button"onClick={() => setExpanded(v => !v)}diff --git a/client/src/components/ui/CollapsibleText.test.jsx b/client/src/components/ui/CollapsibleText.test.jsxindex 443c2430bb..88d41ce576 100644--- a/client/src/components/ui/CollapsibleText.test.jsx+++ b/client/src/components/ui/CollapsibleText.test.jsx@@ -107,6 +107,25 @@ describe('CollapsibleText', () => {expect(document.getElementById('t9')).toHaveClass('line-clamp-2');});+ it('shows the toggle on forceToggle so a fitting-but-lossy preview still reaches its rich content', () => {+ // No forceOverflow here: the preview fits. With expandedContent the toggle+ // is the ONLY route to the rich markup, so a short-but-lossy body (a+ // one-line description holding a link) would otherwise be stranded as+ // inert flattened text.+ render(+ <CollapsibleText id="t11" text="see the report" expandedContent={<a href="/r">the report</a>} forceToggle />+ );++ expect(screen.queryByRole('link')).not.toBeInTheDocument();+ fireEvent.click(screen.getByRole('button', { name: /Show more/ }));+ expect(screen.getByRole('link', { name: 'the report' })).toBeInTheDocument();+ });++ it('keeps the toggle hidden without forceToggle when the text fits', () => {+ render(<CollapsibleText id="t12" text="short" expandedContent={<a href="/r">the report</a>} />);+ expect(screen.queryByRole('button')).not.toBeInTheDocument();+ });+it('swaps in expandedContent on expand and restores the plain-text clamp on collapse', () => {forceOverflow();render(diff --git a/client/src/pages/Review.jsx b/client/src/pages/Review.jsxindex 3c81a17921..d825e24610 100644--- a/client/src/pages/Review.jsx+++ b/client/src/pages/Review.jsx@@ -750,12 +750,16 @@ function ReviewItem({ item, config, idScope, isEditing, onComplete, onDismiss, o<><div className="flex items-start justify-between gap-3"><div className="min-w-0">- <p- className={`text-sm font-medium break-words line-clamp-2 ${isPending ? 'text-white' : 'text-gray-400 line-through'}`}- title={item.title}- >- {item.title}- </p>+ {/* Titles clamp to two lines so cards scan as a uniform list.+ They get a real disclosure rather than a `title` tooltip:+ an alert title runs to 120 characters and overflows two+ lines on a phone, where a hover tooltip never fires. */}+ <CollapsibleText+ id={`review-item-title-${idScope}-${item.id}`}+ lines={2}+ text={item.title}+ className={`text-sm font-medium ${isPending ? 'text-white' : 'text-gray-400 line-through'}`}+ />{/* Triage is a scanning task, so the body is a fixed 3-lineplain-text preview: the raw markdown for a CoS task promptor a stack trace runs thousands of words, and rendering it@@ -771,6 +775,11 @@ function ReviewItem({ item, config, idScope, isEditing, onComplete, onDismiss, oclassName="text-xs text-gray-500 mt-0.5"expandedContent={<MarkdownOutput content={item.description} />}expandedClassName="max-h-80 overflow-y-auto pr-1"+ // Flattening drops links, images and tables, so a body that+ // fits in three lines still needs a route to its rendered+ // form — otherwise a short description holding a scan-report+ // link becomes permanently inert text.+ forceToggle={bodyPreview !== item.description}/>)}{item.metadata?.reportUrl && (diff --git a/client/src/pages/Review.test.jsx b/client/src/pages/Review.test.jsxindex 48eac41469..e48aa4d881 100644--- a/client/src/pages/Review.test.jsx+++ b/client/src/pages/Review.test.jsx@@ -9,8 +9,8 @@ const LONG_BODY = ['','Investigate the **failing** request and file a follow-up.','',- '- url: https://example.com/a',- '- user-agent: Mozilla/5.0 (X11; Linux x86_64) ExampleBrowser/1.0',+ '- url: https://example.com/a_b_c/d',+ '- user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) ExampleBrowser/1.0','','### Stack','',@@ -30,8 +30,20 @@ const ITEM = {metadata: {}};+// A body short enough to fit the clamp, but whose flattened preview is still+// lossy — the link survives only in the markdown.+const SHORT_ITEM = {+ id: 'item-2',+ type: 'todo',+ status: 'pending',+ title: 'Read the scan report',+ description: 'See the [scan report](/data/reports/x.html) for details.',+ createdAt: '2026-08-01T11:00:00.000Z',+ metadata: {}+};+vi.mock('../services/api', () => ({- getReviewItems: vi.fn(() => Promise.resolve([ITEM])),+ getReviewItems: vi.fn(() => Promise.resolve([ITEM, SHORT_ITEM])),getReviewBriefing: vi.fn(() => Promise.resolve(null)),getReviewQueue: vi.fn(() => Promise.resolve({ items: [], sources: {} })),createReviewTodo: vi.fn(() => Promise.resolve({})),@@ -64,6 +76,20 @@ afterEach(() => vi.restoreAllMocks());const actionQueueBody = () => document.getElementById(`review-item-body-action-queue-${ITEM.id}`);+// Wait for the toggle that controls one specific element. `findAllByRole`+// alone is not enough: a forceToggle card renders its toggle on the first+// paint, so the query resolves before the overflow-measuring passive effects+// that reveal the other cards' toggles have flushed.+const findToggleFor = async (controlsId) => {+ let toggle;+ await waitFor(() => {+ toggle = screen.getAllByRole('button', { name: /Show more/ })+ .find(b => b.getAttribute('aria-controls') === controlsId);+ expect(toggle).toBeTruthy();+ });+ return toggle;+};+describe('Review Hub queue-card triage (#3282)', () => {it('previews the body as clamped plain text instead of full markdown', async () => {render(<Review />);@@ -82,6 +108,10 @@ describe('Review Hub queue-card triage (#3282)', () => {expect(body.textContent).toContain('Investigate the failing request');expect(body.textContent).not.toContain('##');expect(body.textContent).not.toContain('**');+ // Technical payloads survive the flatten byte-for-byte — a preview that+ // rewrites `10_15_7` to `10157` is worse than one that shows a marker.+ expect(body.textContent).toContain('Mac OS X 10_15_7');+ expect(body.textContent).toContain('https://example.com/a_b_c/d');// The foreign body contributes no headings to this page's outline.expect(screen.queryByRole('heading', { name: 'Task Prompt' })).not.toBeInTheDocument();expect(screen.queryByRole('heading', { name: 'Stack' })).not.toBeInTheDocument();@@ -102,18 +132,40 @@ describe('Review Hub queue-card triage (#3282)', () => {render(<Review />);await waitFor(() => expect(actionQueueBody()).toBeTruthy());- // findAll, not getAll: the overflow measurement lives in a passive effect,- // which React may flush a tick after the card itself paints.- const toggles = await screen.findAllByRole('button', { name: /Show more/ });- const toggle = toggles.find(b => b.getAttribute('aria-controls') === `review-item-body-action-queue-${ITEM.id}`);- expect(toggle).toBeTruthy();-+ const toggle = await findToggleFor(`review-item-body-action-queue-${ITEM.id}`);fireEvent.click(toggle);expect(screen.getByRole('heading', { name: 'Task Prompt' })).toBeInTheDocument();expect(actionQueueBody()).toHaveClass('max-h-80', 'overflow-y-auto');});+ it('still offers Show more when a short body loses markup to the flatten', async () => {+ // No forced overflow: this body fits the 3-line clamp. Without the lossy+ // check the link would be stranded as inert text with no way to reach it.+ render(<Review />);+ const shortBodyId = `review-item-body-action-queue-${SHORT_ITEM.id}`;+ await waitFor(() => expect(document.getElementById(shortBodyId)).toBeTruthy());++ expect(document.getElementById(shortBodyId).textContent).toBe('See the scan report for details.');+ expect(screen.queryByRole('link', { name: 'scan report' })).not.toBeInTheDocument();++ const toggle = await findToggleFor(shortBodyId);+ fireEvent.click(toggle);+ expect(screen.getAllByRole('link', { name: 'scan report' }).length).toBeGreaterThan(0);+ });++ it('gives a clamped title a real disclosure rather than a hover-only tooltip', async () => {+ // `title` never fires on touch, and the issue measures this page at 375px+ // wide — a two-line-clamped title needs a control, not a tooltip.+ forceOverflow();+ render(<Review />);+ const titleId = `review-item-title-action-queue-${ITEM.id}`;+ await waitFor(() => expect(document.getElementById(titleId)).toBeTruthy());++ expect(document.getElementById(titleId)).toHaveClass('line-clamp-2');+ expect(await findToggleFor(titleId)).toBeTruthy();+ });+it('scopes the body id per placement so the duplicate card is not an id collision', async () => {render(<Review />);await waitFor(() => expect(actionQueueBody()).toBeTruthy());diff --git a/client/src/utils/markdownText.js b/client/src/utils/markdownText.jsindex 02b7b46ecb..202cca4e19 100644--- a/client/src/utils/markdownText.js+++ b/client/src/utils/markdownText.js@@ -29,24 +29,38 @@ export function markdownToPlainText(markdown) {.split('\n').filter(line => !FENCE_LINE.test(line)).map(line => line+ // Thematic breaks first: the spaced forms (`- - -`, `* * *`) also match+ // the bullet rule below, and losing the race turns a divider into a+ // bullet that eats one of only three preview lines.+ .replace(/^[ \t]*([-*_])(?:[ \t]*\1){2,}[ \t]*$/, '').replace(/^\s{0,3}#{1,6}\s+/, '') // ATX heading markers.replace(/^\s{0,3}>\s?/, '') // blockquote markers.replace(/^\s*[-*+]\s+/, '• ') // bullet markers- .replace(/^\s*(\d+)[.)]\s+/, '$1. ') // ordered-list markers- .replace(/^\s*([-*_])(?:\s*\1){2,}\s*$/, '')); // thematic breaks+ .replace(/^\s*(\d+)[.)]\s+/, '$1. ')); // ordered-list markersreturn lines.join('\n').replace(/!\[([^\]]*)\]\([^)]*\)/g, (_, alt) => (alt ? `[${alt}]` : '[image]')).replace(/\[([^\]]+)\]\([^)]*\)/g, '$1') // links → their text.replace(/`([^`]*)`/g, '$1') // inline code- // Emphasis spans are matched within a single line ([^\n], not [\s\S]). Real- // markdown emphasis doesn't span paragraphs, and a line-bounded lazy- // quantifier means an unclosed `**` in a multi-thousand-word agent body- // backtracks over one line instead of the whole document.- .replace(/(\*\*|__)(?=\S)([^\n]*?\S)\1/g, '$2') // bold- .replace(/(\*|_)(?=\S)([^*_\n]*?\S)\1/g, '$2') // italic- .replace(/~~(?=\S)([^\n]*?\S)~~/g, '$1') // strikethrough+ // Emphasis. Two properties matter more than markdown fidelity here:+ //+ // 1. Every content class excludes its own delimiter and `\n`, so each pass+ // is linear. An unbounded `[^\n]*?` rescans to end-of-line for every+ // unmatched opener, and these bodies are routinely ONE enormous line (a+ // pasted transcript, an unwrapped stack dump) — measured at 1.3s for a+ // 50KB body and ~8s for 112KB, on the main thread, per card.+ // 2. Underscore emphasis is gated on word boundaries, per CommonMark. Without+ // that gate the preview silently rewrites real data: `Mac OS X 10_15_7` →+ // `10157`, `__webpack_require__` → `webpackrequire`, `snake_case` →+ // `snakecase`. These bodies are stack traces and user-agent strings, so a+ // corrupted-but-plausible preview is worse than an unstripped marker.+ // Intra-word `*` emphasis IS conformant, so `*` needs no such gate.+ .replace(/\*\*(?=\S)([^*\n]*?\S)\*\*/g, '$1') // bold **…**+ .replace(/(^|\W)__(?=\S)([^_\n]*?\S)__(?!\w)/gm, '$1$2') // bold __…__+ .replace(/\*(?=\S)([^*\n]*?\S)\*/g, '$1') // italic *…*+ .replace(/(^|\W)_(?=\S)([^_\n]*?\S)_(?!\w)/gm, '$1$2') // italic _…_+ .replace(/~~(?=\S)([^~\n]*?\S)~~/g, '$1') // strikethrough.replace(/[ \t]+/g, ' ').replace(/\n{2,}/g, '\n') // collapse blank-line runs.split('\n')diff --git a/client/src/utils/markdownText.test.js b/client/src/utils/markdownText.test.jsindex e90935b97b..b219208f6d 100644--- a/client/src/utils/markdownText.test.js+++ b/client/src/utils/markdownText.test.js@@ -27,6 +27,22 @@ describe('markdownToPlainText', () => {.toBe('see the report');});+ it('leaves intra-word underscores alone so real data is not silently rewritten', () => {+ // These bodies are stack traces, user-agent strings and env dumps. Treating+ // an intra-word `_` as emphasis produces a corrupted-but-plausible preview,+ // which is worse than leaving the marker in — the reader can't tell.+ expect(markdownToPlainText('UA: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)'))+ .toBe('UA: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)');+ expect(markdownToPlainText(' at __webpack_require__ (/assets/index.js:1:1)'))+ .toBe('at __webpack_require__ (/assets/index.js:1:1)');+ expect(markdownToPlainText('Set NODE_ENV=test and MEMORY_BACKEND=file'))+ .toBe('Set NODE_ENV=test and MEMORY_BACKEND=file');+ expect(markdownToPlainText('https://example.com/a_b_c/d')).toBe('https://example.com/a_b_c/d');+ // The trailing `_` of one identifier must not pair with the leading `_` of+ // the next and merge two unrelated words.+ expect(markdownToPlainText('do_work() then snake_case_name')).toBe('do_work() then snake_case_name');+ });+it('scopes emphasis to a single line so a stray marker cannot swallow the body', () => {// An unclosed `**` in an agent-authored body must leave the rest of the// document intact (and must not backtrack across it): the marker on the@@ -56,6 +72,16 @@ describe('markdownToPlainText', () => {expect(markdownToPlainText('kept <!-- hidden --> text')).toBe('kept text');});+ it('drops the spaced thematic-break forms instead of promoting them to bullets', () => {+ // `- - -` and `* * *` also match the bullet rule; if the bullet rule wins,+ // a divider becomes `• - -` and eats one of only three preview lines.+ expect(markdownToPlainText('before\n- - -\nafter')).toBe('before\nafter');+ expect(markdownToPlainText('before\n* * *\nafter')).toBe('before\nafter');+ expect(markdownToPlainText('before\n___\nafter')).toBe('before\nafter');+ // A real bullet is still a bullet.+ expect(markdownToPlainText('- an item')).toBe('• an item');+ });+it('collapses blank-line runs and trailing whitespace so the clamp shows real words', () => {expect(markdownToPlainText('one\n\n\n\ntwo \n\n three')).toBe('one\ntwo\nthree');expect(markdownToPlainText(' spaced out ')).toBe('spaced out');