diff --git a/packages/ui/src/main/flow/OPEN_SETTING_WINDOW/ipc/index.ts b/packages/ui/src/main/flow/OPEN_SETTING_WINDOW/ipc/index.ts index 5a3878b..0b150f0 100644 --- a/packages/ui/src/main/flow/OPEN_SETTING_WINDOW/ipc/index.ts +++ b/packages/ui/src/main/flow/OPEN_SETTING_WINDOW/ipc/index.ts @@ -23,7 +23,8 @@ import { getCompanyLibrary, getJobLibrary, getJobHistoryByEncryptId, - getMarkAsNotSuitRecord + getMarkAsNotSuitRecord, + saveAndGetCurrentRunRecord, } from '../utils/db/index' import { PageReq } from '../../../../common/types/pagination' import { pipeWriteRegardlessError } from '../../utils/pipe' @@ -203,6 +204,7 @@ export default function initIpc() { if (!puppeteerExecutable) { return Promise.reject('NEED_TO_CHECK_RUNTIME_DEPENDENCIES') } + const currentRunRecord = (await saveAndGetCurrentRunRecord())?.data const subProcessEnv = { ...process.env, PUPPETEER_EXECUTABLE_PATH: puppeteerExecutable.executablePath, @@ -219,7 +221,8 @@ export default function initIpc() { command: process.argv[0], args: [ process.argv[1], - `--mode=geekAutoStartWithBossMain` + `--mode=geekAutoStartWithBossMain`, + `--run-record-id=${currentRunRecord?.id || 0}` ], env: subProcessEnv }, @@ -257,6 +260,7 @@ export default function initIpc() { if (!puppeteerExecutable) { return Promise.reject('NEED_TO_CHECK_RUNTIME_DEPENDENCIES') } + const currentRunRecord = (await saveAndGetCurrentRunRecord())?.data const subProcessEnv = { ...process.env, PUPPETEER_EXECUTABLE_PATH: puppeteerExecutable.executablePath, @@ -273,7 +277,8 @@ export default function initIpc() { command: process.argv[0], args: [ process.argv[1], - `--mode=readNoReplyAutoReminder` + `--mode=readNoReplyAutoReminder`, + `--run-record-id=${currentRunRecord?.id || 0}` ], env: subProcessEnv }, diff --git a/packages/ui/src/main/flow/OPEN_SETTING_WINDOW/utils/db/index.ts b/packages/ui/src/main/flow/OPEN_SETTING_WINDOW/utils/db/index.ts index fe8e81e..e00bc65 100644 --- a/packages/ui/src/main/flow/OPEN_SETTING_WINDOW/utils/db/index.ts +++ b/packages/ui/src/main/flow/OPEN_SETTING_WINDOW/utils/db/index.ts @@ -102,3 +102,10 @@ export const getJobHistoryByEncryptId = async (encryptJobId) => { }) return res } + +export const saveAndGetCurrentRunRecord = async () => { + const res = await createWorkerPromise({ + type: 'saveAndGetCurrentRunRecord' + }) + return res +} diff --git a/packages/ui/src/main/flow/OPEN_SETTING_WINDOW/utils/db/worker/index.ts b/packages/ui/src/main/flow/OPEN_SETTING_WINDOW/utils/db/worker/index.ts index c9d1d93..df3a684 100644 --- a/packages/ui/src/main/flow/OPEN_SETTING_WINDOW/utils/db/worker/index.ts +++ b/packages/ui/src/main/flow/OPEN_SETTING_WINDOW/utils/db/worker/index.ts @@ -11,6 +11,7 @@ import { VMarkAsNotSuitLog } from '@geekgeekrun/sqlite-plugin/dist/entity/VMarkA import { measureExecutionTime } from '../../../../../../common/utils/performance' import { PageReq, PagedRes } from '../../../../../../common/types/pagination' import { JobInfoChangeLog } from '@geekgeekrun/sqlite-plugin/dist/entity/JobInfoChangeLog' +import { AutoStartChatRunRecord } from '@geekgeekrun/sqlite-plugin/dist/entity/AutoStartChatRunRecord' const dbInitPromise = initDb(getPublicDbFilePath()) let dataSource: DataSource | null = null @@ -161,6 +162,13 @@ const payloadHandler = { }) ) return data + }, + async saveAndGetCurrentRunRecord() { + const autoStartChatRunRecord = new AutoStartChatRunRecord() + autoStartChatRunRecord.date = new Date() + const autoStartChatRunRecordRepository = dataSource!.getRepository(AutoStartChatRunRecord) + const result = await autoStartChatRunRecordRepository.save(autoStartChatRunRecord) + return result } }