Make workspace, agent, and schedule automation consistent (#2186)

* feat(workspaces): align agent and schedule automation

Make workspace identity the shared placement boundary for MCP and CLI, while caller identity determines parentage. Keep heartbeats minimal and cron-based without changing legacy rolling interval semantics.

* test(cli): expect canonical schedule cadence

* fix(automation): preserve workspace and schedule compatibility

* fix(automation): preserve compatibility edges

* fix(workspaces): align MCP lifecycle resolution

* fix(workspaces): preserve creation intent

* fix(workspaces): preserve branch and schedule identity
This commit is contained in:
Mohamed Boudra
2026-07-18 14:04:48 +02:00
committed by GitHub
parent 98f6611362
commit ffe76a7e57
66 changed files with 2791 additions and 924 deletions
@@ -13,7 +13,7 @@ import { Text, View } from "react-native";
import { Brain, Folder, GitBranch } from "lucide-react-native";
import { StyleSheet } from "react-native-unistyles";
import type { AgentProvider } from "@getpaseo/protocol/agent-types";
import type { ScheduleSummary } from "@getpaseo/protocol/schedule/types";
import type { ScheduleCadence, ScheduleSummary } from "@getpaseo/protocol/schedule/types";
import { useStoreWithEqualityFn } from "zustand/traditional";
import { AdaptiveModalSheet, type SheetHeader } from "@/components/adaptive-modal-sheet";
import { ComboboxItem } from "@/components/ui/combobox";
@@ -71,6 +71,15 @@ function parseMaxRuns(raw: string): number | null {
return Number.isFinite(parsed) && parsed > 0 ? parsed : null;
}
function requireCronCadence(
cadence: Extract<ScheduleCadence, { type: "cron" }> | undefined,
): Extract<ScheduleCadence, { type: "cron" }> {
if (!cadence) {
throw new Error("Choose a cron cadence before creating this schedule");
}
return cadence;
}
function resolveCreateServerId(input: {
mode: "create" | "edit";
serverId: string | null | undefined;
@@ -306,18 +315,15 @@ function OpenScheduleFormSheet({
]);
const submitAgentTarget = useCallback(async (): Promise<boolean> => {
if (!schedule) {
if (!schedule || !state.submitCadence) {
return false;
}
await updateSchedule({
id: schedule.id,
name: state.name.trim() || null,
prompt: state.prompt.trim(),
cadence: state.submitCadence,
maxRuns: parseMaxRuns(state.maxRuns),
});
return true;
}, [schedule, state.maxRuns, state.name, state.prompt, state.submitCadence, updateSchedule]);
}, [schedule, state.submitCadence, updateSchedule]);
const submitNewAgent = useCallback(async (): Promise<boolean> => {
const provider = state.selectedProvider;
@@ -333,7 +339,7 @@ function OpenScheduleFormSheet({
id: schedule.id,
name: state.name.trim() || null,
prompt: state.prompt.trim(),
cadence: state.submitCadence,
...(state.submitCadence ? { cadence: state.submitCadence } : {}),
newAgentConfig: {
provider,
model: state.selectedModel || null,
@@ -353,7 +359,7 @@ function OpenScheduleFormSheet({
await createSchedule({
prompt: state.prompt.trim(),
name: state.name.trim() || undefined,
cadence: state.submitCadence,
cadence: requireCronCadence(state.submitCadence),
target: {
type: "new-agent",
config: {
@@ -394,10 +400,12 @@ function OpenScheduleFormSheet({
void handleSubmit();
}, [handleSubmit]);
const header = useMemo<SheetHeader>(
() => ({ title: mode === "edit" ? "Edit schedule" : "New schedule" }),
[mode],
);
const header = useMemo<SheetHeader>(() => {
if (mode !== "edit") {
return { title: "New schedule" };
}
return { title: schedule?.target.type === "agent" ? "Edit heartbeat" : "Edit schedule" };
}, [mode, schedule?.target.type]);
const footer = useMemo(
() => (
@@ -466,6 +474,21 @@ function ScheduleFormFields({
cadenceError,
mutationServerId,
}: ScheduleFormFieldsProps): ReactElement {
if (state.targetKind === "agent") {
return (
<>
<ScheduleAgentTargetField label={agentTargetLabel} size={controlSize} />
<CadenceEditor
value={state.cadence}
onChange={model.setCadence}
error={cadenceError ?? undefined}
size={controlSize}
/>
{state.submitError ? <Text style={styles.submitError}>{state.submitError}</Text> : null}
</>
);
}
return (
<>
<Field label="Name">
@@ -502,7 +525,7 @@ function ScheduleFormFields({
model={model}
state={state}
providerSnapshot={providerSnapshot}
agentTargetLabel={agentTargetLabel}
agentTargetLabel={null}
controlSize={controlSize}
mutationServerId={mutationServerId}
/>
@@ -16,7 +16,12 @@ import { useIsCompactFormFactor } from "@/constants/layout";
import { settingsStyles } from "@/styles/settings";
import type { Theme } from "@/styles/theme";
import type { ScheduleDerivedState } from "@/schedules/schedule-derivation";
import { formatCadence, formatNextRun, resolveScheduleTitle } from "@/utils/schedule-format";
import {
formatCadence,
formatNextRun,
resolveScheduleTitle,
scheduleProductName,
} from "@/utils/schedule-format";
import { formatTimeAgo } from "@/utils/time";
import type { ScheduleSummary } from "@getpaseo/protocol/schedule/types";
@@ -153,9 +158,10 @@ export function ScheduleRow({
const handlePointerLeave = useCallback(() => setIsHovered(false), []);
const title = resolveScheduleTitle(schedule);
const productName = scheduleProductName(schedule);
const badge = stateBadge(state);
const meta = buildMeta(schedule, state, serverName, singleHost ?? false);
const canRun = state === "active" || state === "paused";
const canRun = schedule.target.type === "new-agent" && (state === "active" || state === "paused");
const rowStyle = useCallback(
({ pressed }: PressableStateCallbackType) => [
@@ -178,7 +184,7 @@ export function ScheduleRow({
style={rowStyle}
onPress={onEdit}
accessibilityRole="button"
accessibilityLabel={`Edit schedule ${title}`}
accessibilityLabel={`Edit ${productName.toLowerCase()} ${title}`}
testID={`schedule-row-${schedule.id}`}
>
<View style={styles.main}>
@@ -222,6 +228,66 @@ const resumeLeading = <ThemedPlay size={MENU_ICON_SIZE} uniProps={mutedColorMapp
const runLeading = <ThemedRotateCw size={MENU_ICON_SIZE} uniProps={mutedColorMapping} />;
const deleteLeading = <ThemedTrash2 size={MENU_ICON_SIZE} uniProps={destructiveColorMapping} />;
function ScheduleExecutionMenuItems({
schedule,
canRun,
pending,
onPause,
onResume,
onRunNow,
}: Pick<ScheduleRowProps, "schedule" | "pending" | "onPause" | "onResume" | "onRunNow"> & {
canRun: boolean;
}): ReactElement | null {
if (schedule.target.type === "agent") {
return null;
}
let cadenceAction: ReactElement;
if (schedule.status === "paused") {
cadenceAction = (
<DropdownMenuItem
leading={resumeLeading}
disabled={!canRun}
status={pending?.resume ? "pending" : "idle"}
pendingLabel="Resuming..."
onSelect={onResume}
testID={`schedule-menu-resume-${schedule.id}`}
>
Resume schedule
</DropdownMenuItem>
);
} else {
cadenceAction = (
<DropdownMenuItem
leading={pauseLeading}
disabled={schedule.status === "completed" || !canRun}
status={pending?.pause ? "pending" : "idle"}
pendingLabel="Pausing..."
onSelect={onPause}
testID={`schedule-menu-pause-${schedule.id}`}
>
Pause schedule
</DropdownMenuItem>
);
}
return (
<>
{cadenceAction}
<DropdownMenuItem
leading={runLeading}
disabled={!canRun}
status={pending?.runNow ? "pending" : "idle"}
pendingLabel="Starting..."
onSelect={onRunNow}
testID={`schedule-menu-run-${schedule.id}`}
>
Run now
</DropdownMenuItem>
</>
);
}
function renderKebabTriggerIcon({ hovered }: { hovered?: boolean }): ReactElement {
return (
<ThemedKebab
@@ -246,13 +312,15 @@ function ScheduleKebabMenu({
> & {
canRun: boolean;
}): ReactElement {
const productName = scheduleProductName(schedule);
const productNameLower = productName.toLowerCase();
return (
<DropdownMenu>
<DropdownMenuTrigger
hitSlop={8}
style={kebabTriggerStyle}
accessibilityRole={isNative ? "button" : undefined}
accessibilityLabel="Schedule actions"
accessibilityLabel={`${productName} actions`}
testID={`schedule-kebab-${schedule.id}`}
>
{renderKebabTriggerIcon}
@@ -263,41 +331,16 @@ function ScheduleKebabMenu({
onSelect={onEdit}
testID={`schedule-menu-edit-${schedule.id}`}
>
Edit schedule
</DropdownMenuItem>
{schedule.status === "paused" ? (
<DropdownMenuItem
leading={resumeLeading}
disabled={!canRun}
status={pending?.resume ? "pending" : "idle"}
pendingLabel="Resuming..."
onSelect={onResume}
testID={`schedule-menu-resume-${schedule.id}`}
>
Resume schedule
</DropdownMenuItem>
) : (
<DropdownMenuItem
leading={pauseLeading}
disabled={schedule.status === "completed" || !canRun}
status={pending?.pause ? "pending" : "idle"}
pendingLabel="Pausing..."
onSelect={onPause}
testID={`schedule-menu-pause-${schedule.id}`}
>
Pause schedule
</DropdownMenuItem>
)}
<DropdownMenuItem
leading={runLeading}
disabled={!canRun}
status={pending?.runNow ? "pending" : "idle"}
pendingLabel="Starting..."
onSelect={onRunNow}
testID={`schedule-menu-run-${schedule.id}`}
>
Run now
Edit {productNameLower}
</DropdownMenuItem>
<ScheduleExecutionMenuItems
schedule={schedule}
canRun={canRun}
pending={pending}
onPause={onPause}
onResume={onResume}
onRunNow={onRunNow}
/>
<DropdownMenuSeparator />
<DropdownMenuItem
leading={deleteLeading}
@@ -307,7 +350,7 @@ function ScheduleKebabMenu({
onSelect={onDelete}
testID={`schedule-menu-delete-${schedule.id}`}
>
Delete schedule
Delete {productNameLower}
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
@@ -7,7 +7,7 @@ import type { AggregatedSchedule } from "@/hooks/use-schedules";
import type { ScheduleDerivedState } from "@/schedules/schedule-derivation";
import { settingsStyles } from "@/styles/settings";
import { confirmDialog } from "@/utils/confirm-dialog";
import { resolveScheduleTitle } from "@/utils/schedule-format";
import { resolveScheduleTitle, scheduleProductName } from "@/utils/schedule-format";
/** A schedule plus the client-derived fields the row renders. */
export interface ScheduleRowView {
@@ -113,8 +113,9 @@ function SchedulesTableRow({
const handleDelete = useCallback(() => {
void (async () => {
const productName = scheduleProductName(schedule);
const confirmed = await confirmDialog({
title: "Delete schedule",
title: `Delete ${productName.toLowerCase()}`,
message: `Delete "${resolveScheduleTitle(schedule)}"? This cannot be undone.`,
confirmLabel: "Delete",
destructive: true,