diff --git a/backend/app/api/work.py b/backend/app/api/work.py index 8892d620..d1f87aa3 100644 --- a/backend/app/api/work.py +++ b/backend/app/api/work.py @@ -8,6 +8,7 @@ from sqlalchemy.exc import IntegrityError from app.api.utils import log_activity, get_actor_employee_id from app.db.session import get_session +from app.models.org import Employee from app.models.work import Task, TaskComment from app.schemas.work import TaskCommentCreate, TaskCreate, TaskUpdate from app.integrations.notify import NotifyContext, notify_openclaw @@ -30,6 +31,12 @@ def create_task(payload: TaskCreate, background: BackgroundTasks, session: Sessi if payload.created_by_employee_id is None: payload = TaskCreate(**{**payload.model_dump(), "created_by_employee_id": actor_employee_id}) + # Default reviewer to the manager of the assignee (if not explicitly provided). + if payload.reviewer_employee_id is None and payload.assignee_employee_id is not None: + assignee = session.get(Employee, payload.assignee_employee_id) + if assignee is not None and assignee.manager_id is not None: + payload = TaskCreate(**{**payload.model_dump(), "reviewer_employee_id": assignee.manager_id}) + task = Task(**payload.model_dump()) if task.status not in ALLOWED_STATUSES: raise HTTPException(status_code=400, detail="Invalid status") diff --git a/frontend/src/app/projects/[id]/page.tsx b/frontend/src/app/projects/[id]/page.tsx index 69398dea..e4aacdcb 100644 --- a/frontend/src/app/projects/[id]/page.tsx +++ b/frontend/src/app/projects/[id]/page.tsx @@ -79,7 +79,6 @@ export default function ProjectDetailPage() { const [title, setTitle] = useState(""); const [description, setDescription] = useState(""); const [assigneeId, setAssigneeId] = useState(""); - const [reviewerId, setReviewerId] = useState(""); const [commentTaskId, setCommentTaskId] = useState(null); const [replyToCommentId, setReplyToCommentId] = useState(null); @@ -152,19 +151,13 @@ export default function ProjectDetailPage() { {createTask.error ?
{(createTask.error as Error).message}
: null} setTitle(e.target.value)} />