mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-03 11:47:42 +01:00
fix(ui): skip Step 3 early setup draft in free_inference_1 and ignore setup drafts in paused banner (#23555)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work.
> - In the `free_inference_1` onboarding flow, `OnboardingWizard` skips
Step 4 ("Connect a model") and hires the first agent directly on starter
inference when the user submits Step 3.
> - However, Step 3's early-setup effect still auto-created a
provisional `General` draft agent (`pauseReason: "setup"`, `adapterType:
"process"`) as soon as Step 3 mounted, even though Step 4 login is never
used in `free_inference_1`.
> - If the user reloaded or navigated to the Dashboard before submitting
Step 3, that orphaned `pauseReason: "setup"` draft prevented onboarding
from re-opening and caused `Dashboard.tsx` to show "All agents in this
organization are paused — nothing will run."
> - This pull request skips Step 3 early-setup draft creation while
`free_inference_1` is active (or while the onboarding variant/status
queries are still pending) and filters out unfinished `pauseReason:
"setup"` drafts and terminated agents in
`Dashboard.derivePausedAgentBanner` and `hasNoAgents`.
> - The benefit is a clean `free_inference_1` onboarding experience with
no orphaned paused drafts and accurate Dashboard empty-state banners.
## Linked Issues or Issue Description
**Subsystem affected**
`ui/` — React + Vite board UI
**Problem or motivation**
When a Cloud workspace is assigned to `free_inference_1`, opening Step 3
of `OnboardingWizard` immediately created an unfinished `General` draft
agent (`pauseReason: "setup"`, `adapterType: "process"`) meant only for
Step 4 provider login. Navigating to `/dashboard` before clicking "Start
chatting" left that orphaned draft in place and triggered the "All
agents in this organization are paused — nothing will run." warning
banner.
**Proposed solution**
- Add `shouldSkipEarlyOnboardingSetupDraft` in
`ui/src/lib/cloud-trial-gate.ts` and gate `OnboardingWizard`'s Step 3
early-setup effect on `!shouldSkipEarlyOnboardingSetupDraft({
isFreeInferenceOnboarding, onboardingVariantPending })`.
- Update `derivePausedAgentBanner` and `hasNoAgents` in
`ui/src/pages/Dashboard.tsx` to ignore unfinished `pauseReason: "setup"`
drafts and `terminated` agents.
- Add unit tests in `ui/src/pages/Dashboard.test.ts` and
`ui/src/components/CloudTrialGate.test.tsx`.
**Alternatives considered**
- Deleting the setup draft on wizard unmount was ruled out because
browser reloads or tab closes do not reliably run unmount cleanup, and
`free_inference_1` never needs a Step 3 setup draft in the first place.
## What Changed
- `ui/src/lib/cloud-trial-gate.ts`: Added
`shouldSkipEarlyOnboardingSetupDraft`.
- `ui/src/components/OnboardingWizard.tsx`: Tracked
`onboardingVariantPending` (`onboardingSessionPending` /
`cloudTrialStatusPending`) and gated the Step 3 early-setup draft
creation effect so `free_inference_1` never creates a provisional
`General` (`pauseReason: "setup"`) draft.
- `ui/src/pages/Dashboard.tsx`: Excluded `pauseReason: "setup"` drafts
and `terminated` agents from `derivePausedAgentBanner` and
`hasNoAgents`.
- `ui/src/pages/Dashboard.test.ts` &
`ui/src/components/CloudTrialGate.test.tsx`: Added unit test coverage.
## Verification
- `pnpm --filter @paperclipai/ui typecheck` (0 errors)
- `pnpm exec vitest run ui/src/pages/Dashboard.test.ts
ui/src/components/CloudTrialGate.test.tsx
ui/src/lib/onboarding-auto-open.test.ts` (24/24 passed)
## Risks
- Low risk: `baseline` onboarding behavior is unchanged once
`onboardingSession` resolves (a cached session query already loaded by
the app shell), and `Dashboard` still shows the all-paused banner
whenever real hired agents are paused.
## Model Used
- Google Gemini (Antigravity agentic coding environment with tool use
and local Vitest + TypeScript verification)
## 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 either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [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 any risks above
- [ ] All Paperclip CI gates are green
- [ ] 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: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
86927d4933
commit
d5c22b8424
6 files changed
+336
-16
No files matched your search
@@ -12,6 +12,7 @@ import {
|
||||
isCloudTrialLlmBlocked,
|
||||
isFreeInferenceOnboardingVariant,
|
||||
requestCloudTrialConnectModal,
|
||||
shouldSkipEarlyOnboardingSetupDraft,
|
||||
subscribeCloudTrialConnectModal,
|
||||
type CloudTrialInferenceStatusCompat,
|
||||
} from "@/lib/cloud-trial-gate";
|
||||
@@ -100,6 +101,27 @@ describe("cloud-trial-gate helpers", () => {
|
||||
expect(isFreeInferenceOnboardingVariant(null)).toBe(false);
|
||||
});
|
||||
|
||||
it("skips Step 3 early setup draft when free_inference_1 is active or variant is still pending", () => {
|
||||
expect(
|
||||
shouldSkipEarlyOnboardingSetupDraft({
|
||||
isFreeInferenceOnboarding: true,
|
||||
onboardingVariantPending: false,
|
||||
}),
|
||||
).toBe(true);
|
||||
expect(
|
||||
shouldSkipEarlyOnboardingSetupDraft({
|
||||
isFreeInferenceOnboarding: false,
|
||||
onboardingVariantPending: true,
|
||||
}),
|
||||
).toBe(true);
|
||||
expect(
|
||||
shouldSkipEarlyOnboardingSetupDraft({
|
||||
isFreeInferenceOnboarding: false,
|
||||
onboardingVariantPending: false,
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("derives gateReason and llmBlocked for both work_requires_model and exhausted", () => {
|
||||
expect(getCloudTrialGateReason(baseStatus)).toBe("work_requires_model");
|
||||
expect(isCloudTrialLlmBlocked(baseStatus)).toBe(true);
|
||||
|
||||
@@ -0,0 +1,228 @@
|
||||
// @vitest-environment jsdom
|
||||
|
||||
import { act } from "react";
|
||||
import { createRoot, type Root } from "react-dom/client";
|
||||
import { MemoryRouter } from "react-router-dom";
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { OnboardingWizard } from "./OnboardingWizard";
|
||||
|
||||
const mockAuthGetSession = vi.fn();
|
||||
const mockCloudInferenceGetStatus = vi.fn();
|
||||
const mockCloudInferenceTrackTelemetry = vi.fn().mockResolvedValue(undefined);
|
||||
const mockAgentsList = vi.fn();
|
||||
const mockAgentsCreate = vi.fn();
|
||||
const mockGetExperimental = vi.fn();
|
||||
|
||||
vi.mock("@/api/auth", () => ({
|
||||
authApi: {
|
||||
getSession: () => mockAuthGetSession(),
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock("@/api/cloud-inference", () => ({
|
||||
cloudInferenceApi: {
|
||||
getStatus: (...args: unknown[]) => mockCloudInferenceGetStatus(...args),
|
||||
trackTelemetry: (...args: unknown[]) => mockCloudInferenceTrackTelemetry(...args),
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock("../api/agents", () => ({
|
||||
agentsApi: {
|
||||
list: (...args: unknown[]) => mockAgentsList(...args),
|
||||
create: (...args: unknown[]) => mockAgentsCreate(...args),
|
||||
get: vi.fn(),
|
||||
hire: vi.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock("../api/instanceSettings", () => ({
|
||||
instanceSettingsApi: {
|
||||
get: vi.fn().mockResolvedValue({ defaultEnvironmentId: null, general: {}, experimental: {} }),
|
||||
getExperimental: () => mockGetExperimental(),
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock("../api/companies-query", () => ({
|
||||
useCompanyListQuery: () => ({
|
||||
isSuccess: true,
|
||||
isFetching: false,
|
||||
data: {
|
||||
companies: [{ id: "company-1", name: "Acme", issuePrefix: "ACM", status: "active" }],
|
||||
unauthorized: false,
|
||||
},
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock("../context/CompanyContext", () => ({
|
||||
useCompany: () => ({
|
||||
companies: [{ id: "company-1", name: "Acme", issuePrefix: "ACM", status: "active" }],
|
||||
loading: false,
|
||||
setSelectedCompanyId: vi.fn(),
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock("../context/DialogContext", () => ({
|
||||
useDialog: () => ({
|
||||
onboardingOpen: true,
|
||||
onboardingOptions: { initialStep: 3, companyId: "company-1" },
|
||||
closeOnboarding: vi.fn(),
|
||||
onboardingRouteDismissed: false,
|
||||
setOnboardingRouteDismissed: vi.fn(),
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock("../adapters/use-disabled-adapters", () => ({
|
||||
useDisabledAdaptersSync: () => new Set<string>(),
|
||||
useAdapterRegistryLoaded: () => true,
|
||||
}));
|
||||
|
||||
vi.mock("../adapters/use-adapter-capabilities", () => ({
|
||||
useAdapterCapabilities: () => () => ({}),
|
||||
}));
|
||||
|
||||
vi.mock("../hooks/useCloudInstance", () => ({
|
||||
useCloudInstance: () => ({ stackId: "stack-1" }),
|
||||
}));
|
||||
|
||||
vi.mock("./onboarding/OnboardingCharacter", () => ({
|
||||
OnboardingCharacter: () => <div data-testid="onboarding-character" />,
|
||||
}));
|
||||
|
||||
let root: Root | null = null;
|
||||
let container: HTMLDivElement | null = null;
|
||||
|
||||
async function flushQueries(ticks = 6) {
|
||||
for (let i = 0; i < ticks; i += 1) {
|
||||
await act(async () => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function mountWizard() {
|
||||
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
|
||||
container = document.createElement("div");
|
||||
document.body.appendChild(container);
|
||||
root = createRoot(container);
|
||||
act(() => {
|
||||
root!.render(
|
||||
<QueryClientProvider client={client}>
|
||||
<MemoryRouter initialEntries={["/ACM/dashboard"]}>
|
||||
<OnboardingWizard />
|
||||
</MemoryRouter>
|
||||
</QueryClientProvider>,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
window.localStorage.clear();
|
||||
mockAgentsList.mockResolvedValue([]);
|
||||
mockAgentsCreate.mockResolvedValue({
|
||||
id: "draft-1",
|
||||
companyId: "company-1",
|
||||
name: "General",
|
||||
status: "paused",
|
||||
pauseReason: "setup",
|
||||
adapterType: "process",
|
||||
adapterConfig: {},
|
||||
metadata: { setupAdapterPending: true },
|
||||
});
|
||||
mockGetExperimental.mockResolvedValue({ enableCloudTrialInference: true });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
if (root) {
|
||||
act(() => {
|
||||
root?.unmount();
|
||||
});
|
||||
root = null;
|
||||
}
|
||||
container?.remove();
|
||||
container = null;
|
||||
document.body.innerHTML = "";
|
||||
});
|
||||
|
||||
describe("OnboardingWizard Step 3 early setup draft gating", () => {
|
||||
it("does not create a Step 3 setup draft while session/status queries are pending or when free_inference_1 resolves", async () => {
|
||||
let resolveSession!: (value: unknown) => void;
|
||||
let resolveStatus!: (value: unknown) => void;
|
||||
mockAuthGetSession.mockReturnValue(new Promise((resolve) => { resolveSession = resolve; }));
|
||||
mockCloudInferenceGetStatus.mockReturnValue(new Promise((resolve) => { resolveStatus = resolve; }));
|
||||
|
||||
mountWizard();
|
||||
await flushQueries();
|
||||
|
||||
// Still pending: must NOT create a provisional setup draft yet.
|
||||
expect(mockAgentsCreate).not.toHaveBeenCalled();
|
||||
|
||||
// Resolve to free_inference_1: must STILL NOT create a setup draft.
|
||||
resolveSession({
|
||||
session: { id: "s1", userId: "u1" },
|
||||
user: { id: "u1", email: "founder@example.com", name: "Founder" },
|
||||
onboardingVariant: "free_inference_1",
|
||||
});
|
||||
resolveStatus({
|
||||
enabled: true,
|
||||
onboardingVariant: "free_inference_1",
|
||||
provider: "openrouter",
|
||||
status: "not_issued",
|
||||
gateReason: null,
|
||||
llmBlocked: false,
|
||||
heldIssueIds: [],
|
||||
heldIssues: [],
|
||||
limitUsdCents: 100,
|
||||
spentUsdCents: 0,
|
||||
remainingUsdCents: 100,
|
||||
defaultModel: "openrouter/openai/gpt-6-luna",
|
||||
canMigrate: true,
|
||||
trialAgentIds: [],
|
||||
trialAgents: [],
|
||||
blockedRun: null,
|
||||
});
|
||||
await flushQueries();
|
||||
|
||||
expect(mockAgentsCreate).not.toHaveBeenCalled();
|
||||
expect(document.body.textContent).toContain("Start chatting");
|
||||
});
|
||||
|
||||
it("creates the Step 3 setup draft once baseline resolves", async () => {
|
||||
mockAuthGetSession.mockResolvedValue({
|
||||
session: { id: "s1", userId: "u1" },
|
||||
user: { id: "u1", email: "founder@example.com", name: "Founder" },
|
||||
onboardingVariant: "baseline",
|
||||
});
|
||||
mockCloudInferenceGetStatus.mockResolvedValue({
|
||||
enabled: false,
|
||||
onboardingVariant: "baseline",
|
||||
provider: "openrouter",
|
||||
status: "disabled",
|
||||
gateReason: null,
|
||||
llmBlocked: false,
|
||||
heldIssueIds: [],
|
||||
heldIssues: [],
|
||||
limitUsdCents: 100,
|
||||
spentUsdCents: 0,
|
||||
remainingUsdCents: 100,
|
||||
defaultModel: "openrouter/openai/gpt-6-luna",
|
||||
canMigrate: true,
|
||||
trialAgentIds: [],
|
||||
trialAgents: [],
|
||||
blockedRun: null,
|
||||
});
|
||||
|
||||
mountWizard();
|
||||
await flushQueries(10);
|
||||
|
||||
expect(mockAgentsCreate).toHaveBeenCalledTimes(1);
|
||||
expect(mockAgentsCreate).toHaveBeenCalledWith(
|
||||
"company-1",
|
||||
expect.objectContaining({
|
||||
metadata: { setupAdapterPending: true },
|
||||
onboardingFirstAgent: true,
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -25,6 +25,7 @@ import { cloudInferenceApi } from "@/api/cloud-inference";
|
||||
import {
|
||||
FREE_INFERENCE_ONBOARDING_VARIANT,
|
||||
getCloudTrialOnboardingVariant,
|
||||
shouldSkipEarlyOnboardingSetupDraft,
|
||||
type CloudTrialInferenceStatusCompat,
|
||||
} from "@/lib/cloud-trial-gate";
|
||||
import { aiProviderForAdapter } from "./ai-connections/AiConnectionField";
|
||||
@@ -987,7 +988,7 @@ function OnboardingWizardInner({
|
||||
queryFn: () => instanceSettingsApi.getExperimental(),
|
||||
enabled: effectiveOnboardingOpen && step >= 3 && step <= 5,
|
||||
});
|
||||
const { data: onboardingSession } = useQuery({
|
||||
const { data: onboardingSession, isPending: onboardingSessionPending } = useQuery({
|
||||
queryKey: queryKeys.auth.session,
|
||||
queryFn: () => authApi.getSession(),
|
||||
enabled: effectiveOnboardingOpen,
|
||||
@@ -997,17 +998,21 @@ function OnboardingWizardInner({
|
||||
(onboardingSession as { browserAnalytics?: { onboardingVariant?: string } } | null | undefined)?.browserAnalytics?.onboardingVariant ??
|
||||
null;
|
||||
const cloudTrialInferenceEnabled = experimentalSettingsForLogin?.enableCloudTrialInference === true;
|
||||
const { data: cloudTrialStatusRaw } = useQuery({
|
||||
const cloudTrialStatusQueryEnabled =
|
||||
effectiveOnboardingOpen &&
|
||||
step >= 3 &&
|
||||
Boolean(createdCompanyId) &&
|
||||
(cloudTrialInferenceEnabled ||
|
||||
Boolean(cloudInstance) ||
|
||||
sessionOnboardingVariant === FREE_INFERENCE_ONBOARDING_VARIANT);
|
||||
const { data: cloudTrialStatusRaw, isPending: cloudTrialStatusPending } = useQuery({
|
||||
queryKey: queryKeys.cloudInference.status(createdCompanyId ?? "__none__"),
|
||||
queryFn: () => cloudInferenceApi.getStatus(createdCompanyId!),
|
||||
enabled:
|
||||
effectiveOnboardingOpen &&
|
||||
step >= 3 &&
|
||||
Boolean(createdCompanyId) &&
|
||||
(cloudTrialInferenceEnabled ||
|
||||
Boolean(cloudInstance) ||
|
||||
sessionOnboardingVariant === FREE_INFERENCE_ONBOARDING_VARIANT),
|
||||
enabled: cloudTrialStatusQueryEnabled,
|
||||
});
|
||||
const onboardingVariantPending =
|
||||
(effectiveOnboardingOpen && onboardingSessionPending) ||
|
||||
(cloudTrialStatusQueryEnabled && cloudTrialStatusPending);
|
||||
const cloudTrialStatus = cloudTrialStatusRaw as CloudTrialInferenceStatusCompat | undefined;
|
||||
const resolvedOnboardingVariant =
|
||||
cloudTrialStatus?.onboardingVariant
|
||||
@@ -1539,7 +1544,8 @@ function OnboardingWizardInner({
|
||||
useEffect(() => {
|
||||
if (step !== 3 || !createdCompanyId || !adapterRegistryLoaded || setupAgentId || createdAgentId
|
||||
|| setupPrepared || preparingSetup.current.has(createdCompanyId) || earlySetupTried.current.has(createdCompanyId)
|
||||
|| setupError || mobileDesktopHandoffAvailable) return;
|
||||
|| setupError || mobileDesktopHandoffAvailable
|
||||
|| shouldSkipEarlyOnboardingSetupDraft({ isFreeInferenceOnboarding, onboardingVariantPending })) return;
|
||||
const companyId = createdCompanyId;
|
||||
earlySetupTried.current.add(companyId);
|
||||
preparingSetup.current.add(companyId);
|
||||
@@ -1567,7 +1573,7 @@ function OnboardingWizardInner({
|
||||
preparingSetup.current.delete(companyId);
|
||||
setSetupAttempt(attempt => attempt + 1);
|
||||
});
|
||||
}, [step, createdCompanyId, adapterRegistryLoaded, setupAgentId, createdAgentId, setupPrepared, setupError, mobileDesktopHandoffAvailable]);
|
||||
}, [step, createdCompanyId, adapterRegistryLoaded, setupAgentId, createdAgentId, setupPrepared, setupError, mobileDesktopHandoffAvailable, isFreeInferenceOnboarding, onboardingVariantPending]);
|
||||
|
||||
useEffect(() => {
|
||||
if (step !== 4 || !createdCompanyId || !agentName.trim() || !adapterRegistryLoaded
|
||||
|
||||
@@ -38,6 +38,21 @@ export function isFreeInferenceOnboardingVariant(
|
||||
return getCloudTrialOnboardingVariant(status) === FREE_INFERENCE_ONBOARDING_VARIANT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 3 early-setup creates a paused `pauseReason: "setup"` draft agent only
|
||||
* so Step 4's provider login PTY has a target agent. In `free_inference_1`,
|
||||
* Step 4 is skipped completely, so creating that draft is unnecessary and
|
||||
* leaves an orphaned paused agent if the user reloads before clicking Start.
|
||||
* Also wait while the onboarding variant/status queries are still pending so a
|
||||
* first-render race never creates the draft prematurely.
|
||||
*/
|
||||
export function shouldSkipEarlyOnboardingSetupDraft(params: {
|
||||
isFreeInferenceOnboarding: boolean;
|
||||
onboardingVariantPending: boolean;
|
||||
}): boolean {
|
||||
return params.isFreeInferenceOnboarding || params.onboardingVariantPending;
|
||||
}
|
||||
|
||||
export function getCloudTrialGateReason(
|
||||
status?: CloudTrialInferenceStatusCompat | null,
|
||||
): CloudTrialGateReason | null {
|
||||
|
||||
@@ -42,6 +42,48 @@ describe("derivePausedAgentBanner", () => {
|
||||
]);
|
||||
expect(banner).toBeNull();
|
||||
});
|
||||
|
||||
it("ignores unfinished onboarding setup drafts and terminated agents", () => {
|
||||
expect(
|
||||
derivePausedAgentBanner([
|
||||
agent({ id: "setup-1", status: "paused", pauseReason: "setup" }),
|
||||
]),
|
||||
).toBeNull();
|
||||
expect(
|
||||
derivePausedAgentBanner([
|
||||
agent({ id: "setup-1", status: "paused", pauseReason: "setup" }),
|
||||
agent({ id: "term-1", status: "terminated", pauseReason: null }),
|
||||
]),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("handles a large mixed-agent organization within a bounded linear property-read budget", () => {
|
||||
const TOTAL = 500;
|
||||
const MAX_READS = TOTAL * 6;
|
||||
let reads = 0;
|
||||
|
||||
const rawAgents: Agent[] = Array.from({ length: TOTAL }, (_, index) => {
|
||||
if (index % 10 === 0) return agent({ id: `setup-${index}`, status: "paused", pauseReason: "setup" });
|
||||
if (index % 10 === 1) return agent({ id: `term-${index}`, status: "terminated", pauseReason: null });
|
||||
return agent({ id: `paused-${index}`, status: "paused", pauseReason: "manual" });
|
||||
});
|
||||
|
||||
const countedAgents = rawAgents.map(
|
||||
(entry) =>
|
||||
new Proxy(entry, {
|
||||
get(target, prop, receiver) {
|
||||
reads += 1;
|
||||
if (reads > MAX_READS) {
|
||||
throw new Error(`derivePausedAgentBanner exceeded property read budget (${reads} > ${MAX_READS})`);
|
||||
}
|
||||
return Reflect.get(target, prop, receiver);
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
expect(derivePausedAgentBanner(countedAgents)).toEqual({ kind: "all-paused" });
|
||||
expect(reads).toBeLessThanOrEqual(MAX_READS);
|
||||
});
|
||||
});
|
||||
|
||||
describe("dashboard recent tasks from the task index", () => {
|
||||
|
||||
@@ -86,13 +86,17 @@ export type PausedAgentBanner =
|
||||
*/
|
||||
export function derivePausedAgentBanner(agents: Agent[] | undefined): PausedAgentBanner {
|
||||
if (!agents || agents.length === 0) return null;
|
||||
const importedPaused = agents.filter(
|
||||
const liveAgents = agents.filter(
|
||||
(agent) => agent.status !== "terminated" && agent.pauseReason !== "setup",
|
||||
);
|
||||
if (liveAgents.length === 0) return null;
|
||||
const importedPaused = liveAgents.filter(
|
||||
(agent) => agent.status === "paused" && agent.pauseReason === "import",
|
||||
);
|
||||
if (importedPaused.length > 0) {
|
||||
return { kind: "imported", pausedImportedAgentIds: importedPaused.map((agent) => agent.id) };
|
||||
}
|
||||
if (agents.every((agent) => agent.status === "paused")) return { kind: "all-paused" };
|
||||
if (liveAgents.every((agent) => agent.status === "paused")) return { kind: "all-paused" };
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -328,9 +332,12 @@ export function Dashboard() {
|
||||
}
|
||||
|
||||
// Same rule as the auto-offer above: a list still being refreshed may be the
|
||||
// empty one cached before the first hire, and the banner's "Create one here"
|
||||
// opens the same agent step the offer does.
|
||||
const hasNoAgents = agents !== undefined && !agentsRefreshing && agents.length === 0;
|
||||
// empty one cached before the first hire, and an unfinished onboarding setup
|
||||
// draft (`pauseReason: "setup"`) is not a real hired agent.
|
||||
const hasNoAgents =
|
||||
agents !== undefined &&
|
||||
!agentsRefreshing &&
|
||||
agents.every((agent) => agent.status === "terminated" || agent.pauseReason === "setup");
|
||||
const pausedBanner = derivePausedAgentBanner(agents);
|
||||
const pausedImportedCount =
|
||||
pausedBanner?.kind === "imported" ? pausedBanner.pausedImportedAgentIds.length : 0;
|
||||
|
||||
Reference in new issue
Block a user