mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-12 18:06:11 +02:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Human messages start agent work through task, chat, and external-channel intake. > - Agent startup can delay the first visible response. > - A small direct model call can acknowledge the request while normal work starts. > - This response must remain separate from evidence that the agent answered or completed work. > - This pull request adds optional company-wide fast responses with durable receipts, access checks, and cost accounting. > - Users receive prompt acknowledgement without changing the agent execution path. ## Linked Issues or Issue Description **Subsystem affected** Cross-cutting: database, shared contracts, server orchestration, connections, and UI. **Problem or motivation** Users can wait for an agent to start before they receive a contextual response. Generic progress messages do not confirm what the user asked. An acknowledgement must not falsely complete work or satisfy an unanswered turn. **Proposed solution** Add a disabled-by-default experimental fast-response model using an existing shared API connection. Generate one short acknowledgement for each accepted human turn. Use the existing agent identity and external publication outboxes. Retain platform provenance and account for the inference independently. **Alternatives considered** Running the acknowledgement through the agent runtime adds startup latency. Restricting implementation to OpenRouter leaves other existing API connections unsupported. This change supports all existing API connections and uses OpenRouter for live verification. **Roadmap alignment** This extends existing agent communication and connection settings. ROADMAP.md and open pull requests were checked. No duplicate fast-response implementation was found. The maintainer supplied the feature plan directly. ## What Changed - Add Experimental fast responses to instance settings. Keep the feature off by default. Enforce the flag at intake, dispatch, and publication. - Move Decision model and Fast response setup to company Settings → Connections when the experiment is enabled. Place Connections below Environments. Separate the model sections with clear headings and a divider. Keep Decision model in General when the experiment is off. Route Costs setup links to the available settings page. - Make the acknowledgement prompt a multiline template string. Ask for a brief, positive response in the user’s language. - Add settings, connection/model selection, sponsorship, fixed-sample testing, and Costs history. - Add a Vercel AI SDK text service for existing native, routed, Bedrock, and local API connections. - Add durable per-turn requests, a bounded worker, a three-second admission deadline, and one inference attempt. - Integrate task creation, task and agent chat, steering, queued follow-ups, experimental board chat, shared chat intake, and email. - Preserve receipt provenance and exclude receipts from completion, recovery, interaction resolution, and agent wakeups. - Recheck authorization, source validity, real replies, budgets, and destination binding before publication. Preserve accounting for suppressed or uncertain outcomes. - Add provider contracts, database race tests, channel outbox tests, UI tests, Stories, and documentation. Keep decision-model execution unchanged. ## Verification - Local `pnpm -r typecheck`, `pnpm build`, and UI token gates pass after rebase. The UI typecheck and build also pass after the final navigation fixes. All 37 focused navigation tests pass. The first full local `pnpm test:run` invocation reported seven chat failures. All seven passed in isolated reruns after fixture updates and host cleanup. This invocation was stopped after the full final-head CI suite passed. - Initial local database tests hit macOS shared-memory exhaustion. A diagnostic confirmed `shmget: No space left on device` with the system limit of 32 IDs. Three abandoned, unattached PostgreSQL IPC headers were reclaimed. The isolated rerun passed all 31 fast-response and channel tests. The two additional Slack regression cases also passed in a separate rerun. No active database was stopped. - UI token gates pass. Provider contract tests cover all supported API connection types. Fast-response tests cover uniqueness, authorization, budgets, expiry, cancellation, restart, real-reply races, and the experimental flag. - The test drive verified that disabling the experiment hides Connections and redirects its direct URL. Enabling it restores the saved OpenRouter setup. After restart on the final commit, the OpenRouter settings sample returned “Sure, I’ll take care of fixing the border around the settings panel.” in 428 ms. It used 260 input and 31 output tokens and recorded $0.0000576 in reported cost. - Earlier live OpenRouter verification produced a receipt in 1.013 seconds for a new task. The real agent then supplied its substantive answer. A separate settings test took 1.34 seconds, used 246 input and 23 output tokens, and recorded $0.0000361. - Live Slack verification on final commit `24016fa525961ebc7a4acffdc5019ce123970549` passed for a fresh initial task and a follow-up in a disposable bot DM. The initial acknowledgement appeared 2.405 seconds after the Slack message and 1.413 seconds after durable acceptance; the follow-up appeared in 2.322 seconds and 1.160 seconds respectively. The recorded generation/settlement durations were 898 ms and 697 ms. The initial call used 291 input / 39 output tokens and cost $0.00006705; the follow-up used 281 / 47 and cost $0.00007035. - The Slack acknowledgements retained the assigned agent identity and `origin: fast_response`, source-turn references, and no fabricated run ID. A status snapshot after the initial receipt showed the task still `in_progress` with its real execution run. The agent then read the CSV fixture and correctly reported two ready items, two blockers, and their owners. Both replies stayed in the originating DM, and no duplicate generic working message followed the delivered contextual acknowledgements. The `new` command started a fresh conversation session without generating a fast response. - An earlier eligible Slack turn generated a response but suppressed publication. Its reported cost was retained, generic progress remained, and the real agent completed the requested result. This is recorded separately from the two delivered acknowledgements; the history did not expose a precise suppression reason. - Slack verification used real signed provider events, the existing intake/publication paths, and a user-approved temporary webhook-only HTTPS tunnel. Subscriptions were limited to direct-message events. The test bot was paused and the tunnel stopped afterward. Live channel/group-thread and GitHub journeys remain unverified; their mocked tests cover intake, destination binding, publication, and continued underlying work. - Greptile reviewed final commit `24016fa525961ebc7a4acffdc5019ce123970549` at 5/5. Both new review findings are fixed and all threads are resolved. [Final-head CI run](https://github.com/paperclipai/paperclip/actions/runs/38060015730) passed. This includes grouped server/chat/workspace tests, serialized suites, runner checks, browser journeys, typecheck, build, release registry, policy, and the canary dry run. - Manual check: enable Experimental fast responses. Open company Settings → Connections. Select a shared API connection and model. Save and use Test response. Submit a task message and confirm that its receipt does not complete the task. ## Risks - The migration adds receipt and configuration tables plus accounting references. It uses idempotent statements and follows the current migration sequence. - A slow provider, authorization change, or real-agent reply can suppress an acknowledgement. Existing progress feedback remains available. - Unknown provider billing retains a reservation until reconciliation. External deliveries with uncertain outcomes must not be blindly repeated. - Live Slack initial-task and follow-up DM journeys pass. Live Slack channel/group-thread and GitHub journeys remain unverified. The PR remains a draft and records these gaps. Final-head repository CI and automated review pass. ## Model Used OpenAI Codex, based on GPT-6, with reasoning, repository tools, code execution, and browser interaction. The runtime does not expose an exact model snapshot ID or context-window size; these are not asserted. ## 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 - [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: Paperclip <noreply@paperclip.ing>
905 lines
46 KiB
TypeScript
905 lines
46 KiB
TypeScript
import { lazy, Suspense, type ReactNode } from "react";
|
|
import type { ToolConnectionCredentialSource } from "@paperclipai/shared";
|
|
import { Navigate, Outlet, Route, Routes, useActiveCompanyPrefix, useLocation, useParams } from "@/lib/router";
|
|
import { Button } from "@/components/ui/button";
|
|
import { useTranslation } from "@/i18n";
|
|
import { Layout } from "./components/Layout";
|
|
import { Layout as ProductionLayout } from "./components/Layout.production";
|
|
import { ConferenceRoomChatGate } from "./components/ConferenceRoomChatGate";
|
|
import { TaskChatLab } from "./pages/TaskChatLab";
|
|
import { PipelinesExperimentalGate } from "./components/PipelinesExperimentalGate";
|
|
import { CasesExperimentalGate } from "./components/CasesExperimentalGate";
|
|
import { StatusCardsExperimentalGate } from "./components/StatusCardsExperimentalGate";
|
|
import { CloudManagedPageGate } from "./components/CloudManagedPageGate";
|
|
import { HiddenSettingsPageGate } from "./components/HiddenSettingsPageGate";
|
|
import { IsolatedWorkspacesRouteGate } from "./components/IsolatedWorkspacesRouteGate";
|
|
import {
|
|
ExecutionWorkspaceCompanyGate,
|
|
UnprefixedExecutionWorkspaceRedirect,
|
|
} from "./components/UnprefixedExecutionWorkspaceRedirect";
|
|
import { useHiddenSettings } from "./hooks/useHiddenSettings";
|
|
import { Cases } from "./pages/Cases";
|
|
import { CaseDetail } from "./pages/CaseDetail";
|
|
import { OnboardingWizardVariant } from "./components/OnboardingWizardVariant";
|
|
import { CloudAccessGate } from "./components/CloudAccessGate";
|
|
import { PaperclipLoading } from "./components/AnimatedPaperclipIcon";
|
|
import { Dashboard } from "./pages/Dashboard";
|
|
import { DashboardLive } from "./pages/DashboardLive";
|
|
import { Timeline } from "./pages/Timeline";
|
|
import { Companies } from "./pages/Companies";
|
|
import { AGENT_FILTER_TABS, Agents } from "./pages/Agents";
|
|
import { AgentDetail } from "./pages/AgentDetail";
|
|
import { Projects } from "./pages/Projects";
|
|
import { ProjectDetail } from "./pages/ProjectDetail";
|
|
import { ProjectWorkspaceDetail } from "./pages/ProjectWorkspaceDetail";
|
|
import { Workspaces } from "./pages/Workspaces";
|
|
import { Issues } from "./pages/Issues";
|
|
import { Search } from "./pages/Search";
|
|
import { IssueDetail } from "./pages/IssueDetail";
|
|
import { AgentChats } from "./pages/AgentChats";
|
|
import { AgentChat } from "./pages/AgentChat";
|
|
import { IssueChatLongThreadPerf } from "./pages/IssueChatLongThreadPerf";
|
|
import { Routines } from "./pages/Routines";
|
|
import { Learnings, PipelineItemDetail, PipelineItemLegacyRedirect, Pipelines, ReviewQueue } from "./pages/Pipelines";
|
|
import { PipelineSettings } from "./pages/PipelineSettings";
|
|
import { StatusCards } from "./pages/StatusCards";
|
|
import { RoutineDetail } from "./pages/RoutineDetail";
|
|
import { UserProfile } from "./pages/UserProfile";
|
|
import { ExecutionWorkspaceDetail } from "./pages/ExecutionWorkspaceDetail";
|
|
import { Goals } from "./pages/Goals";
|
|
import { Artifacts } from "./pages/Artifacts";
|
|
import { GoalDetail } from "./pages/GoalDetail";
|
|
import { Approvals } from "./pages/Approvals";
|
|
import { ApprovalDetail } from "./pages/ApprovalDetail";
|
|
import { CompanyActivity } from "./pages/audit/CompanyActivity";
|
|
import { AuditHub } from "./pages/audit/AuditHub";
|
|
import { Costs } from "./pages/Costs";
|
|
import { Inbox } from "./pages/Inbox";
|
|
import { useCombinedInboxTasksEnabled } from "./hooks/useCombinedInboxTasksEnabled";
|
|
import { WhatNeedsMe } from "./pages/WhatNeedsMe";
|
|
import { DecisionQueuePage } from "./pages/DecisionQueuePage";
|
|
import { BoardChat } from "./pages/BoardChat";
|
|
import { CompanySettings } from "./pages/CompanySettings";
|
|
import { CompanyConnections } from "./pages/CompanyConnections";
|
|
import { CompanyEnvironments } from "./pages/CompanyEnvironments";
|
|
import { BootstrapSetupUxLab } from "./pages/BootstrapSetupUxLab";
|
|
import { ResponsibleUserDenialUxLab } from "./pages/ResponsibleUserDenialUxLab";
|
|
import { CrossIssueCollaborationUxLab } from "./pages/CrossIssueCollaborationUxLab";
|
|
import { CompanySettingsPluginPage } from "./pages/CompanySettingsPluginPage";
|
|
import { CompanyAccess, CompanyAccessLegacyRoute } from "./pages/CompanyAccess";
|
|
import { AdvancedToolsRoute } from "./pages/tools/AdvancedToolsRoute";
|
|
import { ProfileWizardRoute } from "./pages/tools/profiles/ProfileWizardRoute";
|
|
import { ProfileDetailRoute } from "./pages/tools/profiles/ProfileDetailRoute";
|
|
import { Browse } from "./pages/apps/Browse";
|
|
import { AppsConnect } from "./pages/apps/AppsConnect";
|
|
import { ChatEndpointSetup } from "./pages/apps/chat/ChatEndpointSetup";
|
|
import { ChatEndpointDetail } from "./pages/apps/chat/ChatEndpointDetail";
|
|
import { ChatIdentityConfirm } from "./pages/apps/chat/ChatIdentityConfirm";
|
|
import { ChatConnectorsExperimentalGate } from "./components/ChatConnectorsExperimentalGate";
|
|
import { useChatConnectorsEnabled } from "./hooks/useChatConnectorsEnabled";
|
|
import { canEnterAppsConnect } from "./pages/apps/app-connect-policy";
|
|
import { AppsReview } from "./pages/apps/AppsReview";
|
|
import { AppDetail } from "./pages/apps/AppDetail";
|
|
import { AppNotConnected } from "./pages/apps/AppNotConnected";
|
|
import { PaperclipCloudOAuthHandoffPage } from "./pages/apps/PaperclipCloudOAuthHandoff";
|
|
import { GatewaysList } from "./pages/apps/gateways/GatewaysList";
|
|
import { GatewayDetail } from "./pages/apps/gateways/GatewayDetail";
|
|
import { CompanySkills } from "./pages/CompanySkills";
|
|
import { SkillSources } from "./pages/SkillSources";
|
|
import { SkillStudio } from "./pages/SkillStudio";
|
|
import { Secrets } from "./pages/Secrets";
|
|
import { CompanyImport } from "./pages/CompanyImport";
|
|
import { DesignGuide } from "./pages/DesignGuide";
|
|
import { InstanceExperimentalSettings } from "./pages/InstanceExperimentalSettings";
|
|
import { InstanceAccess } from "./pages/InstanceAccess";
|
|
import { ProfileSettings } from "./pages/ProfileSettings";
|
|
import { PluginManager } from "./pages/PluginManager";
|
|
import { PluginSettings } from "./pages/PluginSettings";
|
|
import { AdapterManager } from "./pages/AdapterManager";
|
|
import { PluginPage } from "./pages/PluginPage";
|
|
import { NewAgent } from "./pages/NewAgent";
|
|
import { AuthPage } from "./pages/Auth";
|
|
import { BoardClaimPage } from "./pages/BoardClaim";
|
|
import { AssistantConnection } from "./pages/apps/AssistantConnection";
|
|
import { McpConnectPage, McpDevicePage, AssistantConnectionsPage } from "./pages/McpConnect";
|
|
import { CliAuthPage } from "./pages/CliAuth";
|
|
import { InviteLandingPage } from "./pages/InviteLanding";
|
|
import { JoinRequestQueue } from "./pages/JoinRequestQueue";
|
|
import { NotFoundPage } from "./pages/NotFound";
|
|
import { useCompany } from "./context/CompanyContext";
|
|
import { useDialogActions, useDialogState } from "./context/DialogContext";
|
|
import { loadLastInboxTab } from "./lib/inbox";
|
|
import { TASK_VIEW_PARAM, taskViewForInboxTab, type TaskViewKey } from "./lib/task-views";
|
|
import {
|
|
isOnboardingWizardActive,
|
|
onboardingStepForCompany,
|
|
shouldRedirectCompanylessRouteToOnboarding,
|
|
} from "./lib/onboarding-route";
|
|
import { filterHiddenInstanceSettingsPath, normalizeRememberedInstanceSettingsPath } from "./lib/instance-settings";
|
|
import { useCloudInstance } from "./hooks/useCloudInstance";
|
|
import { useStreamlinedUiEnabled } from "./hooks/useStreamlinedUiEnabled";
|
|
import { cloudStackCreateUrl } from "./lib/cloudLinks";
|
|
import { navigateTopLevel } from "@/lib/browserNavigation";
|
|
|
|
const CompanyExport = lazy(() =>
|
|
import("./pages/CompanyExport").then((module) => ({ default: module.CompanyExport })),
|
|
);
|
|
|
|
const ProductionAgents = lazy(() =>
|
|
import("./pages/Agents.production").then((module) => ({ default: module.Agents })),
|
|
);
|
|
const ProductionRoutines = lazy(() =>
|
|
import("./pages/Routines.production").then((module) => ({ default: module.Routines })),
|
|
);
|
|
const ProductionRoutineDetail = lazy(() =>
|
|
import("./pages/RoutineDetail.production").then((module) => ({ default: module.RoutineDetail })),
|
|
);
|
|
const ProductionCompanySkills = lazy(() =>
|
|
import("./pages/CompanySkills.production").then((module) => ({ default: module.CompanySkills })),
|
|
);
|
|
const ProductionCompanyActivity = lazy(() =>
|
|
import("./pages/audit/CompanyActivity.production").then((module) => ({ default: module.CompanyActivity })),
|
|
);
|
|
const ProductionOrgChart = lazy(() =>
|
|
import("./pages/OrgChart.production").then((module) => ({ default: module.OrgChart })),
|
|
);
|
|
|
|
function ProductionSurface({ children }: { children: ReactNode }) {
|
|
return <Suspense fallback={<PaperclipLoading />}>{children}</Suspense>;
|
|
}
|
|
|
|
function boardRoutes(streamlinedUiEnabled: boolean, combinedInboxTasksEnabled: boolean) {
|
|
// Combined Inbox + Task List (PAP-670) only exists in the streamlined shell.
|
|
const mergedTasks = streamlinedUiEnabled && combinedInboxTasksEnabled;
|
|
return (
|
|
<>
|
|
<Route index element={<Navigate to="dashboard" replace />} />
|
|
<Route path="dashboard" element={<Dashboard />} />
|
|
<Route path="dashboard/live" element={<DashboardLive />} />
|
|
<Route
|
|
path="timeline"
|
|
element={streamlinedUiEnabled ? <AuditCompatibilityRedirect to="/activity/timeline" /> : <Timeline />}
|
|
/>
|
|
<Route path="onboarding" element={<OnboardingRoutePage />} />
|
|
<Route path="companies" element={<Companies />} />
|
|
<Route path="company/settings" element={<CompanySettings />} />
|
|
<Route path="company/settings/connections" element={<CompanyConnections />} />
|
|
<Route path="company/settings/environments" element={<Navigate to="/company/settings/instance/environments" replace />} />
|
|
<Route path="company/settings/cloud-upstream" element={<Navigate to="/company/export" replace />} />
|
|
<Route element={<HiddenSettingsPageGate pageKey="company.members" />}>
|
|
<Route path="company/settings/members" element={<CompanyAccess />} />
|
|
<Route path="company/settings/access" element={<CompanyAccessLegacyRoute />} />
|
|
</Route>
|
|
{/* Invites moved into the Members page; the old URL redirects (and stays
|
|
gated so a hidden Invites surface never round-trips through it). */}
|
|
<Route element={<HiddenSettingsPageGate pageKey="company.invites" />}>
|
|
<Route
|
|
path="company/settings/invites"
|
|
element={<Navigate to="/company/settings/members?tab=invites" replace />}
|
|
/>
|
|
</Route>
|
|
<Route element={<HiddenSettingsPageGate pageKey="company.export" />}>
|
|
<Route
|
|
path="company/export/*"
|
|
element={(
|
|
<Suspense fallback={<PaperclipLoading />}>
|
|
<CompanyExport />
|
|
</Suspense>
|
|
)}
|
|
/>
|
|
</Route>
|
|
<Route element={<CloudManagedPageGate />}>
|
|
<Route element={<HiddenSettingsPageGate pageKey="company.import" />}>
|
|
<Route path="company/import" element={<CompanyImport />} />
|
|
</Route>
|
|
</Route>
|
|
<Route element={<HiddenSettingsPageGate pageKey="company.secrets" />}>
|
|
<Route path="company/settings/secrets" element={<Secrets />} />
|
|
</Route>
|
|
<Route path="company/settings/tools" element={<LegacyToolsSettingsRedirect />} />
|
|
<Route path="company/settings/tools/:tab" element={<LegacyToolsSettingsRedirect />} />
|
|
<Route path="tools" element={<LegacyToolsRedirect />} />
|
|
<Route path="tools/:tab" element={<LegacyToolsRedirect />} />
|
|
<Route path="apps" element={<Browse />} />
|
|
<Route path="apps/assistant-connection" element={<AssistantConnection />} />
|
|
<Route path="apps/browse" element={<Navigate to="/apps" replace />} />
|
|
<Route path="apps/connections" element={<Navigate to="/apps" replace />} />
|
|
<Route path="apps/byo" element={<AppsConnect byoOnly />} />
|
|
<Route
|
|
path="apps/vercel-connect"
|
|
element={<AppsConnectEntryRoute credentialSource="vercel_connect" />}
|
|
/>
|
|
<Route path="apps/connect" element={<AppsConnectEntryRoute />} />
|
|
<Route path="apps/chat/connect" element={
|
|
<ChatConnectorsExperimentalGate><ChatEndpointSetup /></ChatConnectorsExperimentalGate>
|
|
} />
|
|
<Route path="apps/chat/:endpointId" element={
|
|
<ChatConnectorsExperimentalGate><Navigate to="settings" replace /></ChatConnectorsExperimentalGate>
|
|
} />
|
|
<Route path="apps/chat/:endpointId/reviews/:reviewId" element={
|
|
<ChatConnectorsExperimentalGate><ChatEndpointDetail /></ChatConnectorsExperimentalGate>
|
|
} />
|
|
<Route path="apps/chat/:endpointId/:tab" element={
|
|
<ChatConnectorsExperimentalGate><ChatEndpointDetail /></ChatConnectorsExperimentalGate>
|
|
} />
|
|
<Route path="apps/connect/:appKey" element={<Navigate to="/apps" replace />} />
|
|
<Route path="apps/connect/:appKey/:stage" element={<Navigate to="/apps" replace />} />
|
|
<Route path="apps/review" element={<AppsReview />} />
|
|
{/* Connector health is inline on the Apps landing page; keep legacy links working. */}
|
|
<Route path="apps/attention" element={<Navigate to="/apps" replace />} />
|
|
<Route path="apps/gateways" element={<GatewaysList />} />
|
|
<Route path="apps/gateways/:gatewayId" element={<Navigate to="overview" replace />} />
|
|
<Route path="apps/gateways/:gatewayId/:tab" element={<GatewayDetail />} />
|
|
<Route path="apps/advanced" element={<AdvancedToolsRoute />} />
|
|
<Route path="apps/advanced/gateways" element={<GatewaysList />} />
|
|
<Route path="apps/advanced/profiles/new" element={<ProfileWizardRoute mode="new" />} />
|
|
<Route path="apps/advanced/profiles/:profileId/edit" element={<ProfileWizardRoute mode="edit" />} />
|
|
<Route path="apps/advanced/profiles/:profileId" element={<ProfileDetailRoute />} />
|
|
<Route path="apps/advanced/audit" element={<Navigate to="/apps" replace />} />
|
|
<Route path="apps/advanced/run-your-own" element={<Navigate to="/apps" replace />} />
|
|
<Route path="apps/advanced/:tab" element={<AdvancedToolsRoute />} />
|
|
<Route path="apps/app/:applicationId" element={<AppNotConnected />} />
|
|
<Route path="apps/app/:applicationId/:tab" element={<AppNotConnected />} />
|
|
<Route path="apps/:connectionId" element={<Navigate to="permissions" replace />} />
|
|
<Route path="apps/:connectionId/:tab" element={<AppDetail />} />
|
|
<Route path="company/settings/instance" element={<Navigate to="/company/settings" replace />} />
|
|
<Route element={<HiddenSettingsPageGate pageKey="instance.profile" />}>
|
|
<Route path="company/settings/instance/profile" element={<ProfileSettings />} />
|
|
</Route>
|
|
<Route path="company/settings/instance/general" element={<Navigate to="/company/settings" replace />} />
|
|
<Route path="company/settings/instance/heartbeats" element={<Navigate to="/company/settings" replace />} />
|
|
<Route element={<HiddenSettingsPageGate pageKey="instance.environments" />}>
|
|
<Route path="company/settings/instance/environments" element={<CompanyEnvironments />} />
|
|
<Route path="company/settings/instance/environments/new" element={<CompanyEnvironments mode="create" />} />
|
|
<Route path="company/settings/instance/environments/:environmentId/edit" element={<CompanyEnvironments mode="edit" />} />
|
|
</Route>
|
|
<Route element={<HiddenSettingsPageGate pageKey="instance.access" />}>
|
|
<Route path="company/settings/instance/access" element={<InstanceAccess />} />
|
|
</Route>
|
|
<Route element={<HiddenSettingsPageGate pageKey="instance.experimental" />}>
|
|
<Route path="company/settings/instance/experimental" element={<InstanceExperimentalSettings />} />
|
|
</Route>
|
|
<Route element={<HiddenSettingsPageGate pageKey="instance.plugins" />}>
|
|
<Route path="company/settings/instance/plugins" element={<PluginManager />} />
|
|
<Route path="company/settings/instance/plugins/:pluginId" element={<PluginSettings />} />
|
|
</Route>
|
|
<Route element={<HiddenSettingsPageGate pageKey="instance.adapters" />}>
|
|
<Route path="company/settings/instance/adapters" element={<AdapterManager />} />
|
|
</Route>
|
|
<Route path="company/settings/:settingsRoutePath/*" element={<CompanySettingsPluginPage />} />
|
|
<Route path="skills/sources" element={<SkillSources />} />
|
|
<Route path="skills/sources/:sourceId" element={<SkillSources />} />
|
|
<Route path="skills/studio" element={<SkillStudio />} />
|
|
<Route path="skills/studio/new" element={<SkillStudio />} />
|
|
<Route path="skills/studio/:skillId" element={<SkillStudio />} />
|
|
<Route path="skills/:skillId/studio" element={<LegacySkillStudioRedirect />} />
|
|
<Route
|
|
path="skills/*"
|
|
element={streamlinedUiEnabled ? <CompanySkills /> : <ProductionSurface><ProductionCompanySkills /></ProductionSurface>}
|
|
/>
|
|
<Route path="settings" element={<LegacySettingsRedirect />} />
|
|
<Route path="settings/*" element={<LegacySettingsRedirect />} />
|
|
<Route path="plugins/:pluginId" element={<PluginPage />} />
|
|
<Route
|
|
path="org"
|
|
element={streamlinedUiEnabled ? <Navigate to="/agents/all" replace /> : <ProductionSurface><ProductionOrgChart /></ProductionSurface>}
|
|
/>
|
|
<Route path="agents" element={<Navigate to="/agents/all" replace />} />
|
|
{AGENT_FILTER_TABS.map((tab) => (
|
|
<Route
|
|
key={tab}
|
|
path={`agents/${tab}`}
|
|
element={streamlinedUiEnabled ? <Agents /> : <ProductionSurface><ProductionAgents /></ProductionSurface>}
|
|
/>
|
|
))}
|
|
<Route path="agents/new" element={<NewAgent />} />
|
|
<Route path="agents/:agentId" element={<AgentDetail />} />
|
|
<Route path="agents/:agentId/:tab" element={<AgentDetail />} />
|
|
<Route path="agents/:agentId/runs/:runId" element={<AgentDetail />} />
|
|
<Route path="projects" element={<Projects />} />
|
|
<Route path="projects/:projectId" element={<ProjectDetail />} />
|
|
<Route path="projects/:projectId/overview" element={<ProjectDetail />} />
|
|
<Route path="projects/:projectId/issues" element={<ProjectDetail />} />
|
|
<Route path="projects/:projectId/issues/:filter" element={<ProjectDetail />} />
|
|
<Route element={<IsolatedWorkspacesRouteGate />}>
|
|
<Route path="projects/:projectId/workspaces/:workspaceId" element={<ProjectWorkspaceDetail />} />
|
|
</Route>
|
|
<Route path="projects/:projectId/workspaces" element={<ProjectDetail />} />
|
|
<Route path="projects/:projectId/configuration" element={<ProjectDetail />} />
|
|
<Route path="projects/:projectId/budget" element={<ProjectDetail />} />
|
|
<Route element={<IsolatedWorkspacesRouteGate />}>
|
|
<Route path="workspaces" element={<Workspaces />} />
|
|
</Route>
|
|
<Route path="issues" element={<Issues />} />
|
|
<Route path="tasks" element={<Navigate to="/issues" replace />} />
|
|
<Route path="search" element={<Search />} />
|
|
{mergedTasks ? (
|
|
<>
|
|
{/* Combined Inbox + Task List: the status presets are real views, not aliases of /issues. */}
|
|
<Route path="issues/all" element={<TaskViewRedirect view="all" />} />
|
|
<Route path="issues/active" element={<TaskViewRedirect view="active" />} />
|
|
<Route path="issues/backlog" element={<TaskViewRedirect view="backlog" />} />
|
|
<Route path="issues/done" element={<TaskViewRedirect view="done" />} />
|
|
<Route path="issues/recent" element={<TaskViewRedirect view="recent" />} />
|
|
</>
|
|
) : (
|
|
<>
|
|
<Route path="issues/all" element={<Navigate to="/issues" replace />} />
|
|
<Route path="issues/active" element={<Navigate to="/issues" replace />} />
|
|
<Route path="issues/backlog" element={<Navigate to="/issues" replace />} />
|
|
<Route path="issues/done" element={<Navigate to="/issues" replace />} />
|
|
<Route path="issues/recent" element={<Navigate to="/issues" replace />} />
|
|
</>
|
|
)}
|
|
<Route path="chats" element={<AgentChats />} />
|
|
<Route path="chats/:agentRef" element={<AgentChat />} />
|
|
<Route path="issues/:issueId" element={<IssueDetail />} />
|
|
{import.meta.env.DEV ? (
|
|
<Route path="tests/perf/long-thread" element={<IssueChatLongThreadPerf />} />
|
|
) : null}
|
|
<Route path="routines" element={streamlinedUiEnabled ? <Routines /> : <ProductionSurface><ProductionRoutines /></ProductionSurface>} />
|
|
<Route
|
|
path="cases"
|
|
element={<CasesExperimentalGate><Cases /></CasesExperimentalGate>}
|
|
/>
|
|
<Route
|
|
path="cases/:caseIdentifier"
|
|
element={<CasesExperimentalGate><CaseDetail /></CasesExperimentalGate>}
|
|
/>
|
|
<Route
|
|
path="status"
|
|
element={<StatusCardsExperimentalGate><StatusCards /></StatusCardsExperimentalGate>}
|
|
/>
|
|
<Route
|
|
path="status/:cardId"
|
|
element={<StatusCardsExperimentalGate><StatusCards /></StatusCardsExperimentalGate>}
|
|
/>
|
|
{/* Back-compat: the board lived at /status-cards before PAP-15223. */}
|
|
<Route path="status-cards" element={<StatusCardsLegacyRedirect />} />
|
|
<Route path="status-cards/:cardId" element={<StatusCardsLegacyRedirect />} />
|
|
<Route
|
|
path="review-queue"
|
|
element={<PipelinesExperimentalGate><ReviewQueue /></PipelinesExperimentalGate>}
|
|
/>
|
|
<Route
|
|
path="learnings"
|
|
element={<PipelinesExperimentalGate><Learnings /></PipelinesExperimentalGate>}
|
|
/>
|
|
<Route
|
|
path="pipelines"
|
|
element={<PipelinesExperimentalGate><Pipelines /></PipelinesExperimentalGate>}
|
|
/>
|
|
<Route
|
|
path="pipelines/:pipelineId"
|
|
element={<PipelinesExperimentalGate><Pipelines /></PipelinesExperimentalGate>}
|
|
/>
|
|
<Route
|
|
path="pipelines/:pipelineId/add"
|
|
element={<PipelinesExperimentalGate><Pipelines /></PipelinesExperimentalGate>}
|
|
/>
|
|
<Route
|
|
path="pipelines/:pipelineId/settings"
|
|
element={<PipelinesExperimentalGate><PipelineSettings /></PipelinesExperimentalGate>}
|
|
/>
|
|
<Route
|
|
path="pipelines/:pipelineId/items/:caseId"
|
|
element={<PipelinesExperimentalGate><PipelineItemDetail /></PipelinesExperimentalGate>}
|
|
/>
|
|
<Route
|
|
path="pipelines/:pipelineId/cases/:caseId"
|
|
element={<PipelinesExperimentalGate><PipelineItemLegacyRedirect /></PipelinesExperimentalGate>}
|
|
/>
|
|
<Route path="routines/:routineId" element={streamlinedUiEnabled ? <RoutineDetail /> : <ProductionSurface><ProductionRoutineDetail /></ProductionSurface>} />
|
|
<Route path="routines/:routineId/:section" element={streamlinedUiEnabled ? <RoutineDetail /> : <ProductionSurface><ProductionRoutineDetail /></ProductionSurface>} />
|
|
<Route element={<IsolatedWorkspacesRouteGate />}>
|
|
<Route element={<ExecutionWorkspaceCompanyGate />}>
|
|
<Route path="execution-workspaces/:workspaceId" element={<ExecutionWorkspaceDetail />} />
|
|
<Route path="execution-workspaces/:workspaceId/services" element={<ExecutionWorkspaceDetail />} />
|
|
<Route path="execution-workspaces/:workspaceId/configuration" element={<ExecutionWorkspaceDetail />} />
|
|
<Route path="execution-workspaces/:workspaceId/runtime-logs" element={<ExecutionWorkspaceDetail />} />
|
|
<Route path="execution-workspaces/:workspaceId/issues" element={<ExecutionWorkspaceDetail />} />
|
|
<Route path="execution-workspaces/:workspaceId/routines" element={<ExecutionWorkspaceDetail />} />
|
|
</Route>
|
|
</Route>
|
|
<Route path="goals" element={<Goals />} />
|
|
<Route path="goals/:goalId" element={<GoalDetail />} />
|
|
<Route path="artifacts" element={<Artifacts />} />
|
|
<Route path="approvals" element={<Navigate to="/approvals/pending" replace />} />
|
|
<Route path="approvals/pending" element={<Approvals />} />
|
|
<Route path="approvals/all" element={<Approvals />} />
|
|
<Route path="approvals/:approvalId" element={<ApprovalDetail />} />
|
|
<Route path="activity" element={streamlinedUiEnabled ? <CompanyActivity /> : <ProductionSurface><ProductionCompanyActivity /></ProductionSurface>} />
|
|
{streamlinedUiEnabled ? (
|
|
<>
|
|
<Route path="activity/runs" element={<AuditHub section="runs" />} />
|
|
<Route path="activity/costs" element={<AuditHub section="costs" />} />
|
|
<Route path="activity/budgets" element={<AuditHub section="budgets" />} />
|
|
<Route path="activity/timeline" element={<AuditHub section="timeline" />} />
|
|
<Route path="audit" element={<AuditCompatibilityRedirect to="/activity" forceAgentMode />} />
|
|
<Route path="audit/activity" element={<AuditCompatibilityRedirect to="/activity" />} />
|
|
<Route path="audit/runs" element={<AuditCompatibilityRedirect to="/activity/runs" />} />
|
|
<Route path="audit/costs" element={<AuditCompatibilityRedirect to="/activity/costs" />} />
|
|
<Route path="audit/budgets" element={<AuditCompatibilityRedirect to="/activity/budgets" />} />
|
|
<Route path="audit/timeline" element={<AuditCompatibilityRedirect to="/activity/timeline" />} />
|
|
<Route path="runs" element={<AuditCompatibilityRedirect to="/activity/runs" />} />
|
|
<Route path="costs" element={<AuditCompatibilityRedirect to="/activity/costs" />} />
|
|
<Route path="budgets" element={<AuditCompatibilityRedirect to="/activity/budgets" />} />
|
|
</>
|
|
) : (
|
|
<>
|
|
<Route path="costs" element={<Costs />} />
|
|
<Route path="audit" element={<Navigate to="/activity?mode=agents" replace />} />
|
|
</>
|
|
)}
|
|
{/* Conference Room Chat surfaces (PAP-136/PAP-137): routes stay
|
|
registered but redirect to the company home while the experimental
|
|
flag is off. The board-level `artifacts` mount below is the new
|
|
conference-room one; the master-level mount above it still serves
|
|
`/artifacts` in both modes. */}
|
|
<Route element={<ConferenceRoomChatGate />}>
|
|
<Route path="board-chat" element={<BoardChat />} />
|
|
<Route path="artifacts" element={<Artifacts />} />
|
|
</Route>
|
|
{/* Task chat dev harness — dev builds only. */}
|
|
{import.meta.env.DEV ? (
|
|
<Route path="dev/task-chat-lab" element={<TaskChatLab />} />
|
|
) : null}
|
|
<Route path="decisions" element={<WhatNeedsMe />} />
|
|
<Route path="decisions/queues/:key" element={<DecisionQueuePage />} />
|
|
{/* Combined Inbox + Task List: Inbox is a view inside Tasks. Every /inbox/* URL still
|
|
resolves — it redirects into the matching view — and with the flag off
|
|
(or in the legacy shell) the standalone pages stay. /inbox/requests
|
|
stays its own page either way; Settings → Members links straight to it. */}
|
|
{mergedTasks ? (
|
|
<>
|
|
<Route path="inbox" element={<InboxRootRedirect />} />
|
|
<Route path="inbox/mine" element={<TaskViewRedirect view="mine" />} />
|
|
<Route path="inbox/recent" element={<TaskViewRedirect view="recent" />} />
|
|
<Route path="inbox/unread" element={<TaskViewRedirect view="unread" />} />
|
|
<Route path="inbox/blocked" element={<TaskViewRedirect view="blocked" />} />
|
|
<Route path="inbox/all" element={<TaskViewRedirect view="everything" />} />
|
|
<Route path="inbox/new" element={<TaskViewRedirect view="mine" />} />
|
|
</>
|
|
) : (
|
|
<>
|
|
<Route path="inbox" element={<InboxRootRedirect />} />
|
|
<Route path="inbox/mine" element={<Inbox />} />
|
|
<Route path="inbox/recent" element={<Inbox />} />
|
|
<Route path="inbox/unread" element={<Inbox />} />
|
|
<Route path="inbox/blocked" element={<Inbox />} />
|
|
<Route path="inbox/all" element={<Inbox />} />
|
|
<Route path="inbox/new" element={<Navigate to="/inbox/mine" replace />} />
|
|
</>
|
|
)}
|
|
<Route path="inbox/requests" element={<JoinRequestQueue />} />
|
|
<Route path="u/:userSlug" element={<UserProfile />} />
|
|
<Route path="design-guide" element={<DesignGuide />} />
|
|
<Route path="instance/settings/adapters" element={<AdapterManager />} />
|
|
<Route path=":pluginRoutePath/*" element={<PluginPage />} />
|
|
<Route path="*" element={<NotFoundPage scope="board" />} />
|
|
</>
|
|
);
|
|
}
|
|
|
|
function AppsConnectEntryRoute({
|
|
credentialSource = "paperclip_vault",
|
|
}: {
|
|
credentialSource?: ToolConnectionCredentialSource;
|
|
} = {}) {
|
|
const location = useLocation();
|
|
const searchParams = new URLSearchParams(location.search);
|
|
const { enabled: chatConnectorsEnabled, githubEnabled: githubReviewBotsEnabled } = useChatConnectorsEnabled();
|
|
return canEnterAppsConnect(searchParams, { chatConnectorsEnabled, githubReviewBotsEnabled })
|
|
? <AppsConnect credentialSource={credentialSource} />
|
|
: <Navigate to="/apps" replace />;
|
|
}
|
|
|
|
function InboxRootRedirect() {
|
|
const { enabled: streamlinedUiEnabled } = useStreamlinedUiEnabled();
|
|
const { enabled: combinedInboxTasksEnabled } = useCombinedInboxTasksEnabled();
|
|
return streamlinedUiEnabled && combinedInboxTasksEnabled
|
|
? <TaskViewRedirect view={taskViewForInboxTab(loadLastInboxTab())} />
|
|
: <Navigate to={`/inbox/${loadLastInboxTab()}`} replace />;
|
|
}
|
|
|
|
/** Sends a retired Inbox/Tasks URL to its view on the merged Tasks surface. */
|
|
function TaskViewRedirect({ view }: { view: TaskViewKey }) {
|
|
const location = useLocation();
|
|
const params = new URLSearchParams(location.search);
|
|
params.set(TASK_VIEW_PARAM, view);
|
|
return <Navigate to={`/issues?${params.toString()}${location.hash}`} replace />;
|
|
}
|
|
|
|
function LegacySkillStudioRedirect() {
|
|
const location = useLocation();
|
|
const { companies, selectedCompany, loading } = useCompany();
|
|
const { companyPrefix, skillId } = useParams<{ companyPrefix?: string; skillId?: string }>();
|
|
|
|
if (loading) return null;
|
|
|
|
const targetCompany =
|
|
(companyPrefix
|
|
? companies.find((company) => company.issuePrefix.toUpperCase() === companyPrefix.toUpperCase())
|
|
: null) ??
|
|
selectedCompany ??
|
|
companies[0] ??
|
|
null;
|
|
|
|
if (!targetCompany || !skillId) {
|
|
return <Navigate to="/skills/studio" replace />;
|
|
}
|
|
|
|
return (
|
|
<Navigate
|
|
to={`/${targetCompany.issuePrefix}/skills/studio/${encodeURIComponent(skillId)}${location.search}${location.hash}`}
|
|
replace
|
|
/>
|
|
);
|
|
}
|
|
|
|
function LegacySettingsRedirect() {
|
|
const location = useLocation();
|
|
const { companies, selectedCompany, loading } = useCompany();
|
|
const { companyPrefix } = useParams<{ companyPrefix?: string }>();
|
|
const { hidden: hiddenSettings } = useHiddenSettings();
|
|
|
|
if (loading) {
|
|
return <PaperclipLoading />;
|
|
}
|
|
|
|
const targetCompany =
|
|
(companyPrefix
|
|
? companies.find((company) => company.issuePrefix.toUpperCase() === companyPrefix.toUpperCase())
|
|
: null) ??
|
|
selectedCompany ??
|
|
companies[0] ??
|
|
null;
|
|
|
|
if (!targetCompany) {
|
|
if (
|
|
shouldRedirectCompanylessRouteToOnboarding({
|
|
pathname: location.pathname,
|
|
hasCompanies: false,
|
|
})
|
|
) {
|
|
return <Navigate to="/onboarding" replace />;
|
|
}
|
|
return <NoCompaniesStartPage />;
|
|
}
|
|
|
|
const normalizedPath = filterHiddenInstanceSettingsPath(
|
|
normalizeRememberedInstanceSettingsPath(
|
|
`${location.pathname}${location.search}${location.hash}`,
|
|
),
|
|
hiddenSettings,
|
|
);
|
|
|
|
return (
|
|
<Navigate
|
|
to={`/${targetCompany.issuePrefix}${normalizedPath}`}
|
|
replace
|
|
/>
|
|
);
|
|
}
|
|
|
|
function LegacyToolsSettingsRedirect() {
|
|
const { tab } = useParams<{ tab?: string }>();
|
|
return <Navigate to={legacyToolsRedirectTarget(tab)} replace />;
|
|
}
|
|
|
|
// The developer "Tools" surface moved under the Apps "Advanced setup" door
|
|
// (PAP-10862). `/tools` and `/tools/:tab` redirect to their new home.
|
|
function LegacyToolsRedirect() {
|
|
const { tab } = useParams<{ tab?: string }>();
|
|
return <Navigate to={legacyToolsRedirectTarget(tab)} replace />;
|
|
}
|
|
|
|
function legacyToolsRedirectTarget(tab?: string) {
|
|
if (!tab) return "/apps/advanced/profiles";
|
|
if (tab === "applications" || tab === "connections" || tab === "overview" || tab === "examples") return "/apps";
|
|
if (tab === "runtime" || tab === "audit") return "/apps";
|
|
if (tab === "policies") return "/apps/advanced/profiles";
|
|
return `/apps/advanced/${tab}`;
|
|
}
|
|
|
|
export function OnboardingRoutePage() {
|
|
const { companies } = useCompany();
|
|
const { openOnboarding } = useDialogActions();
|
|
const { t } = useTranslation();
|
|
const cloudInstance = useCloudInstance();
|
|
const createStackUrl = cloudStackCreateUrl(cloudInstance?.cloudBaseUrl ?? null);
|
|
const { onboardingOpen, onboardingRouteDismissed } = useDialogState();
|
|
const { companyPrefix } = useParams<{ companyPrefix?: string }>();
|
|
const matchedCompany = companyPrefix
|
|
? companies.find((company) => company.issuePrefix.toUpperCase() === companyPrefix.toUpperCase()) ?? null
|
|
: null;
|
|
// The OnboardingWizard auto-opens on this route (and can also be opened
|
|
// explicitly). While it is showing it covers the whole screen, so the
|
|
// launcher card below must not stay interactive behind it — otherwise users
|
|
// can tab/click through to the form behind the modal (PAP-52). The launcher
|
|
// only needs to render as a re-entry point once the wizard is dismissed.
|
|
if (isOnboardingWizardActive({ onboardingOpen, routeDismissed: onboardingRouteDismissed })) {
|
|
return null;
|
|
}
|
|
|
|
const title = matchedCompany
|
|
? `Add another agent to ${matchedCompany.name}`
|
|
: companies.length > 0
|
|
? "Create another organization"
|
|
: "Create your first organization";
|
|
const description = matchedCompany
|
|
? "Run onboarding again to add an agent and a starter task for this organization."
|
|
: companies.length > 0
|
|
? "Run onboarding again to create another organization and seed its first agent."
|
|
: "Get started by creating an organization and your first agent.";
|
|
|
|
return (
|
|
<div className="mx-auto max-w-xl py-10">
|
|
<div className="rounded-lg border border-border bg-card p-6">
|
|
<h1 className="text-xl font-semibold">{title}</h1>
|
|
<p className="mt-2 text-sm text-muted-foreground">{description}</p>
|
|
<div className="mt-4">
|
|
{/* On a managed stack whose Cloud origin is unknown there is nowhere
|
|
to send this click: creation lives on Cloud, and in-app creation
|
|
is a 403 floor. A button that does nothing is worse than none, so
|
|
say why instead of rendering an inert control. */}
|
|
{!matchedCompany && cloudInstance && !createStackUrl ? (
|
|
<p className="text-sm text-muted-foreground">
|
|
{t("app.cloudCreateUnavailable", {
|
|
defaultValue:
|
|
"Organizations are created in Paperclip Cloud. This instance can't reach it right now — try again from your Cloud portfolio.",
|
|
})}
|
|
</p>
|
|
) : (
|
|
<Button
|
|
onClick={() =>
|
|
matchedCompany
|
|
? openOnboarding({
|
|
// "Add another agent" to a company that already has its
|
|
// mission must not stop to ask for the mission again. An
|
|
// unsettled or failed lookup reads as "no mission" and
|
|
// costs the step, which the customer can pass - and the
|
|
// mission step now updates the existing goal rather than
|
|
// adding a second one.
|
|
initialStep: onboardingStepForCompany(),
|
|
companyId: matchedCompany.id,
|
|
})
|
|
: cloudInstance && createStackUrl
|
|
? navigateTopLevel(createStackUrl)
|
|
: openOnboarding()
|
|
}
|
|
>
|
|
{matchedCompany ? "Add Agent" : "Start Onboarding"}
|
|
</Button>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function CompanyRootRedirect() {
|
|
const { companies, selectedCompany, loading } = useCompany();
|
|
const location = useLocation();
|
|
|
|
if (loading) {
|
|
return <PaperclipLoading />;
|
|
}
|
|
|
|
const targetCompany = selectedCompany ?? companies[0] ?? null;
|
|
if (!targetCompany) {
|
|
if (
|
|
shouldRedirectCompanylessRouteToOnboarding({
|
|
pathname: location.pathname,
|
|
hasCompanies: false,
|
|
})
|
|
) {
|
|
return <Navigate to="/onboarding" replace />;
|
|
}
|
|
return <NoCompaniesStartPage />;
|
|
}
|
|
|
|
return <Navigate to={`/${targetCompany.issuePrefix}/dashboard`} replace />;
|
|
}
|
|
|
|
function StatusCardsLegacyRedirect() {
|
|
const { cardId } = useParams<{ cardId?: string }>();
|
|
const prefix = useActiveCompanyPrefix();
|
|
const base = prefix ? `/${prefix}` : "";
|
|
return <Navigate to={`${base}/status${cardId ? `/${cardId}` : ""}`} replace />;
|
|
}
|
|
|
|
function AuditCompatibilityRedirect({
|
|
to,
|
|
forceAgentMode = false,
|
|
}: {
|
|
to: string;
|
|
forceAgentMode?: boolean;
|
|
}) {
|
|
const location = useLocation();
|
|
const searchParams = new URLSearchParams(location.search);
|
|
if (forceAgentMode) searchParams.set("mode", "agents");
|
|
const search = searchParams.toString();
|
|
return <Navigate to={`${to}${search ? `?${search}` : ""}${location.hash}`} replace />;
|
|
}
|
|
|
|
function UnprefixedBoardRedirect() {
|
|
const location = useLocation();
|
|
const { companies, selectedCompany, loading } = useCompany();
|
|
|
|
if (loading) {
|
|
return <PaperclipLoading />;
|
|
}
|
|
|
|
const targetCompany = selectedCompany ?? companies[0] ?? null;
|
|
if (!targetCompany) {
|
|
if (
|
|
shouldRedirectCompanylessRouteToOnboarding({
|
|
pathname: location.pathname,
|
|
hasCompanies: false,
|
|
})
|
|
) {
|
|
return <Navigate to="/onboarding" replace />;
|
|
}
|
|
return <NoCompaniesStartPage />;
|
|
}
|
|
|
|
return (
|
|
<Navigate
|
|
to={`/${targetCompany.issuePrefix}${location.pathname}${location.search}${location.hash}`}
|
|
replace
|
|
/>
|
|
);
|
|
}
|
|
|
|
function NoCompaniesStartPage() {
|
|
const { openOnboarding } = useDialogActions();
|
|
const { t } = useTranslation();
|
|
// A managed stack with no visible companies is a loading or error state, not
|
|
// an invitation to create one in-app — creation lives on Cloud (403 floor).
|
|
const cloudInstance = useCloudInstance();
|
|
const createStackUrl = cloudStackCreateUrl(cloudInstance?.cloudBaseUrl ?? null);
|
|
|
|
return (
|
|
<div className="mx-auto max-w-xl py-10">
|
|
<div className="rounded-lg border border-border bg-card p-6">
|
|
<h1 className="text-xl font-semibold">
|
|
{t("app.noCompanies.title", { defaultValue: "Create your first organization" })}
|
|
</h1>
|
|
<p className="mt-2 text-sm text-muted-foreground">
|
|
{t("app.noCompanies.description", { defaultValue: "Get started by creating an organization." })}
|
|
</p>
|
|
<div className="mt-4">
|
|
{/* Same as the onboarding route: no Cloud origin means nowhere to
|
|
send the click, and in-app creation is a 403 floor here. */}
|
|
{cloudInstance && !createStackUrl ? (
|
|
<p className="text-sm text-muted-foreground">
|
|
{t("app.cloudCreateUnavailable", {
|
|
defaultValue:
|
|
"Organizations are created in Paperclip Cloud. This instance can't reach it right now — try again from your Cloud portfolio.",
|
|
})}
|
|
</p>
|
|
) : (
|
|
<Button
|
|
onClick={() =>
|
|
cloudInstance && createStackUrl
|
|
? navigateTopLevel(createStackUrl)
|
|
: openOnboarding()
|
|
}
|
|
>
|
|
{t("app.noCompanies.newCompany", { defaultValue: "New Organization" })}
|
|
</Button>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export function App() {
|
|
const { enabled: streamlinedUiEnabled, loaded: streamlinedUiLoaded } = useStreamlinedUiEnabled();
|
|
const { enabled: combinedInboxTasksEnabled } = useCombinedInboxTasksEnabled();
|
|
|
|
return (
|
|
<>
|
|
<Routes>
|
|
<Route path="oauth-handoff" element={<PaperclipCloudOAuthHandoffPage />} />
|
|
<Route path="auth" element={<AuthPage />} />
|
|
<Route path="board-claim/:token" element={<BoardClaimPage />} />
|
|
<Route path="mcp-connect/:id" element={<McpConnectPage />} />
|
|
<Route path="dot-connect/:id" element={<McpConnectPage agentPairingOnly />} />
|
|
<Route path="mcp-device" element={<McpDevicePage />} />
|
|
<Route path="assistant-connections" element={<AssistantConnectionsPage />} />
|
|
<Route path="cli-auth/:id" element={<CliAuthPage />} />
|
|
<Route path="invite/:token" element={<InviteLandingPage />} />
|
|
<Route element={streamlinedUiLoaded ? <CloudAccessGate allowMembershipRequest /> : <PaperclipLoading />}>
|
|
{/* The identity APIs enforce the chat rollout flag. Nonmembers cannot
|
|
read experimental settings, but a private invitation may request membership. */}
|
|
<Route path="chat-identity/confirm" element={<ChatIdentityConfirm />} />
|
|
</Route>
|
|
<Route path="tests/perf/long-thread" element={<IssueChatLongThreadPerf />} />
|
|
<Route path="ux-lab/bootstrap-setup" element={<BootstrapSetupUxLab />} />
|
|
<Route path="ux-lab/responsible-user-denial" element={<ResponsibleUserDenialUxLab />} />
|
|
<Route path="ux-lab/cross-issue-collaboration" element={<CrossIssueCollaborationUxLab />} />
|
|
|
|
<Route element={streamlinedUiLoaded ? <CloudAccessGate /> : <PaperclipLoading />}>
|
|
<Route index element={<CompanyRootRedirect />} />
|
|
<Route path="onboarding" element={<OnboardingRoutePage />} />
|
|
<Route path="instance" element={<LegacySettingsRedirect />} />
|
|
<Route path="instance/settings" element={<LegacySettingsRedirect />} />
|
|
<Route path="instance/settings/*" element={<LegacySettingsRedirect />} />
|
|
<Route path="companies" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="issues" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="tasks" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="issues/:issueId" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="routines" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="routines/:routineId" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="review-queue" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="learnings" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="cases" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="cases/:caseIdentifier" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="status" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="status/:cardId" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="status-cards" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="status-cards/:cardId" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="pipelines" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="pipelines/:pipelineId" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="pipelines/:pipelineId/add" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="pipelines/:pipelineId/settings" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="pipelines/:pipelineId/items/:caseId" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="pipelines/:pipelineId/cases/:caseId" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="artifacts" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="audit" element={<UnprefixedBoardRedirect />} />
|
|
{streamlinedUiEnabled ? (
|
|
<>
|
|
<Route path="audit/*" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="activity" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="activity/*" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="runs" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="costs" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="budgets" element={<UnprefixedBoardRedirect />} />
|
|
</>
|
|
) : null}
|
|
<Route path="decisions" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="u/:userSlug" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="skills/studio" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="skills/studio/new" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="skills/studio/:skillId" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="skills/:skillId/studio" element={<LegacySkillStudioRedirect />} />
|
|
<Route path="skills/*" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="settings" element={<LegacySettingsRedirect />} />
|
|
<Route path="settings/*" element={<LegacySettingsRedirect />} />
|
|
<Route path="agents" element={<UnprefixedBoardRedirect />} />
|
|
{AGENT_FILTER_TABS.map((tab) => (
|
|
<Route key={tab} path={`agents/${tab}`} element={<UnprefixedBoardRedirect />} />
|
|
))}
|
|
<Route path="agents/new" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="agents/:agentId" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="agents/:agentId/:tab" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="agents/:agentId/runs/:runId" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="projects" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="projects/:projectId" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="projects/:projectId/overview" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="projects/:projectId/issues" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="projects/:projectId/issues/:filter" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="projects/:projectId/workspaces" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="projects/:projectId/workspaces/:workspaceId" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="projects/:projectId/configuration" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="workspaces" element={<UnprefixedBoardRedirect />} />
|
|
<Route path="execution-workspaces/:workspaceId" element={<UnprefixedExecutionWorkspaceRedirect />} />
|
|
<Route path="execution-workspaces/:workspaceId/services" element={<UnprefixedExecutionWorkspaceRedirect />} />
|
|
<Route path="execution-workspaces/:workspaceId/configuration" element={<UnprefixedExecutionWorkspaceRedirect />} />
|
|
<Route path="execution-workspaces/:workspaceId/runtime-logs" element={<UnprefixedExecutionWorkspaceRedirect />} />
|
|
<Route path="execution-workspaces/:workspaceId/issues" element={<UnprefixedExecutionWorkspaceRedirect />} />
|
|
<Route path="execution-workspaces/:workspaceId/routines" element={<UnprefixedExecutionWorkspaceRedirect />} />
|
|
<Route path=":companyPrefix" element={streamlinedUiEnabled ? <Layout /> : <ProductionLayout />}>
|
|
{boardRoutes(streamlinedUiEnabled, combinedInboxTasksEnabled)}
|
|
</Route>
|
|
<Route path="*" element={<NotFoundPage scope="global" />} />
|
|
</Route>
|
|
</Routes>
|
|
<OnboardingWizardVariant />
|
|
</>
|
|
);
|
|
}
|