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