toeverything/AFFiNE · error

FRONTEND_UNAVAILABLE

FRONTEND_UNAVAILABLE

Error message

No focused editor is available for this session.

What it means

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.

Solutions

  1. Focus an editor session before invoking the delegated read.
  2. Re-establish the editor connection and retry.
Defensive patterns

Strategy: retry

When it happens

Trigger: 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.

Common situations: 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.


AI-assisted analysis of toeverything/AFFiNE@2af30773ae (2026-08-18). Data as JSON: /api/errors/72fc66f6555ee7f9. Report an issue: GitHub.

Appendix: source

Thrown at packages/backend/server/src/plugins/copilot/delegated/service.ts:120

      ) {
        selected = lease;
      }
    }
    return selected;
  }

  async execute(
    options: CopilotChatOptions,
    tool: DelegatedToolName,
    args: Record<string, unknown>,
    signal?: AbortSignal,
    execution?: { runId?: string; toolCallId?: string }
  ) {
    const lease = this.getLease(options, tool);
    if (!lease) {
      return {
        error: {
          code: 'FRONTEND_UNAVAILABLE',
          message: 'No focused editor is available for this session.',
          retryable: true,
        },
      };
    }
    const mode = await this.access.sessionResource(
      {
        userId: lease.userId,
        workspaceId: lease.workspaceId,
        docId: lease.docId,
        action: 'Doc.Read',
      },
      [lease.sessionId]
    );
    if (mode === 'canonical') {
      await this.ac
        .user(lease.userId)
        .workspace(lease.workspaceId)

View on GitHub (pinned to 2af30773ae)