返回 DeepSeek-Reasonix
GoalLifecycleActions.tsx
根目录 / desktop / frontend / src / components / GoalLifecycleActions.tsx
1 import { useI18n } from "../lib/i18n";
2 import type { GoalLifecycleView } from "../lib/types";
3
4 export function GoalLifecycleActions({
5 goalView,
6 goalStatus,
7 disabled,
8 running,
9 onEditGoal,
10 onPauseGoal,
11 onResumeGoal,
12 onStopGoal,
13 }: {
14 goalView?: GoalLifecycleView;
15 goalStatus?: string;
16 disabled?: boolean;
17 running: boolean;
18 onEditGoal: (objective: string, maxGoalRounds: number | null) => void;
19 onPauseGoal: () => void;
20 onResumeGoal: () => void;
21 onStopGoal: () => void;
22 }) {
23 const { t } = useI18n();
24 const resumable = goalView?.phase === "paused"
25 || goalView?.phase === "blocked"
26 || (goalView?.phase === "active" && goalView.activation === "disarmed")
27 || (!goalView && goalStatus === "blocked");
28
29 const editGoal = () => {
30 if (!goalView) return;
31 const objective = window.prompt(t("composer.goalEditObjective"), goalView.objective);
32 if (objective === null) return;
33 const rawLimit = window.prompt(t("composer.goalEditMaxRounds"), goalView.maxGoalRounds?.toString() ?? "");
34 if (rawLimit === null) return;
35 const trimmedLimit = rawLimit.trim();
36 const parsedLimit = trimmedLimit === "" ? null : Number(trimmedLimit);
37 if (parsedLimit !== null && (!Number.isSafeInteger(parsedLimit) || parsedLimit <= 0)) {
38 window.alert(t("composer.goalEditInvalidRounds"));
39 return;
40 }
41 onEditGoal(objective, parsedLimit);
42 };
43
44 return <>
45 {goalView && <button type="button" className="composer-intent-menu__stop" onClick={editGoal} disabled={disabled}>
46 {t("composer.taskModeEditGoal")}
47 </button>}
48 {resumable ? (
49 <button type="button" className="composer-intent-menu__stop" onClick={onResumeGoal} disabled={disabled}>
50 {t("composer.taskModeResumeGoal")}
51 </button>
52 ) : (
53 <button type="button" className="composer-intent-menu__stop" onClick={onPauseGoal} disabled={disabled}>
54 {t("composer.taskModePauseGoal")}
55 </button>
56 )}
57 <button type="button" className="composer-intent-menu__stop" onClick={onStopGoal} disabled={disabled || running}>
58 {t("composer.taskModeStopGoal")}
59 </button>
60 </>;
61 }
62
62 lines Plain Text