fix(team): notify lead on task create with startImmediately

Extract sendUserTaskStartNotification as reusable private method.
When a task is created via UI directly in "In Progress" column
(startImmediately=true), the controller's maybeNotifyAssignedOwner
skips the lead. Now createTask sends the notification to the lead
with full description, prompt, and task_get instructions.
This commit is contained in:
iliya 2026-03-25 15:03:44 +02:00
parent 58f3ccd4b4
commit bd90de8e81

View file

@ -877,6 +877,19 @@ export class TeamDataService {
...(shouldStart ? { startImmediately: true } : {}), ...(shouldStart ? { startImmediately: true } : {}),
}) as TeamTask; }) as TeamTask;
// Controller's maybeNotifyAssignedOwner skips the lead (owner === lead).
// For user-created tasks with startImmediately, ensure the lead also gets notified.
if (shouldStart) {
try {
const leadName = await this.resolveLeadName(teamName);
if (this.isLeadOwner(task.owner!, leadName)) {
await this.sendUserTaskStartNotification(teamName, task);
}
} catch {
/* best-effort */
}
}
return task; return task;
} }
@ -945,10 +958,21 @@ export class TeamDataService {
this.getController(teamName).tasks.startTask(taskId, 'user'); this.getController(teamName).tasks.startTask(taskId, 'user');
if (task.owner) { if (task.owner) {
await this.sendUserTaskStartNotification(teamName, task);
}
return { notifiedOwner: !!task.owner };
}
/**
* Send a task start notification from the user to the task owner.
* Includes description, prompt, and task_get/task_complete instructions.
* Used by startTaskByUser and createTask (startImmediately).
*/
private async sendUserTaskStartNotification(teamName: string, task: TeamTask): Promise<void> {
if (!task.owner) return;
try { try {
const parts = [ const parts = [`**start working on task now** ${this.getTaskLabel(task)} "${task.subject}"`];
`**start working on task now** ${this.getTaskLabel(task)} "${task.subject}"`,
];
if (task.description?.trim()) { if (task.description?.trim()) {
parts.push(`\nDetails:\n${task.description.trim()}`); parts.push(`\nDetails:\n${task.description.trim()}`);
} }
@ -980,9 +1004,6 @@ export class TeamDataService {
} }
} }
return { notifiedOwner: !!task.owner };
}
async updateTaskStatus( async updateTaskStatus(
teamName: string, teamName: string,
taskId: string, taskId: string,