fix(extension): resolve race condition in hub config and fix tab initialization crash
Some checks failed
CI / test (24) (push) Has been cancelled
Deploy Demo / deploy (push) Has been cancelled

add: erp scrape python demo
This commit is contained in:
Zou-Seay
2026-06-25 15:31:41 +08:00
parent e26589bc54
commit 9f22a730df
3 changed files with 75 additions and 3 deletions

View File

@@ -47,7 +47,7 @@ export class RemotePageController {
}
async getLastUpdateTime(): Promise<number> {
if (!this.currentTabId) throw new Error('tabsController not initialized.')
if (!this.currentTabId) return Date.now()
return sendMessage({
type: 'PAGE_CONTROL',
action: 'get_last_update_time',

View File

@@ -218,9 +218,23 @@ export function useHubWs(
Number(wsPort),
{
onExecute: async (task, incomingConfig) => {
const { execute, configure, config } = latestRef.current
let { execute } = latestRef.current
const { configure, config } = latestRef.current
if (incomingConfig) {
await configure({ ...config, ...incomingConfig } as ExtConfig)
let changed = false
for (const key of Object.keys(incomingConfig)) {
if (incomingConfig[key] !== (config as any)?.[key]) {
changed = true
break
}
}
if (changed) {
await configure({ ...config, ...incomingConfig } as ExtConfig)
// Wait a bit for React to re-render and instantiate the new MultiPageAgent
await new Promise((resolve) => setTimeout(resolve, 500))
// Re-fetch the newly generated execute function after re-render
execute = latestRef.current.execute
}
}
const result = await execute(task)
return { success: result.success, data: result.data }