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
address review (claude): keep the expand toggle through the resize race, scope task text ids
[._.]/ Adam Eivy721fdd8b0642
diff --git a/client/src/components/cos/tabs/TaskItem.jsx b/client/src/components/cos/tabs/TaskItem.jsxindex 143bfc88f0..69d4940000 100644--- a/client/src/components/cos/tabs/TaskItem.jsx+++ b/client/src/components/cos/tabs/TaskItem.jsx@@ -100,6 +100,13 @@ export default function TaskItem({ task, isSystem, awaitingApproval, onRefresh,// mutation must name that source; otherwise the API's user-queue default// searches TASKS.md and reports the system task as missing.const taskSource = isSystem || awaitingApproval ? 'internal' : 'user';+ // DOM-id scope. An approval-gated pending task renders TWICE — TasksTab's+ // `pendingSystemTasks` filters only on `status === 'pending'`, and the+ // "Awaiting Approval" section renders the `approvalRequired && pending`+ // subset again — so a bare `task-desc-${task.id}` would be duplicated across+ // the two cards. `aria-controls` resolves by first match, which would point+ // the approval card's toggle at the pending card's paragraph.+ const idScope = awaitingApproval ? 'approval' : isSystem ? 'sys' : 'user';const [editing, setEditingInternal] = useState(false);const setEditing = useCallback((val) => {setEditingInternal(val);@@ -367,7 +374,7 @@ export default function TaskItem({ task, isSystem, awaitingApproval, onRefresh,) : (<><CollapsibleText- id={`task-desc-${task.id}`}+ id={`task-desc-${idScope}-${task.id}`}text={task.description}className="text-white"/>@@ -377,7 +384,7 @@ export default function TaskItem({ task, isSystem, awaitingApproval, onRefresh,wall of text the user has to scroll past. */}{task.metadata?.context && (<CollapsibleText- id={`task-context-${task.id}`}+ id={`task-context-${idScope}-${task.id}`}text={task.metadata.context}className="text-sm text-gray-500 mt-1"/>@@ -427,7 +434,7 @@ export default function TaskItem({ task, isSystem, awaitingApproval, onRefresh,LLM error analysis / raw stderr, which can run very long. */}<div className="min-w-0 flex-1"><CollapsibleText- id={`task-blocker-${task.id}`}+ id={`task-blocker-${idScope}-${task.id}`}text={task.metadata.blocker || task.metadata.blockedReason}className="text-port-error/90"/>@@ -446,7 +453,7 @@ export default function TaskItem({ task, isSystem, awaitingApproval, onRefresh,{/* Clamped: the reason is free text a worker agent writes toargue its case, so multi-paragraph is the expected shape. */}<CollapsibleText- id={`task-challenge-${task.id}`}+ id={`task-challenge-${idScope}-${task.id}`}text={task.metadata.challenge.reason}/>{task.metadata.challengeResolution?.outcome && (diff --git a/client/src/components/cos/tabs/TaskItem.test.jsx b/client/src/components/cos/tabs/TaskItem.test.jsxindex fe58b867c6..f194385276 100644--- a/client/src/components/cos/tabs/TaskItem.test.jsx+++ b/client/src/components/cos/tabs/TaskItem.test.jsx@@ -107,10 +107,10 @@ describe('TaskItem long-text clamping', () => {const withContext = { ...task, id: 'sys-long-context', metadata: { context: longPrompt } };render(<TaskItem task={withContext} isSystem onRefresh={vi.fn()} providers={providers} />);- const context = document.getElementById('task-context-sys-long-context');+ const context = document.getElementById('task-context-sys-sys-long-context');expect(context).toHaveClass('line-clamp-2');- fireEvent.click(toggleFor('task-context-sys-long-context'));+ fireEvent.click(toggleFor('task-context-sys-sys-long-context'));expect(context).not.toHaveClass('line-clamp-2');});@@ -124,8 +124,8 @@ describe('TaskItem long-text clamping', () => {};render(<TaskItem task={blocked} isSystem onRefresh={vi.fn()} providers={providers} />);- expect(document.getElementById('task-blocker-sys-long-block')).toHaveClass('line-clamp-2');- expect(toggleFor('task-blocker-sys-long-block')).toBeInTheDocument();+ expect(document.getElementById('task-blocker-sys-sys-long-block')).toHaveClass('line-clamp-2');+ expect(toggleFor('task-blocker-sys-sys-long-block')).toBeInTheDocument();});it('omits the toggle when the context fits within the clamp', () => {@@ -135,6 +135,31 @@ describe('TaskItem long-text clamping', () => {expect(screen.queryByRole('button', { name: /Show more/ })).not.toBeInTheDocument();});+ it('scopes the text ids so an approval-gated task rendered twice does not collide', () => {+ // TasksTab renders `pendingSystemTasks` (status === 'pending') AND the+ // "Awaiting Approval" subset (approvalRequired && pending), so one+ // approval-gated task mounts two cards. Unscoped ids would duplicate, and+ // aria-controls resolves by first match — pointing the approval card's+ // toggle at the pending card's paragraph.+ forceOverflow();+ const gated = {+ ...task,+ id: 'sys-gated',+ approvalRequired: true,+ metadata: { context: longPrompt },+ };+ const { container: pending } = render(+ <TaskItem task={gated} isSystem onRefresh={vi.fn()} providers={providers} />);+ const { container: approval } = render(+ <TaskItem task={gated} awaitingApproval onRefresh={vi.fn()} providers={providers} />);++ const pendingId = pending.querySelector('[id^="task-context-"]').id;+ const approvalId = approval.querySelector('[id^="task-context-"]').id;+ expect(pendingId).not.toBe(approvalId);+ expect(document.querySelectorAll(`[id="${pendingId}"]`)).toHaveLength(1);+ expect(document.querySelectorAll(`[id="${approvalId}"]`)).toHaveLength(1);+ });+it('edits the context in a multi-line textarea, not a single-line input', () => {const withContext = { ...task, id: 'sys-edit-context', metadata: { context: longPrompt } };render(<TaskItem task={withContext} isSystem onRefresh={vi.fn()} providers={providers} />);diff --git a/client/src/components/ui/CollapsibleText.jsx b/client/src/components/ui/CollapsibleText.jsxindex 448c4e155c..755015ad60 100644--- a/client/src/components/ui/CollapsibleText.jsx+++ b/client/src/components/ui/CollapsibleText.jsx@@ -5,14 +5,21 @@ import { ChevronDown, ChevronUp } from 'lucide-react';* Long text collapsed to two lines with a Show more / Show less toggle.** The overflow measurement runs against the *clamped* element, so the toggle- * only appears when the text actually spills. It stays sticky once expanded —- * the effect early-returns rather than re-measuring, because removing the clamp- * collapses scrollHeight and would otherwise hide the toggle mid-expand — and is- * recomputed on the collapsed path when the text changes, so an edit that- * shortens the text clears a stale toggle. A ResizeObserver re-measures on width- * changes (sidebar collapse, rotation, window resize) so text that wraps to a new- * line at a narrower width still surfaces the toggle instead of silently- * clamping with no affordance.+ * 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+ * toggle. A ResizeObserver re-measures on width changes (sidebar collapse,+ * rotation, window resize) so text that wraps to a new line at a narrower width+ * still surfaces the toggle instead of silently clamping with no affordance.+ *+ * Two separate guards keep the toggle from vanishing mid-expand (which would+ * strand the user in the expanded wall of text with no way back): the effect+ * early-returns while expanded rather than re-measuring an unclamped element,+ * AND the render gates on `isOverflowing || expanded`. The second is not+ * redundant — expanding *is* a resize of the observed element, and the observer+ * is still connected at that moment (its `disconnect()` runs in passive-effect+ * cleanup, which the scheduler may flush after the browser delivers the resize+ * notification). Without the `|| expanded` term that in-flight callback can+ * measure the now-unclamped element, see no overflow, and drop the toggle.** `id` is required: it wires the toggle's `aria-controls` to the text it expands.*/@@ -42,7 +49,7 @@ export default function CollapsibleText({ id, text, className = '' }) {>{text}</p>- {isOverflowing && (+ {(isOverflowing || expanded) && (<buttontype="button"onClick={() => setExpanded(v => !v)}diff --git a/client/src/components/ui/CollapsibleText.test.jsx b/client/src/components/ui/CollapsibleText.test.jsxindex 0823af64a8..259414b1bd 100644--- a/client/src/components/ui/CollapsibleText.test.jsx+++ b/client/src/components/ui/CollapsibleText.test.jsx@@ -1,5 +1,5 @@import { describe, it, expect, vi, afterEach } from 'vitest';-import { fireEvent, render, screen } from '@testing-library/react';+import { act, fireEvent, render, screen } from '@testing-library/react';import CollapsibleText from './CollapsibleText';// jsdom reports 0 for both scrollHeight and clientHeight, so nothing measures as@@ -41,6 +41,31 @@ describe('CollapsibleText', () => {expect(screen.getByRole('button', { name: /Show less/ })).toBeInTheDocument();});+ it('keeps the toggle when a resize fires against the unclamped element', () => {+ // Expanding IS a resize of the observed <p>, and the observer is still+ // connected at that moment (disconnect runs in passive-effect cleanup, which+ // the scheduler may flush after the browser delivers the notification). A+ // callback that lands then measures an unclamped element, sees no overflow,+ // and — without the `|| expanded` render guard — would drop the toggle,+ // stranding the user in the expanded wall of text with no way back.+ let fire;+ const observers = [];+ vi.stubGlobal('ResizeObserver', class {+ constructor(cb) { fire = cb; observers.push(this); }+ observe() {}+ disconnect() {}+ });+ const spy = forceOverflow();+ render(<CollapsibleText id="t7" text={'long '.repeat(500)} />);++ fireEvent.click(screen.getByRole('button', { name: /Show more/ }));+ // The clamp is gone, so a late measurement reports no overflow.+ spy.mockReturnValue(0);+ act(() => fire());++ expect(screen.getByRole('button', { name: /Show less/ })).toBeInTheDocument();+ });+it('drops a stale toggle when the text shrinks below the clamp', () => {const spy = forceOverflow();const { rerender } = render(<CollapsibleText id="t6" text={'long '.repeat(500)} />);