fix(chat): 索引改为后台异步执行,前端轮询状态并展示进度提示

后端:
- /chat/index 改为 BackgroundTasks 异步执行,立即返回
- /chat/status 返回细粒度状态(idle/indexing/indexed/failed)
- 内存追踪索引进度,避免重复触发

前端:
- ChatPanel 每 2 秒轮询索引状态,索引完成后自动停止
- 索引中显示"正在索引笔记内容..."及首次下载模型提示
- 索引失败显示重试按钮

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
huangjianwu
2026-03-23 14:46:37 +08:00
parent fdc888512a
commit 2f2eb646a4
3 changed files with 72 additions and 41 deletions

View File

@@ -18,8 +18,11 @@ export interface AskResponse {
sources: ChatSource[]
}
export type IndexStatus = 'idle' | 'indexing' | 'indexed' | 'failed'
export interface ChatStatusResponse {
indexed: boolean
status: IndexStatus
}
export const indexTask = async (taskId: string): Promise<void> => {