Merge origin/master into feat/antigravity-swarm-command

Resolve the recovery service import conflict by keeping both the swarm
refusal code (non-retryable continuation) and master's dependency-wake
circuit breaker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DottaandClaude Opus 5.5 committed 2026-11-24 15:31:24 -06:00
commit 6f36e2a24a
139 files changed
+13035 -5187

No files matched your search

+1 -3
View File
@@ -1,6 +1,5 @@
import { Pin, PinOff } from "lucide-react";
import { useQuery } from "@tanstack/react-query";
import { useMemo } from "react";
import { authApi } from "@/api/auth";
import { usePinnedNavigation } from "@/hooks/usePinnedNavigation";
import { queryKeys } from "@/lib/queryKeys";
@@ -12,8 +11,7 @@ export function useAgentChatPins() {
const session = useQuery({ queryKey: queryKeys.auth.session, queryFn: () => authApi.getSession() });
const userId = session.data?.user?.id ?? session.data?.session?.userId;
const navigation = usePinnedNavigation(userId);
const keys = useMemo(() => new Set(navigation.pins), [navigation.pins]);
return { keys, orderedKeys: navigation.pins, toggle: navigation.toggle, reorder: navigation.reorder, canPin: navigation.canPin, error: navigation.error };
return { ...navigation, orderedKeys: navigation.pins };
}
export function AgentChatPin({ agent, pins, className }: {
+50
View File
@@ -2611,6 +2611,10 @@ export type AdapterLoginPanelProps = AdapterLoginDescriptor & {
// the completion failed, or the session failed or ran out of time. The pair
// of `onCodeSubmitted`, so a caller that showed work can stop showing it.
onSubmitFailed?: () => void;
// Fires once per failed sign-in attempt across both displayed-code and
// submitted-code panels (start failure, poll error, session failure, or
// timeout), excluding user cancellations and in-flight retries.
onLoginFailed?: () => void;
onOpenAuthorization?: () => void;
onSubmitReady?: (submit: (() => void) | null) => void;
onRetryReady?: (retry: (() => void) | null) => void;
@@ -2644,6 +2648,30 @@ function adapterLoginTitle(adapterType: string): string {
return provider ? `Sign in to ${provider}` : "Sign in to the environment";
}
export function isReportableAdapterLoginFailure(input: {
active: boolean;
retrying: boolean;
status: AdapterAuthSessionStatus | null | undefined;
hasFailure: boolean;
}): boolean {
return input.active && !input.retrying && input.status !== "cancelled" && input.hasFailure;
}
function useReportLoginFailureOnce(failed: boolean, onLoginFailed?: () => void) {
const onLoginFailedRef = useRef(onLoginFailed);
onLoginFailedRef.current = onLoginFailed;
const reportedFailureRef = useRef(false);
useEffect(() => {
if (!failed) {
reportedFailureRef.current = false;
return;
}
if (reportedFailureRef.current) return;
reportedFailureRef.current = true;
onLoginFailedRef.current?.();
}, [failed]);
}
export function AdapterLoginPanel(props: AdapterLoginPanelProps) {
const getCapabilities = useAdapterCapabilities();
const Panel = getCapabilities(props.adapterType).login?.panelMode === "submitted_browser_code"
@@ -2673,6 +2701,7 @@ function DisplayedCodeLoginPanel({
onPromptReady,
onOpenAuthorization,
onRetryReady,
onLoginFailed,
}: AdapterLoginPanelProps) {
const [sessionId, setSessionId] = useState<string | null>(null);
const automaticComputer = Boolean(requiresAgent && !agentId && aiConnection);
@@ -2994,6 +3023,16 @@ function DisplayedCodeLoginPanel({
return () => onRetryReadyRef.current?.(null);
}, [retryReady]);
useReportLoginFailureOnce(
isReportableAdapterLoginFailure({
active: loginActive,
retrying: retrying || retryLogin.isPending,
status,
hasFailure: Boolean(startError || (isTerminal && status !== "authenticated")),
}),
onLoginFailed,
);
if (chrome === "onboarding") {
const failure = !retryLogin.isPending && (startError || failed)
? status === "timed_out" ? "expired" : "failed"
@@ -3219,6 +3258,7 @@ function SubmittedBrowserCodeLoginPanel({
onConnected,
onCodeSubmitted,
onSubmitFailed,
onLoginFailed,
chrome = "panel",
aiConnection,
onPromptReady,
@@ -3741,6 +3781,16 @@ function SubmittedBrowserCodeLoginPanel({
onSubmitFailedRef.current?.();
}, [codeSubmitted, startError, isFailure, timedOut]);
useReportLoginFailureOnce(
isReportableAdapterLoginFailure({
active: loginActive,
retrying,
status,
hasFailure: Boolean(startError || isFailure || timedOut),
}),
onLoginFailed,
);
const onPromptReadyRef = useRef(onPromptReady);
onPromptReadyRef.current = onPromptReady;
useEffect(() => {
+14 -28
View File
@@ -1,6 +1,6 @@
import { useEffect, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from "react";
import { useQuery } from "@tanstack/react-query";
import { Inbox, Boxes, CircleCheck, Compass, FolderOpen, History, LayoutDashboard, MessageCircle, MoreHorizontal, Network, Pin, PinOff, Plus, Repeat, Search, Settings, SquarePen, Unplug, type LucideIcon } from "lucide-react";
import { Inbox, Boxes, CircleCheck, Compass, Folder, History, LayoutDashboard, MessageCircle, MoreHorizontal, Network, Plus, Repeat, Search, Settings, SquarePen, Unplug, type LucideIcon } from "lucide-react";
import type { Agent, IssueSummary, Project } from "@paperclipai/shared";
import { useCoordinatorAttentionCount } from "@/hooks/useCoordinatorAttentionCount";
import { instanceSettingsApi } from "@/api/instanceSettings";
@@ -8,13 +8,13 @@ import { useAgentChatNavigation } from "@/hooks/useAgentChatNavigation";
import { useResponsibilitiesEnabled } from "@/hooks/useResponsibilitiesEnabled";
import { useRecentTasks } from "@/hooks/useRecentTasks";
import { useRecentTaskOpenWarmup } from "@/hooks/useRecentTaskOpenWarmup";
import { usePinnedNavigation } from "@/hooks/usePinnedNavigation";
import { projectPinKey, usePinnedNavigation } from "@/hooks/usePinnedNavigation";
import { useDialogActions } from "@/context/DialogContext";
import { useSidebar } from "@/context/SidebarContext";
import { queryKeys } from "@/lib/queryKeys";
import type { RecentTaskEntry } from "@/lib/recent-tasks";
import { Link, useLocation } from "@/lib/router";
import { agentRouteRef, cn, projectRouteRef } from "@/lib/utils";
import { agentRouteRef, projectRouteRef } from "@/lib/utils";
import { SidebarCompanyMenu } from "./SidebarCompanyMenu";
import { SidebarNavItem } from "./SidebarNavItem";
import { RecentTaskNavItem, recentTaskPathRef } from "./RecentTaskNavItem";
@@ -30,17 +30,17 @@ import { AgentAvatar } from "./AgentAvatar";
import { agentChatPinKey } from "./AgentChatPin";
import { PinnedNavigationList, type PinnedNavigationItem } from "./PinnedNavigationList";
import { companyProjectsQuery } from "@/lib/company-projects-query";
import { NavigationPinButton, type PinControls } from "./NavigationPinButton";
import { SidebarProjectTasks } from "./SidebarProjectTasks";
const NO_RECENT_TASKS: never[] = [];
const TASK_PIN_ID_PATTERN = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i;
const taskPinKey = (companyId: string, id: string) => `task:${companyId}:${id}`;
const projectPinKey = (project: Project) => `project:${project.companyId}:${project.id}`;
const moreDestinations = [
{ label: "Search", to: "/search", icon: Search },
{ label: "Dashboard", to: "/dashboard", icon: LayoutDashboard },
{ label: "Projects", to: "/projects", icon: FolderOpen },
{ label: "Projects", to: "/projects", icon: Folder },
{ label: "Routines", to: "/routines", icon: Repeat },
{ label: "Artifacts", to: "/artifacts", icon: Boxes },
{ label: "Agents", to: "/agents/all", icon: Network },
@@ -70,7 +70,7 @@ export function buildPinnedNavigationItems(
}
for (const project of projects) {
const key = projectPinKey(project);
if (keys.has(key)) items.set(key, { key, to: `/projects/${projectRouteRef(project)}/issues`, label: project.name, icon: <FolderOpen className="size-4" />, project });
if (keys.has(key)) items.set(key, { key, label: project.name, project });
}
return pins.flatMap(key => {
const item = items.get(key);
@@ -78,24 +78,13 @@ export function buildPinnedNavigationItems(
});
}
type PinControls = { keys: ReadonlySet<string>; canPin: boolean; toggle: (key: string) => void };
type RecentTaskLink = Omit<RecentTaskEntry, "recordedAt">;
function NavigationPinButton({ pinKey, label, pins, className }: { pinKey: string; label: string; pins: PinControls; className: string }) {
const pinned = pins.keys.has(pinKey);
const Icon = pinned ? PinOff : Pin;
const actionLabel = `${pinned ? "Unpin" : "Pin"} ${label}`;
return <button type="button" aria-label={actionLabel} title={actionLabel} aria-pressed={pinned} disabled={!pins.canPin}
onClick={() => pins.toggle(pinKey)} className={cn("absolute top-1/2 flex -translate-y-1/2 items-center justify-center rounded-md outline-none focus-visible:ring-2 focus-visible:ring-ring hover:text-foreground", pinned ? "text-foreground" : "text-muted-foreground", className)}>
<Icon aria-hidden className="size-3.5" />
</button>;
}
function RecentPinRow({ pinKey, label, pins, children }: { pinKey: string; label: string; pins: PinControls; children: ReactNode }) {
if (!pins.canPin) return <>{children}</>;
return <div className="design-sidebar-pin-target relative min-w-0">
{children}
<NavigationPinButton pinKey={pinKey} label={label} pins={pins} className="right-3 size-7" />
<NavigationPinButton pinKey={pinKey} label={label} pins={pins} className="absolute right-3 top-1/2 size-7 -translate-y-1/2" />
</div>;
}
@@ -134,8 +123,6 @@ export function CoordinatorSidebar({ children }: { children?: ReactNode }) {
const { companyId, userId, agents, chats, session } = useAgentChatNavigation();
const unreadChatCount = chats.data?.filter(chat => chat.isUnreadForMe).length ?? 0;
const pinnedNavigation = usePinnedNavigation(userId);
const pinKeys = useMemo(() => new Set(pinnedNavigation.pins), [pinnedNavigation.pins]);
const pins = { keys: pinKeys, canPin: pinnedNavigation.canPin, toggle: pinnedNavigation.toggle };
const pinnedTaskIds = useMemo(() => {
if (!companyId || !session.isSuccess) return [];
const prefix = taskPinKey(companyId, "");
@@ -224,7 +211,7 @@ export function CoordinatorSidebar({ children }: { children?: ReactNode }) {
<Link to={to} onClick={() => { setMoreOpen(false); if (isMobile) setSidebarOpen(false); }} className="flex min-w-0 flex-1 items-center gap-2 rounded-sm px-2 py-1.5 pr-10 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring">
<Icon className="size-4 shrink-0 text-muted-foreground" />{label}
</Link>
<NavigationPinButton pinKey={to} label={label} pins={pins} className="right-0.5 size-8 rounded-sm opacity-0 transition-opacity group-hover/navigation-pin:opacity-100 group-focus-within/navigation-pin:opacity-100 pointer-coarse:opacity-100" />
<NavigationPinButton pinKey={to} label={label} pins={pinnedNavigation} className="absolute right-0.5 top-1/2 size-8 -translate-y-1/2 rounded-sm opacity-0 transition-opacity group-hover/navigation-pin:opacity-100 group-focus-within/navigation-pin:opacity-100 pointer-coarse:opacity-100" />
</div>
</div>)}
</FlyoutContent>
@@ -234,17 +221,16 @@ export function CoordinatorSidebar({ children }: { children?: ReactNode }) {
{session.isSuccess && recents.length > 0 && <div className="design-sidebar-recents"><SidebarSection label="Recents" collapsible={{ open: recentsOpen, onOpenChange: setRecentsOpen }}>
<RecentNavigationList>
{recents.map(item => item.kind === "task"
? <RecentTaskPinRow key={`${scope}:${item.id}`} task={item.task} pins={pins} />
? <RecentTaskPinRow key={`${scope}:${item.id}`} task={item.task} pins={pinnedNavigation} />
: item.kind === "chat"
? <RecentPinRow key={item.id} pinKey={agentChatPinKey(item.agent.companyId, item.agent.id)} label={item.agent.name} pins={pins}>
? <RecentPinRow key={item.id} pinKey={agentChatPinKey(item.agent.companyId, item.agent.id)} label={item.agent.name} pins={pinnedNavigation}>
<SidebarNavItem className="design-sidebar-item" to={`/chats/${encodeURIComponent(agentRouteRef(item.agent))}`} label={item.agent.name} iconNode={<AgentAvatar agent={item.agent} size={16} />} />
</RecentPinRow>
: <SidebarProjectTasks key={`${scope}:${item.id}`} project={item.project} userId={userId}
renderTask={task => <RecentTaskPinRow task={task} pins={pins} />}>
<RecentPinRow pinKey={projectPinKey(item.project)} label={item.project.name} pins={pins}>
<SidebarNavItem className="design-sidebar-item" to={`/projects/${projectRouteRef(item.project)}/issues`} label={item.project.name} icon={FolderOpen} />
</RecentPinRow>
</SidebarProjectTasks>)}
renderTask={task => <RecentTaskPinRow task={task} pins={pinnedNavigation} />}
renderRow={toggle => <RecentPinRow pinKey={projectPinKey(item.project)} label={item.project.name} pins={pinnedNavigation}>
{toggle}
</RecentPinRow>} />)}
</RecentNavigationList>
</SidebarSection></div>}
{children}
+1 -5
View File
@@ -23,7 +23,6 @@ interface EntityRowProps {
titleClassName?: string;
titleTextClassName?: string;
subtitleClassName?: string;
reserveSubtitleSpace?: boolean;
/**
* Make the title (the row's primary identifier) win the flex fight: it keeps a
* usable min-width floor and ellipsizes, while the `meta` cluster is the item
@@ -59,7 +58,6 @@ export function EntityRow({
titleClassName,
titleTextClassName,
subtitleClassName,
reserveSubtitleSpace,
titlePriority,
secondaryRow,
secondaryRowClassName,
@@ -98,15 +96,13 @@ export function EntityRow({
</span>
{titleAccessory}
</div>
{(subtitle || reserveSubtitleSpace) && (
{Boolean(subtitle) && (
<p
className={cn(
"text-xs text-muted-foreground mt-0.5 min-h-4",
!subtitleClassName && "truncate",
subtitleClassName,
!subtitle && "invisible",
)}
aria-hidden={!subtitle}
>
{subtitle}
</p>
@@ -0,0 +1,30 @@
// @vitest-environment node
import { renderToStaticMarkup } from "react-dom/server";
import { expect, it } from "vitest";
import type { Issue } from "@paperclipai/shared";
import { IssueMonitorComposerStrip } from "./IssueMonitorBanner";
function waitingIssue(scheduledRetryReason: string) {
return {
id: "issue-1",
status: "todo",
scheduledRetry: {
status: "scheduled_retry",
scheduledRetryAt: new Date(Date.now() + 24 * 60 * 60_000).toISOString(),
scheduledRetryAttempt: 1,
scheduledRetryReason,
},
} as unknown as Issue;
}
it("tells a user that a reply rechecks usage, not that it starts work outright", () => {
const markup = renderToStaticMarkup(<IssueMonitorComposerStrip issue={waitingIssue("ai_connection_pool_wait")} />);
expect(markup).toContain("Pool exhausted");
expect(markup).toContain("Sending a reply checks usage again now.");
expect(markup).not.toContain("wakes the agent now");
});
it("keeps the wake-now promise for an ordinary scheduled retry", () => {
const markup = renderToStaticMarkup(<IssueMonitorComposerStrip issue={waitingIssue("transient_failure")} />);
expect(markup).toContain("Sending a reply wakes the agent now");
});
+6 -1
View File
@@ -68,6 +68,8 @@ export interface MonitorSurfaceCopy {
automaticChecksPaused?: boolean;
checkUnavailable?: boolean;
executionWait?: boolean;
/** Waiting for AI account usage; a reply rechecks usage instead of starting work outright. */
usageWait?: boolean;
}
function capitalize(value: string): string {
@@ -157,9 +159,10 @@ export function buildMonitorSurfaceCopy(
return {
bannerTitle: "Pool exhausted",
stripTitle: "Pool exhausted",
bannerMeta: [`Usage recheck ${eta} · ${absolute} (your time)`, "Tasks with a selected account keep it while waiting. Work resumes when usage permits."],
bannerMeta: [`Usage recheck ${eta} · ${absolute} (your time)`, "Tasks with a selected account keep it while waiting. Work resumes when usage permits or the agent uses a different account."],
stripMeta: [`Usage recheck ${eta} · ${absolute}`, "Tasks with a selected account keep it while waiting."],
tone: "info",
usageWait: true,
};
}
@@ -374,6 +377,8 @@ export function IssueMonitorComposerStrip({
? "Review on GitHub, then check status to have the agent verify the result."
: copy.workspaceWait || copy.executionWait
? "You can keep sending instructions while the agent waits."
: copy.usageWait
? "Sending a reply checks usage again now. The agent starts as soon as usage is available."
: "Sending a reply wakes the agent now — before the scheduled check."}
</p>
) : null}
+40
View File
@@ -0,0 +1,40 @@
import { Pin, PinOff } from "lucide-react";
import { cn } from "@/lib/utils";
import type { usePinnedNavigation } from "@/hooks/usePinnedNavigation";
export type PinControls = Pick<ReturnType<typeof usePinnedNavigation>, "keys" | "canPin" | "toggle">;
interface NavigationPinButtonProps {
pinKey: string;
label: string;
pins: PinControls;
className: string;
}
export function NavigationPinButton({ pinKey, label, pins, className }: NavigationPinButtonProps) {
const pinned = pins.keys.has(pinKey);
const Icon = pinned ? PinOff : Pin;
const action = `${pinned ? "Unpin" : "Pin"} ${label}`;
return (
<button
type="button"
aria-label={action}
title={`${action} ${pinned ? "from" : "to"} sidebar`}
aria-pressed={pinned}
disabled={!pins.canPin}
onClick={(event) => {
event.preventDefault();
event.stopPropagation();
pins.toggle(pinKey);
}}
className={cn(
"flex items-center justify-center rounded-md outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",
pinned ? "text-foreground" : "text-muted-foreground",
className,
)}
>
<Icon aria-hidden className="size-3.5" />
</button>
);
}
+54 -20
View File
@@ -3,7 +3,7 @@ import { cancelAdapterLoginSession, cancelPendingAdapterLogin, matchesAdapterLog
import { useQueryView } from "@/components/QueryView";
import type { AgentRunner, AgentRunnerChoice } from "@paperclipai/shared";
import { needsClaudeSetupQualification, qualifyClaudeSetup } from "../lib/qualify-claude-setup";
import { runOnboardingConnectionTest } from "../lib/onboarding-connection-test";
import { blocksAgentCreate, runOnboardingConnectionTest } from "../lib/onboarding-connection-test";
import { agentHarnessType, agentRunner } from "@paperclipai/shared";
import { adaptersApi, type AdapterInfo } from "../api/adapters";
import { healthApi } from "@/api/health";
@@ -140,7 +140,11 @@ import { OnboardingHeading } from "./onboarding/OnboardingPrimitives";
import { DEFAULT_AGENT_ROLE } from "../lib/onboarding-agent-role";
import { capsuleHeroMotion, capsuleRoomEnter, capsuleRoomExit, heroRoomArrival, heroRoomMotion, ledeMotion, stepContentMotion, titleSwapMotion } from "./onboarding/onboarding-motion";
import { Badge } from "@/components/ui/badge";
import { captureOnboardingStepCompleted, useOnboardingAnalytics } from "@/lib/analytics/onboarding-analytics";
import {
captureOnboardingStepCompleted,
captureOnboardingStepFailed,
useOnboardingAnalytics,
} from "@/lib/analytics/onboarding-analytics";
import {
ArrowLeft,
ArrowRight,
@@ -165,19 +169,6 @@ function restoreOnboardingAdapterType(savedAdapterType: unknown, provider?: unkn
: "claude_local";
}
/**
* True when an adapter-test result blocks a hire. A `fail` status always
* blocks. A `warn` or a `pass` status blocks too when a check reports
* `ADAPTER_AUTH_MISSING_CHECK_CODE`. That check means the agent has no
* working authentication, so it cannot run. A `warn` with no such check
* still lets the hire proceed. The wizard widened the gate for missing
* authentication only, not for every other warning.
*/
function blocksAgentCreate(result: AdapterEnvironmentTestResult): boolean {
if (result.status === "fail") return true;
return result.checks.some((check) => check.code === ADAPTER_AUTH_MISSING_CHECK_CODE);
}
/** True when `value` is a plain object, so callers can spread it as env config. */
function isEnvRecord(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -1912,6 +1903,7 @@ function OnboardingWizardInner({
navigate(`${prefix ? `/${prefix}` : ""}/chats/${agentId}`);
} catch (err) {
captureOnboardingStepCompleted("launch", "failed");
captureOnboardingStepFailed({ step: "launch", reason: "launch_failed" });
setError(err instanceof Error ? err.message : "Failed to open your chat. Please try again.");
} finally {
setLoading(false);
@@ -1958,11 +1950,19 @@ function OnboardingWizardInner({
apiKeySecretRef.current = { key, companyId, envKey, binding: legacyStored.binding };
return true;
} catch (err) {
if (isCurrent()) setError(
err instanceof Error
? `Could not store the API key: ${describeError(err).body}`
: "Could not store the API key.",
);
if (isCurrent()) {
captureOnboardingStepFailed({
step: "connect_model",
reason: "api_key_save_failed",
provider: managedProvider ?? adapterType,
method: "api_key",
});
setError(
err instanceof Error
? `Could not store the API key: ${describeError(err).body}`
: "Could not store the API key.",
);
}
return false;
}
}
@@ -2184,6 +2184,12 @@ function OnboardingWizardInner({
managedSandboxOnly = experimentalSettings?.enableManagedSandboxOnly === true;
} catch {
if (!testIsCurrent()) return null;
captureOnboardingStepFailed({
step: "connect_model",
reason: "environment_test_failed",
provider: managedProvider ?? adapterType,
method: credentialMode === "api" ? "api_key" : "subscription",
});
setAdapterEnvError(
"Could not load environment settings to determine which environment to test in. Retry the test.",
);
@@ -2274,12 +2280,26 @@ function OnboardingWizardInner({
{ signal },
);
if (!testIsCurrent()) return null;
if (blocksAgentCreate(result)) {
captureOnboardingStepFailed({
step: "connect_model",
reason: "environment_test_failed",
provider: managedProvider ?? adapterType,
method: credentialMode === "api" ? "api_key" : "subscription",
});
}
setAdapterEnvResult(result);
adapterEnvResultAppliedStoredLoginRef.current = appliedStoredClaudeLoginBinding;
return result;
});
} catch (err) {
if (!selectionIsCurrent()) return null;
captureOnboardingStepFailed({
step: "connect_model",
reason: "environment_test_failed",
provider: managedProvider ?? adapterType,
method: credentialMode === "api" ? "api_key" : "subscription",
});
adapterEnvErrorSelectionRef.current = selection || null;
setAdapterEnvError(
err instanceof Error ? err.message : "Adapter environment test failed"
@@ -2600,6 +2620,12 @@ function OnboardingWizardInner({
setStep(5);
} catch (err) {
if (!isCurrent()) return;
captureOnboardingStepFailed({
step: "connect_model",
reason: "agent_create_failed",
provider: managedProvider ?? adapterType,
method: credentialMode === "api" ? "api_key" : "subscription",
});
setError(err instanceof Error ? err.message : "Failed to create agent");
} finally {
if (hiringAgentRef.current === attempt) hiringAgentRef.current = null;
@@ -3248,6 +3274,14 @@ function OnboardingWizardInner({
phaseBeforeSubmitRef.current === "ready" ? "ready" : "waiting",
);
}}
onLoginFailed={() => {
captureOnboardingStepFailed({
step: "connect_model",
reason: "subscription_login_failed",
provider: managedProvider ?? adapterType,
method: "subscription",
});
}}
onConnected={(sessionId) => {
if (managedSubscriptionProvider) managedSubscriptionRef.current = { companyId: createdCompanyId, binding: { provider: managedSubscriptionProvider, method: "subscription", mode: "responsible_user" }, sessionId };
setConnectAuthUrl(null);
+19 -16
View File
@@ -9,14 +9,10 @@ import { cn } from "@/lib/utils";
import type { Project } from "@paperclipai/shared";
import { SidebarProjectTasks } from "./SidebarProjectTasks";
export interface PinnedNavigationItem {
key: string;
to: string;
label: string;
icon: ReactNode;
task?: { id: string; identifier: string | null; isUnreadForMe?: boolean };
project?: Pick<Project, "id" | "companyId" | "name">;
}
export type PinnedNavigationItem = { key: string; label: string } & (
| { project: Pick<Project, "id" | "companyId" | "name"> }
| { project?: never; to: string; icon: ReactNode; task?: { id: string; identifier: string | null; isUnreadForMe?: boolean } }
);
/** Keep this row mounted when a pin is toggled so its controls retain focus. */
export function SortablePinnedRow({ id, label, disabled = false, className, handleClassName, handleIconClassName, children, ...props }: Omit<ComponentPropsWithoutRef<"div">, "id" | "children"> & {
@@ -37,17 +33,24 @@ export function SortablePinnedRow({ id, label, disabled = false, className, hand
}
function PinnedItem({ item, userId, onUnpin }: { item: PinnedNavigationItem; userId?: string | null; onUnpin: (key: string) => void }) {
const link = { to: item.to, label: item.label, iconNode: item.icon, className: "design-sidebar-item design-sidebar-pinned-item group-hover/coordinator-pin:bg-sidebar-accent" };
const row = (handle: ReactNode) => <>
{item.task ? <RecentTaskNavItem {...link} task={item.task} /> : <SidebarNavItem {...link} />}
const rowClassName = "design-sidebar-item design-sidebar-pinned-item";
const row = (primary: ReactNode, handle: ReactNode) => <div className="design-sidebar-pinned-row relative">
{primary}
<button type="button" aria-label={`Unpin ${item.label}`} title={`Unpin ${item.label}`}
onMouseDown={event => event.stopPropagation()} onClick={() => onUnpin(item.key)}
className="absolute right-10 top-1/2 flex size-7 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity hover:bg-sidebar-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring group-hover/coordinator-pin:opacity-100 group-focus-within/coordinator-pin:opacity-100 pointer-coarse:opacity-100"><PinOff className="size-3.5" /></button>
className="absolute right-10 top-1/2 flex size-7 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity hover:bg-sidebar-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring pointer-coarse:opacity-100"><PinOff className="size-3.5" /></button>
{handle}
</>;
return <SortablePinnedRow id={item.key} label={item.label} className="group/coordinator-pin relative"
handleClassName="right-3 size-7 group-hover/coordinator-pin:opacity-100 group-focus-within/coordinator-pin:opacity-100" handleIconClassName="size-3.5">
{handle => item.project ? <SidebarProjectTasks project={item.project} userId={userId}>{row(handle)}</SidebarProjectTasks> : row(handle)}
</div>;
return <SortablePinnedRow id={item.key} label={item.label} className="relative"
handleClassName="right-3 size-7" handleIconClassName="size-3.5">
{handle => {
if (item.project) {
return <SidebarProjectTasks project={item.project} userId={userId} className={rowClassName}
renderRow={toggle => row(toggle, handle)} />;
}
const link = { to: item.to, label: item.label, iconNode: item.icon, className: rowClassName };
return row(item.task ? <RecentTaskNavItem {...link} task={item.task} /> : <SidebarNavItem {...link} />, handle);
}}
</SortablePinnedRow>;
}
+19 -12
View File
@@ -1,18 +1,20 @@
import { useId, useState, type ReactNode } from "react";
import { useQuery } from "@tanstack/react-query";
import { ChevronRight } from "lucide-react";
import { Folder, FolderOpen } from "lucide-react";
import type { Issue, Project } from "@paperclipai/shared";
import { issuesApi } from "@/api/issues";
import { queryKeys } from "@/lib/queryKeys";
import { cn } from "@/lib/utils";
import { taskStatusIconProps } from "@/lib/task-status-presentation";
import { RecentTaskNavItem } from "./RecentTaskNavItem";
import { TruncatedText } from "./TruncatedText";
import { StatusIcon } from "./StatusIcon";
export function SidebarProjectTasks({ project, userId, children, renderTask }: {
export function SidebarProjectTasks({ project, userId, renderRow, className, renderTask }: {
project: Pick<Project, "id" | "companyId" | "name">;
userId?: string | null;
children: ReactNode;
renderRow: (toggle: ReactNode) => ReactNode;
className?: string;
renderTask?: (task: Issue) => ReactNode;
}) {
const [expanded, setExpanded] = useState(false);
@@ -24,16 +26,21 @@ export function SidebarProjectTasks({ project, userId, children, renderTask }: {
}, { signal }),
enabled: expanded,
});
return <div>
<div className="flex min-w-0 items-center">
<div className="relative min-w-0 flex-1">{children}</div>
<button type="button" aria-label={`${expanded ? "Collapse" : "Expand"} ${project.name}`} aria-expanded={expanded} aria-controls={contentId}
className="mr-2 flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-sidebar-accent focus-visible:ring-2 focus-visible:ring-ring"
onClick={() => setExpanded(previous => !previous)}>
<ChevronRight aria-hidden className={cn("size-3.5 transition-transform", expanded && "rotate-90")} />
const FolderIcon = expanded ? FolderOpen : Folder;
return <div className="design-sidebar-primary">
{renderRow(
<button
type="button"
aria-expanded={expanded}
aria-controls={expanded ? contentId : undefined}
onClick={() => setExpanded(previous => !previous)}
className={cn("design-sidebar-item design-sidebar-project-toggle flex items-center gap-2.5 rounded-lg py-1.5 text-left font-medium focus-visible:outline-ring", className)}
>
<FolderIcon aria-hidden className="size-4 shrink-0" />
<TruncatedText className="min-w-0 flex-1 truncate">{project.name}</TruncatedText>
</button>
</div>
{expanded && <div id={contentId} className="ml-5 border-l border-border pl-1">
)}
{expanded && <div id={contentId} className="design-sidebar-primary ms-2">
{isPending ? <p className="px-3 py-2 text-xs text-muted-foreground" role="status">Loading tasks…</p>
: error ? <p className="px-3 py-2 text-xs text-muted-foreground" role="alert">Couldn’t load tasks.</p>
: tasks?.length ? tasks.map(task => <div key={task.id}>{renderTask ? renderTask(task)