block/buzz · error · Error

Bestie is unavailable outside a community

Error message

Bestie is unavailable outside a community

What it means

useBestie's assignMutation guards its mutationFn: Bestie (the auto-assist agent) can only be assigned within a community scope. When `scope` is undefined — no community/relay context is active — the mutation throws 'Bestie is unavailable outside a community' instead of calling assignBestie.

Source

Thrown at desktop/src/protectedFeatures/bestie/useBestie.ts:100

  );
  const presenceQuery = usePresenceQuery(
    assignedAgent ? [assignedAgent.pubkey] : [],
    { enabled: assignedAgent !== null },
  );
  const presenceStatus = assignedAgent
    ? (presenceQuery.data?.[assignedAgent.pubkey.toLowerCase()] ?? "offline")
    : undefined;
  const runtime = assignedAgent
    ? findManagedAgentRuntime(
        runtimesQuery.data ?? [],
        assignedAgent.pubkey,
        relayUrl,
      )
    : undefined;

  const assignMutation = useMutation({
    mutationFn: (agent: ManagedAgent) => {
      if (!scope) throw new Error("Bestie is unavailable outside a community");
      return assignBestie(agent.pubkey, scope);
    },
    onSuccess: (assignment) => {
      queryClient.setQueryData(queryKey, assignment);
    },
  });
  const clearMutation = useMutation({
    mutationFn: () => {
      if (!scope) throw new Error("Bestie is unavailable outside a community");
      return clearBestieAssignment(scope);
    },
    onSuccess: () => {
      queryClient.setQueryData(queryKey, null);
    },
  });
  const resolveMutation = useMutation({
    mutationFn: () => {
      if (!scope) throw new Error("Bestie is unavailable outside a community");

View on GitHub (pinned to dad5a33865)

Solutions

  1. Ensure a community is active before rendering Bestie controls (gate the UI on scope being defined).
  2. Disable the assign button while `scope` is undefined and show the unavailability message instead.
  3. Wait for community initialization (relay URL + scope resolution) to complete, then retry the assignment.
  4. If scope should exist but doesn't, fix the community context provider wiring upstream of useBestie.

Example fix

// before
assignMutation.mutate(agent);

// after
if (!scope) {
  toast.error("Bestie is unavailable outside a community");
  return;
}
assignMutation.mutate(agent);
Defensive patterns

Strategy: validation

Validate before calling

if (!scope) {
  toast.error("Bestie is unavailable outside a community");
  return;
}
assignMutation.mutate(agent);

Type guard

function hasCommunityScope(s: CommunityScope | undefined): s is CommunityScope {
  return s !== undefined;
}

Try / catch

try {
  await assignMutation.mutateAsync(agent);
} catch (e) {
  if (e instanceof Error && e.message.includes("outside a community")) {
    toast.error("Select a community before assigning Bestie.");
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: Invoking assignMutation.mutate(agent) while the app has no active community scope (scope is undefined), e.g. before a community is selected or when the community context failed to initialize.

Common situations: Rendering the Bestie assignment UI outside a community view; app launched without a configured relay/community; community switch in flight so scope is temporarily undefined when the mutation fires.

Related errors


AI-assisted analysis of block/buzz@dad5a33865 (2026-09-05). Data as JSON: /api/errors/38a25b28688d1208. Report an issue: GitHub.