feat: 修改重新运行按钮展示逻辑

This commit is contained in:
dolphin
2025-09-17 20:47:58 +08:00
parent aeb32dd7d4
commit 48dbd39416
5 changed files with 22 additions and 3 deletions
+2
View File
@@ -91,6 +91,8 @@ export interface RunningStatus {
showStop: boolean;
/** 引导词 */
guideWord?: string[];
/** 重新运行展示 */
showReRun?: boolean;
}
// 毕昇配置
@@ -7,7 +7,7 @@ import { useAreaText } from "./useAreaText";
export default function ChatInput({ v }) {
const [bishengConfig] = useRecoilState(bishengConfState)
const { inputDisabled, error: inputMsg, showUpload, showStop } = useRecoilValue(currentRunningState)
const { inputDisabled, error: inputMsg, showUpload, showStop, showReRun } = useRecoilValue(currentRunningState)
const { accepts, chatState, inputRef, setChatFiles, handleInput, handleRestart, handleSendClick, handleStopClick } = useAreaText()
const [fileUploading, setFileUploading] = useState(false)
@@ -57,7 +57,8 @@ export default function ChatInput({ v }) {
is工作流 & 未展示停止按钮 & 没有错误消息
*/}
<div className="absolute w-full flex justify-center left-0 -top-14">
{!showStop && chatState?.flow?.flow_type === 10 && !inputMsg && <Button
{/* {!showStop && chatState?.flow?.flow_type === 10 && !inputMsg */}
{!showStop && showReRun && !inputMsg && <Button
className="rounded-full bg-primary/10 bg-blue-50 text-primary"
variant="ghost"
onClick={handleRestart}>
@@ -128,7 +128,8 @@ export default function index() {
inputForm: numericType !== FLOW_TYPES.WORK_FLOW || null,
showUpload: numericType === FLOW_TYPES.WORK_FLOW,
showStop: false,
guideWord: flowData?.guide_question
guideWord: flowData?.guide_question,
showReRun: false
}
}
})
@@ -78,6 +78,17 @@ export default function useChatHelpers() {
}))
}
// 显示重试按钮
const reRunShow = (show: boolean) => {
setRunningState((prev) => ({
...prev,
[chatId]: {
...prev[chatId],
showReRun: show,
},
}))
}
// 唤起输入(表单输入,文本输入)
const showInputForm = (inputSchema) => {
const { tab, value } = inputSchema
@@ -365,6 +376,7 @@ export default function useChatHelpers() {
message,
flow: chatState?.flow,
stopShow,
reRunShow,
handleMsgError,
clearError,
showInputForm,
@@ -112,6 +112,7 @@ export const useWebSocket = (helpers) => {
// 工作流input会有再begin之前出现的情况
// helpers.stopShow(true)
} else if (data.type === 'close' && data.category === 'processing') {
helpers.flow.flow_type === 10 && helpers.reRunShow(true)
helpers.stopShow(false)
}
@@ -135,11 +136,13 @@ export const useWebSocket = (helpers) => {
sessionInfoMap.set(helpers.chatId, { node_id, message_id: data.message_id })
// 待用户输入
helpers.showInputForm({ ...input_schema, node_id })
helpers.flow.flow_type === 10 && helpers.reRunShow(true)
return
} else if (data.category === 'guide_question') {
return helpers.showGuideQuestion(helpers.chatId, data.message.guide_question.filter(q => q))
} else if (data.category === 'stream_msg') {
helpers.message.streamMsg(helpers.chatId, data)
helpers.flow.flow_type === 10 && helpers.reRunShow(true)
} else if (data.category === 'end_cover' && data.type === 'end_cover') {
// helpers.handleMsgError('')
_ws.send(JSON.stringify({ action: 'stop' }))