Design: task board Done semantics, None-schedule tasks, AI task drafts, tool group titles
Date: 2026-10-29. Status: approved sections 1–4, pending spec review.
Date: 2026-10-29. Status: approved sections 1–4, pending spec review.
1. Problem
- Manually triggering a recurring task never lands it in Done. Root cause:
isDoneincomponents/shared/scheduling-tab.tsxonly understandsintervalMinutes. Real recurring tasks use wall-clock schedules (hour/minute/weekdays/monthDay, e.g. the daily 6 AM report in production data has nointervalMinutes), so they stay in To do forever after running. - There is no way to create a task without a time: a reminder / backlog item the agent should just do at the next heartbeat, still visible in Settings.
- The New task dialog forces manual field entry (name, instructions, timing) before anything exists.
- Finished tool-group titles say
used 1 toolfor a single tool, and show a connector action label instead of a count for connector-only groups.
2. Decisions (from brainstorming)
- Done detection trusts persisted
nextRunAtinstead of recomputing windows. - Task drafts are generated by a new server endpoint with the default model.
- Scheduling
nonemeans a schedule-less task card + a heartbeat reminder; heartbeat fulfils it with a full task run. - Single finished tool shows its friendly label; connector-only groups show
used N appsfor any N including 1.
3. Done column + manual re-runs
3.1 Rule
Extract board status into lib/scheduler/board-status.ts as isTaskDone(task, now):
once: Done ifflastRunAt != null.interval(any shape:intervalMinutes, wall-clock, weekly, monthly): Done ifflastRunAt != null && nextRunAt != null && now < nextRunAt.none: Done ifflastRunAt != null, else To do.
SchedulingTab uses this instead of its local isDone. Manual trigger sets
lastRunAt = now and advances nextRunAt, so a finished run lands in Done
inside its own period for every recurring shape.
3.2 Re-triggering Done tasks
triggerTask currently returns early for any Done task. Change to block only
finished one-shots:
if (!task) return;
if (task.schedule.kind === "once" && isTaskDone(task, Date.now())) return;Recurring and none tasks stay re-runnable; fresh timestamps keep them Done.
The in-flight runningRef guard is unchanged.
3.3 Acceptance
- Daily/weekly/monthly recurring tasks appear in Done after a run (manual or
scheduled) until
nextRunAtpasses, then return to To do. - Re-triggering a Done recurring task runs it again and it stays Done.
- One-shot behavior is unchanged.
4. none schedule kind
4.1 Model
TaskScheduleKindbecomes"interval" | "once" | "none".ScheduledTask.nextRunAtbecomesnumber | null.createTaskwithnonestoresschedule: { kind: "none" }andnextRunAt: null.updateTask: switching tononesetsnextRunAt: null; switching away recomputes it via the existing rules.updateTaskRunTime: explicitnonebranch — setlastRunAt, keepnextRunAt: null.
4.2 Scheduler must ignore null nextRunAt
- Tick due filter:
t.enabled && t.nextRunAt != null && t.nextRunAt <= now. (null <= nowis true in JS — the explicit check is the whole fix.) handleMissedExecutionsskips tasks with nullnextRunAt.- Board recap (
heartbeat-brief) renders null as manual, e.g.manual — runs from the board.
4.3 Agent tools + HTTP API
schedule_taskschemas (zod inlib/pi/agent-tools.ts, TypeBox inlib/pi/durable-scheduler.ts): accept"none"inscheduleKind. The recurring-cue creation gate is unchanged (nonewithout a cue is still rejected on the agent path; the settings UI saves via HTTP directly).POST /api/scheduler/taskscreate/updateacceptscheduleKind: "none".triggeron anonetask runsexecuteTaskwith the task's stored permissions, thenupdateTaskRunTime→ card moves to Done.- On
triggerof anonetask, best-effort remove its linked heartbeat reminder (section 4.4) so the next heartbeat does not run it twice.
4.4 Heartbeat fulfilment (full task run)
- Saving a
nonetask (HTTP create) also writes a heartbeat checklist entry viaaddPendingAction, containing a machine marker plus human text, e.g.[manual-task:<taskId>] <name> — <instructions, truncated>. - In
executeHeartbeat, afterconsumeDueActions, split dues into manual-task refs (marker present, task still exists, enabled, kindnone,lastRunAt == null) and regular dues. Regular dues flow through the existing path unchanged. - Each linked manual task runs via
executeTask(task)— full scheduled-task powers, the task's own permission flags — thenupdateTaskRunTimeand, on success,recordAnnouncementexactly like a scheduled run. Success consumes the reminder (already consumed; do not requeue). Failure requeues the reminder through the existingrequeueDueActionspath. nonefulfilment requires heartbeat enabled; the New task dialog says so.
4.5 Board presentation
- Run segmented control gains
None. Withnoneselected, timing inputs are hidden andcanCreaterequires only name + instructions. - Dialog copy for
none: never auto-runs; card stays until dragged to In progress or deleted; also picked up by the next heartbeat with full powers; lands in Done when finished. - Done-column
persistprotection stays interval-only; finishednonecards follow one-shot overflow cleanup. - Log/recap lines show
manualinstead of a next-run time.
5. AI task drafts in the New task dialog
5.1 Endpoint
New POST /api/scheduler/draft:
- Request:
{ prompt: string, current?: DraftInput }whereDraftInputis the current form values for edit passes. - Uses
createPiModelClientForRequestwith the configured default model (works for ChatGPT defaults via the request proxy), ~60 s timeout. - System prompt demands one JSON object:
{ name, instructions, scheduleKind: once|interval|none, intervalMinutes?, runAt?, hour?, minute?, weekdays?, monthDay? }, plus current date/time and timezone. Guidance: explicit timing wins; recurring language → interval or wall-clock fields; one-off/reminder with no timing →none; ambiguous → sensible default, never an empty schedule. - Pure helpers in
lib/scheduler/task-draft.ts(buildDraftPrompt,validateDraft): non-empty name/instructions, known kind, ranges (hour 0–23, minute 0–59, weekdays 0–6, positiveintervalMinutes,runAtparses to a future time). Invalid → 4xx with message. - No persistence, no side effects. Draft failures never create tasks.
5.2 Dialog flow (SchedulingTab create dialog)
Three states, same morph animation as DocComposer idle ↔ three-dots:
prompt— title, description, single pill input (placeholder e.g. “Describe the task — timing optional…”). This is the initial state every time the dialog opens.generating— the pill morphs to the three-dot animation while the draft endpoint runs (first draft and every edit).review— today's fields prefilled from the draft (Name, Instructions, Once/Recurring/None incl. timing inputs), pill pinned at bottom for follow-up edits, green tick button right of the pill = save (samehandleCreatepath as today, then close + refresh).
- Each edit sends current draft + edit text; the model returns a full replacement draft. All fields stay hand-editable at any time.
- The AI never saves: only the green tick persists.
- No usable default model or draft failure → today's fully-manual form, unchanged, with the existing Create button.
- New presentational
PromptPill(components/shared/prompt-pill.tsx) carries the idle/dots states;DocComposeris not refactored in this change.
6. Finished tool-group titles
In ToolGroupWithTitle (components/examples/base.tsx), live (running)
titles are unchanged. Finished titles:
- Extract pure
finishedGroupTitle({ labels, visibleCount, connectorOnly, connectorAppCount })into a tested module (e.g.components/assistant-ui/tools/group-title.ts). connectorOnly(every visible tool resolves to connector meta, viagetConnectorMetaForToolor the existingmcp_tool_call/connect_servicearg inference) →used ${connectorAppCount} app(s), icons unchanged before the text. Applies for any count, including exactly one app.- Else single visible tool → its friendly label (
labels[last]), neverused 1 tooland never a raw id. - Else mixed/multi non-connector → today's behavior (last label when
connector icons present, otherwise
used N tools). - Hidden inline tools (
TodoWidth,present_file) and reasoning parts keep today's counting rules.
7. Tests
board-status: once done, interval done/not-done across boundary, wall-clock daily done/not-done, manual re-run timestamps stay Done,nonebefore/after run.task-store: create/updatenone,nextRunAt: nullround-trip,updateTaskRunTimenone-branch, kind switching.- Scheduler tick + missed-execution skip null
nextRunAt(regression:null <= nowis true). task-draft: prompt builder contents, validator accept/reject matrix.- Draft route: thin-handler tests with mocked model client (success, invalid JSON, no default model).
group-title: single tool → label; connector-only 1/2/3 apps → counts; mixed → legacy behavior; hidden tools excluded.- Heartbeat manual-task split: ref extraction, success consumes, failure requeues, already-done/missing/disabled tasks skipped.
- Existing suites (
tool-labels,durable-scheduler,agent-proactivity, scheduler/announcement tests) stay green; extend where schemas changed.
8. Rollout + risks
- One spec, implemented as separate commits per section (3 → 4 → 5 → 6).
- Data migration: none. Existing persisted tasks have numeric
nextRunAt; only newnonetasks store null. Readers must tolerate both (typed). - Key risk: heartbeat executing
nonetasks with full powers (sends allowed per instructions). Mitigations: task permissions UI unchanged and enforced bycreateTaskPermissionChecker; instructions are user-authored; run only when heartbeat enabled; outcome announced once. - Secondary risk: model-generated schedules misfire (wrong time). Mitigations: server-side validation, full review step before save, manual override.
Design history: task board and tool titles
This folder keeps the design spec and implementation plans written on 2026-10-29 for four related changes to scheduled tasks and the chat's tool activity cards. They were produced with an AI-assisted planning…
Board Done Status Implementation Plan
import { isTaskDone } from "@/lib/scheduler/board-status";