chore: initial branch commit

This commit is contained in:
Björn Otgaar
2026-01-07 15:44:56 +01:00
parent 4e07b95722
commit ad8111d6c2
2 changed files with 34 additions and 12 deletions

View File

@@ -5,6 +5,7 @@ export type Plan = {
} }
export type PlanElement = Goal | Action export type PlanElement = Goal | Action
export type PlanElementTypes = ActionTypes | "goal"
export type Goal = { export type Goal = {
id: string, id: string,
@@ -20,7 +21,7 @@ export type SpeechAction = { id: string, text: string, type:"speech" }
export type GestureAction = { id: string, gesture: string, isTag: boolean, type:"gesture" } export type GestureAction = { id: string, gesture: string, isTag: boolean, type:"gesture" }
export type LLMAction = { id: string, goal: string, type:"llm" } export type LLMAction = { id: string, goal: string, type:"llm" }
export type ActionTypes = "speech" | "gesture" | "llm"; export type ActionTypes = "speech" | "gesture" | "llm"
// Extract the wanted information from a plan within the reducing of nodes // Extract the wanted information from a plan within the reducing of nodes
@@ -75,7 +76,7 @@ function StepReduce(planElement: PlanElement) {
export function DoesPlanIterate(plan?: Plan) : boolean { export function DoesPlanIterate(plan?: Plan) : boolean {
// TODO: should recursively check plans that have goals (and thus more plans) in them. // TODO: should recursively check plans that have goals (and thus more plans) in them.
if (!plan) return false if (!plan) return false
return plan.steps.filter((step) => step.type == "llm").length > 0; return plan.steps.filter((step) => step.type == "llm").length > 0 || (plan.steps.filter((x) => x.type == "goal").map((x) => DoesPlanIterate(x.plan))).includes(true);
} }
/** /**

View File

@@ -1,7 +1,7 @@
import {useRef, useState} from "react"; import {useRef, useState} from "react";
import useFlowStore from "../VisProgStores.tsx"; import useFlowStore from "../VisProgStores.tsx";
import styles from './PlanEditor.module.css'; import styles from './PlanEditor.module.css';
import { GetActionValue, type Action, type ActionTypes, type Plan } from "../components/Plan"; import { GetActionValue, type Action, type ActionTypes, type Goal, type Plan, type PlanElement, type PlanElementTypes } from "../components/Plan";
import { defaultPlan } from "../components/Plan.default"; import { defaultPlan } from "../components/Plan.default";
import { TextField } from "../../../../components/TextField"; import { TextField } from "../../../../components/TextField";
import GestureValueEditor from "./GestureValueEditor"; import GestureValueEditor from "./GestureValueEditor";
@@ -21,6 +21,7 @@ export default function PlanEditorDialog({
const dialogRef = useRef<HTMLDialogElement | null>(null); const dialogRef = useRef<HTMLDialogElement | null>(null);
const [draftPlan, setDraftPlan] = useState<Plan | null>(null); const [draftPlan, setDraftPlan] = useState<Plan | null>(null);
const [newActionType, setNewActionType] = useState<ActionTypes>("speech"); const [newActionType, setNewActionType] = useState<ActionTypes>("speech");
const [newPlanElementType, setNewPlanElementType] = useState<PlanElementTypes>("speech")
const [newActionGestureType, setNewActionGestureType] = useState<boolean>(true); const [newActionGestureType, setNewActionGestureType] = useState<boolean>(true);
const [newActionValue, setNewActionValue] = useState(""); const [newActionValue, setNewActionValue] = useState("");
const { setScrollable } = useFlowStore(); const { setScrollable } = useFlowStore();
@@ -57,14 +58,24 @@ export default function PlanEditorDialog({
const id = crypto.randomUUID(); const id = crypto.randomUUID();
switch (newActionType) { switch (newActionType) {
case "speech": case "speech":
return { id, text: newActionValue, type: "speech" }; return { id, text: newPlanElementType, type: "speech" };
case "gesture": case "gesture":
return { id, gesture: newActionValue, isTag: newActionGestureType, type: "gesture" }; return { id, gesture: newPlanElementType, isTag: newActionGestureType, type: "gesture" };
case "llm": case "llm":
return { id, goal: newActionValue, type: "llm" }; return { id, goal: newPlanElementType, type: "llm" };
} }
}; };
const buildGoal = (): Goal => {
return {
id: "",
name: "",
plan: defaultPlan,
can_fail: false,
type: "goal"
}
}
return (<> return (<>
{/* Create and edit buttons */} {/* Create and edit buttons */}
{!plan && ( {!plan && (
@@ -110,20 +121,21 @@ export default function PlanEditorDialog({
Action Type <wbr /> Action Type <wbr />
{/* Type selection */} {/* Type selection */}
<select <select
value={newActionType} value={newPlanElementType}
onChange={(e) => { onChange={(e) => {
setNewActionType(e.target.value as ActionTypes); setNewPlanElementType(e.target.value as PlanElementTypes);
// Reset value when action type changes // Reset value when action type changes
setNewActionValue(""); setNewActionValue("");
}}> }}>
<option value="speech">Speech Action</option> <option value="speech">Speech Action</option>
<option value="gesture">Gesture Action</option> <option value="gesture">Gesture Action</option>
<option value="llm">LLM Action</option> <option value="llm">LLM Action</option>
<option value="goal">Seperate Goal</option>
</select> </select>
</label> </label>
{/* Action value editor*/} {/* Action value editor*/}
{newActionType === "gesture" ? ( {newPlanElementType === "gesture" ? (
// Gesture get their own editor component // Gesture get their own editor component
<GestureValueEditor <GestureValueEditor
value={newActionValue} value={newActionValue}
@@ -131,16 +143,25 @@ export default function PlanEditorDialog({
setType={setNewActionGestureType} setType={setNewActionGestureType}
placeholder="Gesture name" placeholder="Gesture name"
/> />
) : ( )
: (newPlanElementType === "goal" ? (
<div>
</div>
)
:
// Only used for the Speech and LLM elements
(
<TextField <TextField
value={newActionValue} value={newActionValue}
setValue={setNewActionValue} setValue={setNewActionValue}
placeholder={ placeholder={
newActionType === "speech" ? "Speech text" newPlanElementType === "speech" ? "Speech text"
: "LLM goal" : "LLM goal"
} }
/> />
)} ))}
{/* Adding steps */} {/* Adding steps */}
<button <button