chore: change goal text, correct output for gestures, allow step specific reducing, fix tests/ add tests for new things

This commit is contained in:
Björn Otgaar
2026-01-05 16:38:06 +01:00
parent 111400bd82
commit 216b136a75
6 changed files with 122 additions and 8 deletions

View File

@@ -10,6 +10,7 @@ import styles from './GestureValueEditor.module.css'
type GestureValueEditorProps = {
value: string;
setValue: (value: string) => void;
setType: (value: boolean) => void;
placeholder?: string;
};
@@ -443,6 +444,7 @@ const GESTURE_SINGLES = [
export default function GestureValueEditor({
value,
setValue,
setType,
placeholder = "Gesture name",
}: GestureValueEditorProps) {
@@ -465,10 +467,12 @@ export default function GestureValueEditor({
if (newMode === "single") {
setValue(customValue || value);
setType(false);
setFilteredSuggestions(GESTURE_SINGLES);
setShowSuggestions(true);
} else {
// Clear value if it does not match a valid tag
setType(true);
const isValidTag = GESTURE_TAGS.some(
tag => tag.toLowerCase() === value.toLowerCase()
);

View File

@@ -17,7 +17,7 @@ export type Goal = {
// Actions
export type Action = SpeechAction | GestureAction | LLMAction
export type SpeechAction = { id: string, text: string, type:"speech" }
export type GestureAction = { id: string, gesture: string, type:"gesture" }
export type GestureAction = { id: string, gesture: string, isTag: boolean, type:"gesture" }
export type LLMAction = { id: string, goal: string, type:"llm" }
export type ActionTypes = "speech" | "gesture" | "llm";
@@ -29,7 +29,40 @@ export function PlanReduce(plan?: Plan) {
return {
name: plan.name,
id: plan.id,
steps: plan.steps,
steps: plan.steps.map((x) => StepReduce(x))
}
}
// Extract the wanted information from a plan element.
function StepReduce(planElement: PlanElement) {
// We have different types of plan elements, requiring differnt types of output
switch (planElement.type) {
case ("speech"):
return {
id: planElement.id,
text: planElement.text,
}
case ("gesture"):
return {
id: planElement.id,
gesture: {
type: planElement.isTag ? "tag" : "single",
name: planElement.gesture
},
}
case ("llm"):
return {
id: planElement.id,
goal: planElement.goal,
}
case ("goal"):
return {
id: planElement.id,
plan: planElement.plan,
can_fail: planElement.can_fail,
};
default:
}
}

View File

@@ -21,6 +21,7 @@ export default function PlanEditorDialog({
const dialogRef = useRef<HTMLDialogElement | null>(null);
const [draftPlan, setDraftPlan] = useState<Plan | null>(null);
const [newActionType, setNewActionType] = useState<ActionTypes>("speech");
const [newActionGestureType, setNewActionGestureType] = useState<boolean>(true);
const [newActionValue, setNewActionValue] = useState("");
const { setScrollable } = useFlowStore();
@@ -58,7 +59,7 @@ export default function PlanEditorDialog({
case "speech":
return { id, text: newActionValue, type: "speech" };
case "gesture":
return { id, gesture: newActionValue, type: "gesture" };
return { id, gesture: newActionValue, isTag: newActionGestureType, type: "gesture" };
case "llm":
return { id, goal: newActionValue, type: "llm" };
}
@@ -127,6 +128,7 @@ export default function PlanEditorDialog({
<GestureValueEditor
value={newActionValue}
setValue={setNewActionValue}
setType={setNewActionGestureType}
placeholder="Gesture name"
/>
) : (