From e6ec96cef7573868f80219d83e20f52eb910b2b4 Mon Sep 17 00:00:00 2001 From: Dotta Date: Sun, 10 May 2026 07:54:56 -0500 Subject: [PATCH] Preserve LLM Wiki event ingestion sources Co-Authored-By: Paperclip --- .../plugins/plugin-llm-wiki/src/worker.ts | 40 +++++++++++++------ .../plugin-llm-wiki/tests/plugin.spec.ts | 35 ++++++++++++++++ 2 files changed, 63 insertions(+), 12 deletions(-) diff --git a/packages/plugins/plugin-llm-wiki/src/worker.ts b/packages/plugins/plugin-llm-wiki/src/worker.ts index 356d82fe503..0335b31b6e6 100644 --- a/packages/plugins/plugin-llm-wiki/src/worker.ts +++ b/packages/plugins/plugin-llm-wiki/src/worker.ts @@ -337,21 +337,37 @@ const plugin = definePlugin({ }); ctx.actions.register("update-event-ingestion-settings", async (params) => { - const sources = typeof params.sources === "object" && params.sources != null && !Array.isArray(params.sources) + const requestedSources = typeof params.sources === "object" && params.sources != null && !Array.isArray(params.sources) ? params.sources as Record - : {}; + : null; + const sources: { issues?: boolean; comments?: boolean; documents?: boolean } = {}; + if (requestedSources && Object.prototype.hasOwnProperty.call(requestedSources, "issues")) { + sources.issues = requestedSources.issues === true; + } + if (requestedSources && Object.prototype.hasOwnProperty.call(requestedSources, "comments")) { + sources.comments = requestedSources.comments === true; + } + if (requestedSources && Object.prototype.hasOwnProperty.call(requestedSources, "documents")) { + sources.documents = requestedSources.documents === true; + } + const settings: { + enabled?: boolean; + wikiId?: string; + maxCharacters?: number; + sources?: typeof sources; + } = { + wikiId: stringField(params.wikiId) ?? undefined, + maxCharacters: typeof params.maxCharacters === "number" ? params.maxCharacters : undefined, + }; + if (typeof params.enabled === "boolean") { + settings.enabled = params.enabled; + } + if (Object.keys(sources).length > 0) { + settings.sources = sources; + } return updateEventIngestionSettings(ctx, { companyId: readCompanyIdFromParams(params), - settings: { - enabled: params.enabled === true, - wikiId: stringField(params.wikiId) ?? undefined, - maxCharacters: typeof params.maxCharacters === "number" ? params.maxCharacters : undefined, - sources: { - issues: sources.issues === true, - comments: sources.comments === true, - documents: sources.documents === true, - }, - }, + settings, }); }); diff --git a/packages/plugins/plugin-llm-wiki/tests/plugin.spec.ts b/packages/plugins/plugin-llm-wiki/tests/plugin.spec.ts index 75592d76395..69dbf26b355 100644 --- a/packages/plugins/plugin-llm-wiki/tests/plugin.spec.ts +++ b/packages/plugins/plugin-llm-wiki/tests/plugin.spec.ts @@ -1713,6 +1713,41 @@ Duplicate headings receive stable suffixes. ])); }); + it("preserves Paperclip event ingestion sources when only enabled changes", async () => { + const harness = createTestHarness({ manifest }); + + await plugin.definition.setup(harness.ctx); + await harness.performAction("update-event-ingestion-settings", { + companyId: COMPANY_ID, + enabled: true, + sources: { issues: true, comments: true, documents: true }, + }); + + const disabled = await harness.performAction<{ + enabled: boolean; + sources: { issues: boolean; comments: boolean; documents: boolean }; + }>("update-event-ingestion-settings", { + companyId: COMPANY_ID, + enabled: false, + }); + expect(disabled).toMatchObject({ + enabled: false, + sources: { issues: true, comments: true, documents: true }, + }); + + const reenabled = await harness.performAction<{ + enabled: boolean; + sources: { issues: boolean; comments: boolean; documents: boolean }; + }>("update-event-ingestion-settings", { + companyId: COMPANY_ID, + enabled: true, + }); + expect(reenabled).toMatchObject({ + enabled: true, + sources: { issues: true, comments: true, documents: true }, + }); + }); + it("keeps Paperclip event cursor observations company scoped and ignores plugin-operation issues", async () => { const harness = createTestHarness({ manifest }); const visibleIssue = paperclipIssue({ projectId: "77777777-7777-4777-8777-777777777777" });