{"record":{"id":"74fd7d4ad42df7c3","repo":"toeverything/AFFiNE","slug":"frontend-disconnected","errorCode":"FRONTEND_DISCONNECTED","errorMessage":"The focused editor disconnected during the read.","messagePattern":"The focused editor disconnected during the read\\.","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/backend/server/src/plugins/copilot/delegated/service.ts","lineNumber":256,"sourceCode":"  @OnEvent('copilot.delegated.tool.responded', { suppressError: true })\n  onRemoteResponse(event: Events['copilot.delegated.tool.responded']) {\n    this.receive(event.userId, event.response);\n  }\n\n  @OnEvent('realtime.connection.disconnected', { suppressError: true })\n  onDisconnect({ connectionId }: Events['realtime.connection.disconnected']) {\n    for (const [key, lease] of this.leases) {\n      if (lease.connectionId === connectionId) {\n        this.leases.delete(key);\n      }\n    }\n    for (const [requestId, request] of this.pending) {\n      if (request.connectionId !== connectionId) continue;\n      this.pending.delete(requestId);\n      request.resolve({\n        ...request.identity,\n        error: {\n          code: 'FRONTEND_DISCONNECTED',\n          message: 'The focused editor disconnected during the read.',\n          retryable: true,\n        },\n      });\n      this.publisher.publish(\n        'copilot.delegated.tool.requested',\n        { clientId: request.identity.clientId },\n        { type: 'cancel', ...request.identity, reason: 'disconnect' },\n        {\n          room: realtimeUserRoom(\n            request.userId,\n            `copilot:${request.identity.clientId}`\n          ),\n        }\n      );\n    }\n  }\n","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/backend/server/src/plugins/copilot/delegated/service.ts#L238-L274","documentation":"The realtime connection backing a delegated-tool lease dropped; onDisconnect deletes the lease and fails any pending request bound to that connectionId, so in-flight delegated reads resolve with a structured error reporting the focused editor disconnected.","triggerScenarios":"Returned as FRONTEND_DISCONNECTED when the realtime connection of the focused editor drops while a delegated read is pending, resolving the request on disconnect.","commonSituations":"The app lost connection or the tab closed during a copilot tool call. Reconnect, refocus the document, and retry the operation.","solutions":["Reconnect the focused editor and retry the read.","Check the editor session for unexpected termination."],"exampleFix":null,"handlingStrategy":"fallback","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-14T00:17:10.932Z"}