This repository has no description
flarebot docs scheduled-tasks-ui.md
3.7 kB

Scheduled tasks UI #

/tasks lists the owner's saved tasks. /tasks/<id> shows the exact saved instructions, enabled state, UTC schedule, actual previous run, actual next armed run, and paginated run history. These routes use the same authenticated owner APIs as the task service; public SSR contains generic placeholders. Results link to the task's existing conversation. Think owns its messages and execution.

The Kumo form creates and edits numeric five-field UTC cron schedules or a one-off UTC date/time with whole seconds. Presets are daily or Monday at 09:00 UTC. Validation, future-time checks and recurrence calculation remain in the Worker. The browser does not infer a timezone or implement another scheduler. Run now also works for paused tasks, preserves the scheduled next run, and reports a request rather than claiming completion. Running can include time waiting for other conversation work; unavailable scheduling and native failures are displayed explicitly.

src/runtime/task-session.ts owns the mounted native connection, drafts and command state. Dedicated useTaskListQuery, useTaskQuery and useTaskRunsQuery hooks in src/runtime/queries/ own saved task data and read status in the customer Query cache. Keys include the authenticated browser scope and task ID; the route URL selects the task. The session retains the creation UUID and exact payload after an ambiguous response; the user can close the dialog and resume that pending request. Run-now retries retain their request UUID. Neither is saved in browser storage. Native task versions protect edits; a conflict retains the draft and requires loading the latest version before explicitly saving it. Pausing and deletion use the same versioned service. Deleting a task keeps its shared conversation messages.

Reads use bounded native RPC timeouts and Query cancellation. Confirmed commands cancel conflicting reads, update the saved task cache and invalidate affected resources; cancellation does not stop durable work. Query owns polling, with no second read timer or result copy in TaskSession. Visible pages refresh every 30 seconds, or every 3 seconds when loaded runs are active. A refresh reads the newest page and at most one older page with unsettled runs. Immutable older pages and their cursor remain loaded when overlapping history proves continuity; otherwise the latest page and its cursor replace a disconnected tail. Each task has one history cache. Page reads call the native RPC directly; explicit pagination appends confirmed rows into that cache without retaining a second copy. Failed pagination preserves the cursor for retry. Query cancellation guards refreshes, and pagination lifetime guards reject replies after a task selection, connection or command change. Route changes, disconnects and unmounts invalidate stale replies, and hidden pages stop polling. Ordinary disconnection preserves drafts; confirmed authentication failure clears private task content and editors. Navigating away does not cancel durable agent work.

The conversational schedule action can return /tasks/${task.id} after using the existing task service. A task created by that action appears and is editable here without another endpoint or UI adapter. tests/tasks-ui.test.mjs runs the packaged customer Worker for CRUD and the real native execution fixture (tests/fixtures/execution-worker.ts) for model results, replay and history. Its WebSocket fault injection drops or delays real RPC replies, with no production bypass or fake successful task results. Run it after pnpm build:release using pnpm test:tasks-ui. FLAREBOT_TASK_SCREENSHOTS optionally captures desktop and mobile evidence.