Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 51 additions & 2 deletions apps/code/src/renderer/sagas/task/task-creation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ describe("TaskCreationSaga", () => {
model: "gpt-5.4",
reasoningLevel: "high",
sandboxEnvironmentId: undefined,
prAuthorshipMode: "bot",
prAuthorshipMode: "user",
runSource: "manual",
signalReportId: undefined,
initialPermissionMode: "auto",
Expand Down Expand Up @@ -259,7 +259,7 @@ describe("TaskCreationSaga", () => {
model: "gpt-5.4",
reasoningLevel: "medium",
sandboxEnvironmentId: undefined,
prAuthorshipMode: "bot",
prAuthorshipMode: "user",
runSource: "manual",
signalReportId: undefined,
initialPermissionMode: "auto",
Expand Down Expand Up @@ -326,6 +326,55 @@ describe("TaskCreationSaga", () => {
);
});

it("uses user authorship for signal report cloud task creation", async () => {
const createdTask = createTask({ origin_product: "signal_report" });
const startedTask = createTask({
origin_product: "signal_report",
latest_run: createRun(),
});
const createTaskMock = vi.fn().mockResolvedValue(createdTask);
const createTaskRunMock = vi.fn().mockResolvedValue(createRun());
const startTaskRunMock = vi.fn().mockResolvedValue(startedTask);

const saga = new TaskCreationSaga({
posthogClient: {
createTask: createTaskMock,
deleteTask: vi.fn(),
getTask: vi.fn(),
createTaskRun: createTaskRunMock,
startTaskRun: startTaskRunMock,
sendRunCommand: vi.fn(),
updateTask: vi.fn(),
} as never,
});

const result = await saga.run({
content: "Ship the report",
repository: "posthog/posthog",
workspaceMode: "cloud",
branch: "main",
cloudRunSource: "signal_report",
signalReportId: "report-123",
githubIntegrationId: 123,
});

expect(result.success).toBe(true);
expect(createTaskMock).toHaveBeenCalledWith(
expect.objectContaining({
github_integration: 123,
github_user_integration: undefined,
origin_product: "signal_report",
}),
);
expect(createTaskRunMock).toHaveBeenCalledWith(
"task-123",
expect.objectContaining({
prAuthorshipMode: "user",
runSource: "signal_report",
}),
);
});

it("sets title from plain text when description has text", async () => {
const createdTask = createTask();
const startedTask = createTask({ latest_run: createRun() });
Expand Down
6 changes: 1 addition & 5 deletions apps/code/src/renderer/sagas/task/task-creation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,7 @@ export class TaskCreationSaga extends Saga<
task = await this.step({
name: "cloud_run",
execute: async () => {
const hasUserGitHubIntegration =
!!input.githubUserIntegrationId || !!task.github_user_integration;
const prAuthorshipMode =
input.cloudPrAuthorshipMode ??
(hasUserGitHubIntegration ? "user" : "bot");
const prAuthorshipMode = input.cloudPrAuthorshipMode ?? "user";

const transport =
(input.content || input.filePaths?.length) &&
Expand Down
Loading