()
| 246 | |
| 247 | // A way for gui to retrieve initial statuses |
| 248 | async initStatuses(): Promise<void> { |
| 249 | if (!this.config?.docs) { |
| 250 | return; |
| 251 | } |
| 252 | const metadata = await this.listMetadata(); |
| 253 | |
| 254 | this.config.docs?.forEach((doc) => { |
| 255 | if (!doc.startUrl) { |
| 256 | console.error("Invalid config docs entry, no start url", doc.title); |
| 257 | return; |
| 258 | } |
| 259 | |
| 260 | const currentStatus = this.statuses.get(doc.startUrl); |
| 261 | if (currentStatus) { |
| 262 | this.handleStatusUpdate(currentStatus); |
| 263 | return; |
| 264 | } |
| 265 | |
| 266 | const sharedStatus: Omit< |
| 267 | IndexingStatus, |
| 268 | "progress" | "description" | "status" |
| 269 | > = { |
| 270 | type: "docs", |
| 271 | id: doc.startUrl, |
| 272 | isReindexing: false, |
| 273 | title: doc.title, |
| 274 | debugInfo: `max depth: ${doc.maxDepth ?? "unlimited"}`, |
| 275 | icon: doc.faviconUrl, |
| 276 | url: doc.startUrl, |
| 277 | }; |
| 278 | if (this.config.selectedModelByRole.embed) { |
| 279 | sharedStatus.embeddingsProviderId = |
| 280 | this.config.selectedModelByRole.embed.embeddingId; |
| 281 | } |
| 282 | const indexedStatus: IndexingStatus = metadata.find( |
| 283 | (meta) => meta.startUrl === doc.startUrl, |
| 284 | ) |
| 285 | ? { |
| 286 | ...sharedStatus, |
| 287 | progress: 0, |
| 288 | description: "Pending", |
| 289 | status: "pending", |
| 290 | } |
| 291 | : { |
| 292 | ...sharedStatus, |
| 293 | progress: 1, |
| 294 | description: "Complete", |
| 295 | status: "complete", |
| 296 | }; |
| 297 | this.handleStatusUpdate(indexedStatus); |
| 298 | }); |
| 299 | } |
| 300 | |
| 301 | abort(startUrl: string) { |
| 302 | if (this.docsIndexingQueue.has(startUrl)) { |
no test coverage detected