{"record":{"id":"72fc66f6555ee7f9","repo":"toeverything/AFFiNE","slug":"frontend-unavailable","errorCode":"FRONTEND_UNAVAILABLE","errorMessage":"No focused editor is available for this session.","messagePattern":"No focused editor is available for this session\\.","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/backend/server/src/plugins/copilot/delegated/service.ts","lineNumber":114,"sourceCode":"      ) {\n        selected = lease;\n      }\n    }\n    return selected;\n  }\n\n  async execute(\n    options: CopilotChatOptions,\n    tool: DelegatedToolName,\n    args: Record<string, unknown>,\n    signal?: AbortSignal,\n    execution?: { runId?: string; toolCallId?: string }\n  ) {\n    const lease = this.getLease(options, tool);\n    if (!lease) {\n      return {\n        error: {\n          code: 'FRONTEND_UNAVAILABLE',\n          message: 'No focused editor is available for this session.',\n          retryable: true,\n        },\n      };\n    }\n\n    const identity = {\n      requestId: randomUUID(),\n      runId: execution?.runId ?? randomUUID(),\n      toolCallId: execution?.toolCallId ?? randomUUID(),\n      sessionId: lease.sessionId,\n      workspaceId: lease.workspaceId,\n      docId: lease.docId,\n      clientId: lease.clientId,\n      editorStateId: lease.editorStateId,\n    };\n    const deadlineAt = Date.now() + TOOL_TIMEOUT_MS;\n    const response = new Promise<DelegatedToolResponse>(resolve => {","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/backend/server/src/plugins/copilot/delegated/service.ts#L96-L132","documentation":"execute() could not obtain a delegated-tool lease because no focused editor client is attached to this session; without a live editor there is no frontend to run the delegated read, so a structured FRONTEND_UNAVAILABLE tool error (retryable) is returned to the model instead of throwing.","triggerScenarios":"Returned as FRONTEND_UNAVAILABLE when getLease finds no active editor lease for the session, so there is no focused editor to delegate the tool call to.","commonSituations":"A copilot delegated tool runs while no document is open or focused in the client. Focus an editor in the app and retry; the error is retryable.","solutions":["Focus an editor session before invoking the delegated read.","Re-establish the editor connection and retry."],"exampleFix":null,"handlingStrategy":"retry","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"}