perf(async): 交互端点后台化 skim/deep/embed + TaskStatus 类型对齐 + 前端轮询改造 - #45
Merged
Conversation
PR5 — 交互端点后台化(高风险)
5a. TaskStatus 类型不一致修复(前置 bug):
- 后端 task_tracker.to_dict 加 status 便利字段(由 finished/success 派生 running/completed/failed)
+ progress 别名(0-1 小数,前端期望)
- 前端 TaskStatus 类型补 finished/success/progress_pct/elapsed_seconds
此前前端读 status.status 拿 undefined,Wiki/DailyBrief 轮询靠 status 判断失配
5b. pipelines.py skim/deep/embed 改 global_tracker.submit:
- 同步阻塞(5s-2min 占请求线程)→ 后台任务,立即返回 {task_id, status}
- _fn 内 progress_callback 上报进度,结果存 task.result
5c. 前端调用方改造:
- 新建 pollTaskUntilDone helper(递归 setTimeout 轮询 getStatus 直到 finished,
5min 超时 + 10 次错误上限 + 可取消)
- useSkim/useDeepRead/useEmbed:调端点拿 task_id → pollTaskUntilDone → getResult
- onCancel 改用 cancelSkim/cancelDeep/cancelEmbed(标记 cancelledRef,轮询退出)
- useAutoAnalyze 的 3 处直接调 pipelineApi 同步改 pollTaskUntilDone
- pipelineApi.skim/deep/embed 返回类型改 {task_id, status}
不做(如实标注):
- reasoning 后台化:papers.py reasoning 保留同步(低频手动触发,收益小于 skim/deep,列后续)
- 后台任务后端 cancel 端点:前端 cancel 仅标记退出轮询,后端任务仍跑完(标注后续)
🔍 OpenCode PR Review Required这是一个受保护的分支,merge 前需要进行 code review。 请运行以下命令进行 OpenCode review: 或者在 PR 页面评论 This is an automated reminder from PR Review Gate. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR5 — 交互端点后台化(高风险,依赖 PR4 轮询基建)
5a. TaskStatus 类型不一致修复(前置 bug)
5b. pipelines.py skim/deep/embed 改 global_tracker.submit
5c. 前端调用方改造
不做(如实标注)
验证