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 <noreply@paperclip.ing>
This commit is contained in:
TonioandPaperclip authored and GitHub committed 2026-12-04 14:01:43 -08:00
1 parent a62aa6a85f
commit 5e59737ef3
3 files changed
+181 -1

No files matched your search

+5 -1
View File
@@ -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 ? (
<div className="flex flex-col items-start gap-3 rounded-xl border border-dashed border-border bg-card px-4 py-6 text-sm text-muted-foreground">
<p className="flex items-center gap-2"><Link2 className="h-4 w-4" />No connectors match “{query.trim()}”.</p>
<Button variant="outline" size="sm" onClick={() => changeQuery("")}>Clear search</Button>
<div className="flex flex-wrap gap-2">
<Button variant="outline" size="sm" onClick={() => changeQuery("")}>Clear search</Button>
<RequestPluginDialog searchedName={query} />
</div>
</div>
) : (
openRow ? (
@@ -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(<QueryClientProvider client={client}><RequestPluginDialog searchedName="QA plugin" /></QueryClientProvider>));
await act(async () => container.querySelector("button")!.click());
const form = document.querySelector("form")!;
expect(form.querySelector<HTMLInputElement>('[name="name"]')!.value).toBe("QA plugin");
form.querySelector<HTMLInputElement>('[name="url"]')!.value = "https://example.com";
await act(async () => form.querySelector<HTMLButtonElement>('[role="checkbox"]')!.click());
form.querySelector<HTMLInputElement>('[name="email"]')!.value = "qa@example.com";
await act(async () => form.querySelector<HTMLButtonElement>('[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();
}
});
+119
View File
@@ -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 (
<Dialog open={open} onOpenChange={(next) => {
if (submission.isPending) return;
if (next) {
submission.reset();
setNotify(false);
}
setOpen(next);
}}>
<DialogTrigger asChild><Button size="sm">Request plugin/tool</Button></DialogTrigger>
<DialogContent className={ANALYTICS_MASK_CLASS} showCloseButton={!submission.isPending}>
{submission.isSuccess ? <>
<DialogHeader>
<DialogTitle>Request submitted</DialogTitle>
<DialogDescription>Your request was saved as company task {submission.data.identifier}.</DialogDescription>
</DialogHeader>
<DialogFooter><DialogClose asChild><Button>Done</Button></DialogClose></DialogFooter>
</> : <>
<DialogHeader>
<DialogTitle>Request a plugin or tool</DialogTitle>
<DialogDescription>Your request will be saved as a company task.</DialogDescription>
</DialogHeader>
<form className="grid gap-5" onSubmit={(event) => {
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,
});
}}>
<div className="grid gap-2">
<Label htmlFor="requested-plugin-name">Plugin or tool name</Label>
<Input id="requested-plugin-name" name="name" defaultValue={searchedName.trim()} />
</div>
<div className="grid gap-2">
<Label htmlFor="requested-plugin-url">Website (optional)</Label>
<Input id="requested-plugin-url" name="url" type="url" placeholder="https://example.com" />
</div>
<div className="flex items-center gap-2">
<Checkbox id="requested-plugin-notify" checked={notify} onCheckedChange={(checked) => setNotify(checked === true)} />
<Label htmlFor="requested-plugin-notify">Email me when this integration is available</Label>
</div>
{notify && <div className="grid gap-2">
<Label htmlFor="requested-plugin-email">Notification email</Label>
<Input id="requested-plugin-email" name="email" type="email" autoComplete="email" required />
</div>}
{submission.error && <p role="alert" className="text-sm text-destructive">
Couldn’t submit your request. {describeError(submission.error).body}
</p>}
<DialogFooter className="flex-row items-center justify-between sm:justify-between">
<DialogClose asChild><Button type="button" variant="ghost" disabled={submission.isPending}>Cancel</Button></DialogClose>
<Button type="submit" disabled={!selectedCompanyId || submission.isPending}>
{submission.isPending ? "Submitting…" : "Submit request"}
</Button>
</DialogFooter>
</form>
</>}
</DialogContent>
</Dialog>
);
}