| 1 | import type { CollaborationMode } from "../lib/types"; |
| 2 | import { useGoalActionHandler } from "../lib/goalAction"; |
| 3 | import { useCommittedCommand } from "../lib/useCommittedCommand"; |
| 4 | |
| 5 | /** Void Composer events share one error boundary; awaited send paths still reject. */ |
| 6 | export function useComposerGoalCommands(input: { |
| 7 | applyGoal: (goal: string) => Promise<void>; |
| 8 | editGoal: (objective: string, maxGoalRounds: number | null) => Promise<void>; |
| 9 | applyCollaborationMode: (mode: CollaborationMode) => Promise<void>; |
| 10 | }) { |
| 11 | const { runGoalAction } = useGoalActionHandler(); |
| 12 | const clearGoalFromUi = useCommittedCommand(() => runGoalAction(() => input.applyGoal(""))); |
| 13 | const setCollaborationModeFromUi = useCommittedCommand((mode: CollaborationMode) => runGoalAction(() => input.applyCollaborationMode(mode))); |
| 14 | const editGoalFromUi = useCommittedCommand((objective: string, maxGoalRounds: number | null) => runGoalAction(() => input.editGoal(objective, maxGoalRounds))); |
| 15 | return { clearGoalFromUi, editGoalFromUi, setCollaborationModeFromUi }; |
| 16 | } |
| 17 |