feat(studio): 回退/重roll 与 R5 用户确认下一步
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -6,7 +6,7 @@ import {
|
||||
buildWorkflowVariableLabelMap,
|
||||
getWorkflowVariableLabel,
|
||||
} from './edit/workflowVariableLabels';
|
||||
import { resolveBoundCharacterName } from './studioRunUtils';
|
||||
import { resolveBoundCharacterName, canUndoRun, canRerollRun, canAdvanceNextStep } from './studioRunUtils';
|
||||
import useCharacterStore from '../../Store/SideBarLeft/CharacterSlice';
|
||||
|
||||
import StudioContextBlockPopup from './StudioContextBlockPopup';
|
||||
@@ -469,6 +469,8 @@ function StudioRunPage() {
|
||||
selectRun,
|
||||
advanceRun,
|
||||
sendRunMessage,
|
||||
undoRun,
|
||||
rerollRun,
|
||||
deleteRun,
|
||||
renameRun,
|
||||
} = useStudioStore();
|
||||
@@ -629,8 +631,26 @@ function StudioRunPage() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleNextStep = () => {
|
||||
window.alert('(R5 占位:确认当前产物后将进入下一步)');
|
||||
const handleUndo = async () => {
|
||||
if (!isWorldbookActive || runMessaging || !canUndoRun(activeNodeState)) return;
|
||||
await undoRun();
|
||||
};
|
||||
|
||||
const handleReroll = async () => {
|
||||
if (!isWorldbookActive || runMessaging || !canRerollRun(activeNodeState)) return;
|
||||
await rerollRun({ stream: streamOutput });
|
||||
};
|
||||
|
||||
const handleNextStep = async () => {
|
||||
if (!isWorldbookActive || runAdvancing || runMessaging || !canAdvanceNextStep(activeNodeState)) {
|
||||
return;
|
||||
}
|
||||
const run = await advanceRun({});
|
||||
if (run) {
|
||||
setChatInput('');
|
||||
setToolOptionIndex(0);
|
||||
setPendingUserText(null);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeleteRun = async (runId) => {
|
||||
@@ -659,6 +679,10 @@ function StudioRunPage() {
|
||||
const inSession = runSessionEntered && !!currentRun;
|
||||
const showToolCarousel = inSession && isWorldbookActive && toolQuestions.length > 0;
|
||||
const showNextStep = inSession && isWorldbookActive;
|
||||
const canUndo = canUndoRun(activeNodeState);
|
||||
const canReroll = canRerollRun(activeNodeState);
|
||||
const canNextStep = canAdvanceNextStep(activeNodeState);
|
||||
const showTurnActions = inSession && isWorldbookActive;
|
||||
|
||||
const renderRunList = () => (
|
||||
<>
|
||||
@@ -881,13 +905,40 @@ function StudioRunPage() {
|
||||
/>
|
||||
)}
|
||||
|
||||
{showTurnActions && (
|
||||
<div className="studio-run-right-section studio-run-turn-actions">
|
||||
<h2 className="studio-run-section-title">回合控制</h2>
|
||||
<div className="studio-run-turn-actions__row">
|
||||
<button
|
||||
type="button"
|
||||
className="studio-run-turn-btn studio-run-turn-btn--undo"
|
||||
onClick={handleUndo}
|
||||
disabled={runAdvancing || runMessaging || !canUndo}
|
||||
title={canUndo ? '回退到上一回合' : '无可回退的回合'}
|
||||
>
|
||||
回退
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="studio-run-turn-btn studio-run-turn-btn--reroll"
|
||||
onClick={handleReroll}
|
||||
disabled={runAdvancing || runMessaging || !canReroll}
|
||||
title={canReroll ? '用相同输入重新生成' : '尚无用户消息'}
|
||||
>
|
||||
重roll
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{showNextStep && (
|
||||
<div className="studio-run-right-section studio-run-right-actions">
|
||||
<button
|
||||
type="button"
|
||||
className="studio-run-next-btn"
|
||||
onClick={handleNextStep}
|
||||
disabled={runAdvancing || runMessaging}
|
||||
disabled={runAdvancing || runMessaging || !canNextStep}
|
||||
title={canNextStep ? '确认当前产物并进入下一节点' : '请先生成当前步骤产物'}
|
||||
>
|
||||
下一步
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user