mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-01 09:39:53 +01:00
fix(issues): derive scope for imported issues
importIssues inserts creatorless rows with originKind 'manual' without setting scope, so the database default of 'board' previously leaked newly imported tasks into includeAgentCreatedTasks=false queries. Derive scope via deriveDefaultIssueScope in importIssues so creatorless imports land in scope 'agent', matching migration backfill and pre-scope visibility behavior. Tested with issue-scope-visibility, issues-creation-visibility, company-portability-import-batching, migration-snapshot-drift, and issue-filters Vitest suites plus db, shared, and server typechecks. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
64aca2a59e
commit
3db819854f
2 files changed
+38
No files matched your search
@@ -493,4 +493,37 @@ describeEmbeddedPostgres("issues.scope visibility and lifecycle", () => {
|
||||
.sort(),
|
||||
).toEqual([boardTask.id, agentTask.id, touchedAgentTask.id].sort());
|
||||
});
|
||||
|
||||
it("derives scope='agent' for creatorless imported tasks so includeAgentCreatedTasks=false excludes them", async () => {
|
||||
const { companyId } = await seedCompanyWithBoardAccess(ctx.db, "Imported scope");
|
||||
const svc = issueService(ctx.db);
|
||||
const importedId = randomUUID();
|
||||
|
||||
await svc.importIssues(companyId, [
|
||||
{
|
||||
id: importedId,
|
||||
ref: "imported-task",
|
||||
projectId: null,
|
||||
projectWorkspaceId: null,
|
||||
title: "Imported historical task",
|
||||
description: null,
|
||||
assigneeAgentId: null,
|
||||
status: "todo",
|
||||
priority: "medium",
|
||||
billingCode: null,
|
||||
assigneeAdapterOverrides: null,
|
||||
executionWorkspaceSettings: null,
|
||||
labelIds: [],
|
||||
monitorNotes: null,
|
||||
monitorScheduledBy: null,
|
||||
},
|
||||
]);
|
||||
|
||||
const imported = await svc.getById(importedId);
|
||||
expect(imported?.scope).toBe("agent");
|
||||
expect(await svc.list(companyId, { includeAgentCreatedTasks: false })).toEqual([]);
|
||||
expect((await svc.list(companyId, { scope: "agent" })).map((row) => row.id)).toEqual([
|
||||
importedId,
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -11572,6 +11572,11 @@ export function issueService(db: Db) {
|
||||
responsibleUserId: null,
|
||||
requestDepth: clampIssueRequestDepth(undefined),
|
||||
originKind: "manual",
|
||||
scope: deriveDefaultIssueScope({
|
||||
createdByAgentId: null,
|
||||
createdByUserId: null,
|
||||
originKind: "manual",
|
||||
}),
|
||||
// The caller resolves parentId against ids in this same batch, so a
|
||||
// parent always lands in the same insert (rows arrive parents-first).
|
||||
parentId: row.parentId ?? null,
|
||||
|
||||
Reference in new issue
Block a user