-
Notifications
You must be signed in to change notification settings - Fork 71
Add delegate support for agent users on issues #172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
9c050bf
341648f
11fb810
f746a7c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ import { | |
| getProjectIdByName, | ||
| getTeamIdByKey, | ||
| getWorkflowStateByNameOrType, | ||
| lookupUserId, | ||
| lookupUser, | ||
| } from "../../utils/linear.ts" | ||
| import { | ||
| CliError, | ||
|
|
@@ -28,6 +28,10 @@ export const updateCommand = new Command() | |
| "-a, --assignee <assignee:string>", | ||
| "Assign the issue to 'self' or someone (by username or name)", | ||
| ) | ||
| .option( | ||
| "--delegate <delegate:string>", | ||
| "Delegate the issue to an agent user (by username or name)", | ||
| ) | ||
| .option( | ||
| "--due-date <dueDate:string>", | ||
| "Due date of the issue", | ||
|
|
@@ -82,6 +86,7 @@ export const updateCommand = new Command() | |
| async ( | ||
| { | ||
| assignee, | ||
| delegate, | ||
| dueDate, | ||
| parent, | ||
| priority, | ||
|
|
@@ -175,10 +180,38 @@ export const updateCommand = new Command() | |
|
|
||
| let assigneeId: string | undefined | ||
| if (assignee !== undefined) { | ||
| assigneeId = await lookupUserId(assignee) | ||
| if (!assigneeId) { | ||
| const resolvedAssignee = await lookupUser(assignee) | ||
| if (!resolvedAssignee) { | ||
| throw new NotFoundError("User", assignee) | ||
| } | ||
| if (resolvedAssignee.app) { | ||
| throw new ValidationError( | ||
| `Cannot use --assignee with app user '${assignee}'`, | ||
| { | ||
| suggestion: | ||
| `Use --delegate ${assignee} to delegate the issue to an agent user.`, | ||
| }, | ||
| ) | ||
| } | ||
| assigneeId = resolvedAssignee.id | ||
| } | ||
|
|
||
| let delegateId: string | undefined | ||
| if (delegate !== undefined) { | ||
| const resolvedDelegate = await lookupUser(delegate) | ||
| if (!resolvedDelegate) { | ||
| throw new NotFoundError("User", delegate) | ||
| } | ||
| if (!resolvedDelegate.app) { | ||
| throw new ValidationError( | ||
| `Cannot use --delegate with human user '${delegate}'`, | ||
| { | ||
| suggestion: | ||
| `Use --assignee ${delegate} to assign the issue to a human user.`, | ||
| }, | ||
| ) | ||
|
||
| } | ||
| delegateId = resolvedDelegate.id | ||
| } | ||
|
|
||
| const labelIds = [] | ||
|
|
@@ -229,6 +262,7 @@ export const updateCommand = new Command() | |
|
|
||
| if (title !== undefined) input.title = title | ||
| if (assigneeId !== undefined) input.assigneeId = assigneeId | ||
| if (delegateId !== undefined) input.delegateId = delegateId | ||
| if (dueDate !== undefined) input.dueDate = dueDate | ||
| if (parent !== undefined) { | ||
| const parentIdentifier = await getIssueIdentifier(parent) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new validation that rejects using
--delegatewith a human user (!resolvedDelegate.app) isn’t covered by a snapshot test in this PR. Add a test case that passes--delegatewith a non-app user and asserts the failure message/suggestion, similar to the new app-user rejection tests for--assignee.