Files
PaperClipAI/ui/src/components/new-agent/ExternalAgentInviteDialog.tsx
T
a3313f6944 fix(ui): complete read recovery and enforce query error rendering (#18822)
## Thinking Path

> - Paperclip lets people manage agent work through the board.
> - The board reads task, agent, settings, plugin, and run data from the
server.
> - A deploy can interrupt those reads after content is already visible.
> - Local error branches can replace that content with an error or show
raw codes.
> - This pull request moves the remaining reads to the shared recovery
behavior.
> - The query-error guard prevents new local error patterns from
returning.

## Linked Issues or Issue Description

**What happened?**
Loaded lists, settings, task panels, and manual reads could clear their
content or show errors during a server restart. Some reads also disabled
the shared retry policy.

**Expected behavior**
Keep loaded content during a temporary failure. Show the shared
connection banner. Retry reads after recovery. Replace content after a
real access denial or missing resource, with readable copy.

**Steps to reproduce**
Open a task, settings page, or run log. Return 503 with
`tenant_app_unavailable` from the API. Restore the API and check that
content refreshes. Repeat with 403 and 404 to check the failure state.

Related merged work: Refs #15754, Refs #15772, Refs #17960. This change
covers remaining reads and enforcement. Browser persistence and the
outage browser suite follow separately.

## What Changed

- Repair an existing PostgreSQL deadline fixture at UTC boundaries. A
daily cap defers a heartbeat until both its original interval and the
next UTC day allow it. Keep the counted run in its seeded day and cover
noon, just before midnight and the first second after midnight with
explicit clocks and real PostgreSQL. Production scheduling is unchanged.

- Integrate the saved list, settings, shell, task, and manual-read
recovery changes against current master. Preserve the current task,
Inbox, and run-log structure.
- Add `useResilientFetch` for component-local reads. Preserve loaded
data, cancel stale requests, and retry through the shared connectivity
policy. Keep browser and pairing capabilities in memory.
- Retain run log chunks across stream changes and catch up after
recovery without duplicate chunks or stalled requests.
- Keep genuine authorization and missing-resource failures visible.
Translate known single-word codes such as `forbidden`. Show known skills
and disconnected-app failures before sibling loading states. Keep Retry
bound to its failed request.
- Make the query-error guard enforce by default and run it in the CI
policy job. Document the narrow exceptions and the read recovery
contract.
- Invalidate pending OAuth discovery when the operator leaves setup or
its context changes. Keep reserved-popup cleanup bound to the current
attempt.

## Verification

- Current read head `09d1db29dea` is merge-ready: all 59 check runs are
completed (54 successful, three skipped, two neutral), the legacy Snyk
status is successful, and both required `ci / verify` and `ci / e2e`
gates pass. Greptile Apex reviewed this exact head at 5/5 with no
unresolved threads; the branch has no merge conflicts. The current CI
run is `41748339602`.
- Current read head `09d1db29dea` includes master `683fa4725e9`. The
latest change touches only the existing server deadline test fixture.
Application source remains the previously verified `86376fa751e`
revision: all 60 affected skills/disconnected-app tests and both
application UI typechecks passed, along with token gates and the
enforcing query-error guard. Those UI suites were not repeated for this
test-only repair.
- The fixture repair passes all seven deadline integration cases and the
complete server typecheck, including the server test layer. The old
assertion deterministically fails at 23:59:06.888 UTC; its
one-second-old run also fails the first-second-of-day probe. The
corrected fixture passes noon and both midnight probes. The permanent
three-case coverage uses seeded 2099 clocks.
- Twelve new regressions fail against the previous implementation. Both
skills variants and disconnected-app pages show either request's 403 or
429 while the sibling pauses or remains fetching. Permission failures
stay visible. Retry stays usable for its failed request and recovers
independently. An initial test-fixture query-key typo was corrected
before the passing run. The finding is replied to and resolved. Greptile
reviewed prior application revision `86376fa751e` at 5/5 with no new
actionable findings or unresolved threads. The current test-only head
has now received its own Apex 5/5 review with no unresolved threads, and
its CI is successful as recorded above.
- The preceding OAuth fix passed all 237 setup tests on both application
branches. Its ten regressions prove that Back, Cancel, unmount, or
context changes retire initial discovery without creating a connection,
caching old identities, navigating an abandoned popup, or closing a
newer attempt.
- Earlier master integration `e992f770339` passed all 309 tests across
eight affected Slack, recovery, retry, submission and task files, plus
UI typecheck, token gates, enforcing query-error scan and seven guard
tests. The integration preserves Slack workspace reconnect and shared
recovery, readable execution errors, source-inspection company scoping,
and current submission behavior. Newly inherited retained-file recovery
controls keep cached data through transient failures and hide it after
definitive denial.
- The preceding cache head `97c0bc3966f` passed 1,038 focused
cache/write/editor/account/task/API tests. All 22 built-UI
outage/write/loading cases passed in 4.7 minutes on exact browser head
`b7deaaee5da`, with strict checking of all three specs. The latest
skills/app rendering fix is covered by its affected component suites;
those broader cases were not repeated for this separate read path.
- Historical broader UI, CLI and build results and unresolved aggregate
server/DB/adapter failures remain in the PR discussion. Interrupted CI
runs were audited and recorded separately; they are not counted as
passes. Controlled local outages do not prove hosted authentication or a
real Cloud restart/deploy. Real hosted acceptance remains required after
merge and deployment.

Commands for the latest fix:

```sh
pnpm --filter @paperclipai/ui exec vitest run src/pages/CompanySkills.test.tsx src/pages/apps/AppNotConnected.test.tsx
pnpm --filter @paperclipai/ui typecheck
pnpm check:token-gates
node scripts/check-query-error-rendering.mjs --enforce --summary
```

## Risks

This migration touches many read surfaces. The main risks are initial
loading, request cancellation, retained authorization state, and run-log
paging. The tests cover those states. There are no server, schema,
dependency, or API contract changes. The follow-up browser suite and
hosted deploy acceptance are required before release acceptance.

Recovered commits retain their original authors. If squash-merging,
preserve `Co-Authored-By: Bender (Fable) <bender@agents.paperclip.ing>`
and the Paperclip trailer.

## Model Used

OpenAI `gpt-6.1-sol` through Codex, with xhigh reasoning effort, tool
use, and code execution. The context window size is not exposed. Saved
source commits keep their original authorship.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have described the issue in-PR following the bug report template
- [x] I have not referenced internal/instance-local Paperclip issues or
links
- [x] My branch name describes the change and contains no internal
ticket id
- [x] The affected local tests pass; broader limitations are recorded
above
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: devinfoley <139239+devinfoley@users.noreply.github.com>
Co-authored-by: Paperclip <noreply@paperclip.ing>
Co-authored-by: Bender (Fable) <bender@agents.paperclip.ing>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-04 14:07:18 -08:00

240 lines
18 KiB
TypeScript

import { useEffect, useRef, useState } from "react";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import type { MuseInvitation } from "@paperclipai/shared";
import { ApiError } from "@/api/client";
import { museInvitationsApi } from "@/api/museInvitations";
import { useAccountIdentity } from "@/api/companies-query";
import { useMuseConnection, useMuseConnectionState } from "@/hooks/useMuseConnection";
import { clearMuseInvitationDraft, readMuseInvitationDraft, saveMuseInvitationDraft, type MuseInvitationDraft } from "@/lib/muse-invitation-draft";
import { accessApi } from "@/api/access";
import { dotInvitationsApi, type DotInvitation, type DotPairing } from "@/api/dotInvitations";
import { describeError } from "@/api/errors";
import { instanceSettingsApi } from "@/api/instanceSettings";
import { useCompany } from "@/context/CompanyContext";
import { queryKeys } from "@/lib/queryKeys";
import { buildAgentOnboardingPrompt } from "@/lib/agent-onboarding-prompt";
import { buildDotSetupPrompt } from "@/lib/dot-setup-prompt";
import { GrokBotSetup } from "./GrokBotSetup";
import { AnimatedDialogContent } from "../AnimatedDialogContent";
import { Dialog } from "../ui/dialog";
import { ExternalAgentInviteContent, type DotConnectionState, type ExternalAgentPreset } from "./ExternalAgentInviteContent";
/** Pairing secrets live only in this mounted dialog. Reloads resume the agent, never duplicate it. */
export function ExternalAgentInviteDialog({ companyId, onClose, onBack, initialPreset = null, initialMuseName = "" }: {
companyId: string;
initialPreset?: ExternalAgentPreset | null;
initialMuseName?: string;
onClose: () => void;
onBack: () => void;
}) {
const cache = useQueryClient();
const { selectedCompany } = useCompany();
const [preset, setPreset] = useState<ExternalAgentPreset | null>(initialPreset);
const [invitation, setInvitation] = useState<DotInvitation | null>(null);
const [pairing, setPairing] = useState<DotPairing | null>(null);
const [expiredPairingBindingId, setExpiredPairingBindingId] = useState<string | null>(null);
const [genericPrompt, setGenericPrompt] = useState("");
const attemptedAutomaticPairing = useRef(false);
const experimental = useQuery({ queryKey: queryKeys.instance.experimentalSettings, queryFn: instanceSettingsApi.getExperimental });
const dotDisabledReason = experimental.isPending ? "Loading available agents…"
: experimental.error ? "Unable to load experimental settings. Try again after refreshing."
: !experimental.data?.enableOpenAiDot || !experimental.data.enablePublicMcp
? "Enable OpenAI Dot and Assistant connections (MCP) in experimental settings." : undefined;
const grokDisabledReason = experimental.isPending ? "Loading available agents…" : experimental.error ? "Unable to load experimental settings."
: !experimental.data?.enableGrokBot || !experimental.data.enablePublicMcp || !experimental.data.enableNativeRunner
? "Enable Grok Bot, Assistant connections (MCP), and Paperclip Runner in experimental settings." : undefined;
const key = ["dot-binding", companyId, invitation?.agent.id];
const state = useQuery({ queryKey: key,
queryFn: ({ signal }) => dotInvitationsApi.connection(companyId, invitation!.agent.id, signal),
enabled: preset === "dot" && !!invitation,
staleTime: 0,
refetchInterval: query => query.state.error ? false : query.state.data?.agentLifecycleState === "ready" && query.state.data.canConfigureConnection
&& query.state.data.binding?.status === "ready" && query.state.data.binding.subscriptionVerified ? false : 2500,
});
const generate = useMutation({
mutationFn: async (kind: ExternalAgentPreset) => {
if (kind === "dot") {
const result = await dotInvitationsApi.create(companyId);
setInvitation(result);
await cache.invalidateQueries({ queryKey: queryKeys.agents.list(companyId) });
return;
}
const invite = await accessApi.createCompanyInvite(companyId, { allowedJoinTypes: "agent", humanRole: null, agentMessage: null });
void cache.invalidateQueries({ queryKey: queryKeys.access.invites(companyId, "all", 5) });
const path = invite.onboardingTextUrl ?? invite.onboardingTextPath ?? `/api/invites/${invite.token}/onboarding.txt`;
const manifest = await accessApi.getInviteOnboarding(invite.token).catch(() => null);
setGenericPrompt(buildAgentOnboardingPrompt({ onboardingTextUrl: new URL(path, window.location.origin).href,
connectionCandidates: manifest?.onboarding.connectivity?.connectionCandidates ?? null,
testResolutionUrl: manifest?.onboarding.connectivity?.testResolutionEndpoint?.url ?? null }));
},
gcTime: 0,
});
const pair = useMutation({
mutationFn: async (replaceBindingId?: string) => {
const result = await dotInvitationsApi.pair(companyId, invitation!.agent.id, replaceBindingId);
setPairing(result);
setExpiredPairingBindingId(null);
// Do not retain a one-use code in React Query's mutation cache.
},
onSuccess: () => { void cache.invalidateQueries({ queryKey: key }); },
onError: () => { void state.refetch(); },
gcTime: 0,
});
const test = useMutation({ mutationFn: () => dotInvitationsApi.retry(companyId, invitation!.agent.id, state.data!.binding!.id),
onSuccess: () => { void cache.invalidateQueries({ queryKey: key }); } });
const binding = state.data?.binding;
const canPreparePairing = preset === "dot" && state.data?.enabled && !!state.data.resourceUrl
&& state.data.canConfigureConnection
&& (!binding || binding.status === "pairing");
const preparePairing = canPreparePairing && !pairing && !state.error && !pair.error
&& !attemptedAutomaticPairing.current
&& (!expiredPairingBindingId || binding?.id === expiredPairingBindingId);
useEffect(() => {
// Revalidate cached connection state before rotating an unfinished capability.
// Attempt once per opening/expiry, so failed requests and other tabs cannot cause a renewal loop.
if (preparePairing && state.isFetchedAfterMount && !state.isFetching && !pair.isPending) {
attemptedAutomaticPairing.current = true;
pair.mutate(binding?.id);
}
}, [preparePairing, state.isFetchedAfterMount, state.isFetching, pair.isPending, pair.mutate, binding?.id]);
useEffect(() => {
if (!pairing) return;
const timer = window.setTimeout(() => {
attemptedAutomaticPairing.current = false;
setExpiredPairingBindingId(pairing.bindingId);
setPairing(null);
}, Math.max(0, Date.parse(pairing.expiresAt) - Date.now()));
return () => window.clearTimeout(timer);
}, [pairing]);
const checksReady = binding?.status === "ready" && binding.subscriptionVerified;
const agentReady = state.data?.agentLifecycleState === "ready" && state.data.canConfigureConnection;
const finishingSetup = ["preparing", "verifying"].includes(state.data?.agentLifecycleState ?? "")
&& state.data?.canConfigureConnection;
const connection: DotConnectionState = {
phase: checksReady ? agentReady ? "ready" : finishingSetup ? "finishing" : "ready"
: binding?.hasPendingChallenge ? "testing" : binding?.subscriptionVerified ? "subscribed" : binding?.connected ? "connected" : "waiting",
problem: state.error ? "offline"
: checksReady && !agentReady && !finishingSetup ? "agent_unavailable"
: binding?.status === "pairing" && !preparePairing && !pair.isPending && !state.isFetching && !pair.error && pairing?.bindingId !== binding.id ? "prompt_unavailable" // query-error-ok: derived connection-state label;copy rendered by the dialog
: binding?.challengeExpiresAt && !binding.hasPendingChallenge && binding.status !== "ready" ? "event_timeout" : undefined,
};
const pendingApproval = (state.data?.agentStatus ?? invitation?.agent.status) === "pending_approval";
const unavailable = state.data && !state.data.canConfigureConnection && !pendingApproval;
const prompt = preset === "dot" ? pairing && pairing.bindingId === binding?.id && state.data?.resourceUrl && invitation
? buildDotSetupPrompt({ companyId, agentId: invitation.agent.id, resourceUrl: state.data.resourceUrl, ...pairing }) : "" : genericPrompt;
const error = (generate.variables === preset ? generate.error : null) ?? (preset === "dot" ? (binding?.connected ? null : pair.error) ?? test.error : null);
const busy = generate.isPending || pair.isPending || test.isPending || preparePairing
|| (preset === "dot" && !!invitation && (state.isPending || (!prompt && state.isFetching)));
const retry = () => {
if (preset === "muse") { void experimental.refetch(); return; }
if (unavailable) { void state.refetch(); return; }
if (state.error) { void state.refetch(); return; }
if (generate.error || !invitation) { if (preset) generate.mutate(preset); return; }
if (pair.error && !binding?.connected) { pair.mutate(binding?.status === "pairing" ? binding.id : undefined); return; }
test.mutate();
};
return <Dialog open onOpenChange={open => { if (!open) onClose(); }}>
<AnimatedDialogContent className={preset === "grok_bot" ? "sm:max-w-(--sz-560px)" : "flex max-h-(--sz-calc-18) flex-col gap-0 overflow-hidden p-0 sm:max-w-(--sz-560px)"}>
{preset === "muse" && experimental.data?.enableMuse && experimental.data?.enableNativeRunner ? <MuseInvitationController initialName={initialMuseName} companyId={companyId} companyName={selectedCompany?.name ?? "your organization"} onClose={onClose} onBack={() => setPreset(null)} /> :
preset === "grok_bot" ? <GrokBotSetup companyId={companyId} companyName={selectedCompany?.name ?? "your organization"} onClose={onClose} onBack={() => setPreset(null)} /> :
<ExternalAgentInviteContent preset={preset === "muse" ? null : preset} prompt={prompt} companyName={selectedCompany?.name ?? "your organization"}
connection={connection} museEnabled={experimental.data?.enableMuse === true && experimental.data?.enableNativeRunner === true} dotDisabledReason={dotDisabledReason} grokDisabledReason={grokDisabledReason} busy={busy}
error={preset === "muse" ? experimental.isPending ? undefined : "Enable Muse and Paperclip Runner in experimental settings to connect your personal Muse." : (error ? describeError(error).body : undefined) ?? (unavailable ? state.data?.agentLifecycleState === "terminated" ? "This agent was terminated. Invite another agent to connect Dot." : "Resume this agent before connecting Dot." : undefined)}
approvalHref={pendingApproval && invitation?.approvalId ? `/approvals/${invitation.approvalId}` : undefined}
onSelect={kind => { setPreset(kind); if (kind !== "muse" && kind !== "grok_bot" && (kind === "dot" ? !invitation : !genericPrompt)) generate.mutate(kind); }}
onBack={() => setPreset(null)} onClose={preset ? onClose : onBack} onCopied={() => { if (preset === "dot") void state.refetch(); }}
onRetry={retry} onNewPrompt={() => pair.mutate(binding?.id)} />}
</AnimatedDialogContent>
</Dialog>;
}
function MuseInvitationController({ companyId, companyName, onClose, onBack, initialName }: {
companyId: string; companyName: string; initialName: string; onClose: () => void; onBack: () => void;
}) {
const cache = useQueryClient();
const identity = useAccountIdentity();
const scopeKey = `${companyId}:${identity.userId}`;
const loadDraft = () => { const value = readMuseInvitationDraft(companyId, identity.userId); return { ...value, name: value.name || initialName }; };
const [draftState, setDraftState] = useState(() => ({ scopeKey, value: loadDraft() }));
if (draftState.scopeKey !== scopeKey) setDraftState({ scopeKey, value: loadDraft() });
const draft = draftState.value;
const [created, setCreated] = useState<{ scopeKey: string; invitation: MuseInvitation } | null>(null);
const currentScope = useRef(scopeKey); currentScope.current = scopeKey;
const invitationKey = ["muse-invitation", companyId, identity.userId];
const resume = useQuery({ queryKey: invitationKey,
queryFn: ({ signal }) => museInvitationsApi.resume(companyId, signal), enabled: identity.settled,
staleTime: 0, refetchOnMount: "always",
refetchInterval: query => query.state.data?.agent.status === "pending_approval" ? 2500 : false });
const resumedInvitation = resume.isFetchedAfterMount ? resume.data : null;
useEffect(() => {
if (resumedInvitation) setCreated(current => current?.scopeKey === scopeKey
? current : { scopeKey, invitation: resumedInvitation });
}, [scopeKey, resumedInvitation]);
const createdInvitation = created?.scopeKey === scopeKey ? created.invitation : null;
// Resume omits completed bindings; keep this mounted hire while accepting its fresh server status.
const invitation = createdInvitation
? resumedInvitation?.agent.id === createdInvitation.agent.id ? resumedInvitation : createdInvitation
: resumedInvitation;
const muse = useMuseConnection(companyId, invitation?.agent.id);
const attemptedAutomaticPairing = useRef(false);
const attemptedAutomaticVerification = useRef<string | null>(null);
useEffect(() => { attemptedAutomaticPairing.current = false; attemptedAutomaticVerification.current = null; }, [scopeKey, invitation?.agent.id]);
const create = useMutation({ mutationFn: async (input: MuseInvitationDraft) => {
const requestScope = scopeKey;
const result = await museInvitationsApi.create(companyId, { name: input.name.trim(), role: input.role });
if (currentScope.current === requestScope) {
setCreated({ scopeKey: requestScope, invitation: result });
cache.setQueryData(invitationKey, result);
void cache.invalidateQueries({ queryKey: invitationKey, exact: true });
}
void cache.invalidateQueries({ queryKey: queryKeys.agents.list(companyId) });
// The creation receipt contains no ticket; pairing happens in the mounted connection hook.
}, gcTime: 0 });
const b = muse.binding;
const canPrepare = !!invitation && !(muse.state.status === "error") && muse.state.data?.enabled && muse.state.data.canConfigureConnection
&& !!muse.state.data.publicOrigin && (!b || b.status === "pairing");
useEffect(() => {
if (canPrepare && muse.state.isFetchedAfterMount && !muse.state.isFetching && !muse.pair.isPending
&& !muse.pairing && !attemptedAutomaticPairing.current) {
attemptedAutomaticPairing.current = true;
muse.repair();
}
}, [canPrepare, muse.state.isFetchedAfterMount, muse.state.isFetching, muse.pair.isPending, muse.pairing, b?.id, b?.revision]);
useEffect(() => {
if (!(muse.state.status === "error") && b?.paired && b.credentialState === "active" && b.receiverDetected && !b.backgroundReplyVerified && !b.challengeExpiresAt
&& muse.state.data?.enabled && muse.state.data.canConfigureConnection
&& muse.state.isFetchedAfterMount && !muse.state.isFetching && !muse.verify.isPending && !muse.verify.isError) {
const identity = `${b.id}:${b.generation}`;
if (attemptedAutomaticVerification.current !== identity) {
attemptedAutomaticVerification.current = identity;
muse.verify.mutate(b);
}
}
}, [b, muse.state.data, (muse.state.status === "error"), muse.state.isFetchedAfterMount, muse.state.isFetching, muse.verify.isPending, muse.verify.isError]);
const pendingApproval = (muse.state.data?.agentStatus ?? invitation?.agent.status) === "pending_approval";
const busy = create.isPending || muse.pair.isPending || muse.verify.isPending || (!invitation && (resume.isPending && !identity.failed || !identity.settled && !identity.failed))
|| (!!invitation && muse.state.isPending);
const promptUnavailable = !!b && !b.paired && b.status === "pairing" && !muse.pairing
&& attemptedAutomaticPairing.current && !muse.pair.isPending && !muse.state.isFetching;
const connection = useMuseConnectionState(muse.state.data, { offline: (muse.state.status === "error"), promptUnavailable });
const verifyError = muse.verify.error instanceof ApiError && muse.verify.error.status === 409 && b?.challengeExpiresAt
&& Date.parse(b.challengeExpiresAt) > Date.now() ? null : muse.verify.error;
const error = create.error ?? resume.error ?? muse.state.error ?? muse.pair.error ?? verifyError;
const operatorRequired = error instanceof ApiError && (error.status === 401 || error.status === 403)
&& !invitation;
const missingPublicOrigin = !!invitation && muse.state.isSuccess && !muse.state.data.publicOrigin;
const errorMessage = missingPublicOrigin ? "This instance has no public HTTPS URL for Muse. Ask your instance administrator to configure a stable public HTTPS address, then refresh setup. Muse cannot connect through a local-only address." : operatorRequired ? "Use an authenticated Paperclip instance with a public HTTPS URL and a company operator account. Local trusted access alone cannot connect Muse." : error?.message;
return <ExternalAgentInviteContent preset="muse" companyName={companyName} prompt={muse.pairing?.setupInstruction ?? ""}
connection={{ phase: "waiting" }} museConnection={invitation && !missingPublicOrigin && (muse.state.data || (muse.state.status === "error")) ? connection : undefined} busy={busy} error={identity.failed ? "Unable to confirm your account. Refresh to resume Muse setup." : errorMessage}
approvalHref={pendingApproval && invitation?.approvalId ? `/approvals/${invitation.approvalId}` : undefined}
museDraft={!invitation && resume.isSuccess && identity.settled ? draft : undefined}
onMuseDraftChange={value => { setDraftState({ scopeKey, value }); saveMuseInvitationDraft(companyId, identity.userId, value); }}
onMuseContinue={() => create.mutate(draft)} onSelect={() => {}} onBack={onBack}
onClose={() => { if (connection.ready) { clearMuseInvitationDraft(companyId, identity.userId); void cache.invalidateQueries({ queryKey: queryKeys.agents.list(companyId) }); } onClose(); }}
onCopied={() => { void muse.state.refetch(); }}
onRetry={() => { if (identity.failed) { void cache.invalidateQueries({ queryKey: queryKeys.auth.session }); return; } if ((resume.status === "error")) { void resume.refetch(); return; } if (missingPublicOrigin) { void muse.state.refetch(); return; } if (create.error && !invitation) { create.mutate(draft); return; }
if ((muse.state.status === "error")) { void muse.state.refetch(); return; } if (b?.paired) muse.verify.mutate(b); else muse.repair(); }}
onNewPrompt={() => muse.repair()} />;
}