Add scheduled task creation, and stop a bad cron unscheduling everything
Build App / compute-version (pull_request) Successful in 4s
Build Container / build-container (pull_request) Successful in 9m35s
Build App / build-linux (pull_request) Successful in 5m35s
Build App / build-windows (pull_request) Failing after 2m26s
Build App / build-macos (pull_request) Successful in 2m49s
Build App / create-tag (pull_request) Skipped
Build App / sync-to-github (pull_request) Skipped
Build App / compute-version (pull_request) Successful in 4s
Build Container / build-container (pull_request) Successful in 9m35s
Build App / build-linux (pull_request) Successful in 5m35s
Build App / build-windows (pull_request) Failing after 2m26s
Build App / build-macos (pull_request) Successful in 2m49s
Build App / create-tag (pull_request) Skipped
Build App / sync-to-github (pull_request) Skipped
Completes the Automation tab: it could list, toggle, run, log and remove tasks but not create them, so task creation still meant dropping to the CLI. Adds add_scheduled_task and update_scheduled_task, plus a task editor with cron presets and a plain-English reading of the expression. Every field is free user text, so all of it goes to the scheduler as a bare argv vector through bollard — no shell, no quoting. Validation is shape-only rather than metacharacter scrubbing: length caps, no control characters in single-line fields, no leading-dash name, absolute working_dir. Verified by round-tripping a prompt containing `; rm -rf /`, `$(id)`, backticks and newlines: it landed byte-for-byte in the task JSON with nothing executed. The scheduler CLI has no `edit`, so update is add-then-remove with the add first — a rejected edit leaves the original intact. The new id is surfaced in the editor rather than hidden. Root-cause fix, and the more serious half of this commit: triple-c-scheduler never validated --schedule, and rebuild_crontab regenerates the entire crontab and pipes it to `crontab`, which rejects the whole file if any line is malformed — with the error thrown away by `2>/dev/null || true`. A single bad schedule therefore silently unscheduled every other task in the container while reporting success. Reproduced directly. It matters because the global CLAUDE.md tells Claude to drive this CLI, so Claude could trigger it unprompted. `add` now validates the expression and exits non-zero, and rebuild_crontab reports a rejected crontab instead of swallowing it, keeping the offending file for inspection. Verified against the real CLI in this container: a bad schedule is refused without disturbing an existing task's crontab entry, and `0 9 * * 1-5`, `*/30 * * * *`, `0,30 8-17 * * *` and `0 0 1 1 *` are all still accepted. The Rust layer validates independently, agreeing with vixie cron on 23 probed expressions including `1/2` and `*/0` being invalid. 121 frontend tests, 44 Rust tests, both builds clean. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import type { Project, ProjectPath, ContainerInfo, SiblingContainer, AppSettings, UpdateInfo, ImageUpdateInfo, FileEntry, WebTerminalInfo, SttStatus, InstallOptions, ClaudeSession, ContainerCapabilities, ScheduledTask, SchedulerNotification, AuthBridgeStatus } from "./types";
|
||||
import type { Project, ProjectPath, ContainerInfo, SiblingContainer, AppSettings, UpdateInfo, ImageUpdateInfo, FileEntry, WebTerminalInfo, SttStatus, InstallOptions, ClaudeSession, ContainerCapabilities, ScheduledTask, ScheduledTaskInput, SchedulerNotification, AuthBridgeStatus } from "./types";
|
||||
|
||||
// Docker
|
||||
export const checkDocker = () => invoke<boolean>("check_docker");
|
||||
@@ -121,6 +121,16 @@ export const listContainerCapabilities = (projectId: string) =>
|
||||
// Container introspection — scheduler
|
||||
export const listScheduledTasks = (projectId: string) =>
|
||||
invoke<ScheduledTask[]>("list_scheduled_tasks", { projectId });
|
||||
/** Returns the new task's id. */
|
||||
export const addScheduledTask = (projectId: string, input: ScheduledTaskInput) =>
|
||||
invoke<string>("add_scheduled_task", { projectId, ...input });
|
||||
/** Edit = add + remove, so this returns a *new* task id (see the Rust doc). */
|
||||
export const updateScheduledTask = (
|
||||
projectId: string,
|
||||
taskId: string,
|
||||
input: ScheduledTaskInput,
|
||||
enabled: boolean,
|
||||
) => invoke<string>("update_scheduled_task", { projectId, taskId, enabled, ...input });
|
||||
export const getScheduledTaskLog = (projectId: string, taskId: string, tailLines?: number) =>
|
||||
invoke<string>("get_scheduled_task_log", { projectId, taskId, tailLines });
|
||||
export const setScheduledTaskEnabled = (projectId: string, taskId: string, enabled: boolean) =>
|
||||
|
||||
@@ -291,6 +291,22 @@ export interface ScheduledTask {
|
||||
next_run: string | null;
|
||||
}
|
||||
|
||||
/** Mirrors Rust `ScheduleKind` — which of the scheduler's two `add` flags to
|
||||
* use: `--schedule "<cron>"` or `--at "YYYY-MM-DD HH:MM"`. */
|
||||
export type ScheduleKind = "recurring" | "once";
|
||||
|
||||
/** The editable fields of a scheduled task, as `add`/`update` take them. */
|
||||
export interface ScheduledTaskInput {
|
||||
name: string;
|
||||
prompt: string;
|
||||
scheduleKind: ScheduleKind;
|
||||
/** A cron expression when `scheduleKind` is `recurring`, otherwise the
|
||||
* `YYYY-MM-DD HH:MM` one-shot time. */
|
||||
schedule: string;
|
||||
/** Absolute path inside the container; blank means `/workspace`. */
|
||||
workingDir: string;
|
||||
}
|
||||
|
||||
export interface SchedulerNotification {
|
||||
task_id: string;
|
||||
task_name: string | null;
|
||||
|
||||
Reference in New Issue
Block a user