From 5e59737ef39f16ed27e6d4b60ebea29a9e318c49 Mon Sep 17 00:00:00 2001 From: Tonio Date: Fri, 4 Dec 2026 14:01:43 -0800 Subject: [PATCH] feat(ui): request missing plugins from catalog search (#23777) ## Thinking Path > - Paperclip helps people manage AI agents and their work. > - Operators search the Plugins catalog for tools their agents need. > - An empty search offers only a way to clear the query. > - Operators can now use the search term to request the missing tool. > - Each submission creates a backlog task that the company can track. ## Linked Issues or Issue Description **Subsystem affected** Plugins catalog search. **Problem or motivation** An operator who cannot find a tool must leave the catalog to write a request. **Proposed solution** Add a primary request button beside Clear search. Open a form with the search term as its editable name. ## What Changed - Collect an optional website and notification email. Save the request as a company backlog task and show its identifier. - Capture `plugin_request_submitted` after a successful save. Include the source and flags for website presence and email opt-in. - Add a test that submits the form and checks the saved fields, confirmation, and event count. ## Verification - Run `node_modules/.bin/vitest run ui/src/pages/apps/RequestPluginDialog.test.tsx ui/src/lib/analytics/product-analytics-events.test.ts`. All three tests passed locally. The query error policy check reported zero findings. - A manual worktree submission produced one PostHog event with both flags true. - [Final CI run](https://github.com/paperclipai/paperclip/actions/runs/47424073788) passed the required verification and end-to-end gates on `e749348c05`. ## Risks The optional email becomes visible to people who can read the company task. The form records the notification preference. Email delivery requires a future integration. ## Model Used OpenAI GPT-6 via Codex, with local code execution and browser 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 - [ ] 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 --- ui/src/pages/apps/Browse.tsx | 6 +- .../pages/apps/RequestPluginDialog.test.tsx | 57 +++++++++ ui/src/pages/apps/RequestPluginDialog.tsx | 119 ++++++++++++++++++ 3 files changed, 181 insertions(+), 1 deletion(-) create mode 100644 ui/src/pages/apps/RequestPluginDialog.test.tsx create mode 100644 ui/src/pages/apps/RequestPluginDialog.tsx diff --git a/ui/src/pages/apps/Browse.tsx b/ui/src/pages/apps/Browse.tsx index f62a97da27c..09eeaabe081 100644 --- a/ui/src/pages/apps/Browse.tsx +++ b/ui/src/pages/apps/Browse.tsx @@ -64,6 +64,7 @@ import { useMemoryConnectorsEnabled } from "@/hooks/useMemoryConnectorsEnabled"; import { useConnectorAvailability } from "@/hooks/useConnectorAvailability"; import { useCloudInstance } from "@/hooks/useCloudInstance"; import { appCopyFor } from "@/lib/app-gallery-copy"; +import { RequestPluginDialog } from "./RequestPluginDialog"; import { useCompany } from "@/context/CompanyContext"; import { useBreadcrumbs } from "@/context/BreadcrumbContext"; import { useToast } from "@/context/ToastContext"; @@ -1209,7 +1210,10 @@ export function Browse({ renderAccountDetails = (connection) => connection.conne ) : nothingMatches && !pluginKey ? (

No connectors match “{query.trim()}”.

- +
+ + +
) : ( openRow ? ( diff --git a/ui/src/pages/apps/RequestPluginDialog.test.tsx b/ui/src/pages/apps/RequestPluginDialog.test.tsx new file mode 100644 index 00000000000..47bd7d7c7ea --- /dev/null +++ b/ui/src/pages/apps/RequestPluginDialog.test.tsx @@ -0,0 +1,57 @@ +// @vitest-environment jsdom +import { act } from "react"; +import { createRoot } from "react-dom/client"; +import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; +import { expect, it, vi } from "vitest"; +import { resetProductAnalyticsForTest, startProductAnalytics } from "@/lib/analytics/product-analytics"; +import { RequestPluginDialog } from "./RequestPluginDialog"; + +const createIssue = vi.hoisted(() => vi.fn()); +vi.mock("@/api/issues", () => ({ issuesApi: { create: createIssue } })); +vi.mock("@/context/CompanyContext", () => ({ useCompany: () => ({ selectedCompanyId: "local-qa" }) })); + +it("captures one plugin request after the issue is saved, with the submitted flags", async () => { + vi.stubGlobal("ResizeObserver", class { observe() {} unobserve() {} disconnect() {} }); + const capture = vi.fn(); + startProductAnalytics({ token: "local", apiHost: "/_ph", uiHost: null, environment: "test", stackId: "local", replayEnabled: false }, { + load: async () => ({ init: vi.fn(), register: vi.fn(), identify: vi.fn(), reset: vi.fn(), group: vi.fn(), capture }), + schedule: (start) => { start(); return () => {}; }, + }); + let finishSave!: (issue: { identifier: string }) => void; + createIssue.mockReturnValue(new Promise(resolve => { finishSave = resolve; })); + const client = new QueryClient(); + const container = document.body.appendChild(document.createElement("div")); + const root = createRoot(container); + try { + await act(async () => root.render()); + await act(async () => container.querySelector("button")!.click()); + const form = document.querySelector("form")!; + expect(form.querySelector('[name="name"]')!.value).toBe("QA plugin"); + form.querySelector('[name="url"]')!.value = "https://example.com"; + await act(async () => form.querySelector('[role="checkbox"]')!.click()); + form.querySelector('[name="email"]')!.value = "qa@example.com"; + await act(async () => form.querySelector('[type="submit"]')!.click()); + expect(createIssue).toHaveBeenCalledTimes(1); + expect(createIssue).toHaveBeenCalledWith("local-qa", expect.objectContaining({ + allowDuplicate: true, + idempotencyKey: expect.any(String), + description: "Website: https://example.com\n\nEmail me when available: qa@example.com", + })); + expect(capture).not.toHaveBeenCalled(); + await act(async () => { + finishSave({ identifier: "QA-1" }); + await vi.waitFor(() => expect(capture).toHaveBeenCalledTimes(1)); + }); + expect(document.body.textContent).toContain("Request submitted"); + expect(capture).toHaveBeenCalledTimes(1); + expect(capture).toHaveBeenCalledWith("plugin_request_submitted", { + source: "plugins_empty_search", has_website: "true", notification_opt_in: "true", + }, expect.anything()); + } finally { + await act(async () => root.unmount()); + container.remove(); + client.clear(); + resetProductAnalyticsForTest(); + vi.unstubAllGlobals(); + } +}); diff --git a/ui/src/pages/apps/RequestPluginDialog.tsx b/ui/src/pages/apps/RequestPluginDialog.tsx new file mode 100644 index 00000000000..3ea97248005 --- /dev/null +++ b/ui/src/pages/apps/RequestPluginDialog.tsx @@ -0,0 +1,119 @@ +import { useState } from "react"; +import { Button } from "@/components/ui/button"; +import { Checkbox } from "@/components/ui/checkbox"; +import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; +import { useMutation, useQueryClient } from "@tanstack/react-query"; +import { createUuid } from "@/lib/uuid"; +import { describeError } from "@/api/errors"; +import { issuesApi } from "@/api/issues"; +import { useCompany } from "@/context/CompanyContext"; +import { queryKeys } from "@/lib/queryKeys"; +import { ANALYTICS_MASK_CLASS } from "@/lib/analytics/privacy"; +import { captureProductAnalyticsEvent } from "@/lib/analytics/product-analytics"; + +interface PluginRequestSubmission { + idempotencyKey: string; + companyId: string; + title: string; + description: string; + hasWebsite: boolean; + notificationOptIn: boolean; +} + +export function RequestPluginDialog({ searchedName }: { searchedName: string }) { + const { selectedCompanyId } = useCompany(); + const queryClient = useQueryClient(); + const submission = useMutation({ + mutationFn: ({ companyId, title, description, idempotencyKey }: PluginRequestSubmission) => + issuesApi.create(companyId, { title, description, status: "backlog", allowDuplicate: true, idempotencyKey }), + onSuccess: (_, { companyId, hasWebsite, notificationOptIn }) => { + captureProductAnalyticsEvent("plugin_request_submitted", { + source: "plugins_empty_search", + has_website: String(hasWebsite), + notification_opt_in: String(notificationOptIn), + }); + void queryClient.invalidateQueries({ queryKey: queryKeys.issues.list(companyId) }); + }, + }); + const [open, setOpen] = useState(false); + const [notify, setNotify] = useState(false); + + return ( + { + if (submission.isPending) return; + if (next) { + submission.reset(); + setNotify(false); + } + setOpen(next); + }}> + + + {submission.isSuccess ? <> + + Request submitted + Your request was saved as company task {submission.data.identifier}. + + + : <> + + Request a plugin or tool + Your request will be saved as a company task. + +
{ + event.preventDefault(); + if (!selectedCompanyId || submission.isPending) return; + const data = new FormData(event.currentTarget); + const name = String(data.get("name") ?? "").trim(); + const url = String(data.get("url") ?? "").trim(); + const description = [ + url && `Website: ${url}`, + notify && `Email me when available: ${data.get("email")}`, + ].filter(Boolean).join("\n\n"); + const title = name ? `Request plugin/tool: ${name}` : "Request plugin/tool"; + const previous = submission.variables; + const idempotencyKey = previous?.companyId === selectedCompanyId + && previous.title === title && previous.description === description + ? previous.idempotencyKey : createUuid(); + submission.mutate({ + idempotencyKey, + companyId: selectedCompanyId, + title, + description, + hasWebsite: Boolean(url), + notificationOptIn: notify, + }); + }}> +
+ + +
+
+ + +
+
+ setNotify(checked === true)} /> + +
+ {notify &&
+ + +
} + {submission.error &&

+ Couldn’t submit your request. {describeError(submission.error).body} +

} + + + + +
+ } +
+
+ ); +}