Repository navigation
feat(actions): assign by email and clear assignees through the API - #1147
Conversation
Agents and other non-UI callers (CLI, MCP) create follow-up actions but could not say who they are for: they know a colleague's email, not their user id, and there was no way to clear assignees in one call. - action.create accepts `assigneeEmails`, merged with `assigneeIds`. - action.assign accepts `emails` alongside `userIds` (either is enough). - action.unassign accepts `emails` and `all: true`. Emails resolve case-insensitively to user ids, then go through the same assertAssignableUsers containment as ids, so an email reaches no further than an id. An unregistered email fails with the same NOT_FOUND message as a registered user who is not assignable here (no registration oracle). On unassign, emails match current assignees only. Update semantics stay additive: assign adds, unassign removes, nothing replaces the set wholesale.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e75102a2a9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const emailAssigneeIds = assigneeEmails?.length | ||
| ? await resolveAssigneeEmails( | ||
| ctx.db, |
There was a problem hiding this comment.
Resolve assignee emails after validating the create destination
Any authenticated caller can use action.create with a nonexistent projectId to determine whether an arbitrary email has an account: an unregistered address fails here with Assignee not found in this project, whereas a registered address reaches createAction and fails with Project not found (src/server/services/actions/createAction.ts:127–128). This bypasses the intended indistinguishability between unknown and unassignable addresses without requiring access to any project. Resolve emails after the destination authorization and existence checks, but before writing the action.
Useful? React with 👍 / 👎.
|
PR-Agent: nothing blocking on |
PR Reviewer Guide 🔍(Review updated until commit 1db1256)Here are some key observations to aid the review process:
✅ Resolved findingssrc/server/api/routers/action.ts:487-498[blocker] Registration oracle in create
src/server/api/routers/action.ts:501-503[minor] Un-deduped assignee ids on create
src/server/api/routers/tests/action.test.ts:1857-1864[minor] Suppressed House rule (TypeScript/ESLint — no |
PR-Agent blocker: action.create looked emails up before createAction's workspace write check, so an unregistered email failed early with NOT_FOUND while a registered one went on to FORBIDDEN, which let any signed-in user probe whether an address has an account. On create, an unknown email now becomes a placeholder id that can never match a user (assigneeIdsForEmails). It fails at assertAssignableUsers, after authorisation, with the same error as a registered non-member. assign keeps resolveAssigneeEmails, which already runs after the edit check. Also: dedupe ids merged from assigneeIds and assigneeEmails, and type the test's membership mock instead of suppressing no-explicit-any.
…emails action.assign now takes optional `emails` and `userIds` defaults to []; the contract test compares the router's inputs with this file.
Why
Agents create follow-up actions through the CLI/MCP (e.g. candidate follow-ups in a Syntrofi hiring project). Those land with no assignee, so they reach nobody's Today list and a person has to assign them in the app.
action.assign/action.unassignandassigneeIdson create already existed, but a caller outside the UI usually knows a colleague's email, not their CUID, and there was no one-call way to clear assignees.What
action.createacceptsassigneeEmails, merged withassigneeIds.action.assignacceptsemailsalongsideuserIds(either is enough; neither isBAD_REQUEST).action.unassignacceptsemailsandall: true.Rules (unchanged containment, documented)
assertAssignableUserscheck as ids: project access for a project action, team membership for a team action, workspace membership otherwise. An email reaches no further than an id. An agent key can assign anyone who passes that check in an action it can edit.NOT_FOUNDmessage as a registered user who isn't assignable here, so the API is not an oracle for whether an address has an account.unassign, emails match the action's current assignees only (unknown address = no-op).assignadds,unassignremoves,unassign { all: true }clears. No replace-the-set call: an agent adding the requester never silently drops a person a human assigned. Clients get "replace" by clearing, then assigning (the CLI's--clear-assignees --assignee x).Tests
src/server/api/routers/__tests__/action.test.ts→ "assignees by email and clear": member by email (case-insensitive), registered non-member refused, cross-workspace member refused by id, unregistered email answers like a non-member, empty assign refused, unassign all, unassign by email matches current assignees only, create with an unknown email writes nothing, create resolves emails into the create.Linked PRs (dependency order)
actions.assign/actions.unassign/ create assignees--assignee,--unassign,--clear-assigneesassignees,addAssignees,removeAssignees,clearAssigneesNo migration. Assigning by
userIdskeeps working for older clients.