mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-07 16:37:06 +08:00
add stepStatusMapByStepId in runtimeStorage and logic for update related status on ui
This commit is contained in:
+20
-1
@@ -143,6 +143,23 @@ function handleMessage(socket, message) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
case 'worker-to-gui-message': {
|
case 'worker-to-gui-message': {
|
||||||
|
// 将 prerequisite step 状态写入 worker 的 runtimeStorage
|
||||||
|
if (
|
||||||
|
workerInfo &&
|
||||||
|
message.data?.type === 'prerequisite-step-by-step-check' &&
|
||||||
|
message.data?.step?.id
|
||||||
|
) {
|
||||||
|
workerInfo.runtimeStorage = workerInfo.runtimeStorage || {}
|
||||||
|
workerInfo.runtimeStorage.stepStatusMapByStepId =
|
||||||
|
workerInfo.runtimeStorage.stepStatusMapByStepId || {}
|
||||||
|
workerInfo.runtimeStorage.stepStatusMapByStepId[
|
||||||
|
message.data.step.id
|
||||||
|
] = {
|
||||||
|
step: message.data.step,
|
||||||
|
runRecordId: message.data.runRecordId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 转发工具进程消息到GUI客户端
|
// 转发工具进程消息到GUI客户端
|
||||||
broadcastToGUI({
|
broadcastToGUI({
|
||||||
type: 'worker-to-gui-message',
|
type: 'worker-to-gui-message',
|
||||||
@@ -329,7 +346,9 @@ function startWorker({ workerId, command, args, env }, restartCount = 0) {
|
|||||||
status: 'running',
|
status: 'running',
|
||||||
startTime: Date.now(),
|
startTime: Date.now(),
|
||||||
restartCount, // 使用传入的重启次数
|
restartCount, // 使用传入的重启次数
|
||||||
runtimeStorage: {},
|
runtimeStorage: {
|
||||||
|
stepStatusMapByStepId: {}
|
||||||
|
},
|
||||||
// socket: null, // 工具进程的TCP连接,稍后由工具进程注册
|
// socket: null, // 工具进程的TCP连接,稍后由工具进程注册
|
||||||
// lastHeartbeat: null,
|
// lastHeartbeat: null,
|
||||||
command,
|
command,
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ export class CookieInvalidHandlePlugin {
|
|||||||
if (e?.message === 'USER_CANCELLED_LOGIN') {
|
if (e?.message === 'USER_CANCELLED_LOGIN') {
|
||||||
sendToDaemon({
|
sendToDaemon({
|
||||||
type: 'worker-to-gui-message',
|
type: 'worker-to-gui-message',
|
||||||
|
workerId: process.env.GEEKGEEKRUND_WORKER_ID,
|
||||||
data: {
|
data: {
|
||||||
type: 'prerequisite-step-by-step-check',
|
type: 'prerequisite-step-by-step-check',
|
||||||
step: {
|
step: {
|
||||||
@@ -42,6 +43,7 @@ export class CookieInvalidHandlePlugin {
|
|||||||
}
|
}
|
||||||
sendToDaemon({
|
sendToDaemon({
|
||||||
type: 'worker-to-gui-message',
|
type: 'worker-to-gui-message',
|
||||||
|
workerId: process.env.GEEKGEEKRUND_WORKER_ID,
|
||||||
data: {
|
data: {
|
||||||
type: 'prerequisite-step-by-step-check',
|
type: 'prerequisite-step-by-step-check',
|
||||||
step: {
|
step: {
|
||||||
@@ -56,6 +58,7 @@ export class CookieInvalidHandlePlugin {
|
|||||||
if (userInfoResponse.code === 0) {
|
if (userInfoResponse.code === 0) {
|
||||||
sendToDaemon({
|
sendToDaemon({
|
||||||
type: 'worker-to-gui-message',
|
type: 'worker-to-gui-message',
|
||||||
|
workerId: process.env.GEEKGEEKRUND_WORKER_ID,
|
||||||
data: {
|
data: {
|
||||||
type: 'prerequisite-step-by-step-check',
|
type: 'prerequisite-step-by-step-check',
|
||||||
step: {
|
step: {
|
||||||
@@ -74,6 +77,7 @@ export class CookieInvalidHandlePlugin {
|
|||||||
if (e?.message === 'USER_CANCELLED_LOGIN') {
|
if (e?.message === 'USER_CANCELLED_LOGIN') {
|
||||||
sendToDaemon({
|
sendToDaemon({
|
||||||
type: 'worker-to-gui-message',
|
type: 'worker-to-gui-message',
|
||||||
|
workerId: process.env.GEEKGEEKRUND_WORKER_ID,
|
||||||
data: {
|
data: {
|
||||||
type: 'prerequisite-step-by-step-check',
|
type: 'prerequisite-step-by-step-check',
|
||||||
step: {
|
step: {
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ const runAutoChat = async () => {
|
|||||||
})
|
})
|
||||||
sendToDaemon({
|
sendToDaemon({
|
||||||
type: 'worker-to-gui-message',
|
type: 'worker-to-gui-message',
|
||||||
|
workerId: process.env.GEEKGEEKRUND_WORKER_ID,
|
||||||
data: {
|
data: {
|
||||||
type: 'prerequisite-step-by-step-check',
|
type: 'prerequisite-step-by-step-check',
|
||||||
step: {
|
step: {
|
||||||
@@ -80,6 +81,7 @@ const runAutoChat = async () => {
|
|||||||
}
|
}
|
||||||
sendToDaemon({
|
sendToDaemon({
|
||||||
type: 'worker-to-gui-message',
|
type: 'worker-to-gui-message',
|
||||||
|
workerId: process.env.GEEKGEEKRUND_WORKER_ID,
|
||||||
data: {
|
data: {
|
||||||
type: 'prerequisite-step-by-step-check',
|
type: 'prerequisite-step-by-step-check',
|
||||||
step: {
|
step: {
|
||||||
@@ -183,6 +185,7 @@ export const waitForProcessHandShakeAndRunAutoChat = async () => {
|
|||||||
)
|
)
|
||||||
sendToDaemon({
|
sendToDaemon({
|
||||||
type: 'worker-to-gui-message',
|
type: 'worker-to-gui-message',
|
||||||
|
workerId: process.env.GEEKGEEKRUND_WORKER_ID,
|
||||||
data: {
|
data: {
|
||||||
type: 'prerequisite-step-by-step-check',
|
type: 'prerequisite-step-by-step-check',
|
||||||
step: {
|
step: {
|
||||||
|
|||||||
@@ -314,6 +314,7 @@ const mainLoop = async () => {
|
|||||||
})
|
})
|
||||||
sendToDaemon({
|
sendToDaemon({
|
||||||
type: 'worker-to-gui-message',
|
type: 'worker-to-gui-message',
|
||||||
|
workerId: process.env.GEEKGEEKRUND_WORKER_ID,
|
||||||
data: {
|
data: {
|
||||||
type: 'prerequisite-step-by-step-check',
|
type: 'prerequisite-step-by-step-check',
|
||||||
step: {
|
step: {
|
||||||
@@ -328,6 +329,7 @@ const mainLoop = async () => {
|
|||||||
}
|
}
|
||||||
sendToDaemon({
|
sendToDaemon({
|
||||||
type: 'worker-to-gui-message',
|
type: 'worker-to-gui-message',
|
||||||
|
workerId: process.env.GEEKGEEKRUND_WORKER_ID,
|
||||||
data: {
|
data: {
|
||||||
type: 'prerequisite-step-by-step-check',
|
type: 'prerequisite-step-by-step-check',
|
||||||
step: {
|
step: {
|
||||||
@@ -366,6 +368,7 @@ const mainLoop = async () => {
|
|||||||
})
|
})
|
||||||
sendToDaemon({
|
sendToDaemon({
|
||||||
type: 'worker-to-gui-message',
|
type: 'worker-to-gui-message',
|
||||||
|
workerId: process.env.GEEKGEEKRUND_WORKER_ID,
|
||||||
data: {
|
data: {
|
||||||
type: 'prerequisite-step-by-step-check',
|
type: 'prerequisite-step-by-step-check',
|
||||||
step: {
|
step: {
|
||||||
@@ -385,6 +388,7 @@ const mainLoop = async () => {
|
|||||||
) {
|
) {
|
||||||
sendToDaemon({
|
sendToDaemon({
|
||||||
type: 'worker-to-gui-message',
|
type: 'worker-to-gui-message',
|
||||||
|
workerId: process.env.GEEKGEEKRUND_WORKER_ID,
|
||||||
data: {
|
data: {
|
||||||
type: 'prerequisite-step-by-step-check',
|
type: 'prerequisite-step-by-step-check',
|
||||||
step: {
|
step: {
|
||||||
@@ -418,6 +422,7 @@ const mainLoop = async () => {
|
|||||||
await storeStorage(pageMapByName.boss)
|
await storeStorage(pageMapByName.boss)
|
||||||
sendToDaemon({
|
sendToDaemon({
|
||||||
type: 'worker-to-gui-message',
|
type: 'worker-to-gui-message',
|
||||||
|
workerId: process.env.GEEKGEEKRUND_WORKER_ID,
|
||||||
data: {
|
data: {
|
||||||
type: 'prerequisite-step-by-step-check',
|
type: 'prerequisite-step-by-step-check',
|
||||||
step: {
|
step: {
|
||||||
@@ -432,6 +437,7 @@ const mainLoop = async () => {
|
|||||||
}
|
}
|
||||||
sendToDaemon({
|
sendToDaemon({
|
||||||
type: 'worker-to-gui-message',
|
type: 'worker-to-gui-message',
|
||||||
|
workerId: process.env.GEEKGEEKRUND_WORKER_ID,
|
||||||
data: {
|
data: {
|
||||||
type: 'prerequisite-step-by-step-check',
|
type: 'prerequisite-step-by-step-check',
|
||||||
step: {
|
step: {
|
||||||
@@ -681,6 +687,7 @@ export async function runEntry() {
|
|||||||
)
|
)
|
||||||
sendToDaemon({
|
sendToDaemon({
|
||||||
type: 'worker-to-gui-message',
|
type: 'worker-to-gui-message',
|
||||||
|
workerId: process.env.GEEKGEEKRUND_WORKER_ID,
|
||||||
data: {
|
data: {
|
||||||
type: 'prerequisite-step-by-step-check',
|
type: 'prerequisite-step-by-step-check',
|
||||||
step: {
|
step: {
|
||||||
@@ -707,6 +714,7 @@ export async function runEntry() {
|
|||||||
})
|
})
|
||||||
sendToDaemon({
|
sendToDaemon({
|
||||||
type: 'worker-to-gui-message',
|
type: 'worker-to-gui-message',
|
||||||
|
workerId: process.env.GEEKGEEKRUND_WORKER_ID,
|
||||||
data: {
|
data: {
|
||||||
type: 'prerequisite-step-by-step-check',
|
type: 'prerequisite-step-by-step-check',
|
||||||
step: {
|
step: {
|
||||||
@@ -720,6 +728,7 @@ export async function runEntry() {
|
|||||||
}
|
}
|
||||||
sendToDaemon({
|
sendToDaemon({
|
||||||
type: 'worker-to-gui-message',
|
type: 'worker-to-gui-message',
|
||||||
|
workerId: process.env.GEEKGEEKRUND_WORKER_ID,
|
||||||
data: {
|
data: {
|
||||||
type: 'prerequisite-step-by-step-check',
|
type: 'prerequisite-step-by-step-check',
|
||||||
step: {
|
step: {
|
||||||
|
|||||||
@@ -55,7 +55,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
// import { useTaskManagerStore } from '@renderer/store'
|
import { useTaskManagerStore } from '@renderer/store'
|
||||||
import { getAutoStartChatSteps } from '../../../../common/prerequisite-step-by-step-check'
|
import { getAutoStartChatSteps } from '../../../../common/prerequisite-step-by-step-check'
|
||||||
import { computed, onUnmounted, ref, watch } from 'vue'
|
import { computed, onUnmounted, ref, watch } from 'vue'
|
||||||
import {
|
import {
|
||||||
@@ -71,12 +71,12 @@ const props = defineProps({
|
|||||||
type: Number
|
type: Number
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// const taskManagerStore = useTaskManagerStore()
|
const taskManagerStore = useTaskManagerStore()
|
||||||
// const runningTaskInfo = computed(() => {
|
const runningTaskInfo = computed(() => {
|
||||||
// return taskManagerStore.runningTasks?.find((it) => {
|
return taskManagerStore.runningTasks?.find((it) => {
|
||||||
// return it.workerId === props.workerId
|
return it.workerId === props.workerId
|
||||||
// })
|
})
|
||||||
// })
|
})
|
||||||
const steps = ref([])
|
const steps = ref([])
|
||||||
const stepsForRender = computed(() => {
|
const stepsForRender = computed(() => {
|
||||||
const clonedSteps = JSON.parse(JSON.stringify(steps.value))
|
const clonedSteps = JSON.parse(JSON.stringify(steps.value))
|
||||||
@@ -101,9 +101,43 @@ function fillEmptySteps() {
|
|||||||
steps.value = arr
|
steps.value = arr
|
||||||
currentRunningStatus.value = RUNNING_STATUS_ENUM.RUNNING
|
currentRunningStatus.value = RUNNING_STATUS_ENUM.RUNNING
|
||||||
}
|
}
|
||||||
watch(() => props.runRecordId, fillEmptySteps, {
|
|
||||||
immediate: true
|
function applyRuntimeStepStatus() {
|
||||||
})
|
const task = runningTaskInfo.value
|
||||||
|
if (!task?.runtimeStorage?.stepStatusMapByStepId) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const stepMap = task.runtimeStorage.stepStatusMapByStepId
|
||||||
|
steps.value = getAutoStartChatSteps().map((step) => {
|
||||||
|
const saved = stepMap[step.id]
|
||||||
|
if (!saved || !saved.step) {
|
||||||
|
return step
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
...step,
|
||||||
|
status: saved.step.status
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.runRecordId,
|
||||||
|
() => {
|
||||||
|
fillEmptySteps()
|
||||||
|
applyRuntimeStepStatus()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => taskManagerStore.runningTasks,
|
||||||
|
() => {
|
||||||
|
applyRuntimeStepStatus()
|
||||||
|
},
|
||||||
|
{ deep: true }
|
||||||
|
)
|
||||||
watch(
|
watch(
|
||||||
() => stepsForRender.value,
|
() => stepsForRender.value,
|
||||||
(v) => {
|
(v) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user