perf(admin-web): relax template wizard assist poll cadence to 3s
Polling analyze/title/outline task results every 1.2s was over-eager for AI tasks that typically run 15-30s. Bump interval to 3s and lower max attempts to 40, extending total timeout from 72s to 120s while roughly halving request volume. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -946,8 +946,11 @@ async function runOutlineTask(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
const ASSIST_POLL_INTERVAL_MS = 3000
|
||||
const ASSIST_POLL_MAX_ATTEMPTS = 40
|
||||
|
||||
async function pollAnalyzeTask(taskId: string): Promise<TemplateAnalyzeResult> {
|
||||
for (let attempt = 0; attempt < 60; attempt += 1) {
|
||||
for (let attempt = 0; attempt < ASSIST_POLL_MAX_ATTEMPTS; attempt += 1) {
|
||||
const task = await templatesApi.getAnalyzeTaskResult(templateId.value, taskId)
|
||||
advanceAssistProgress(attempt, task.status)
|
||||
|
||||
@@ -959,14 +962,14 @@ async function pollAnalyzeTask(taskId: string): Promise<TemplateAnalyzeResult> {
|
||||
throw new Error(task.error_message || t('templates.wizard.messages.assistFailed'))
|
||||
}
|
||||
|
||||
await sleep(1200)
|
||||
await sleep(ASSIST_POLL_INTERVAL_MS)
|
||||
}
|
||||
|
||||
throw new Error(t('templates.wizard.messages.assistTimeout'))
|
||||
}
|
||||
|
||||
async function pollTitleTask(taskId: string): Promise<string[]> {
|
||||
for (let attempt = 0; attempt < 60; attempt += 1) {
|
||||
for (let attempt = 0; attempt < ASSIST_POLL_MAX_ATTEMPTS; attempt += 1) {
|
||||
const task = await templatesApi.getTitleTaskResult(templateId.value, taskId)
|
||||
advanceAssistProgress(attempt, task.status)
|
||||
|
||||
@@ -978,14 +981,14 @@ async function pollTitleTask(taskId: string): Promise<string[]> {
|
||||
throw new Error(task.error_message || t('templates.wizard.messages.titleFailed'))
|
||||
}
|
||||
|
||||
await sleep(1200)
|
||||
await sleep(ASSIST_POLL_INTERVAL_MS)
|
||||
}
|
||||
|
||||
throw new Error(t('templates.wizard.messages.titleTimeout'))
|
||||
}
|
||||
|
||||
async function pollOutlineTask(taskId: string): Promise<TemplateOutlineNode[]> {
|
||||
for (let attempt = 0; attempt < 60; attempt += 1) {
|
||||
for (let attempt = 0; attempt < ASSIST_POLL_MAX_ATTEMPTS; attempt += 1) {
|
||||
const task = await templatesApi.getOutlineTaskResult(templateId.value, taskId)
|
||||
advanceAssistProgress(attempt, task.status)
|
||||
|
||||
@@ -997,7 +1000,7 @@ async function pollOutlineTask(taskId: string): Promise<TemplateOutlineNode[]> {
|
||||
throw new Error(task.error_message || t('templates.wizard.messages.outlineFailed'))
|
||||
}
|
||||
|
||||
await sleep(1200)
|
||||
await sleep(ASSIST_POLL_INTERVAL_MS)
|
||||
}
|
||||
|
||||
throw new Error(t('templates.wizard.messages.outlineTimeout'))
|
||||
|
||||
Reference in New Issue
Block a user