Skip to content

An open-source, faster Devin alternative

TypeScript

schedules: address implementation review (F4, F5, F10, F11)

Igor Zalutskic35ad5ac7bb7
diff --git a/cmd/oc/internal/commands/agent_schedules.go b/cmd/oc/internal/commands/agent_schedules.go
index 749f1f77..e0ee62a5 100644
--- a/cmd/oc/internal/commands/agent_schedules.go
+++ b/cmd/oc/internal/commands/agent_schedules.go
@@ -64,6 +64,8 @@ func schedStr(p *string) string {
}
// resolveScheduleID maps a "sch_…" id (used as-is) or a schedule NAME (looked up on the agent) to id.
+// The prefix check is unambiguous: schedule names are strict slugs (^[a-z0-9][a-z0-9-]{0,63}$, no
+// underscores), so a name can never begin with "sch_".
func resolveScheduleID(cmd *cobra.Command, sc *client.Client, agentID, ref string) (string, error) {
if strings.HasPrefix(ref, "sch_") {
return ref, nil
diff --git a/docs/agent-sessions/schedules.mdx b/docs/agent-sessions/schedules.mdx
index a014c977..e5c4ea66 100644
--- a/docs/agent-sessions/schedules.mdx
+++ b/docs/agent-sessions/schedules.mdx
@@ -20,7 +20,7 @@ A platform tick runs every minute: it claims schedules whose `next_fire_at` has
| **Attribution** | The first `user.message` carries `actor { kind: "schedule", id, display }`; the session carries `metadata.schedule = { id, run_id, scheduled_for }`. |
| **Idempotency** | One session per slot, keyed `sch_<id>:<slot>`. A tick that crashes and retries converges on the same session. |
| **Overlap** | `skip` (default): if the previous run's session is still `queued`/`running`, record `skipped` and advance. `allow`: fire regardless. |
-| **Catch-up** | After downtime, fire **once** for the most recent missed slot, then advance past now — never replays a backlog. |
+| **Catch-up** | After downtime, a schedule fires **once** — the run's `scheduled_for` is the slot that was due — then advances past now. It never replays a backlog. |
| **Failure** | Five consecutive scheduled-firing *enactment* failures (missing credential, no credit) → `auto_paused` with `last_error`. Session outcomes never change schedule state; neither do manual fires. |
**Common crons** (`minute hour day-of-month month day-of-week`):
@@ -249,7 +249,7 @@ Scheduled sessions run unattended — cap them. Set agent [`limits`](/agent-sess
## Dashboard
-The agent's **Schedules** card lists each schedule with its next fire and state, a create dialog that previews upcoming fire times as you type the cron, and per-schedule run history linked to the sessions. Repo-linked schedules are read-only except pause/resume; `auto_paused` shows the last error.
+The agent's **Schedules** tab lists each schedule with its next fire and state, plus controls (pause/resume, test-fire, edit, delete) and per-schedule run history. The create form takes a cron — with quick presets and a plain-English gloss for common expressions — and a message; schedules created here run in **UTC** (a zone set via the API/CLI still displays). Repo-linked schedules are read-only except pause/resume; `auto_paused` shows the last error.
## Example
diff --git a/web/src/components/agent-schedules.tsx b/web/src/components/agent-schedules.tsx
index ad28c242..81087cd0 100644
--- a/web/src/components/agent-schedules.tsx
+++ b/web/src/components/agent-schedules.tsx
@@ -28,6 +28,7 @@ import {
} from '@/api/client'
import { Panel, PanelContent } from '@/components/panel'
import { Button } from '@/components/ui/button'
+import { ConfirmDialog } from '@/components/confirm-dialog'
import { Field, Input, Select, Textarea } from '@/components/form'
// ── helpers ────────────────────────────────────────────────────────────────────
@@ -123,6 +124,7 @@ export function AgentSchedulesTab({ agentId }: { agentId: string }) {
const queryClient = useQueryClient()
const [form, setForm] = useState<FormState | null>(null)
const [expanded, setExpanded] = useState<string | null>(null)
+ const [pendingDelete, setPendingDelete] = useState<Schedule | null>(null)
const { data: repoManaged } = useQuery({
queryKey: ['agent-deploy-source', agentId],
@@ -190,6 +192,7 @@ export function AgentSchedulesTab({ agentId }: { agentId: string }) {
mutationFn: (s: Schedule) => deleteSchedule(agentId, s.id),
onSuccess: () => {
invalidate()
+ setPendingDelete(null)
notifySuccess('Schedule deleted.')
},
onError: (e) => notifyError("Couldn't delete the schedule.", e),
@@ -235,7 +238,7 @@ export function AgentSchedulesTab({ agentId }: { agentId: string }) {
id="sch-name"
value={form.name}
onChange={(e) => setForm({ ...form, name: e.target.value })}
- placeholder="Morning docs sweep"
+ placeholder="morning-docs-sweep"
disabled={!!form.id}
/>
{form.id ? <p className="text-muted-foreground mt-1 text-xs">Name can’t be changed after creation.</p> : null}
@@ -369,8 +372,7 @@ export function AgentSchedulesTab({ agentId }: { agentId: string }) {
variant="ghost"
className="text-muted-foreground hover:text-red-600"
title="Delete"
- disabled={remove.isPending}
- onClick={() => remove.mutate(s)}
+ onClick={() => setPendingDelete(s)}
>
<Trash2 className="size-4" />
</Button>
@@ -439,6 +441,17 @@ export function AgentSchedulesTab({ agentId }: { agentId: string }) {
<p className="text-muted-foreground text-xs">
Or from the CLI: <code className="font-mono">oc agent schedule create &lt;name&gt; --cron "0 9 * * 1-5" --input …</code>
</p>
+
+ <ConfirmDialog
+ open={pendingDelete !== null}
+ onOpenChange={(open) => !open && setPendingDelete(null)}
+ title={`Delete "${pendingDelete?.name ?? ''}"?`}
+ description="This schedule stops firing immediately. Run history is kept."
+ confirmLabel="Delete"
+ destructive
+ pending={remove.isPending}
+ onConfirm={() => pendingDelete && remove.mutate(pendingDelete)}
+ />
</div>
)
}