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

feat(apps): add per-ticket play button on the JIRA sprint board

Adam Eivy29f649186616
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index e3aca9a5b2..8ea83b5332 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -35,6 +35,7 @@
## Fixed
+- **Claude Code TUI agents now reliably wait for the input prompt before sending their task (and no longer wedge the shell on startup hiccups).** TUI-provider CoS agents (e.g. `claude-code-tui`) run their CLI as a *child* of a persistent PTY shell, and the old prompt-delivery gate fired on a crude "saw output, then went idle" heuristic. During Claude Code's startup that lull happens *before* the input box exists — and on a folder it hasn't seen, claude shows a **"trust this folder?" gate** that `--dangerously-skip-permissions` does not bypass (common because agents start in fresh worktrees). The gate would paste the task into the banner / trust menu, or — if claude had already exited — into the returned shell prompt, leaving a frozen, un-typeable session showing a literal `^[[200~ …` and a silently-failed run. The spawner now (1) **waits for the shell to finish loading** before injecting the CLI command — a fixed 200 ms delay raced a heavy interactive shell (powerlevel10k / async plugins / nvm-PATH setup), so the command ran before the env was ready and the launched TUI fell straight back to the prompt. It now waits for the shell's startup output to go QUIET (a settle window re-armed on each chunk, with a bounded fallback) rather than watching for a prompt marker — because powerlevel10k's *instant prompt* renders a fake-ready prompt before `.zshrc` finishes, which a marker watch would fire on too early, (2) gates the paste on claude **re-enabling bracketed-paste mode** (`ESC[?2004h`, after the shell turned it off to run the command) as the input-ready signal — this is what makes the paste's leading `ESC` read as a paste rather than as Escape (which cancels claude's input — the intermittent "something other than Enter canceled it" failure); the visible footer text (`bypass permissions on (shift+tab to cycle)`) is deliberately NOT used because claude renders it with inter-glyph cursor moves that strip its spaces after ANSI-stripping, making it unmatchable, (3) **auto-confirms the folder-trust prompt** (Enter on the default "Yes, I trust") so claims run in fresh worktrees, (4) probes that the CLI is still a live child of the shell before pasting, and (5) **never blind-pastes** — if the input prompt never appears within 45 s (or the CLI exited), it finalizes the run as a failure carrying the CLI's captured output (`tui-not-ready` / `tui-exited-early`) instead of dumping into the shell. Non-claude TUI providers keep their existing handshake. (`server/services/agentTuiSpawning.js`, `server/lib/tuiHandshake.js`, `server/services/shell.js`)
- **AudioLDM2 music generation no longer crashes on current transformers.** Rendering with the AudioLDM2 engine failed mid-generation with `AttributeError: 'GPT2Model' object has no attribute '_update_model_kwargs_for_generation'`. AudioLDM2's internal language model is a bare `GPT2Model` (the pipeline reads its hidden states), and diffusers' `generate_language_model` drives it by hand using generation helpers that used to live on every `PreTrainedModel` — but transformers ≥4.50 decoupled `GenerationMixin`, so non-generative base models like `GPT2Model` no longer carry them, leaving diffusers calling a method that no longer exists. The AudioLDM2 sidecar now re-binds the missing helpers (`_update_model_kwargs_for_generation`, `_get_initial_cache_position`) from `GenerationMixin` onto the language model after loading the pipeline — keeping the runtime on a current transformers instead of pinning an EOL release, and a no-op on older transformers where the methods are already present. (`scripts/generate_audioldm2.py`)
- **Client test suite no longer floods CI with React "not wrapped in act(...)" warnings.** Across eight component/page suites, state updates were being driven outside `act()` — hand-fired mock-EventSource frames (`emit`/`fail`), raw DOM `.blur()` calls, manually-invoked tracker callbacks, and resolved in-flight gates whose follow-up `setState` landed after the test body returned (plus a few synchronous tests whose mount-time fetches resolved late). These surfaced only under CI's verbose reporter (the default reporter hides console output), so they were invisible locally. Each driving call is now wrapped in `act()` (or switched to `fireEvent`, which wraps internally), and synchronous tests that mount components with async effects now flush inside `act()`. The full client suite (2497 tests) runs clean with zero act warnings. (`PipelineManuscriptEditor`, `Layout`, `WidgetSuggestions`, `ApiAccessTab`, `PitchTuner`, `SongTraining`, `AudioStage`, `LocalLlmPlayground` test suites)
- **Deleting a generated image or video now asks for confirmation.** The trash button on image/video preview cards (the Image Gen page's recent-renders strip and the Media History grid) deleted the asset immediately on a single click, with no undo. It now arms an inline confirm row ("Delete this image?" / "Delete this video?" with Delete + Cancel) so an accidental click can't wipe a render. Fixed once in the shared `MediaCard` component, so both surfaces are covered. (`client/src/components/media/MediaCard.jsx`)
@@ -61,6 +62,7 @@
## Added
+- **A ▶ play button on every "To Do" card in an app's JIRA sprint board.** The sprint kanban on an app's Overview tab now puts a play button on each ticket in the **To Do** column — click it to queue a Chief of Staff agent that claims and ships *that specific ticket* (not just "the next ready one"). It reuses the same `claim-issue-jira` flow the scheduled `claim-work`/`do:next` path runs (move To Do → In Progress, implement in a `claim/<KEY>` worktree, open an MR/PR, move → In Review), but pins the agent to the ticket you picked. The task queues as a normal user task — the daemon starts it on the next evaluation. The button shows only on To Do cards (In Progress / Done tickets are already claimed or finished). (`server/routes/cosTaskRoutes.js`, `client/src/components/KanbanBoard.jsx`)
- **Context-window size on available-model cards (Settings → Local LLM).** The model cards in the install catalog and the Hugging Face search results now show each model's native context window (e.g. "128K ctx") alongside its size and parameter count — previously this only appeared on already-installed models, so you couldn't compare context windows before deciding what to install. Live Hugging Face results read the true value from the repo's GGUF metadata (`gguf.context_length`, backfilled from the same per-repo fetch that already supplies file sizes); curated catalog entries carry it when it's a documented spec for that build.
- **A per-stage provider pin now beats a blanket run-level provider default.** Pin a single pipeline stage to a specific provider on the Prompts page (e.g. run *Comic Script Verification* on Codex) and it now sticks even while Series Autopilot runs everything else on a different provider. Previously the autopilot's run-wide provider was threaded as a hard *override* that sat above stage pins, so a pinned stage was silently moved onto the run's provider. Provider resolution is now three-tiered — an explicit per-call override (a route's "regenerate with provider X") still wins, then the stage pin, then a blanket run default that only applies to unpinned stages and softly falls through to the active provider when unavailable. The autopilot's script-verify gate threads its run provider as that soft default, so a `pipeline-script-verify` provider pin is honored. (`server/lib/stageRunner.js`, `server/services/pipeline/scriptVerify.js`)
diff --git a/client/src/components/KanbanBoard.jsx b/client/src/components/KanbanBoard.jsx
index dccaa009a2..0cde09f666 100644
--- a/client/src/components/KanbanBoard.jsx
+++ b/client/src/components/KanbanBoard.jsx
@@ -1,6 +1,6 @@
import { useState, useEffect, useCallback } from 'react';
import { DndContext, DragOverlay, useDraggable, useDroppable, PointerSensor, useSensor, useSensors } from '@dnd-kit/core';
-import { GripVertical } from 'lucide-react';
+import { GripVertical, Play } from 'lucide-react';
import toast from './ui/Toast';
import * as api from '../services/api';
@@ -37,17 +37,27 @@ function TicketCard({ ticket, isDragOverlay }) {
);
}
-function DraggableTicket({ ticket, disabled }) {
+function DraggableTicket({ ticket, disabled, appId, canQueue }) {
const { attributes, listeners, setNodeRef, transform, isDragging } = useDraggable({
id: ticket.key,
data: { ticket },
disabled
});
+ const [queuing, setQueuing] = useState(false);
const style = transform ? {
transform: `translate3d(${transform.x}px, ${transform.y}px, 0)`,
} : undefined;
+ const handleQueue = async () => {
+ setQueuing(true);
+ // silent: this caller owns its own success/error toasts (see CLAUDE.md).
+ await api.createJiraTicketTask(appId, ticket.key, { silent: true })
+ .then(() => toast.success(`Queued agent task for ${ticket.key}`))
+ .catch((err) => toast.error(`Failed to queue ${ticket.key}: ${err.message}`))
+ .finally(() => setQueuing(false));
+ };
+
return (
<div
ref={setNodeRef}
@@ -75,15 +85,30 @@ function DraggableTicket({ ticket, disabled }) {
>
<TicketCard ticket={ticket} />
</a>
+ {canQueue && (
+ <button
+ type="button"
+ onClick={handleQueue}
+ disabled={queuing}
+ className="flex items-center px-1.5 text-port-success/70 hover:text-port-success shrink-0 disabled:opacity-40 disabled:cursor-not-allowed"
+ aria-label={`Start an agent on ${ticket.key}`}
+ title={`Queue a Chief of Staff agent to implement ${ticket.key}`}
+ >
+ <Play size={14} className={queuing ? 'animate-pulse' : ''} />
+ </button>
+ )}
</div>
</div>
);
}
-function DroppableColumn({ category, tickets, isOver, disabled }) {
+function DroppableColumn({ category, tickets, isOver, disabled, appId }) {
const { setNodeRef } = useDroppable({ id: category, disabled });
const config = COLUMN_CONFIG[category];
const totalPoints = tickets.reduce((sum, t) => sum + (Number(t.storyPoints) || 0), 0);
+ // The play button (queue a CoS agent for a ticket) only makes sense for
+ // not-started work, and only when we know which app the board belongs to.
+ const canQueue = category === 'To Do' && !!appId;
return (
<div
@@ -100,7 +125,7 @@ function DroppableColumn({ category, tickets, isOver, disabled }) {
</div>
<div className="space-y-2">
{tickets.map(ticket => (
- <DraggableTicket key={ticket.key} ticket={ticket} disabled={disabled} />
+ <DraggableTicket key={ticket.key} ticket={ticket} disabled={disabled} appId={appId} canQueue={canQueue} />
))}
{tickets.length === 0 && (
<div className={`text-xs text-center py-4 ${isOver ? 'text-gray-300' : 'text-gray-500'}`}>
@@ -112,7 +137,7 @@ function DroppableColumn({ category, tickets, isOver, disabled }) {
);
}
-export default function KanbanBoard({ tickets: initialTickets = [], instanceId, onTicketsChange }) {
+export default function KanbanBoard({ tickets: initialTickets = [], instanceId, onTicketsChange, appId }) {
const [tickets, setTickets] = useState(initialTickets);
const [activeTicket, setActiveTicket] = useState(null);
const [transitioning, setTransitioning] = useState(null);
@@ -218,6 +243,7 @@ export default function KanbanBoard({ tickets: initialTickets = [], instanceId,
tickets={columns[category]}
isOver={overColumn === category}
disabled={!!transitioning}
+ appId={appId}
/>
))}
</div>
diff --git a/client/src/components/apps/tabs/OverviewTab.jsx b/client/src/components/apps/tabs/OverviewTab.jsx
index 6b612ae323..eb46c40045 100644
--- a/client/src/components/apps/tabs/OverviewTab.jsx
+++ b/client/src/components/apps/tabs/OverviewTab.jsx
@@ -248,7 +248,7 @@ export default function OverviewTab({ app, onRefresh }) {
<span>Loading tickets...</span>
</div>
) : jiraTickets?.length > 0 ? (
- <KanbanBoard tickets={jiraTickets} instanceId={app.jira?.instanceId} onTicketsChange={setJiraTickets} />
+ <KanbanBoard tickets={jiraTickets} instanceId={app.jira?.instanceId} onTicketsChange={setJiraTickets} appId={app.id} />
) : (
<div className="px-3 py-2 text-sm text-gray-500 bg-port-card border border-port-border rounded-lg">
No tickets assigned to you in the current sprint
diff --git a/client/src/services/apiAgents.js b/client/src/services/apiAgents.js
index 31a73139c6..dd59fb5938 100644
--- a/client/src/services/apiAgents.js
+++ b/client/src/services/apiAgents.js
@@ -61,6 +61,12 @@ export const createSlashdoTask = (command, app) => request('/cos/tasks/slashdo',
method: 'POST',
body: JSON.stringify({ command, app })
});
+// Queue a CoS task to implement one specific JIRA ticket (sprint-board play button).
+export const createJiraTicketTask = (app, ticketKey, options = {}) => request('/cos/tasks/jira-ticket', {
+ method: 'POST',
+ body: JSON.stringify({ app, ticketKey }),
+ ...options
+});
export const enhanceCosTaskPrompt = (data) => request('/cos/tasks/enhance', {
method: 'POST',
body: JSON.stringify(data)
diff --git a/server/routes/cos.test.js b/server/routes/cos.test.js
index a29f32f6d1..617d66e4c7 100644
--- a/server/routes/cos.test.js
+++ b/server/routes/cos.test.js
@@ -92,6 +92,15 @@ vi.mock('../services/apps.js', () => ({
getAppById: vi.fn()
}));
+// The per-ticket `/tasks/jira-ticket` route loads the claim-issue-jira prompt
+// body and resolves reviewers from the Code Review Defaults.
+vi.mock('../services/taskPromptService.js', () => ({
+ getTaskPrompt: vi.fn()
+}));
+vi.mock('../services/codeReview.js', () => ({
+ getCodeReviewDefaults: vi.fn()
+}));
+
// Import mocked modules
import * as cos from '../services/cos.js';
import * as taskWatcher from '../services/taskWatcher.js';
@@ -101,6 +110,8 @@ import { enhanceTaskPrompt } from '../services/taskEnhancer.js';
import { loadSlashdoCommand } from '../services/subAgentSpawner.js';
import { buildClaimWorkTask } from '../services/cosTaskGenerator.js';
import { getAppById } from '../services/apps.js';
+import { getTaskPrompt } from '../services/taskPromptService.js';
+import { getCodeReviewDefaults } from '../services/codeReview.js';
describe('CoS Routes', () => {
let app;
@@ -887,6 +898,99 @@ describe('CoS Routes', () => {
});
});
+ describe('POST /api/cos/tasks/jira-ticket', () => {
+ const jiraApp = { id: 'my-app', name: 'MyApp', repoPath: '/repo', jira: { enabled: true } };
+ // Template carrying every placeholder the route substitutes.
+ const TEMPLATE = 'Work {appName} at {repoPath} (app {appId}); reviewers: {reviewers}.';
+
+ it('queues a claim task pinned to the selected ticket', async () => {
+ getAppById.mockResolvedValue(jiraApp);
+ getTaskPrompt.mockResolvedValue(TEMPLATE);
+ getCodeReviewDefaults.mockResolvedValue({ reviewers: ['claude'] });
+ cos.addTask.mockResolvedValue({ id: 'task-jira-1', status: 'pending' });
+
+ const response = await request(app)
+ .post('/api/cos/tasks/jira-ticket')
+ .send({ app: 'my-app', ticketKey: 'PROJ-123' });
+
+ expect(response.status).toBe(200);
+ expect(response.body.id).toBe('task-jira-1');
+ expect(getTaskPrompt).toHaveBeenCalledWith('claim-issue-jira');
+
+ const [taskData, taskType] = cos.addTask.mock.calls.at(-1);
+ expect(taskType).toBe('user');
+ // Placeholders substituted, ticket constraint appended.
+ expect(taskData.context).toContain('Work MyApp at /repo (app my-app); reviewers: claude.');
+ expect(taskData.context).not.toMatch(/\{appName\}|\{repoPath\}|\{appId\}|\{reviewers\}/);
+ expect(taskData.context).toContain('Target Ticket Constraint');
+ expect(taskData.context).toContain('PROJ-123');
+ expect(taskData.description).toContain('PROJ-123');
+ // claim-issue-jira self-manages its worktree + PR.
+ expect(taskData.useWorktree).toBe(false);
+ expect(taskData.openPR).toBe(false);
+ });
+
+ it('uppercases the ticket key', async () => {
+ getAppById.mockResolvedValue(jiraApp);
+ getTaskPrompt.mockResolvedValue(TEMPLATE);
+ getCodeReviewDefaults.mockResolvedValue(null);
+ cos.addTask.mockResolvedValue({ id: 'task-jira-2', status: 'pending' });
+
+ const response = await request(app)
+ .post('/api/cos/tasks/jira-ticket')
+ .send({ app: 'my-app', ticketKey: 'proj-7' });
+
+ expect(response.status).toBe(200);
+ const [taskData] = cos.addTask.mock.calls.at(-1);
+ expect(taskData.description).toContain('PROJ-7');
+ expect(taskData.context).toContain('PROJ-7');
+ });
+
+ it('returns 404 for an unknown app', async () => {
+ getAppById.mockResolvedValue(null);
+
+ const response = await request(app)
+ .post('/api/cos/tasks/jira-ticket')
+ .send({ app: 'ghost', ticketKey: 'PROJ-1' });
+
+ expect(response.status).toBe(404);
+ expect(cos.addTask).not.toHaveBeenCalled();
+ });
+
+ it('returns 400 when JIRA is not enabled for the app', async () => {
+ getAppById.mockResolvedValue({ id: 'my-app', name: 'MyApp', repoPath: '/repo', jira: { enabled: false } });
+
+ const response = await request(app)
+ .post('/api/cos/tasks/jira-ticket')
+ .send({ app: 'my-app', ticketKey: 'PROJ-1' });
+
+ expect(response.status).toBe(400);
+ expect(cos.addTask).not.toHaveBeenCalled();
+ });
+
+ it('returns 400 for a malformed ticket key', async () => {
+ const response = await request(app)
+ .post('/api/cos/tasks/jira-ticket')
+ .send({ app: 'my-app', ticketKey: 'not-a-key' });
+
+ expect(response.status).toBe(400);
+ expect(getAppById).not.toHaveBeenCalled();
+ });
+
+ it('returns 409 for a duplicate task', async () => {
+ getAppById.mockResolvedValue(jiraApp);
+ getTaskPrompt.mockResolvedValue(TEMPLATE);
+ getCodeReviewDefaults.mockResolvedValue(null);
+ cos.addTask.mockResolvedValue({ duplicate: true, status: 'pending' });
+
+ const response = await request(app)
+ .post('/api/cos/tasks/jira-ticket')
+ .send({ app: 'my-app', ticketKey: 'PROJ-9' });
+
+ expect(response.status).toBe(409);
+ });
+ });
+
describe('POST /api/cos/tasks (duplicate)', () => {
it('should return 409 for duplicate task', async () => {
cos.addTask.mockResolvedValue({ duplicate: true, status: 'running' });
diff --git a/server/routes/cosTaskRoutes.js b/server/routes/cosTaskRoutes.js
index 816ef5f9d4..0e9ca955a7 100644
--- a/server/routes/cosTaskRoutes.js
+++ b/server/routes/cosTaskRoutes.js
@@ -10,15 +10,55 @@ import { enhanceTaskPrompt } from '../services/taskEnhancer.js';
import { loadSlashdoCommand } from '../services/subAgentSpawner.js';
import { buildClaimWorkTask } from '../services/cosTaskGenerator.js';
import { getAppById } from '../services/apps.js';
+import { getTaskPrompt } from '../services/taskPromptService.js';
+import { getCodeReviewDefaults } from '../services/codeReview.js';
import { workTrackerLabel } from '../lib/workTracker.js';
import { asyncHandler, ServerError, failValidation } from '../lib/errorHandler.js';
-import { createCosTaskSchema, updateCosTaskSchema, validateRequest } from '../lib/validation.js';
+import {
+ createCosTaskSchema,
+ updateCosTaskSchema,
+ validateRequest,
+ normalizeReviewers,
+ LOCAL_LLM_REVIEWERS,
+ DEFAULT_REVIEWERS,
+} from '../lib/validation.js';
const enhanceTaskSchema = z.object({
description: z.string().min(1),
context: z.string().optional(),
});
+// One-off "implement THIS JIRA ticket" task (the per-card play button on the
+// app overview's sprint board). `ticketKey` is a JIRA key like `PROJ-1234`.
+const jiraTicketTaskSchema = z.object({
+ app: z.string().min(1),
+ ticketKey: z.string().trim().regex(/^[A-Za-z][A-Za-z0-9]*-\d+$/, 'Invalid JIRA ticket key'),
+});
+
+// Resolve the reviewers CSV for the claim flow exactly as buildClaimWorkTask
+// does (Code Review Defaults, minus local-LLM reviewers the claim prompt can't
+// drive, falling back to the hardcoded default). Mirrors the scheduled
+// claim-work resolution so the play button honors the user's reviewer choice.
+async function resolveClaimReviewersCsv() {
+ const codeReviewDefaults = await getCodeReviewDefaults().catch(() => null);
+ const list = normalizeReviewers({}, codeReviewDefaults?.reviewers)
+ .filter((r) => !LOCAL_LLM_REVIEWERS.includes(r));
+ return (list.length ? list : [...DEFAULT_REVIEWERS]).join(',');
+}
+
+// Append a "claim exactly this ticket" constraint to the claim-issue-jira body
+// — the JIRA analogue of buildPlanConstraintBlock. The base prompt's Phase 1
+// tells the agent to PICK the next-ready ticket; this overrides that to pin the
+// user's selection while keeping every safety check (already-claimed, stale,
+// too-ambiguous → exit cleanly).
+function buildTargetTicketBlock(ticketKey) {
+ return `
+
+## Target Ticket Constraint
+
+The user explicitly selected JIRA ticket \`${ticketKey}\` from the board. Override Phase 1 ("Pick the target ticket"): do NOT pick a different ticket and do NOT scan for the next-ready one — claim exactly \`${ticketKey}\`. Still honor the safety checks: if \`${ticketKey}\` is already In Progress / In Review / Done / closed, is already on a \`claim/${ticketKey}\` (or \`cos/.../${ticketKey}/...\`) branch, or its requirements are too ambiguous or too large to implement in a single PR, exit cleanly (file a Review Hub todo for ambiguous requirements) rather than forcing it. Otherwise run Phases 2–7 against \`${ticketKey}\`.`;
+}
+
const SLASHDO_COMMANDS = {
push: { label: 'Push', description: 'Commit and push all work with changelog' },
review: { label: 'Review', description: 'Deep code review of changed files' },
@@ -127,6 +167,60 @@ router.post('/tasks/slashdo', asyncHandler(async (req, res) => {
res.json(result);
}));
+// POST /api/cos/tasks/jira-ticket - Queue a CoS task to implement one specific
+// JIRA ticket (the per-card "play" button on the app overview sprint board).
+// Reuses the claim-issue-jira prompt and appends a target-ticket constraint, so
+// it stays in lockstep with the scheduled JIRA claim flow without duplicating
+// the 7-phase body. Queue-only: the daemon picks it up on the next evaluation.
+router.post('/tasks/jira-ticket', asyncHandler(async (req, res) => {
+ const { app, ticketKey } = validateRequest(jiraTicketTaskSchema, req.body);
+ const key = ticketKey.toUpperCase();
+
+ const appObj = await getAppById(app);
+ if (!appObj) {
+ throw new ServerError(`App not found: ${app}`, { status: 404, code: 'APP_NOT_FOUND' });
+ }
+ if (!appObj.jira?.enabled) {
+ throw new ServerError(`JIRA is not enabled for ${appObj.name}`, { status: 400, code: 'JIRA_NOT_ENABLED' });
+ }
+
+ // Resolve the claim-issue-jira body directly (not via buildClaimWorkTask) —
+ // an app can show a JIRA board while its general Work Tracker resolves to
+ // GitHub/PLAN, so route the click to the JIRA flow regardless of that setting.
+ // Independent reads (prompt body + Code Review Defaults) — fetch concurrently.
+ const [template, reviewersCsv] = await Promise.all([
+ getTaskPrompt('claim-issue-jira'),
+ resolveClaimReviewersCsv(),
+ ]);
+ const context = template
+ .replace(/\{appName\}/g, appObj.name)
+ .replace(/\{repoPath\}/g, appObj.repoPath)
+ .replace(/\{appId\}/g, appObj.id)
+ // Function-form replacer so a literal `$` in the reviewers CSV isn't read as
+ // a backreference.
+ .replace(/\{reviewers\}/g, () => reviewersCsv)
+ + buildTargetTicketBlock(key);
+
+ // claim-issue-jira self-manages its worktree + MR/PR, so leave both false
+ // (matching the /do:next slashdo default for the JIRA tracker).
+ const taskData = {
+ description: `Claim JIRA ticket ${key} for ${appObj.name} — implement and ship a PR`,
+ app,
+ context,
+ useWorktree: false,
+ openPR: false,
+ simplify: false,
+ reviewLoop: false,
+ };
+ const result = await cos.addTask(taskData, 'user');
+
+ if (result?.duplicate) {
+ throw new ServerError(`A task for ${key} is already ${result.status}`, { status: 409, code: 'DUPLICATE_TASK' });
+ }
+
+ res.json(result);
+}));
+
// POST /api/cos/tasks - Add a new task
router.post('/tasks', asyncHandler(async (req, res) => {
const parsed = createCosTaskSchema.safeParse(req.body);