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

clamp CoS task context, block reason, and challenge text in the task list

[._.]/ Adam Eivy5dc6ad2b80d4
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 5fc2ad06db..fea506d20f 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -32,6 +32,7 @@
## Fixed
+- **CoS task cards no longer render a wall of prompt text** — a task's `context`, `blockedReason`/`blocker`, and challenge `reason` are now clamped to two lines with a Show more/Show less toggle, matching the description. Orchestrator tasks (e.g. the Creative Director production plan) store their entire prompt in `metadata.context`, so one pending task previously rendered as thousands of pixels of unclamped text the user had to scroll past to reach the rest of the queue; auto-blocked tasks had the same problem with LLM/stderr-derived block reasons, and a challenge reason is free text a worker agent writes to argue its case. The clamp+toggle (measured overflow, so the toggle only appears when the text actually spills) is extracted from `TaskItem` into a shared `client/src/components/ui/CollapsibleText.jsx`. Editing a task's context also moves from a single-line `<input>` to a bounded scrolling `<textarea>`, which was unusable for a multi-thousand-character prompt.
- `executeTuiRun`'s `finish()` now always settles its run promise even if a finalization step throws, so a one-shot TUI run can no longer hang forever (leaking the PTY and wedging `/runs`).
- `execGh` now times out (60s default, overridable) and kills a stalled `gh` CLI child, so a hung network/credential prompt can't wedge the scheduled PR-watcher / issue- and branch-reconcile / update-check jobs or orphan `gh` processes.
- `NextActionBanner`'s question fetch is guarded against stale responses, so a slow earlier request can no longer overwrite a newer question.
diff --git a/PLAN.md b/PLAN.md
index 9b15610a2d..64b8704bba 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -262,3 +262,10 @@ The `kimi-cli`/`kimi-tui` providers shipped without a live `kimi` binary in the
- [ ] **Chief of Staff has no dimension-reserving skeleton** (`client/src/pages/ChiefOfStaff.jsx` ~line 587). It still shows a centered `BrailleSpinner` because it is a bespoke two-pane shell (`lg:grid-cols-[320px_1fr]` avatar panel + chat pane), not the list/detail shape `PageSkeleton` models — a card skeleton there would misrepresent the layout worse than the spinner does. Wants either a two-pane `layout` mode on `PageSkeleton` or a local `CoSSkeleton`.
- [ ] **`/data` (Data Manager) is a self-scrolling `h-full` shell nested in Layout's padded scrolling main** (`client/src/pages/DataManager.jsx` ~line 374; `/data` is absent from the `isFullWidth` list in `client/src/components/Layout.jsx` ~line 1148). The loaded page renders its own bar + `flex-1 overflow-auto` body inside `overflow-auto p-4 md:p-6`, so it double-pads and nests two scroll containers. The skeleton mirrors the page faithfully, so this is pre-existing, not introduced by #2843. Fix by either adding `/data` to `isFullWidth` or dropping the page's `h-full` shell — then drop `padded`/`fullHeight`/`barClassName` from its `PageSkeleton` call accordingly. Raised in the #2843 review, deferred to keep that PR scoped to skeletons.
- [ ] **Sub-region spinners are untouched by #2843.** Tab bodies that refetch (`Brain`/`Goals`/`DigitalTwin` Suspense fallbacks, `Apps` per-app expansion, `DataManager` category detail, `UsagePage` provider-quota section, `CharacterSheet` sync panels) still render bare `BrailleSpinner`s. Lower value than first-paint (the surrounding layout is already reserved), but the taller ones could take a scoped skeleton.
+
+### CoS long-text clamping follow-ups
+
+Deferred from the PR that clamped CoS task text (`client/src/components/ui/CollapsibleText.jsx`).
+
+- [ ] **Consolidate `AgentCard`'s duplicate collapse affordance** (`client/src/components/cos/tabs/AgentCard.jsx` ~line 80). `TaskDescription` is a second "long task text with a Show more toggle" implementation one directory over, using a `text.length > 200` heuristic + `max-h-[3.5rem]` + gradient fade instead of measured `line-clamp-2`, and its toggle carries no `aria-expanded`/`aria-controls`. Not consolidated in that PR because `AgentCard` renders *markdown blocks* via `MarkdownOutput`, which `line-clamp` can't clamp — `CollapsibleText` would need a `children`-based max-height variant, and switching would visibly change that card's fade treatment. Wants a deliberate design call on which affordance wins.
+- [ ] **`metadata.context` is overloaded** — the same key carries a one-line human note (`server/routes/cosJobRoutes.js` ~line 182, `server/services/cosTaskStore.js` ~line 920 escalation context) and a multi-thousand-character agent prompt (`server/services/cosTaskGenerator.js` ~lines 1357-1378, `server/routes/cosTaskRoutes.js` ~line 197). The prompt lives there because `generateTasksMarkdown` flattens `description` to one line and `parseTasksMarkdown` only matches a `- [ ]` block's first line, so newlines in `description` corrupt COS-TASKS.md. Splitting into `metadata.prompt` (payload) + `metadata.context` (note) would touch the markdown round-trip, `LEGACY_DIRECT_FIELDS` in `cosTaskStore.js` ~line 52, `cosTaskMerge.js` ~line 200, the agent prompt builder, and every on-disk task — i.e. a migration. Deferred as disproportionate to what was a presentational problem; the UI clamp handles both shapes correctly today.
diff --git a/client/src/components/cos/tabs/TaskItem.jsx b/client/src/components/cos/tabs/TaskItem.jsx
index 4bb1319b0d..143bfc88f0 100644
--- a/client/src/components/cos/tabs/TaskItem.jsx
+++ b/client/src/components/cos/tabs/TaskItem.jsx
@@ -16,8 +16,6 @@ import {
AlertCircle,
TrendingUp,
Play,
- ChevronDown,
- ChevronUp,
Scale
} from 'lucide-react';
import toast from '../../ui/Toast';
@@ -27,6 +25,7 @@ import { formatDurationMin, formatBytes } from '../../../utils/formatters';
import ConfirmButtonPair from '../../ui/ConfirmButtonPair';
import { useConfirmDelete } from '../../../hooks/useConfirmDelete';
import Modal from '../../ui/Modal';
+import CollapsibleText from '../../ui/CollapsibleText';
const statusIcons = {
pending: <Clock size={16} aria-hidden="true" className="text-yellow-500" />,
@@ -117,13 +116,6 @@ export default function TaskItem({ task, isSystem, awaitingApproval, onRefresh,
const { isConfirming, requestDelete, cancelDelete, confirmDelete } = useConfirmDelete();
const blockedInputRef = useRef(null);
- // Collapse long task prompts to the first couple of lines with an expand
- // toggle. `isOverflowing` is measured against the clamped element so the
- // toggle only appears when the description actually spills past two lines.
- const [promptExpanded, setPromptExpanded] = useState(false);
- const [isOverflowing, setIsOverflowing] = useState(false);
- const descRef = useRef(null);
-
// Focus input when modal opens
useEffect(() => {
if (showBlockedModal && blockedInputRef.current) {
@@ -131,25 +123,6 @@ export default function TaskItem({ task, isSystem, awaitingApproval, onRefresh,
}
}, [showBlockedModal]);
- // Measure overflow while the prompt is collapsed. Kept sticky when expanded
- // (removing the clamp collapses scrollHeight, which would otherwise hide the
- // toggle mid-expand); recomputed only on the collapsed path when the text
- // changes so an edit that shortens the prompt clears a stale toggle. A
- // ResizeObserver re-measures on width changes (sidebar collapse, rotation,
- // window resize) so a prompt that wraps to a new line at a narrower width
- // still surfaces the toggle instead of silently clamping with no affordance.
- useEffect(() => {
- if (promptExpanded) return;
- const el = descRef.current;
- if (!el) return;
- const measure = () => setIsOverflowing(el.scrollHeight > el.clientHeight + 1);
- measure();
- if (typeof ResizeObserver === 'undefined') return;
- const observer = new ResizeObserver(measure);
- observer.observe(el);
- return () => observer.disconnect();
- }, [task.description, promptExpanded, editing]);
-
// Get models for selected provider in edit mode
const editProvider = providers?.find(p => p.id === editData.provider);
const editModels = filterSelectableModels(editProvider?.models);
@@ -341,12 +314,16 @@ export default function TaskItem({ task, isSystem, awaitingApproval, onRefresh,
onChange={e => setEditData(d => ({ ...d, description: e.target.value }))}
className="w-full px-2 py-1 bg-port-bg border border-port-border rounded text-white text-sm"
/>
- <input
- type="text"
+ {/* A textarea, not an input: for orchestrator tasks the context
+ holds the task's entire multi-line prompt, which is unreadable
+ and unnavigable in a single-line field. Bounded rows + its own
+ scroll so editing a long prompt doesn't stretch the card. */}
+ <textarea
+ rows={4}
placeholder="Context"
value={editData.context}
onChange={e => setEditData(d => ({ ...d, context: e.target.value }))}
- className="w-full px-2 py-1 bg-port-bg border border-port-border rounded text-white text-sm"
+ className="w-full px-2 py-1 bg-port-bg border border-port-border rounded text-white text-sm font-mono resize-y overflow-auto"
/>
<div className="flex gap-2">
<select
@@ -389,30 +366,21 @@ export default function TaskItem({ task, isSystem, awaitingApproval, onRefresh,
</div>
) : (
<>
- <p
- ref={descRef}
+ <CollapsibleText
id={`task-desc-${task.id}`}
- className={`text-white whitespace-pre-wrap break-words ${promptExpanded ? '' : 'line-clamp-2'}`}
- >
- {task.description}
- </p>
- {(isOverflowing || promptExpanded) && (
- <button
- type="button"
- onClick={() => setPromptExpanded(v => !v)}
- className="flex items-center gap-0.5 mt-0.5 text-xs text-port-accent hover:text-port-accent/80 transition-colors"
- aria-expanded={promptExpanded}
- aria-controls={`task-desc-${task.id}`}
- >
- {promptExpanded ? (
- <><ChevronUp size={12} aria-hidden="true" /> Show less</>
- ) : (
- <><ChevronDown size={12} aria-hidden="true" /> Show more</>
- )}
- </button>
- )}
+ text={task.description}
+ className="text-white"
+ />
+ {/* The context often carries the task's full prompt (hundreds of
+ lines for orchestrator tasks), so it gets the same clamp as the
+ description — an unclamped one turns the pending list into a
+ wall of text the user has to scroll past. */}
{task.metadata?.context && (
- <p className="text-sm text-gray-500 mt-1">{task.metadata.context}</p>
+ <CollapsibleText
+ id={`task-context-${task.id}`}
+ text={task.metadata.context}
+ className="text-sm text-gray-500 mt-1"
+ />
)}
{(task.metadata?.model || task.metadata?.provider) && (
<div className="flex items-center gap-2 mt-1">
@@ -455,7 +423,15 @@ export default function TaskItem({ task, isSystem, awaitingApproval, onRefresh,
{task.status === 'blocked' && (task.metadata?.blocker || task.metadata?.blockedReason) && (
<div className="flex items-start gap-2 mt-2 px-2 py-1.5 bg-port-error/10 border border-port-error/20 rounded text-sm">
<AlertCircle size={14} className="text-port-error shrink-0 mt-0.5" aria-hidden="true" />
- <span className="text-port-error/90">{task.metadata.blocker || task.metadata.blockedReason}</span>
+ {/* Clamped: server-side auto-blocks write `blockedReason` from
+ LLM error analysis / raw stderr, which can run very long. */}
+ <div className="min-w-0 flex-1">
+ <CollapsibleText
+ id={`task-blocker-${task.id}`}
+ text={task.metadata.blocker || task.metadata.blockedReason}
+ className="text-port-error/90"
+ />
+ </div>
</div>
)}
{/* Challenge case + resolution (#2441). Both sides of a disputed
@@ -466,8 +442,13 @@ export default function TaskItem({ task, isSystem, awaitingApproval, onRefresh,
<div className="flex items-start gap-2 mt-2 px-2 py-1.5 bg-port-warning/10 border border-port-warning/20 rounded text-sm">
<Scale size={14} className="text-port-warning shrink-0 mt-0.5" aria-hidden="true" />
<div className="text-port-warning/90 min-w-0">
- <span className="font-medium">Challenge{task.metadata.challenge.reviewer ? ` (${task.metadata.challenge.reviewer})` : ''}:</span>{' '}
- <span className="break-words">{task.metadata.challenge.reason}</span>
+ <span className="font-medium">Challenge{task.metadata.challenge.reviewer ? ` (${task.metadata.challenge.reviewer})` : ''}:</span>
+ {/* Clamped: the reason is free text a worker agent writes to
+ argue its case, so multi-paragraph is the expected shape. */}
+ <CollapsibleText
+ id={`task-challenge-${task.id}`}
+ text={task.metadata.challenge.reason}
+ />
{task.metadata.challengeResolution?.outcome && (
<div className="mt-1 text-gray-400">
Resolved: {task.metadata.challengeResolution.outcome}
diff --git a/client/src/components/cos/tabs/TaskItem.test.jsx b/client/src/components/cos/tabs/TaskItem.test.jsx
index 820793cbc2..fe58b867c6 100644
--- a/client/src/components/cos/tabs/TaskItem.test.jsx
+++ b/client/src/components/cos/tabs/TaskItem.test.jsx
@@ -1,4 +1,4 @@
-import { describe, it, expect, vi, beforeEach } from 'vitest';
+import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
const api = vi.hoisted(() => ({
@@ -86,6 +86,66 @@ describe('TaskItem blocked reason', () => {
});
});
+describe('TaskItem long-text clamping', () => {
+ // The context often holds a task's entire prompt (orchestrator tasks put the
+ // whole thing there). Rendering it unclamped turned the pending list into a
+ // wall of text the user had to scroll past to reach the rest of the queue.
+ const longPrompt = 'You are the Creative Director. '.repeat(200);
+
+ // jsdom reports 0 for both scrollHeight and clientHeight, so nothing ever
+ // measures as overflowing without this. Restored in afterEach rather than at
+ // the end of the test body, so a failed assertion can't leak it into the next.
+ const forceOverflow = () =>
+ vi.spyOn(HTMLElement.prototype, 'scrollHeight', 'get').mockReturnValue(500);
+ afterEach(() => vi.restoreAllMocks());
+
+ const toggleFor = (id) => screen.getAllByRole('button', { name: /Show more/ })
+ .find(b => b.getAttribute('aria-controls') === id);
+
+ it('clamps the context and offers an expand toggle when it overflows', () => {
+ forceOverflow();
+ 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');
+ expect(context).toHaveClass('line-clamp-2');
+
+ fireEvent.click(toggleFor('task-context-sys-long-context'));
+ expect(context).not.toHaveClass('line-clamp-2');
+ });
+
+ it('clamps a long auto-written blockedReason', () => {
+ forceOverflow();
+ const blocked = {
+ ...task,
+ id: 'sys-long-block',
+ status: 'blocked',
+ metadata: { blockedReason: 'stderr dump '.repeat(200) },
+ };
+ 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();
+ });
+
+ it('omits the toggle when the context fits within the clamp', () => {
+ const withContext = { ...task, id: 'sys-short-context', metadata: { context: 'short note' } };
+ render(<TaskItem task={withContext} isSystem onRefresh={vi.fn()} providers={providers} />);
+
+ expect(screen.queryByRole('button', { name: /Show more/ })).not.toBeInTheDocument();
+ });
+
+ 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} />);
+
+ fireEvent.click(screen.getByRole('button', { name: 'Edit task' }));
+ const contextField = screen.getByPlaceholderText('Context');
+ expect(contextField.tagName).toBe('TEXTAREA');
+ expect(contextField).toHaveValue(longPrompt);
+ });
+});
+
describe('TaskItem challenge resolve controls (#2471)', () => {
const challenged = {
id: 'sys-challenged',
diff --git a/client/src/components/ui/CollapsibleText.jsx b/client/src/components/ui/CollapsibleText.jsx
new file mode 100644
index 0000000000..448c4e155c
--- /dev/null
+++ b/client/src/components/ui/CollapsibleText.jsx
@@ -0,0 +1,62 @@
+import { useState, useRef, useEffect } from 'react';
+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.
+ *
+ * `id` is required: it wires the toggle's `aria-controls` to the text it expands.
+ */
+export default function CollapsibleText({ id, text, className = '' }) {
+ const [expanded, setExpanded] = useState(false);
+ const [isOverflowing, setIsOverflowing] = useState(false);
+ const ref = useRef(null);
+
+ useEffect(() => {
+ if (expanded) return;
+ const el = ref.current;
+ if (!el) return;
+ const measure = () => setIsOverflowing(el.scrollHeight > el.clientHeight + 1);
+ measure();
+ if (typeof ResizeObserver === 'undefined') return;
+ const observer = new ResizeObserver(measure);
+ observer.observe(el);
+ return () => observer.disconnect();
+ }, [text, expanded]);
+
+ return (
+ <>
+ <p
+ ref={ref}
+ id={id}
+ className={`whitespace-pre-wrap break-words ${className} ${expanded ? '' : 'line-clamp-2'}`}
+ >
+ {text}
+ </p>
+ {isOverflowing && (
+ <button
+ type="button"
+ onClick={() => setExpanded(v => !v)}
+ className="flex items-center gap-0.5 mt-0.5 text-xs text-port-accent hover:text-port-accent/80 transition-colors"
+ aria-expanded={expanded}
+ aria-controls={id}
+ >
+ {expanded ? (
+ <><ChevronUp size={12} aria-hidden="true" /> Show less</>
+ ) : (
+ <><ChevronDown size={12} aria-hidden="true" /> Show more</>
+ )}
+ </button>
+ )}
+ </>
+ );
+}
diff --git a/client/src/components/ui/CollapsibleText.test.jsx b/client/src/components/ui/CollapsibleText.test.jsx
new file mode 100644
index 0000000000..0823af64a8
--- /dev/null
+++ b/client/src/components/ui/CollapsibleText.test.jsx
@@ -0,0 +1,71 @@
+import { describe, it, expect, vi, afterEach } from 'vitest';
+import { fireEvent, render, screen } from '@testing-library/react';
+import CollapsibleText from './CollapsibleText';
+
+// jsdom reports 0 for both scrollHeight and clientHeight, so nothing measures as
+// overflowing unless we force it.
+const forceOverflow = () =>
+ vi.spyOn(HTMLElement.prototype, 'scrollHeight', 'get').mockReturnValue(500);
+
+afterEach(() => vi.restoreAllMocks());
+
+describe('CollapsibleText', () => {
+ it('clamps overflowing text and toggles the clamp on expand', () => {
+ forceOverflow();
+ render(<CollapsibleText id="t1" text={'long '.repeat(500)} />);
+
+ const p = document.getElementById('t1');
+ expect(p).toHaveClass('line-clamp-2');
+
+ fireEvent.click(screen.getByRole('button', { name: /Show more/ }));
+ expect(p).not.toHaveClass('line-clamp-2');
+ expect(screen.getByRole('button', { name: /Show less/ })).toBeInTheDocument();
+ });
+
+ it('renders no toggle when the text fits', () => {
+ render(<CollapsibleText id="t2" text="short" />);
+ expect(screen.queryByRole('button')).not.toBeInTheDocument();
+ expect(document.getElementById('t2')).toHaveClass('line-clamp-2');
+ });
+
+ it('keeps the toggle visible while expanded even though the clamp is gone', () => {
+ // Removing the clamp collapses scrollHeight to fit, so a re-measure on the
+ // expanded path would hide the toggle mid-expand and strand the user with no
+ // way back. The effect early-returns while expanded to prevent that.
+ const spy = forceOverflow();
+ render(<CollapsibleText id="t3" text={'long '.repeat(500)} />);
+
+ spy.mockReturnValue(0);
+ fireEvent.click(screen.getByRole('button', { name: /Show more/ }));
+
+ 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)} />);
+ expect(screen.getByRole('button', { name: /Show more/ })).toBeInTheDocument();
+
+ spy.mockReturnValue(0);
+ rerender(<CollapsibleText id="t6" text="now short" />);
+
+ expect(screen.queryByRole('button')).not.toBeInTheDocument();
+ });
+
+ it('wires the toggle to the text it controls', () => {
+ forceOverflow();
+ render(<CollapsibleText id="t4" text={'long '.repeat(500)} />);
+
+ const toggle = screen.getByRole('button');
+ expect(toggle).toHaveAttribute('aria-controls', 't4');
+ expect(toggle).toHaveAttribute('aria-expanded', 'false');
+ fireEvent.click(toggle);
+ expect(toggle).toHaveAttribute('aria-expanded', 'true');
+ });
+
+ it('forwards a caller className alongside the clamp', () => {
+ render(<CollapsibleText id="t5" text="hi" className="text-sm text-gray-500 mt-1" />);
+ const p = document.getElementById('t5');
+ expect(p).toHaveClass('text-sm', 'text-gray-500', 'mt-1', 'line-clamp-2');
+ });
+});