新增: 工作流审批取消端到端(StateMachine Arc 共享 + 取消 IPC 注册表)

- StateMachine 内部 HashMap→Arc<Mutex<HashMap>>,clone 共享底层
- DagExecutor 加 state_machine() 访问器
- AppState 加 workflow_state_registry(execution_id→StateMachine)
- run_workflow 注册执行器状态机 + 完成清理
- cancel_workflow_node IPC 经 execution_id 取共享引用 set_cancelled,直达 HumanNode 轮询
- 前端取消按钮 + cancelHumanApproval store 方法
- 加 clone_shares 单测验证共享语义
This commit is contained in:
2026-06-14 15:19:36 +08:00
parent 0789a36030
commit 4aa689e110
7 changed files with 166 additions and 19 deletions

View File

@@ -244,6 +244,22 @@ function createStore() {
}
}
/** 取消当前待审批节点(调 cancel_workflow_node IPC 置节点 Cancelled */
async function cancelHumanApproval() {
if (!state.pendingApproval) return
try {
await invoke('cancel_workflow_node', {
execution_id: state.pendingApproval.execution_id,
node_id: state.pendingApproval.node_id,
})
// 清除待审批状态
state.pendingApproval = null
} catch (error) {
console.error('取消审批失败:', error)
}
}
function stopEventListener() {
if (_eventUnlisten) {
try {
@@ -284,7 +300,7 @@ function createStore() {
loadIdeas, createIdea, updateIdea, deleteIdea, evaluateIdea, promoteIdea,
// workflow actions
runWorkflow, loadWorkflowExecutions, startEventListener, stopEventListener, clearLiveEvents,
approveHumanApproval, pendingApproval: computed(() => state.pendingApproval),
approveHumanApproval, cancelHumanApproval, pendingApproval: computed(() => state.pendingApproval),
// computed
stats,
})

View File

@@ -189,6 +189,7 @@
</div>
</div>
<div class="modal-actions">
<button class="btn btn-ghost" @click="handleCancelApproval">取消</button>
<button class="btn btn-ghost" @click="showApprovalDialog = false">{{ $t('projectDetail.approvalLater') }}</button>
</div>
</div>
@@ -383,6 +384,12 @@ async function handleApproval(decision: string) {
showApprovalDialog.value = false
}
// ── 取消审批(调 cancel_workflow_node IPC 置节点 Cancelled──
async function handleCancelApproval() {
await store.cancelHumanApproval()
showApprovalDialog.value = false
}
// ── 删除项目(软删 → 回收站,可恢复)──
async function handleDelete() {
const p = currentProject.value