Separate GitHub bot opt-in and add review detail pages

Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-10-07 16:17:14 -05:00
1 parent 7c1d2503db
commit 7dcdbe7eb6
36 files changed
+647 -204

No files matched your search

+26 -8
View File
@@ -11,6 +11,10 @@ required GitHub checks, read
## Set up a bot
Enable **GitHub review bots** in instance **Experimental** settings, then open
the GitHub Code Review Bot connector. This default-off setting is independent of
**Chat connectors**. Hiding either feature does not pause existing provider delivery.
1. Choose the bot agent. Prefer a
[low-trust review agent](https://docs.paperclip.ing/administration/trust-and-low-trust-review/)
with an isolated sandbox and a scoped task boundary. Standard-trust agents
@@ -62,13 +66,16 @@ selected environment.
- **Settings:** edit instructions, choose when the bot runs, and set review output.
Event-specific instructions, filters, formal approvals, and repository overrides
are available in disclosures.
- **Access:** choose enabled repositories, allowed people, each person’s automatic
events, and the bot’s GitHub tools. Repository switches save immediately. Other
- **Access:** choose enabled repositories, allowed people, and each person's
**Run automatically** setting. Repository switches save immediately. Other
changes use **Save changes**. A linked account alone does not grant selected-member
access. External contributors still require a sponsor and restricted permissions.
- **Reviews:** see the latest review for each pull request. The result names the
reviewed commit; earlier reviews remain in history. A previous passing result
does not stand in for a pending review of a newer commit.
access. **Add external contributor** still requires a sponsor and restricted
permissions. Bot tools are enabled during setup; a previously disabled connection
exposes an explicit repair action without silently changing its permissions.
- **Reviews:** see every assessment as one row, newest first. Open a row for its
summary, commit, findings, coverage, and task/run/publication links. Each review
has its own URL. A previous passing result does not stand in for a pending review
of a newer commit.
- **Conversations:** follow the task title to Paperclip or the repository/thread
label to GitHub.
@@ -88,7 +95,13 @@ for that person are a separate choice. Guests receive no company membership or
sponsor credentials. Authority is checked again before tool calls and
publication, so revocation also affects queued or ongoing work.
Automatic events use the configured responsible member. The PR author and
**Run automatically** allows the person's authored PRs and issues to trigger
the automatic events selected in Settings. Turning it off keeps authorized
mentions available while avoiding work on every PR or issue.
Automatic tasks use the configured responsible Paperclip member for accountability,
not that member's personal GitHub credentials. A member named **Board** in a local
test drive is still the responsible user, not a separate GitHub actor. The PR author and
webhook sender are recorded independently. Follow-ups preserve task ownership
while checking the current requester's authority.
@@ -145,7 +158,12 @@ hostname, or the connector's Reviews page when no task has been created yet.
Formal **APPROVE** and **REQUEST_CHANGES** are separate governed tools, each off
by default. Enabling either does not automatically perform it. A score of 5/5
alone never approves a PR.
alone never approves a PR. The agent must finish an assessment and explicitly
choose the allowed action. **Allow approvals** permits a formal ready-to-merge
decision; **Allow request changes** permits a formal change request, which can
prevent merging when the repository's review rules require resolution. Keeping
these off leaves scores, comments, and checks available while making formal
review decisions opt-in. The controls include contextual tooltips.
To enforce the rating at merge time, configure GitHub branch protection or a
ruleset to require **Paperclip Review**, selecting this bot App as the source
@@ -285,3 +285,43 @@ head presentation, and GitHub thread labels. The affected management, setup,
AgentMail, sidebar, and shared UI-contract group has 47 passing tests. Repository
typecheck/build, Storybook build, and token gates pass. The earlier full-suite
failure and outstanding current-head CI/review remain as recorded above.
### Independent GitHub setting and review detail qualification
GitHub review bots now use their own default-off instance experimental setting.
The shared validator, persisted settings, managed feature catalog, setup and
management routes, catalog, agent channels, task controls, identity-link admission,
and agent connector discovery use that setting independently from chat connectors.
Existing event delivery is not paused merely by hiding the UI.
The same local test drive was restarted and inspected with **GitHub review bots
on and Chat connectors off**. Connectors showed both GitHub tools and the dedicated
review bot. Opening Animal Bot still reached Settings and Access. Reviews showed
the two real commit assessments as separate rows. Each row opened its own detail
URL with the exact commit, Markdown summary, rationale, coverage, and task/run,
GitHub comment, and check links. Reload retained the detail route; All reviews
returned to the list. The detail kept the Reviews contextual navigation. Desktop
and 390px list/detail layouts were inspected.
Formal approval and request-changes controls retain their off defaults and have
tooltips describing explicit actions after a completed assessment, independent
of scores and checks. **Run automatically** explains each person's authored
PR/issue scheduling and preserves mention-only access when disabled. The
responsible-member tooltip explains Paperclip accountability without personal
credential delegation. The tooltips were opened in the live UI, including the
approval tooltip at 390px. **Add external contributor** replaces the old label.
The normal bot-tools switch is removed; saved disabled restrictions remain
disabled until an explicit repair is saved. No bot configuration was changed
by this walkthrough. A final read found revision 7 with a separately saved
PR-opened prompt change relative to the previous revision-6 snapshot; that edit
was preserved. Tools, repository access, and formal review permissions remain
unchanged.
Focused verification: 388 UI tests and 134 backend/shared settings and identity
tests pass. The added connector-discovery integration test passes with a disposable
local PostgreSQL database; the sandbox-only attempt skipped because it could not
open the database port. The management UI group was rerun after the final tooltip
copy edit and passes. Repository typecheck/build, production Storybook build,
and token gates pass; the final discovery change also received focused server
typecheck/build. These checks do not qualify a new provider or model run. The
earlier full-suite failure and outstanding current-head CI/review still apply.
+8 -1
View File
@@ -120,10 +120,17 @@ export const INSTANCE_FEATURE_CATALOG: Record<InstanceFeatureKey, FeatureCatalog
cloudDefault: false,
selfHostedDefault: false,
},
enableGitHubReviewBots: {
title: "GitHub review bots",
description: "Show GitHub review bot setup and management independently of chat connectors. Existing bots keep running when hidden; GitHub tool connections are unaffected.",
tier: "managed",
cloudDefault: false,
selfHostedDefault: false,
},
enableChatConnectors: {
title: "Chat connectors",
description:
"Show experimental chat connector setup and Board surfaces. Existing connections keep running when hidden; AgentMail, GitHub tools, and other tool connectors are unaffected.",
"Show experimental chat connector setup and Board surfaces. Existing connections keep running when hidden; AgentMail, GitHub review bots, and tool connectors are unaffected.",
tier: "managed",
cloudDefault: false,
selfHostedDefault: false,
+2
View File
@@ -71,6 +71,8 @@ export interface InstanceExperimentalSettings {
enableApps: boolean;
/** Exposes chat connector setup and Board surfaces; existing delivery continues when hidden. */
enableChatConnectors: boolean;
/** Show GitHub review bot setup and management independently of chat connectors. */
enableGitHubReviewBots: boolean;
/** Allow person-authorized assistant tools and task event delivery. */
enablePublicMcp: boolean;
/** @deprecated Compatibility key only. MCP aggregators are always enabled. */
@@ -5,6 +5,10 @@ import {
} from "./instance.js";
describe("instance experimental settings validators", () => {
it("defaults GitHub review bots off independently of chat and accepts explicit changes", () => {
expect(instanceExperimentalSettingsSchema.parse({ enableChatConnectors: true }).enableGitHubReviewBots).toBe(false);
expect(patchInstanceExperimentalSettingsSchema.parse({ enableGitHubReviewBots: true })).toEqual({ enableGitHubReviewBots: true });
});
it("defaults chat connectors off independently of Apps and accepts only explicit boolean patches", () => {
expect(instanceExperimentalSettingsSchema.parse({}).enableChatConnectors).toBe(false);
expect(instanceExperimentalSettingsSchema.parse({ enableApps: true }).enableChatConnectors).toBe(false);
@@ -53,6 +53,7 @@ export const instanceExperimentalSettingsSchema = z.object({
enableApps: z.boolean().default(true),
enablePublicMcp: z.boolean().default(false),
enableChatConnectors: z.boolean().default(false),
enableGitHubReviewBots: z.boolean().default(false),
// Compatibility only: old stored and managed values must still parse.
enableMcpAggregators: z.boolean().default(true),
enableMemoryConnectors: z.boolean().default(false),
@@ -38,6 +38,7 @@ import { materializeNativeInteractionResponses } from "../services/native-runtim
import { toolAccessService } from "../services/tool-access.js";
import { toolAccessPolicyService } from "../services/tool-access-policy.js";
import { connectionIntentService } from "../services/connection-intents.js";
import { instanceSettingsService } from "../services/instance-settings.js";
import {
getEmbeddedPostgresTestSupport,
startEmbeddedPostgresTestDatabase,
@@ -198,6 +199,29 @@ describeEmbeddedPostgres("connectionIntentService", () => {
expect(serialized).not.toContain(claims.sub);
});
it("discovers GitHub review bots independently from chat connectors", async () => {
const settings = instanceSettingsService(db);
const previous = await settings.getExperimental();
const service = connectionIntentService(db);
try {
await settings.updateExperimental({ enableChatConnectors: false, enableGitHubReviewBots: true });
expect((await service.search(claims, "github")).results).toEqual(expect.arrayContaining([
expect.objectContaining({ service: "github-code-review-bot" }),
expect.objectContaining({ service: "github" }),
]));
expect((await service.search(claims, "slack")).results.some(item =>
item.methods.some(method => method.purpose === "channel"))).toBe(false);
await settings.updateExperimental({ enableChatConnectors: true, enableGitHubReviewBots: false });
expect((await service.search(claims, "github")).results.some(item =>
item.service === "github-code-review-bot")).toBe(false);
} finally {
await settings.updateExperimental({
enableChatConnectors: previous.enableChatConnectors,
enableGitHubReviewBots: previous.enableGitHubReviewBots,
});
}
});
it("creates one addressed request, resolves after install, and then reports ready for the responsible user", async () => {
const service = connectionIntentService(db);
const first = await service.request(claims, "notion");
@@ -16,6 +16,11 @@ describe("instance settings service", () => {
const disabled = applyExperimentalSettingsPatch(enabled, { enableChatConnectors: false });
expect(disabled).toMatchObject({ enableApps: true, enableChatConnectors: false });
});
it("keeps GitHub review bots independent across legacy normalization and persistence", () => {
expect(normalizeExperimentalSettings({ enableChatConnectors: true })).toMatchObject({ enableChatConnectors: true, enableGitHubReviewBots: false });
const saved = applyExperimentalSettingsPatch({}, { enableGitHubReviewBots: true });
expect(normalizeExperimentalSettings(JSON.parse(JSON.stringify(saved)))).toMatchObject({ enableChatConnectors: false, enableGitHubReviewBots: true });
});
it("ignores retired experimental flags without resetting current settings", () => {
expect(normalizeExperimentalSettings({
enableEnvironments: true,
@@ -48,6 +53,7 @@ describe("instance settings service", () => {
enablePublicMcp: false,
enableCombinedInboxTasks: false,
enableChatConnectors: false,
enableGitHubReviewBots: false,
enableMemoryConnectors: false,
enableConferenceRoomChat: false,
enableClassicTaskInterface: false,
@@ -65,6 +65,19 @@ describe("chat identity-link preview authority", () => {
expect(f.requestIdentityAccess).not.toHaveBeenCalled();
});
it.each(["github", "slack"])("uses the token’s verified provider when only GitHub bots are enabled (%s)", async (provider) => {
settings.getExperimental.mockResolvedValue({ enableChatConnectors: false, enableGitHubReviewBots: true });
const f = fixture();
f.previewIdentityLink.mockResolvedValue({ ...preview, provider } as typeof preview);
await request(f.app).get("/api/chat-identity-links/preview").query({ token }).expect(provider === "github" ? 200 : 403);
await request(f.app).post("/api/chat-identity-links/confirm").send({ token }).expect(provider === "github" ? 200 : 403);
expect(f.confirmIdentityLink.mock.calls.length).toBe(provider === "github" ? 1 : 0);
});
it("does not admit GitHub links under chat-only opt-in", async () => {
const f = fixture();
f.previewIdentityLink.mockResolvedValue({ ...preview, provider: "github" } as unknown as typeof preview);
await request(f.app).get("/api/chat-identity-links/preview").query({ token }).expect(403);
});
it("returns the preview to a Board member of its exact company", async () => {
const { app, previewIdentityLink } = fixture();
const response = await request(app)
+22 -6
View File
@@ -92,16 +92,27 @@ export function chatChannelRoutes(db: Db, options: ChatChannelRouteOptions) {
const access = accessService(db);
const github = githubChatManagementService(db, options.fetch);
async function assertIdentityLinkAccess(req: ExpressRequest): Promise<string> {
async function assertIdentityLinkAccess(req: ExpressRequest) {
assertBoard(req);
const userId = actorUserId(req);
if (!userId) throw badRequest("A signed-in Paperclip user is required");
// Enforce rollout here: invited nonmembers cannot read the board's
// experimental-settings API. A private token never bypasses this gate.
if (!(await instanceSettingsService(db).getExperimental()).enableChatConnectors) {
const experimental = await instanceSettingsService(db).getExperimental();
if (!experimental.enableChatConnectors && !experimental.enableGitHubReviewBots) {
throw forbidden("Chat connectors are not enabled on this instance");
}
return userId;
return { userId, experimental };
}
function assertIdentityProviderEnabled(
provider: string,
experimental: { enableChatConnectors: boolean; enableGitHubReviewBots: boolean },
) {
const enabled = provider === "agentmail" || (provider === "github"
? experimental.enableGitHubReviewBots
: experimental.enableChatConnectors);
if (!enabled) throw forbidden("This connector is not enabled on this instance");
}
async function assertConnectionManager(
@@ -353,18 +364,22 @@ export function chatChannelRoutes(db: Db, options: ChatChannelRouteOptions) {
"/chat-identity-links/confirm",
validate(confirmChatIdentityLinkSchema),
async (req, res) => {
const userId = await assertIdentityLinkAccess(req);
const { userId, experimental } = await assertIdentityLinkAccess(req);
const preview = await service.previewIdentityLink(req.body.token, userId);
assertIdentityProviderEnabled(preview.provider, experimental);
res.json(await service.confirmIdentityLink(req.body.token, userId));
},
);
router.post("/chat-identity-links/request-access", validate(confirmChatIdentityLinkSchema), async (req, res) => {
const userId = await assertIdentityLinkAccess(req);
const { userId, experimental } = await assertIdentityLinkAccess(req);
const preview = await service.previewIdentityLink(req.body.token, userId);
assertIdentityProviderEnabled(preview.provider, experimental);
res.json(await service.requestIdentityAccess(req.body.token, userId, req.ip ?? "unknown"));
});
router.get("/chat-identity-links/preview", async (req, res) => {
const userId = await assertIdentityLinkAccess(req);
const { userId, experimental } = await assertIdentityLinkAccess(req);
const token = typeof req.query.token === "string" ? req.query.token : "";
if (token.length < 32 || token.length > 4096)
throw badRequest("A valid identity-link token is required");
@@ -379,6 +394,7 @@ export function chatChannelRoutes(db: Db, options: ChatChannelRouteOptions) {
req, res, Promise.resolve(invitation), "Identity-link request not found",
);
if (!preview) return;
assertIdentityProviderEnabled(preview.provider, experimental);
res.json(preview);
});
+2 -1
View File
@@ -409,7 +409,8 @@ export function connectionIntentService(db: Db) {
const candidates: Array<{ item: ConnectionSearchResultItem; score: number; nameScore: number }> = [];
const authorizedCatalogs = new Map<string, Awaited<ReturnType<typeof indexedCatalog>>>();
const discoveryMethods = (app: (typeof APP_STORE_DEFINITIONS)[number]) => getAvailableConnectionMethods(app)
.filter(method => method.purpose !== "channel" || app.slug === "agentmail" || settings.enableChatConnectors);
.filter(method => method.purpose !== "channel" || app.slug === "agentmail"
|| (method.provider === "github" ? settings.enableGitHubReviewBots : settings.enableChatConnectors));
const services = [...APP_STORE_DEFINITIONS.filter(app => discoveryMethods(app).length).map((app) => app.slug),
...inventory.connections.filter((connection) =>
sourceSlugForConnection(connection, inventory.applicationsById)?.startsWith("connection:")
+2
View File
@@ -235,6 +235,7 @@ export function normalizeExperimentalSettings(raw: unknown): InstanceExperimenta
enableMcpAggregators: true,
enablePublicMcp: parsed.data.enablePublicMcp ?? false,
enableChatConnectors: parsed.data.enableChatConnectors ?? false,
enableGitHubReviewBots: parsed.data.enableGitHubReviewBots ?? false,
enableMemoryConnectors: parsed.data.enableMemoryConnectors ?? false,
enablePipelines: parsed.data.enablePipelines ?? false,
enableCases: parsed.data.enableCases ?? false,
@@ -281,6 +282,7 @@ export function normalizeExperimentalSettings(raw: unknown): InstanceExperimenta
enableMcpAggregators: true,
enablePublicMcp: false,
enableChatConnectors: false,
enableGitHubReviewBots: false,
enableMemoryConnectors: false,
enablePipelines: false,
enableCases: false,
+5 -2
View File
@@ -214,6 +214,9 @@ function boardRoutes(streamlinedUiEnabled: boolean, combinedInboxTasksEnabled: b
<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>
} />
@@ -483,8 +486,8 @@ function AppsConnectEntryRoute({
} = {}) {
const location = useLocation();
const searchParams = new URLSearchParams(location.search);
const { enabled: chatConnectorsEnabled } = useChatConnectorsEnabled();
return canEnterAppsConnect(searchParams, { chatConnectorsEnabled })
const { enabled: chatConnectorsEnabled, githubEnabled: githubReviewBotsEnabled } = useChatConnectorsEnabled();
return canEnterAppsConnect(searchParams, { chatConnectorsEnabled, githubReviewBotsEnabled })
? <AppsConnect credentialSource={credentialSource} />
: <Navigate to="/apps" replace />;
}
+1 -1
View File
@@ -39,7 +39,7 @@ export function AppsSidebar() {
);
if (pathname.endsWith("/apps/chat/connect")) return <ChatSetupSidebar />;
const chatDetail = pathname.match(/\/apps\/chat\/([^/]+)(?:\/(?:settings|access|reviews|conversations|activity))?\/?$/);
const chatDetail = pathname.match(/\/apps\/chat\/([^/]+)(?:\/(?:settings|access|conversations|activity)|\/reviews(?:\/[^/]+)?)?\/?$/);
if (chatDetail) return <ChatDetailSidebar endpointId={chatDetail[1]} NavItem={SidebarNavItem} />;
return (
+1 -1
View File
@@ -27,7 +27,7 @@ export function AppsSidebar() {
});
if (pathname.endsWith("/apps/chat/connect")) return <ChatSetupSidebar />;
const chatDetail = pathname.match(/\/apps\/chat\/([^/]+)(?:\/(?:settings|access|reviews|conversations|activity))?\/?$/);
const chatDetail = pathname.match(/\/apps\/chat\/([^/]+)(?:\/(?:settings|access|conversations|activity)|\/reviews(?:\/[^/]+)?)?\/?$/);
if (chatDetail) return <ChatDetailSidebar endpointId={chatDetail[1]} />;
return (
@@ -104,6 +104,31 @@ describe("Chat connectors visibility gate", () => {
await vi.waitFor(() => expect(Boolean(container.querySelector("[data-chat-setup]"))).toBe(provider === "agentmail"));
if (provider !== "agentmail") expect(container.querySelector("[data-redirect]")).not.toBeNull();
});
it.each([true, false])("gates GitHub setup by its own flag, not chat (%s)", async (githubEnabled) => {
api.provider = "github";
api.settings.mockResolvedValue({ enableChatConnectors: !githubEnabled, enableGitHubReviewBots: githubEnabled });
await render();
expect(Boolean(container.querySelector("[data-chat-setup]"))).toBe(githubEnabled);
});
it.each(["github", "slack"])("gates each existing endpoint by provider with only GitHub enabled (%s)", async (provider) => {
api.endpointId = "endpoint-1";
api.get.mockResolvedValue({ provider });
api.settings.mockResolvedValue({ enableChatConnectors: false, enableGitHubReviewBots: true });
await render();
await vi.waitFor(() => expect(api.get).toHaveBeenCalledWith("endpoint-1"));
await vi.waitFor(() => expect(Boolean(container.querySelector("[data-chat-setup]"))).toBe(provider === "github"));
});
it("keeps GitHub agent channels visible while hiding Slack under the independent flag", async () => {
api.settings.mockResolvedValue({ enableChatConnectors: false, enableGitHubReviewBots: true });
api.list.mockResolvedValue([
{ provider: "github", id: "github", assignedAgentId: "agent-1", status: "active" },
{ provider: "slack", id: "slack", assignedAgentId: "agent-1", status: "active" },
]);
flushSync(() => root.render(<QueryClientProvider client={client}><AgentChannelsPanel companyId="company-1" agentId="agent-1" /></QueryClientProvider>));
await flushReact();
expect(container.querySelector('a[href="/apps/chat/github/settings"]')).not.toBeNull();
expect(container.querySelector('a[href="/apps/chat/slack/settings"]')).toBeNull();
});
it("waits without exposing setup, then enables the route after explicit opt-in", async () => {
let resolve!: (value: unknown) => void;
api.settings.mockReturnValue(
@@ -3,22 +3,41 @@ import { useQuery } from "@tanstack/react-query";
import { chatEndpointsApi } from "@/api/chatEndpoints";
import { queryKeys } from "@/lib/queryKeys";
import { Button } from "@/components/ui/button";
import { useChatConnectorsEnabled } from "@/hooks/useChatConnectorsEnabled";
import {
useChatConnectorsEnabled,
chatProviderVisible,
} from "@/hooks/useChatConnectorsEnabled";
import { Navigate, useParams, useSearchParams } from "@/lib/router";
function DefaultEmailEndpointGate({ endpointId, children }: { endpointId: string; children: ReactNode }) {
function ProviderEndpointGate({
endpointId,
children,
}: {
endpointId: string;
children: ReactNode;
}) {
const endpoint = useQuery({
queryKey: queryKeys.chatEndpoints.detail(endpointId),
queryFn: () => chatEndpointsApi.get(endpointId),
});
if (endpoint.isError) return (
<div className="space-y-3 p-6">
<p role="alert" className="text-sm text-destructive">{endpoint.error.message}</p>
<Button variant="outline" onClick={() => void endpoint.refetch()}>Retry</Button>
</div>
);
const { enabled, githubEnabled } = useChatConnectorsEnabled();
if (endpoint.isError)
return (
<div className="space-y-3 p-6">
<p role="alert" className="text-sm text-destructive">
{endpoint.error.message}
</p>
<Button variant="outline" onClick={() => void endpoint.refetch()}>
Retry
</Button>
</div>
);
if (!endpoint.data) return null;
return endpoint.data.provider === "agentmail" ? <>{children}</> : <Navigate to="/apps" replace />;
return chatProviderVisible(endpoint.data.provider, enabled, githubEnabled) ? (
<>{children}</>
) : (
<Navigate to="/apps" replace />
);
}
export function ChatConnectorsExperimentalGate({
@@ -26,13 +45,21 @@ export function ChatConnectorsExperimentalGate({
}: {
children: ReactNode;
}) {
const { enabled, loaded } = useChatConnectorsEnabled();
const { enabled, githubEnabled, loaded } = useChatConnectorsEnabled();
const [params] = useSearchParams();
const { endpointId } = useParams<{ endpointId: string }>();
if (!endpointId && params.get("provider") === "agentmail") return <>{children}</>;
if (!endpointId && params.get("provider") === "agentmail")
return <>{children}</>;
if (!loaded) return null;
if (!enabled) return endpointId
? <DefaultEmailEndpointGate endpointId={endpointId}>{children}</DefaultEmailEndpointGate>
: <Navigate to="/apps" replace />;
return <>{children}</>;
if (endpointId)
return (
<ProviderEndpointGate endpointId={endpointId}>
{children}
</ProviderEndpointGate>
);
return chatProviderVisible(params.get("provider"), enabled, githubEnabled) ? (
<>{children}</>
) : (
<Navigate to="/apps" replace />
);
}
@@ -5,7 +5,7 @@ import { Button } from "@/components/ui/button";
import { StatusBadge } from "@/components/StatusBadge";
import { queryKeys } from "@/lib/queryKeys";
import { Link } from "@/lib/router";
import { useChatConnectorsEnabled } from "@/hooks/useChatConnectorsEnabled";
import { useChatConnectorsEnabled, chatProviderVisible } from "@/hooks/useChatConnectorsEnabled";
const providerNames: Record<ChatProvider, string> = {
slack: "Slack",
@@ -24,7 +24,7 @@ export function AgentChannelsPanel({
companyId: string;
agentId: string;
}) {
const { enabled } = useChatConnectorsEnabled();
const { enabled, githubEnabled } = useChatConnectorsEnabled();
const query = useQuery({
queryKey: queryKeys.chatEndpoints.list(companyId),
queryFn: () => chatEndpointsApi.list(companyId),
@@ -32,7 +32,7 @@ export function AgentChannelsPanel({
});
const endpoints = (query.data ?? []).filter(
(endpoint) =>
endpoint.assignedAgentId === agentId && endpoint.status !== "archived" && (endpoint.provider === "agentmail" || enabled),
endpoint.assignedAgentId === agentId && endpoint.status !== "archived" && chatProviderVisible(endpoint.provider, enabled, githubEnabled),
);
return (
<section className="max-w-3xl space-y-5">
@@ -56,7 +56,7 @@ export function AgentChannelsPanel({
<div className="rounded-lg border border-dashed border-border p-5">
<p className="text-sm font-medium">No channels connected</p>
<p className="mt-1 text-sm text-muted-foreground">
{enabled ? "Connect AgentMail, Slack, GitHub Code Review Bot, Discord, Microsoft Teams, or Telegram from Connectors." : "Connect AgentMail from Connectors."}
{enabled || githubEnabled ? "Connect an agent identity from Connectors." : "Connect AgentMail from Connectors."}
</p>
<Button asChild className="mt-3" variant="outline" size="sm">
<Link to="/apps">Open Connectors</Link>
@@ -51,7 +51,6 @@ export function ChatDetailSidebar({
to={`/apps/chat/${endpointId}/reviews`}
label="Reviews"
icon={GitPullRequest}
end
/>
)}
<NavItem
@@ -18,7 +18,7 @@ import { Textarea } from "@/components/ui/textarea";
import { useToast } from "@/context/ToastContext";
import { Link } from "@/lib/router";
import { queryKeys } from "@/lib/queryKeys";
import { useChatConnectorsEnabled } from "@/hooks/useChatConnectorsEnabled";
import { useChatConnectorsEnabled, chatProviderVisible } from "@/hooks/useChatConnectorsEnabled";
import { issuesApi } from "@/api/issues";
import {
boardSendDraftKey,
@@ -109,15 +109,15 @@ const filePhaseLabels: Record<ChatFileTransferPhase, string> = {
};
export function useIssueChatBinding(companyId: string, issueId: string) {
const { enabled } = useChatConnectorsEnabled();
const queryEnabled = enabled && Boolean(companyId && issueId) && !issueId.startsWith("chat:");
const { enabled, githubEnabled } = useChatConnectorsEnabled();
const queryEnabled = (enabled || githubEnabled) && Boolean(companyId && issueId) && !issueId.startsWith("chat:");
const query = useQuery({
queryKey: ["issue-chat-binding", companyId, issueId],
queryFn: () => chatEndpointsApi.getIssueBinding(issueId),
enabled: queryEnabled,
});
return {
binding: queryEnabled ? (query.data ?? null) : null,
binding: queryEnabled && chatProviderVisible(query.data?.provider, enabled, githubEnabled) ? (query.data ?? null) : null,
isLoading: queryEnabled && query.isLoading,
};
}
@@ -58,7 +58,7 @@ import { useNavigate, useParams, useSearchParams } from "@/lib/router";
import { useCompany } from "@/context/CompanyContext";
import { useBreadcrumbs } from "@/context/BreadcrumbContext";
import { useToast } from "@/context/ToastContext";
import { useChatConnectorsEnabled } from "@/hooks/useChatConnectorsEnabled";
import { useChatConnectorsEnabled, chatProviderVisible } from "@/hooks/useChatConnectorsEnabled";
import { queryKeys } from "@/lib/queryKeys";
import { RadioCardGroup } from "@/components/ui/radio-card";
import { ApiError } from "@/api/client";
@@ -600,7 +600,7 @@ function StandardConnectionSetupFlow({
}, [host, routeNavigate]);
const routeParams = useParams<{ appKey?: string }>();
const { selectedCompany, selectedCompanyId } = useCompany();
const { enabled: chatConnectorsEnabled } = useChatConnectorsEnabled();
const { enabled: chatConnectorsEnabled, githubEnabled } = useChatConnectorsEnabled();
const { enabled: memoryConnectorsEnabled } = useMemoryConnectorsEnabled();
const { setBreadcrumbs } = useBreadcrumbs();
const { pushToast } = useToast();
@@ -985,11 +985,11 @@ function StandardConnectionSetupFlow({
// Generic custom URLs remain usable without selecting a hidden provider.
const visibleGalleryApps = useMemo(
() => (galleryQuery.data?.apps ?? []).filter((app) => memoryConnectorsEnabled || !isMemoryConnectorId(app.slug)).filter((app) =>
app.slug === "agentmail" || chatConnectorsEnabled ||
chatProviderVisible(app.slug, chatConnectorsEnabled, githubEnabled) ||
!app.methods.some((method) => method.transport === "chat_sdk") ||
appSupportsToolCatalogSetup(app),
),
[galleryQuery.data, chatConnectorsEnabled, memoryConnectorsEnabled],
[galleryQuery.data, chatConnectorsEnabled, githubEnabled, memoryConnectorsEnabled],
);
const fullRequestedDefinition = requestedAppKey
? getConnectableAppDefinition(requestedAppKey)
+19 -2
View File
@@ -9,10 +9,11 @@ import { queryKeys } from "@/lib/queryKeys";
let detachedClient: QueryClient | null = null;
/** One default-off visibility gate; this does not pause existing provider delivery. */
/** Independent default-off visibility gates; these do not pause existing provider delivery. */
export function useChatConnectorsEnabled(): {
enabled: boolean;
loaded: boolean;
githubEnabled: boolean;
} {
const contextClient = useContext(QueryClientContext);
const { data, isFetched, isError } = useQuery(
@@ -23,9 +24,25 @@ export function useChatConnectorsEnabled(): {
},
contextClient ?? (detachedClient ??= new QueryClient()),
);
if (!contextClient) return { enabled: false, loaded: true };
if (!contextClient)
return { enabled: false, githubEnabled: false, loaded: true };
return {
enabled: !isError && data?.enableChatConnectors === true,
githubEnabled: !isError && data?.enableGitHubReviewBots === true,
loaded: isFetched,
};
}
/** Provider visibility only; never changes an existing connection's permissions. */
export function chatProviderVisible(
provider: string | null | undefined,
chatEnabled: boolean,
githubEnabled: boolean,
) {
return (
provider === "agentmail" ||
(provider === "github" || provider === "github-code-review-bot"
? githubEnabled
: chatEnabled)
);
}
+2 -1
View File
@@ -769,7 +769,8 @@ export function AgentDetail() {
const navigate = useNavigate();
const [actionError, setActionError] = useState<string | null>(null);
const [dismissedLeftAgentIds, setDismissedLeftAgentIds] = useState<Set<string>>(() => new Set());
const { enabled: chatConnectorsEnabled, loaded: chatConnectorsLoaded } = useChatConnectorsEnabled();
const { enabled: chatEnabled, githubEnabled, loaded: chatConnectorsLoaded } = useChatConnectorsEnabled();
const chatConnectorsEnabled = chatEnabled || githubEnabled;
const activeView = urlRunId ? "runs" as AgentDetailView
: urlTab === "channels" && !chatConnectorsEnabled ? "dashboard" : parseAgentDetailView(urlTab ?? null);
const needsDashboardData = activeView === "dashboard";
@@ -87,6 +87,7 @@ function defaultExperimentalSettings(): InstanceExperimentalSettingsPayload {
enableMcpAggregators: true,
enablePublicMcp: false,
enableChatConnectors: false,
enableGitHubReviewBots: false,
enableMemoryConnectors: false,
enablePipelines: false,
enableCases: false,
@@ -283,6 +284,18 @@ describe("InstanceExperimentalSettings — Conference Room Chat card (PAP-11233)
}
});
it("toggles GitHub review bots without enabling chat connectors", async () => {
await renderPage();
const selector = 'button[aria-label="Toggle GitHub review bots experimental setting"]';
expect(container.querySelector(selector)?.getAttribute("aria-checked")).toBe("false");
for (const enabled of [true, false]) {
await act(() => container.querySelector<HTMLButtonElement>(selector)!.click());
await flushReact();
expect(mockInstanceSettingsApi.updateExperimental).toHaveBeenLastCalledWith({ enableGitHubReviewBots: enabled });
expect(currentExperimentalSettings.enableChatConnectors).toBe(false);
}
});
it("does not render the Conference Room Chat experimental setting for now", async () => {
await renderPage();
+14 -2
View File
@@ -354,8 +354,8 @@ export function InstanceExperimentalSettings() {
<ExperimentalToggleCard
title="Chat connectors"
description="Connect agents to Slack, GitHub, Discord, Microsoft Teams, and Telegram conversations."
footnote="Turning this off hides experimental chat setup and connected-task controls. Existing chat connections keep running. AgentMail, GitHub tools, and other tool connectors stay available."
description="Connect agents to Slack, Discord, Microsoft Teams, and Telegram conversations."
footnote="Turning this off hides experimental chat setup and connected-task controls. Existing chat connections keep running. AgentMail, GitHub review bots, and tool connectors are controlled separately."
checked={enableChatConnectors}
onCheckedChange={(checked) => toggleMutation.mutate({ enableChatConnectors: checked })}
disabled={toggleMutation.isPending}
@@ -457,6 +457,18 @@ export function InstanceExperimentalSettings() {
ariaLabel="Toggle first task plan proposal experimental setting"
/>
<ExperimentalToggleCard
title="GitHub review bots"
description="Connect agents to GitHub with their own App identity to review pull requests and respond to issues."
footnote="Independent of Chat connectors. Turning this off hides setup and management; existing bots keep running. GitHub tool connections stay available."
checked={experimentalQuery.data?.enableGitHubReviewBots === true}
onCheckedChange={(checked) => toggleMutation.mutate({ enableGitHubReviewBots: checked })}
disabled={toggleMutation.isPending}
settingKey="enableGitHubReviewBots"
managed={managedKeys.enableGitHubReviewBots}
ariaLabel="Toggle GitHub review bots experimental setting"
/>
<ExperimentalToggleCard
title="Memory connectors"
description="Connect Mem0, Zep, Supermemory, Cognee, and Honcho for long-term memory and context."
+6 -3
View File
@@ -189,7 +189,7 @@ describe("Connectors landing page", () => {
manageComposioAppAccountMock.mockReset();
listAgentsMock.mockResolvedValue([{ id: "default-agent", name: "Default agent", role: "ceo", reportsTo: null, status: "active", createdAt: new Date(0) }]);
aggregatorCatalogMock.splice(0);
experimentalMock.mockResolvedValue({ enableChatConnectors: true });
experimentalMock.mockResolvedValue({ enableChatConnectors: true, enableGitHubReviewBots: true });
chatListMock.mockResolvedValue([]);
chatSetupMock.mockReset().mockResolvedValue({ status: "archived" });
emailControlMock.mockReset().mockResolvedValue({ status: "archived" });
@@ -993,7 +993,7 @@ describe("Connectors landing page", () => {
expect(container.querySelector('button[aria-label="Add key GitHub"]')).toBeNull();
});
it("separates tools and saved bots and hides only bots when chat connectors are disabled", async () => {
it("separates tools and saved bots and gates bots independently of chat connectors", async () => {
listGalleryMock.mockResolvedValue({ apps: ["github", "github-code-review-bot"].map(getAppStoreDefinition) });
listApplicationsMock.mockResolvedValue({ applications: [
application({ id: "github-tools", name: "GitHub", metadata: { sourceTemplateKey: "github" } }),
@@ -1023,7 +1023,10 @@ describe("Connectors landing page", () => {
const finish = [...bots.querySelectorAll("button")].find((button) => button.textContent === "Finish setup")!;
await act(() => finish.click());
expect(navigateMock).toHaveBeenLastCalledWith("/apps/chat/connect?provider=github&purpose=chat&resume=endpoint-2");
await act(() => { client.setQueryData(queryKeys.instance.experimentalSettings, { enableChatConnectors: false }); });
await act(() => { client.setQueryData(queryKeys.instance.experimentalSettings, { enableChatConnectors: false, enableGitHubReviewBots: true }); });
await flushReact();
expect(container.querySelector('[data-app-slug="github-code-review-bot"]')).not.toBeNull();
await act(() => { client.setQueryData(queryKeys.instance.experimentalSettings, { enableChatConnectors: true, enableGitHubReviewBots: false }); });
await flushReact();
expect(container.querySelector('[data-app-slug="github-code-review-bot"]')).toBeNull();
expect(container.textContent).not.toContain("Review agent");
+11 -7
View File
@@ -40,7 +40,7 @@ import {
normalizeConnectionQuery,
} from "@paperclipai/shared";
import { useNavigate } from "@/lib/router";
import { useChatConnectorsEnabled } from "@/hooks/useChatConnectorsEnabled";
import { useChatConnectorsEnabled, chatProviderVisible } from "@/hooks/useChatConnectorsEnabled";
import { useMemoryConnectorsEnabled } from "@/hooks/useMemoryConnectorsEnabled";
import { appCopyFor } from "@/lib/app-gallery-copy";
import { useCompany } from "@/context/CompanyContext";
@@ -332,7 +332,7 @@ export function Browse({ renderAccountDetails = (connection) => connection.conne
const { selectedCompanyId } = useCompany();
const assistantConnections = useAssistantConnections();
const { userId: viewingUserId, settled: identitySettled } = useAccountIdentity();
const { enabled: chatConnectorsEnabled } = useChatConnectorsEnabled();
const { enabled: chatConnectorsEnabled, githubEnabled } = useChatConnectorsEnabled();
const { enabled: memoryConnectorsEnabled } = useMemoryConnectorsEnabled();
const { setBreadcrumbs } = useBreadcrumbs();
const [query, setQuery] = useState("");
@@ -486,7 +486,7 @@ export function Browse({ renderAccountDetails = (connection) => connection.conne
if (!memoryConnectorsEnabled && isMemoryConnectorId(appDefinitionSlug(entry))) return false;
const definition = getAppStoreDefinition(appDefinitionSlug(entry));
return (
appDefinitionSlug(entry) === "agentmail" || chatConnectorsEnabled ||
chatProviderVisible(appDefinitionSlug(entry), chatConnectorsEnabled, githubEnabled) ||
!definition?.methods.some((method) => method.purpose === "channel") ||
appSupportsToolCatalogSetup(definition)
);
@@ -536,7 +536,7 @@ export function Browse({ renderAccountDetails = (connection) => connection.conne
slug,
name: appDefinitionName(entry),
description:
!chatConnectorsEnabled && slug !== "agentmail" && chatProviderForSlug(slug)
!chatProviderVisible(slug, chatConnectorsEnabled, githubEnabled) && chatProviderForSlug(slug)
? appCopyFor(slug).tagline
: appDefinitionDescription(entry),
brandKey: slug,
@@ -581,7 +581,7 @@ export function Browse({ renderAccountDetails = (connection) => connection.conne
"Chat with agents from Telegram direct messages, groups, and topics.",
},
] as const;
for (const item of nativeChatApps.filter(item => item.slug === "agentmail" || chatConnectorsEnabled)) {
for (const item of nativeChatApps.filter(item => chatProviderVisible(item.slug, chatConnectorsEnabled, githubEnabled))) {
if (rowsBySlug.has(item.slug)) continue;
rowsBySlug.set(item.slug, {
key: `native-chat:${item.slug}`,
@@ -678,7 +678,7 @@ export function Browse({ renderAccountDetails = (connection) => connection.conne
});
}
for (const endpoint of (chatEndpointsQuery.data ?? []).filter(endpoint => endpoint.provider === "agentmail" || chatConnectorsEnabled)) {
for (const endpoint of (chatEndpointsQuery.data ?? []).filter(endpoint => chatProviderVisible(endpoint.provider, chatConnectorsEnabled, githubEnabled))) {
if (endpoint.status === "archived") continue;
let target = [...rowsBySlug.values()].find(
(row) => chatProviderForSlug(row.slug) === endpoint.provider,
@@ -754,6 +754,7 @@ export function Browse({ renderAccountDetails = (connection) => connection.conne
applicationsQuery.data,
chatEndpointsQuery.data,
chatConnectorsEnabled,
githubEnabled,
connectionsQuery.data,
gallery,
galleryQuery.data,
@@ -930,6 +931,7 @@ export function Browse({ renderAccountDetails = (connection) => connection.conne
onRequestRemove={target => void requestConnectionRemoval(target)}
preselectedAgentId={preselectedChatAgentId}
chatConnectorsEnabled={chatConnectorsEnabled}
githubReviewBotsEnabled={githubEnabled}
onConnectAggregator={connectAggregator}
onManageAggregator={(app, connectionId) => setAggregatorToManage({ app, connectionId })}
onRefreshAggregator={connectionId => refreshAggregator.mutate(connectionId)}
@@ -1026,6 +1028,7 @@ export function ConnectorCard({
onRequestRemove,
preselectedAgentId,
chatConnectorsEnabled,
githubReviewBotsEnabled = false,
onConnectAggregator,
onManageAggregator,
onRefreshComposio,
@@ -1044,6 +1047,7 @@ export function ConnectorCard({
onRequestRemove: (target: ConnectionRemovalTarget) => void;
preselectedAgentId?: string | null;
chatConnectorsEnabled: boolean;
githubReviewBotsEnabled?: boolean;
onConnectAggregator?: (app: AggregatorAppCatalogEntry) => void;
onManageAggregator?: (app: AggregatorAppCatalogEntry, connectionId?: string) => void;
onRefreshComposio?: (connectionId: string) => void;
@@ -1056,7 +1060,7 @@ export function ConnectorCard({
}) {
const action = connectorAction(
row,
chatConnectorsEnabled,
chatProviderVisible(row.slug, chatConnectorsEnabled, githubReviewBotsEnabled),
preselectedAgentId,
);
const upstreamAccounts = (row.upstreamApps ?? []).flatMap(snapshot => {
+8 -1
View File
@@ -83,7 +83,7 @@ describe("app connect policy", () => {
const href = appSourceConnectHref(app.slug);
const searchParams = new URL(href, "http://paperclip.test").searchParams;
expect(canEnterAppsConnect(searchParams, { chatConnectorsEnabled: true }), app.slug).toBe(true);
expect(canEnterAppsConnect(searchParams, { chatConnectorsEnabled: true, githubReviewBotsEnabled: true }), app.slug).toBe(true);
expect(resolveAppsConnectRouteKey({ sourceSlug: searchParams.get("source") }), app.slug).toBe(app.slug);
}
});
@@ -97,6 +97,13 @@ describe("app connect policy", () => {
expect(resolveAppsConnectRouteKey({})).toBeUndefined();
});
it("admits the GitHub bot independently of chat setup and keeps tools available", () => {
const bot = new URLSearchParams("source=github-code-review-bot");
expect(canEnterAppsConnect(bot, { chatConnectorsEnabled: true })).toBe(false);
expect(canEnterAppsConnect(bot, { githubReviewBotsEnabled: true })).toBe(true);
expect(canEnterAppsConnect(new URLSearchParams("source=discord"), { githubReviewBotsEnabled: true })).toBe(false);
expect(canEnterAppsConnect(new URLSearchParams("source=github"))).toBe(true);
});
it("retains GitHub tools but denies chat-only deep links while chat connectors are disabled", () => {
expect(canEnterAppsConnect(new URLSearchParams("source=github"))).toBe(true);
expect(canEnterAppsConnect(new URLSearchParams("source=agentmail"))).toBe(true);
+4 -3
View File
@@ -55,7 +55,7 @@ export function resolveAppsConnectRouteKey(input: {
export function canEnterAppsConnect(
searchParams: URLSearchParams,
{ chatConnectorsEnabled = false }: { chatConnectorsEnabled?: boolean } = {},
{ chatConnectorsEnabled = false, githubReviewBotsEnabled = false }: { chatConnectorsEnabled?: boolean; githubReviewBotsEnabled?: boolean } = {},
): boolean {
if (searchParams.get("byo") === "1") {
// The old BYO discovery page has moved to the Connectors list. Keep only
@@ -74,8 +74,9 @@ export function canEnterAppsConnect(
// actionable unavailable state rather than bouncing back to the catalog.
if (/^ai-router-(?:[a-f0-9]{2})+$/.test(source)) return true;
const entry = getAppStoreDefinition(source);
const channelEnabled = source === "github-code-review-bot" ? githubReviewBotsEnabled : chatConnectorsEnabled;
if (
!chatConnectorsEnabled &&
!channelEnabled &&
entry?.methods.some((method) => method.transport === "chat_sdk") &&
!entry.methods.some((method) => (method.purpose ?? "tool") !== "channel" && method.transport !== "chat_sdk")
) return false;
@@ -83,5 +84,5 @@ export function canEnterAppsConnect(
// setup. Admit only known providers here; the setup flow then proves the
// exact reconnect target is visible to the selected company before rendering.
if (getConnectableAppDefinition(source) && searchParams.get("reconnect")?.trim()) return true;
return source === "agentmail" || chatConnectorsEnabled ? appSupportsCatalogSetup(entry) : appSupportsToolCatalogSetup(entry);
return source === "agentmail" || channelEnabled ? appSupportsCatalogSetup(entry) : appSupportsToolCatalogSetup(entry);
}
@@ -227,10 +227,12 @@ export function connectionHealthPresentation(
}
export function ChatEndpointDetail() {
const { endpointId = "", tab = "settings" } = useParams<{
const { endpointId = "", tab: routeTab, reviewId } = useParams<{
endpointId: string;
tab?: string;
reviewId?: string;
}>();
const tab = reviewId ? "reviews" : (routeTab ?? "settings");
const activeTab = tabs.includes(tab as ChatTab) ? (tab as ChatTab) : null;
const navigate = useNavigate();
const { setBreadcrumbs } = useBreadcrumbs();
@@ -260,14 +262,14 @@ export function ChatEndpointDetail() {
label: `${endpoint.assignedAgentName} · ${providerNames[endpoint.provider]}`,
href: `/apps/chat/${endpoint.id}/settings`,
},
{
...(reviewId ? [{ label: "Reviews", href: `/apps/chat/${endpoint.id}/reviews` }, { label: "Review" }] : [{
label:
tabItems.find((item) => item.value === activeTab)?.label ??
"Settings",
},
}]),
]);
return () => setBreadcrumbs([]);
}, [activeTab, endpoint, setBreadcrumbs]);
}, [activeTab, endpoint, reviewId, setBreadcrumbs]);
if (!activeTab)
return <Navigate replace to={`/apps/chat/${endpointId}/settings`} />;
@@ -339,7 +341,7 @@ export function ChatEndpointDetail() {
<GitHubBotManagement key={endpoint.id} endpoint={endpoint} view={activeTab === "access" ? "access" : "settings"} />
</div>}
{activeTab === "settings" && endpoint.provider !== "github" && <Settings endpointId={endpoint.id} endpoint={endpoint} />}
{activeTab === "reviews" && endpoint.provider === "github" && <GitHubReviews endpointId={endpoint.id} />}
{activeTab === "reviews" && endpoint.provider === "github" && <GitHubReviews endpointId={endpoint.id} reviewId={reviewId} />}
{activeTab === "access" && endpoint.provider === "agentmail" && <EmailAccess endpoint={endpoint} />}
{activeTab === "access" && endpoint.provider !== "github" && endpoint.provider !== "agentmail" && (
<Access
@@ -11,7 +11,7 @@ import { accessApi } from "@/api/access";
import { chatEndpointsApi } from "@/api/chatEndpoints";
import { githubChatApi } from "@/api/githubChat";
import { Button } from "@/components/ui/button";
import { Copy, MoreHorizontal } from "lucide-react";
import { Copy, HelpCircle, MoreHorizontal } from "lucide-react";
import {
DropdownMenu,
DropdownMenuContent,
@@ -23,6 +23,11 @@ import { Textarea } from "@/components/ui/textarea";
import { Label } from "@/components/ui/label";
import { ToggleSwitch } from "@/components/ui/toggle-switch";
import { Link } from "@/lib/router";
import {
Tooltip,
TooltipContent,
TooltipTrigger,
} from "@/components/ui/tooltip";
export const githubSelectClass =
"w-full rounded-md border border-input bg-background px-3 py-2 text-sm";
@@ -34,9 +39,35 @@ const eventLabels = {
mention: "Mention",
comment: "Follow-up comment",
};
function GitHubHelp({
label,
children,
}: {
label: string;
children: React.ReactNode;
}) {
const [open, setOpen] = useState(false);
return (
<Tooltip open={open} onOpenChange={setOpen}>
<TooltipTrigger asChild>
<button
type="button"
aria-label={`About ${label}`}
className="inline-flex shrink-0 items-center text-muted-foreground hover:text-foreground"
onClick={() => setOpen(true)}
>
<HelpCircle className="size-4" />
</button>
</TooltipTrigger>
<TooltipContent className="max-w-xs">{children}</TooltipContent>
</Tooltip>
);
}
export function GitHubToggle({
label,
description,
help,
checked,
onChange,
ariaLabel,
@@ -44,6 +75,7 @@ export function GitHubToggle({
}: {
label: string;
description?: string;
help?: string;
checked: boolean;
onChange: (checked: boolean) => void;
ariaLabel?: string;
@@ -52,7 +84,10 @@ export function GitHubToggle({
return (
<div className="flex items-center justify-between gap-4 py-2">
<div className="min-w-0">
<p className="break-words text-sm font-medium">{label}</p>
<div className="flex items-center gap-2">
<p className="break-words text-sm font-medium">{label}</p>
{help && <GitHubHelp label={label}>{help}</GitHubHelp>}
</div>
{description && (
<p className="mt-1 text-xs text-muted-foreground">{description}</p>
)}
@@ -392,12 +427,13 @@ export function GitHubPolicyEditor({
<h3 className="text-sm font-medium">Formal review actions</h3>
<GitHubToggle
label="Allow approvals"
description="The agent must choose this action. A 5/5 score does not approve a PR."
help="Lets the agent submit an Approve review on GitHub after a complete assessment. The agent must explicitly choose it; a 5/5 score or passing check does not approve the PR. Off still allows scores, comments, and checks."
checked={policy.allowApprove}
onChange={(value) => set("allowApprove", value)}
/>
<GitHubToggle
label="Allow request changes"
help="Lets the agent submit a Request changes review on GitHub after a complete assessment. This is a formal review decision and may prevent merging under your repository rules. Off still allows findings, comments, and a failing check."
checked={policy.allowRequestChanges}
onChange={(value) => set("allowRequestChanges", value)}
/>
@@ -597,8 +633,9 @@ export function GitHubAccessEditor({
</DropdownMenu>
</div>
<GitHubToggle
label="Automatic events"
ariaLabel={`Automatic events for @${person.login}`}
label="Run automatically"
ariaLabel={`Run automatically for @${person.login}`}
help="Lets PRs and issues authored by this person start work without mentioning the bot. Only events enabled in Settings run. Turn this off to keep this person’s use mention-only."
checked={person.automaticReviews}
onChange={(value) =>
onChange({
@@ -699,7 +736,7 @@ export function GitHubAccessEditor({
)}
</div>
<Button variant="ghost" size="sm" onClick={() => setKind("guest")}>
Allow external contributor
Add external contributor
</Button>
{kind === "guest" && (
<div className="space-y-4 rounded-lg border border-border p-4">
@@ -782,26 +819,41 @@ export function GitHubAccessEditor({
})
}
>
Allow this account
Add contributor
</Button>
</div>
</div>
)}
<details className="text-sm">
<summary className="cursor-pointer text-muted-foreground">
Automatic task ownership
Automatic task responsibility
</summary>
<div className="mt-4 space-y-2">
{activeMembers.length === 1 && responsible ? (
<p>
Responsible member:{" "}
<span className="inline-flex items-center gap-2">
Responsible member{" "}
<GitHubHelp label="Responsible member">
The Paperclip member accountable for automatically created
tasks. This does not change the GitHub author or grant the bot
access to the member’s personal credentials.
</GitHubHelp>
</span>
:{" "}
{responsible.user?.name ??
responsible.user?.email ??
responsible.principalId}
</p>
) : (
<>
<Label htmlFor="github-responsible">Responsible member</Label>
<div className="flex items-center gap-2">
<Label htmlFor="github-responsible">Responsible member</Label>
<GitHubHelp label="Responsible member">
The Paperclip member accountable for automatically created
tasks. This does not change the GitHub author or grant the bot
access to the member’s personal credentials.
</GitHubHelp>
</div>
<select
id="github-responsible"
className={githubSelectClass}
@@ -829,8 +881,8 @@ export function GitHubAccessEditor({
</>
)}
<p className="text-xs text-muted-foreground">
Accountable for automatic tasks. GitHub authors remain recorded
separately.
Automatically created tasks are attributed to this member in
Paperclip. The GitHub author is recorded separately.
</p>
</div>
</details>
@@ -9,7 +9,7 @@ import {
type GitHubTaskReview,
} from "@paperclipai/shared";
import { ChatEndpointDetail } from "./ChatEndpointDetail";
import { GitHubReviewList, groupGitHubReviews } from "./GitHubBotManagement";
import { GitHubReviewList, orderedGitHubReviews } from "./GitHubBotManagement";
import { GitHubPolicyEditor } from "./GitHubBotConfiguration";
import { conversationDestination } from "./ChatConversationList";
import { queryKeys } from "@/lib/queryKeys";
@@ -17,6 +17,7 @@ import { TooltipProvider } from "@/components/ui/tooltip";
const mocks = vi.hoisted(() => ({
tab: "settings",
reviewId: undefined as string | undefined,
get: vi.fn(),
config: vi.fn(),
save: vi.fn(),
@@ -56,7 +57,11 @@ vi.mock("@/components/MarkdownBody", () => ({
),
}));
vi.mock("@/lib/router", () => ({
useParams: () => ({ endpointId: "bot", tab: mocks.tab }),
useParams: () => ({
endpointId: "bot",
tab: mocks.tab,
reviewId: mocks.reviewId,
}),
useNavigate: () => vi.fn(),
Link: ({
children,
@@ -108,6 +113,7 @@ describe("GitHub bot management", () => {
beforeEach(() => {
vi.clearAllMocks();
mocks.tab = "settings";
mocks.reviewId = undefined;
mocks.get.mockResolvedValue(endpoint);
mocks.config.mockResolvedValue({
revision: 4,
@@ -216,7 +222,7 @@ describe("GitHub bot management", () => {
await input(container.querySelector("textarea")!, "Edited instructions");
await render("access");
await vi.waitFor(() => expect(container.textContent).toContain("@maya"));
await click("Automatic events for @maya");
await click("Run automatically for @maya");
await render("reviews");
await render("settings");
expect(container.querySelector("textarea")?.value).toBe(
@@ -312,11 +318,52 @@ describe("GitHub bot management", () => {
expect(mocks.save.mock.calls[0][2].memberAccess).toBe("all_linked");
expect(mocks.save.mock.calls[0][2].people[0].automaticReviews).toBe(false);
});
it("does not show an off switch or silently enable a retained disabled bot", async () => {
mocks.config.mockResolvedValue({
revision: 4,
configuration: { ...base, toolsEnabled: false },
});
await render("access");
expect(
container.querySelector('[aria-label="Use this bot’s GitHub tools"]'),
).toBeNull();
expect(container.textContent).toContain("cannot start work or respond");
await render("settings");
await input(container.querySelector("textarea")!, "Edited instructions");
await click("Save changes");
await vi.waitFor(() => expect(mocks.save).toHaveBeenCalled());
expect(mocks.save.mock.calls[0][2].toolsEnabled).toBe(false);
});
it("loads a direct review URL and keeps unknown reviews within the current connection", async () => {
mocks.reviewId = "review-1";
mocks.reviews.mockResolvedValue([
review("review-1", "repo", 1, "2026-10-07T10:00:00Z"),
]);
await render("reviews");
await vi.waitFor(() =>
expect(container.textContent).toContain(
"No assessment has been submitted yet.",
),
);
expect(
container.querySelector('a[href="/apps/chat/bot/reviews"]')?.textContent,
).toContain("All reviews");
mocks.reviewId = "foreign";
await render("reviews");
await vi.waitFor(() =>
expect(container.textContent).toContain("not found in this connection"),
);
expect(container.textContent).not.toContain(
"No assessment has been submitted yet.",
);
});
it("keeps saved automatic triggers when changing to mentions-only", async () => {
const change = vi.fn();
await act(async () =>
root.render(
<GitHubPolicyEditor policy={base.defaults} onChange={change} />,
<TooltipProvider>
<GitHubPolicyEditor policy={base.defaults} onChange={change} />
</TooltipProvider>,
),
);
await input(
@@ -355,7 +402,7 @@ function review(
} as GitHubTaskReview;
}
describe("review history and thread labels", () => {
it("groups by repository and PR and orders by creation, not late updates to an older head", () => {
it("keeps every review in creation order, independent of late updates to an older head", () => {
const old = review(
"old",
"repo",
@@ -365,9 +412,10 @@ describe("review history and thread labels", () => {
);
const current = review("current", "repo", 1, "2026-10-07T11:00:00Z");
const other = review("other", "another-repo", 1, "2026-10-07T12:00:00Z");
expect(groupGitHubReviews([old, current, other])).toEqual([
[other],
[current, old],
expect(orderedGitHubReviews([old, current, other])).toEqual([
other,
current,
old,
]);
});
it("does not present a previous passing score as the pending current commit’s result", async () => {
@@ -388,18 +436,22 @@ describe("review history and thread labels", () => {
const root = createRoot(container);
try {
await act(async () =>
root.render(<GitHubReviewList reviews={[old, current]} />),
root.render(
<GitHubReviewList endpointId="bot" reviews={[old, current]} />,
),
);
const article = container.querySelector("article")!;
const latest = article.cloneNode(true) as HTMLElement;
latest.querySelectorAll("details").forEach((details) => details.remove());
expect(latest.textContent).not.toContain("5/5");
expect(latest.textContent).toContain("Queued");
const history = [...article.querySelectorAll("details")].find((e) =>
e.querySelector("summary")?.textContent?.includes("earlier review"),
const rows = [...container.querySelectorAll("li")];
expect(rows).toHaveLength(2);
expect(rows[0].textContent).toContain("Queued");
expect(rows[0].textContent).not.toContain("5/5");
expect(rows[0].querySelector("a")?.getAttribute("href")).toBe(
"/apps/chat/bot/reviews/current",
);
expect(history?.textContent).toContain("5/5 · Passed");
expect(history?.open).toBe(false);
expect(rows[1].textContent).toContain("5/5 · Passed");
expect(rows[1].querySelector("a")?.getAttribute("href")).toBe(
"/apps/chat/bot/reviews/old",
);
expect(container.querySelector("details")).toBeNull();
} finally {
await act(async () => root.unmount());
}
+170 -91
View File
@@ -217,23 +217,28 @@ export function GitHubBotManagement({
configuration={config}
onChange={edit}
/>
<section className="space-y-3">
<h2 className="text-base font-semibold">Agent tools</h2>
<GitHubToggle
label="Use this bot’s GitHub tools"
description="Limited to enabled repositories and this bot’s tasks. Tool policies still apply."
checked={config.toolsEnabled}
onChange={(toolsEnabled) => edit({ ...config, toolsEnabled })}
/>
{endpoint.connectionId && (
<Link
className="text-xs text-muted-foreground underline underline-offset-4"
to={`/apps/${endpoint.connectionId}`}
{!config.toolsEnabled && (
<div className="space-y-2">
<p className="text-sm text-muted-foreground">
This saved bot has GitHub tools disabled, so it cannot start
work or respond.
</p>
<Button
variant="outline"
onClick={() => edit({ ...config, toolsEnabled: true })}
>
Manage tool permissions
</Link>
)}
</section>
Enable bot tools
</Button>
</div>
)}
{endpoint.connectionId && (
<Link
className="text-xs text-muted-foreground underline underline-offset-4"
to={`/apps/${endpoint.connectionId}`}
>
Manage tool permissions
</Link>
)}
</>
) : (
<>
@@ -360,18 +365,13 @@ export function GitHubBotManagement({
);
}
export function groupGitHubReviews(reviews: GitHubTaskReview[]) {
const groups = new Map<string, GitHubTaskReview[]>();
for (const review of [...reviews].sort(
export function orderedGitHubReviews(reviews: GitHubTaskReview[]) {
return [...reviews].sort(
(a, b) => Date.parse(b.createdAt) - Date.parse(a.createdAt),
)) {
const key = `${review.repositoryId}:${review.pullNumber}`;
groups.set(key, [...(groups.get(key) ?? []), review]);
}
return [...groups.values()];
);
}
function ReviewResult({ review }: { review: GitHubTaskReview }) {
export function gitHubReviewResultLabel(review: GitHubTaskReview) {
const completed = review.state === "completed" && review.assessment?.complete;
const conclusion = review.conclusion
? {
@@ -390,20 +390,30 @@ function ReviewResult({ review }: { review: GitHubTaskReview }) {
superseded: "Superseded",
manual_required: "Action required",
}[review.state];
return completed ? `${review.assessment!.score}/5 · ${conclusion}` : state;
}
function ReviewResult({ review }: { review: GitHubTaskReview }) {
return (
<div className="space-y-4">
<div className="flex flex-wrap items-baseline justify-between gap-3">
<span className="text-sm font-medium">
{completed ? `${review.assessment!.score}/5 · ${conclusion}` : state}
{gitHubReviewResultLabel(review)}
</span>
<span className="text-xs text-muted-foreground">
Commit <code>{review.headSha.slice(0, 7)}</code> ·{" "}
{formatDateTime(review.updatedAt)}
</span>
</div>
<MarkdownBody className="text-sm">
{review.assessment?.summary ?? review.event.title}
</MarkdownBody>
{review.assessment ? (
<MarkdownBody className="text-sm">
{review.assessment.summary}
</MarkdownBody>
) : (
<p className="text-sm text-muted-foreground">
No assessment has been submitted yet.
</p>
)}
<div className="flex flex-wrap items-center gap-4 text-xs text-muted-foreground">
<Link
className="underline underline-offset-4"
@@ -432,11 +442,8 @@ function ReviewResult({ review }: { review: GitHubTaskReview }) {
</a>
)}
</div>
<details className="text-sm">
<summary className="cursor-pointer text-muted-foreground">
Review details
</summary>
<div className="mt-3 space-y-2">
<section className="space-y-4 text-sm" aria-label="Review evidence">
<div className="space-y-3">
{review.runId && (
<Link
className="text-xs underline underline-offset-4"
@@ -447,7 +454,25 @@ function ReviewResult({ review }: { review: GitHubTaskReview }) {
)}
{review.assessment && (
<>
<h3 className="font-medium">Rationale</h3>
<MarkdownBody>{review.assessment.rationale}</MarkdownBody>
{review.assessment.findings.length > 0 && (
<section className="space-y-3">
<h3 className="font-medium">Findings</h3>
{review.assessment.findings.map((finding) => (
<div
key={finding.key}
className="space-y-2 border-l border-border pl-4"
>
<p className="break-all font-mono text-xs">
{finding.path}:{finding.line} · {finding.severity}
</p>
<MarkdownBody>{finding.body}</MarkdownBody>
</div>
))}
</section>
)}
<h3 className="font-medium">Coverage</h3>
<p className="text-xs text-muted-foreground">
{review.assessment.coverage.reviewedPaths.length} files reviewed
· {review.assessment.coverage.omittedPaths.length} omitted
@@ -460,12 +485,18 @@ function ReviewResult({ review }: { review: GitHubTaskReview }) {
</>
)}
</div>
</details>
</section>
</div>
);
}
export function GitHubReviewList({ reviews }: { reviews: GitHubTaskReview[] }) {
export function GitHubReviewList({
endpointId,
reviews,
}: {
endpointId: string;
reviews: GitHubTaskReview[];
}) {
if (!reviews.length)
return (
<EmptyState
@@ -475,70 +506,118 @@ export function GitHubReviewList({ reviews }: { reviews: GitHubTaskReview[] }) {
/>
);
return (
<div className="divide-y divide-border border-y border-border">
{groupGitHubReviews(reviews).map(([latest, ...history]) => (
<article
key={`${latest.repositoryId}:${latest.pullNumber}`}
className="space-y-4 py-5"
>
<div className="space-y-1">
<a
className="text-sm font-semibold hover:underline"
href={`https://github.com/${latest.repository}/pull/${latest.pullNumber}`}
target="_blank"
rel="noreferrer"
>
{latest.event.title || `Pull request #${latest.pullNumber}`}
</a>
<p className="break-all text-xs text-muted-foreground">
{latest.repository} #{latest.pullNumber}
</p>
</div>
<ReviewResult review={latest} />
{history.length > 0 && (
<details className="text-sm">
<summary className="cursor-pointer text-muted-foreground">
{history.length} earlier{" "}
{history.length === 1 ? "review" : "reviews"}
</summary>
<div className="mt-4 space-y-6 border-l border-border pl-4">
{history.map((review) => (
<ReviewResult key={review.id} review={review} />
))}
</div>
</details>
)}
</article>
<ul
aria-label="Reviews"
className="divide-y divide-border border-y border-border"
>
{orderedGitHubReviews(reviews).map((review) => (
<li key={review.id}>
<Link
to={`/apps/chat/${endpointId}/reviews/${review.id}`}
className="flex flex-wrap items-center gap-x-6 gap-y-2 py-4 text-sm hover:bg-accent/50"
>
<div className="min-w-0 flex-1 basis-48 space-y-1">
<p className="break-words font-medium">
{review.event.title || `Pull request #${review.pullNumber}`}
</p>
<p className="break-all text-xs text-muted-foreground">
{review.repository} #{review.pullNumber} ·{" "}
<code>{review.headSha.slice(0, 7)}</code>
</p>
</div>
<div className="space-y-1 text-right">
<p className="font-medium">{gitHubReviewResultLabel(review)}</p>
<time
className="text-xs text-muted-foreground"
dateTime={review.createdAt}
>
{formatDateTime(review.createdAt)}
</time>
</div>
</Link>
</li>
))}
</div>
</ul>
);
}
export function GitHubReviews({ endpointId }: { endpointId: string }) {
export function GitHubReviewDetail({
endpointId,
review,
}: {
endpointId: string;
review: GitHubTaskReview;
}) {
return (
<article className="max-w-3xl space-y-6">
<Link
className="text-sm text-muted-foreground hover:underline"
to={`/apps/chat/${endpointId}/reviews`}
>
← All reviews
</Link>
<header className="space-y-2">
<h2 className="text-lg font-semibold">
{review.event.title || `Pull request #${review.pullNumber}`}
</h2>
<a
className="break-all text-sm text-muted-foreground hover:underline"
href={`https://github.com/${review.repository}/pull/${review.pullNumber}`}
target="_blank"
rel="noreferrer"
>
{review.repository} #{review.pullNumber}
</a>
</header>
<ReviewResult review={review} />
</article>
);
}
export function GitHubReviews({
endpointId,
reviewId,
}: {
endpointId: string;
reviewId?: string;
}) {
const query = useQuery({
queryKey: ["github-bot-reviews", endpointId],
queryFn: () => githubChatApi.reviews(endpointId),
refetchInterval: 5000,
});
return (
<section className="space-y-4">
<p className="text-sm text-muted-foreground">
Latest review for each pull request. Results apply to the commit shown.
if (query.isError)
return (
<p role="alert" className="text-sm text-destructive">
Reviews could not be loaded.{" "}
<Button variant="link" onClick={() => void query.refetch()}>
Try again
</Button>
</p>
{query.isError ? (
<p role="alert" className="text-sm text-destructive">
Reviews could not be loaded.{" "}
<Button variant="link" onClick={() => void query.refetch()}>
Try again
</Button>
);
if (query.isPending)
return (
<p role="status" className="text-sm text-muted-foreground">
Loading reviews…
</p>
);
if (reviewId) {
const review = query.data.find((review) => review.id === reviewId);
return review ? (
<GitHubReviewDetail endpointId={endpointId} review={review} />
) : (
<div className="space-y-3">
<p role="alert" className="text-sm text-muted-foreground">
This review was not found in this connection.
</p>
) : query.isPending ? (
<p role="status" className="text-sm text-muted-foreground">
Loading reviews…
</p>
) : (
<GitHubReviewList reviews={query.data} />
)}
</section>
);
<Link
to={`/apps/chat/${endpointId}/reviews`}
className="text-sm underline"
>
All reviews
</Link>
</div>
);
}
return <GitHubReviewList endpointId={endpointId} reviews={query.data} />;
}
@@ -67,13 +67,6 @@ describe("chat connector UI contract", () => {
expect(detail).toContain("Not observed");
});
it("lists every supported provider in the agent channel empty state", () => {
const panel = source("../../../components/chat/AgentChannelsPanel.tsx");
expect(panel).toContain(
"Connect AgentMail, Slack, GitHub Code Review Bot, Discord, Microsoft Teams, or Telegram from",
);
});
it("keeps provider capabilities automatic and settings focused on plausible reach", () => {
const detail = source("./ChatEndpointDetail.tsx");
const setup = source("./ChatEndpointSetup.tsx");
@@ -11,6 +11,7 @@ import {
import {
GitHubRepositoryAccess,
GitHubReviewList,
GitHubReviewDetail,
} from "@/pages/apps/chat/GitHubBotManagement";
import { ChatConversationList } from "@/pages/apps/chat/ChatConversationList";
import {
@@ -30,7 +31,7 @@ const meta = {
docs: {
description: {
component:
"Production pages and components. Start with **01 Journey / Settings**, then use the actual contextual sidebar to visit Access, Reviews, and Conversations. Try editing instructions, switch tabs, and save or discard the shared draft. **02 States** covers empty, loading, recoverable error, long content, and mobile. **03 Components** isolates the policy editor, people access, repository access, latest review/history, pending current commit, and conversations. Provider operations use isolated fixture APIs; these stories are not live GitHub evidence.",
"Production pages and components. Start with **01 Journey / Settings**, then use the actual contextual sidebar to visit Access, Reviews, and Conversations. Try editing instructions, switch tabs, and save or discard the shared draft. **02 States** covers empty, loading, recoverable error, long content, and mobile. **03 Components** isolates the policy editor, people access, repository access, review rows and detail, pending review, and conversations. Provider operations use isolated fixture APIs; these stories are not live GitHub evidence.",
},
},
},
@@ -46,6 +47,10 @@ const meta = {
<PluginLauncherProvider>
<Routes>
<Route path="/:companyPrefix" element={<Layout />}>
<Route
path="apps/chat/:endpointId/reviews/:reviewId"
element={<ChatEndpointDetail />}
/>
<Route
path="apps/chat/:endpointId/:tab"
element={<ChatEndpointDetail />}
@@ -153,14 +158,16 @@ export const RepositoryAccess: Story = {
render: () => component(<Repositories />),
};
export const ReviewHistory: Story = {
name: "03 Components / Latest review and history",
render: () => component(<GitHubReviewList reviews={reviews} />),
name: "03 Components / Review rows",
render: () =>
component(<GitHubReviewList endpointId={endpoint.id} reviews={reviews} />),
};
export const PendingReview: Story = {
name: "03 Components / Pending current commit",
render: () =>
component(
<GitHubReviewList
endpointId={endpoint.id}
reviews={[
{
...reviews[0],
@@ -178,3 +185,15 @@ export const ConversationRows: Story = {
render: () =>
component(<ChatConversationList rows={conversations} provider="github" />),
};
export const ReviewDetailJourney: Story = {
name: "01 Journey / Review detail",
parameters: route(`reviews/${reviews[0].id}`),
};
export const ReviewDetail: Story = {
name: "03 Components / Review detail",
render: () =>
component(
<GitHubReviewDetail endpointId={endpoint.id} review={reviews[0]} />,
),
};
@@ -33,7 +33,7 @@ function GitHubConnections({ saved = false, chatEnabled = true }) {
],
capabilities: { canSetCompanyInstall: true, canCreatePersonalConnection: true, canCreateOrganizationConnection: true },
});
result.setQueryData(queryKeys.instance.experimentalSettings, { enableChatConnectors: chatEnabled });
result.setQueryData(queryKeys.instance.experimentalSettings, { enableChatConnectors: false, enableGitHubReviewBots: chatEnabled });
result.setQueryData(queryKeys.tools.applications(companyId), { applications: saved ? [
{ id: "github-tools", companyId, name: "GitHub", status: "active", metadata: { sourceTemplateKey: "github" } },
// Existing bots retain their provider/source identity after the catalog split.