Greptile + CodeRabbit findings across core/engine/dashboard. Stale findings (written against earlier commits) verified and skipped; valid ones fixed. Engine: - await-input: do not clear pausedReason in the /input route (the node's marker must survive unpause); the node clears it after consuming input. Embed a colon-free epoch watermark in the marker so only post-pause steering comments count as the reply (ISO timestamps collided with the colon separator and the dashboard question parser). - gate nodes without a registered runner now fail closed (throw) instead of silently passing. - a thrown interpreter error in maybeExecuteWorkflowGraph now falls back to the legacy pipeline instead of stranding the task in-progress. - approved-CLI path clears the stale awaiting-cli-approval status/marker. Core: - persist+cascade workflow selection: purge task_workflow_selection rows and compiled workflow_steps on physical task deletes; migration 105 cleans already-orphaned rows; catch-cleanup for materialized steps when the owner write fails; WF-id allocation now in a BEGIN IMMEDIATE transaction. - compiler validates the canonical execute->review->merge seam order (rejects duplicate/misordered seams). - disk-backed reopen round-trip + tightened updatedAt/list assertions. Dashboard: - WorkflowSelector clears stale default/options across project changes and on fetch failure; InlineCreateCard/NewTaskModal reset the workflow on all clear/discard paths and include it in dirty-state. - WorkflowNodeEditor: config-key deletion now persists; removed an invalid eslint-disable that was itself a hard lint error. - TaskCard: single status badge for awaiting-input (no duplicate). - WorkflowResultsTab: reset paused-action UI between pauses; surface resume/approve failures inline. - TaskDetailModal: treat awaiting-user-input/awaiting-cli-approval/paused as not-in-progress for the live-log subscription. - workflow-flow-mapping: don't write synthetic node names back into IR. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
144 lines
4.1 KiB
TypeScript
144 lines
4.1 KiB
TypeScript
import "./WorkflowSelector.css";
|
|
import { useCallback, useEffect, useState } from "react";
|
|
import { Workflow as WorkflowIcon } from "lucide-react";
|
|
import type { WorkflowDefinition } from "@fusion/core";
|
|
import { getErrorMessage } from "@fusion/core";
|
|
import { fetchWorkflows, fetchProjectDefaultWorkflow, setProjectDefaultWorkflow } from "../api";
|
|
import type { ToastType } from "../hooks/useToast";
|
|
|
|
interface WorkflowSelectorProps {
|
|
/** Currently selected workflow id, or null for none. */
|
|
value: string | null;
|
|
/** Apply a selection. Receives the chosen workflow id, or null to clear. */
|
|
onChange: (workflowId: string | null) => void | Promise<void>;
|
|
projectId?: string;
|
|
addToast?: (message: string, type?: ToastType) => void;
|
|
disabled?: boolean;
|
|
label?: string;
|
|
/** Optional affordance to open the graph editor. */
|
|
onManage?: () => void;
|
|
}
|
|
|
|
export function WorkflowSelector({
|
|
value,
|
|
onChange,
|
|
projectId,
|
|
addToast,
|
|
disabled,
|
|
label = "Workflow",
|
|
onManage,
|
|
}: WorkflowSelectorProps) {
|
|
const [workflows, setWorkflows] = useState<WorkflowDefinition[]>([]);
|
|
const [loading, setLoading] = useState(false);
|
|
const [applying, setApplying] = useState(false);
|
|
|
|
useEffect(() => {
|
|
let cancelled = false;
|
|
setWorkflows([]);
|
|
setLoading(true);
|
|
fetchWorkflows(projectId)
|
|
.then((data) => {
|
|
if (!cancelled) setWorkflows(data);
|
|
})
|
|
.catch((err) => {
|
|
if (!cancelled) setWorkflows([]);
|
|
addToast?.(getErrorMessage(err) || "Failed to load workflows", "error");
|
|
})
|
|
.finally(() => {
|
|
if (!cancelled) setLoading(false);
|
|
});
|
|
return () => {
|
|
cancelled = true;
|
|
};
|
|
}, [projectId, addToast]);
|
|
|
|
const handleChange = useCallback(
|
|
async (next: string) => {
|
|
const workflowId = next === "" ? null : next;
|
|
setApplying(true);
|
|
try {
|
|
await onChange(workflowId);
|
|
} catch (err) {
|
|
addToast?.(getErrorMessage(err) || "Failed to apply workflow", "error");
|
|
} finally {
|
|
setApplying(false);
|
|
}
|
|
},
|
|
[onChange, addToast],
|
|
);
|
|
|
|
return (
|
|
<div className="workflow-selector" data-testid="workflow-selector">
|
|
<label className="workflow-selector-label">
|
|
<span className="workflow-selector-label-text">
|
|
<WorkflowIcon size={14} aria-hidden /> {label}
|
|
</span>
|
|
<select
|
|
value={value ?? ""}
|
|
disabled={disabled || loading || applying}
|
|
onChange={(e) => void handleChange(e.target.value)}
|
|
>
|
|
<option value="">None</option>
|
|
{workflows.map((w) => (
|
|
<option key={w.id} value={w.id}>
|
|
{w.name}
|
|
</option>
|
|
))}
|
|
</select>
|
|
</label>
|
|
{onManage && (
|
|
<button type="button" className="workflow-selector-manage" onClick={onManage}>
|
|
Manage…
|
|
</button>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
interface ProjectDefaultWorkflowFieldProps {
|
|
projectId?: string;
|
|
addToast?: (message: string, type?: ToastType) => void;
|
|
onManage?: () => void;
|
|
}
|
|
|
|
/** Self-contained project-default workflow picker for the settings modal. */
|
|
export function ProjectDefaultWorkflowField({ projectId, addToast, onManage }: ProjectDefaultWorkflowFieldProps) {
|
|
const [value, setValue] = useState<string | null>(null);
|
|
|
|
useEffect(() => {
|
|
let cancelled = false;
|
|
setValue(null);
|
|
fetchProjectDefaultWorkflow(projectId)
|
|
.then((res) => {
|
|
if (!cancelled) setValue(res.workflowId);
|
|
})
|
|
.catch(() => {
|
|
if (!cancelled) setValue(null);
|
|
/* default is optional; ignore load failures */
|
|
});
|
|
return () => {
|
|
cancelled = true;
|
|
};
|
|
}, [projectId]);
|
|
|
|
const handleChange = useCallback(
|
|
async (workflowId: string | null) => {
|
|
const res = await setProjectDefaultWorkflow(workflowId, projectId);
|
|
setValue(res.workflowId);
|
|
addToast?.(workflowId ? "Default workflow set" : "Default workflow cleared", "success");
|
|
},
|
|
[projectId, addToast],
|
|
);
|
|
|
|
return (
|
|
<WorkflowSelector
|
|
value={value}
|
|
onChange={handleChange}
|
|
projectId={projectId}
|
|
addToast={addToast}
|
|
label="Default workflow for new tasks"
|
|
onManage={onManage}
|
|
/>
|
|
);
|
|
}
|