{"record":{"id":"802fff25a6651a6e","repo":"toeverything/AFFiNE","slug":"selected-sources-cannot-be-synchronized","errorCode":null,"errorMessage":"Selected sources cannot be synchronized","messagePattern":"Selected sources cannot be synchronized","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/frontend/core/src/blocksuite/ai/runtime/request/service.ts","lineNumber":64,"sourceCode":"    context(): string;\n  };\n  private activeEditorGeneration = 0;\n  private activeEditorActivation = Promise.resolve();\n  private lastActionSessionId = '';\n  private readonly actionHistory: {\n    action: AIActionId;\n    options: AIActionOptions;\n  }[] = [];\n  readonly actionEvents$ = new Subject<AIRequestActionEvent>();\n\n  constructor(\n    readonly client: CopilotClientType,\n    private readonly syncSelectedSources?: (docIds: string[]) => Promise<void>\n  ) {}\n\n  async waitForSelectedSources(docIds: string[]) {\n    if (!this.syncSelectedSources) {\n      throw new Error('Selected sources cannot be synchronized');\n    }\n    let timeout: ReturnType<typeof setTimeout> | undefined;\n    try {\n      await Promise.race([\n        this.syncSelectedSources(docIds),\n        new Promise<never>((_, reject) => {\n          timeout = setTimeout(\n            () =>\n              reject(new Error('Selected source synchronization timed out')),\n            15000\n          );\n        }),\n      ]);\n    } finally {\n      if (timeout) clearTimeout(timeout);\n    }\n  }\n","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/frontend/core/src/blocksuite/ai/runtime/request/service.ts#L46-L82","documentation":"Guard in waitForSelectedSources fired when the AIRequestService was constructed without a syncSelectedSources callback, so selected doc sources can never be synchronized with the copilot backend. Indicates a wiring/misconfiguration of the AI request service, not a user error.","triggerScenarios":"Thrown in AIRequestService.waitForSelectedSources when no syncSelectedSources callback was provided, so user-selected documents cannot be synced to the server before the AI request.","commonSituations":"Appears when the AI chat panel is used in a context where source synchronization is not wired up. Ensure the service is constructed with a syncSelectedSources implementation.","solutions":["Re-select the sources and retry; the previous selection became stale.","Refresh the document/source list before synchronizing."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}