Repository navigation
feat(github): Add an Inbox item for the assignees of an issue Junior opened - #4308
sentry-junior[bot] wants to merge 45 commits into
Conversation
…opened An issue that Junior opened is an Inbox item for its GitHub assignees with a linked account. Assigning a person on GitHub adds them, and unassigning removes them. The item closes when the issue closes or nobody is left. A dismiss removes the person on GitHub too. A plugin subject kind with `dismissLeaves` gets an `inboxItemDismissed` hook call first, and a refusal fails the dismiss. When others stay on the item, only the dismisser leaves. The item's subject is `github:issue` plus GitHub's numeric issue id. Object Annotations get an optional `objectId`, and the new `annotation` owner names the Conversation that first saved the object's Annotation. Co-Authored-By: BYK <[email protected]>
…at/github-issue-assignee-items Co-Authored-By: BYK <[email protected]>
Co-Authored-By: BYK <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…t once The leave of a dismiss now checks for other assignees under the item's row lock. The last one to leave closes the item as a dismiss, so two dismisses at once no longer leave an open item with nobody on it. Core throws PluginInboxItemOwnerError when a plugin changes an item through a Conversation that does not own it. The issues webhook catches it and logs a warning, so an issue footer that no longer names the owner does not fail the webhook.
A GitHub assignee with a linked account now gets the issue's item even when they are not in the owner Conversation. They can already see the issue on GitHub. The subject flag dismissLeaves becomes assigneeRoles: the role puts a person on the item, and a dismiss removes only them. Their card shows the item and the issue, and no Conversation, unless they can see it. The payload then names no root, Turn, or linked Conversation, and the dashboard links nothing to it. An item of such a kind with nobody Junior knows on it is not added, so it is never up for grabs. design/inbox.md gets the confirmed line for this rule. Co-Authored-By: BYK <[email protected]>
This comment has been minimized.
This comment has been minimized.
A person from outside a private owner Conversation sees a role item only through their role. When their dismiss left others on the item, the reload checked their access again and returned 404, though GitHub had already unassigned them. The reload now skips that check. The dashboard client test gives its list item the root that the API always names for an owner that the viewer can see.
A row read the short repo name only from its owner Conversation's links. A viewer who cannot see that Conversation got "#91" instead of "payments#91". With no Conversation, the name now comes from the key of the subject's card. Co-Authored-By: BYK <[email protected]>
First step of making Conversation Annotations lean pointers. This adds the design doc and gives each Annotation the subject of its object and what the Conversation did to it. Cards and webhooks still read and write the saved JSON. Later PRs read cards live, delete the status writes, and drop the saved facts. ## Design and terms - New `design/annotations.md`, linked from `design/README.md`. - TERMINOLOGY.md: **Annotation** is now a pointer from one Conversation to an object that it created, changed, or attached. A **Message card** is shown with the object's live card, else its label. ## Data `junior_conversation_annotations` gains `subject_kind`, `subject_id`, and `action` (`created | changed | attached`), plus an index on the subject. - `subject_kind` uses the Inbox form: `<plugin>:<kind>`, or a core kind (`automation`, or `link` when the provider id is not known, with the link as the id). - A later change keeps `created`, because the Conversation still created the object. - The Inbox `annotation` owner lookup reads the subject columns, not the JSON `objectId`. - Old workers keep writing JSON-only rows during rollout, so a trigger fills the subject and the action from the JSON. A bounded backfill runs the same trigger for existing rows. GitHub pull requests get GitHub's id from the code change records. Issues get the `objectId` that #4308 saved. Everything else that has no known id becomes a `link`. Old JSON rows don't say which Conversation created an object, so the backfill marks them `changed`. - The JSON `objectId` index stays for now because old workers still query it. PR 6 drops it. ## Plugin API - `objectSubjectSchema` (`{kind, id}`) replaces `objectAnnotationSchema.objectId`. - Tool and hook results (`objectAnnotations`, `afterMcpTool`) use `annotatedObjectSchema`, which adds a required `action` (`created | changed`). - A subject kind must be one that the plugin registers in `inboxSubjects`. Core rejects any other kind, so an Annotation and an Inbox item about the same object always match. ## Plugins - GitHub: pull requests and issues name their subject by GitHub's id. - Google: registers `calendar_event` (owner `annotation`). - Vercel: registers `deployment`. `vercel_inspectDeployment` is read-only, so it no longer returns `objectAnnotations`. Core already rejected that result. - Linear: registers `issue` (label `Ticket`). The subject id is the Ticket identifier because the hosted MCP does not reliably return the Ticket's uuid. A Ticket that moves to another team changes its identifier. - Automations: core `automation` subject, `created` from the create tool and `changed` from the update tool. - Attached links: `attached`, with the plugin's subject when its link type knows the id, else `link`. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A9ae784b11f5e126be225e88df7d26acd --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A9ae784b11f5e126be225e88df7d26acd) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A9ae784b11f5e126be225e88df7d26acd/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <[email protected]>
…at/github-issue-assignee-items # Conflicts: # design/github.md # design/inbox.md # packages/junior-plugin-api/src/tools.ts
The base branch renamed its Inbox item migrations to later timestamps, so the three annotation migrations of this branch sorted before their parent. They keep their order and their parents, with new timestamps. Co-Authored-By: BYK <[email protected]>
The last assignee's dismiss unassigns them on GitHub before Junior closes the item. GitHub can deliver `unassigned` during that call, and the webhook closes the item as done because nobody is left. The dismiss then found a closed item and failed with 409. An agent's close made after the dismiss began now becomes that person's dismiss.
…at/github-issue-assignee-items
| number: issue.number, | ||
| open: !GONE_ACTIONS.has(action) && issue.state === "open", | ||
| url: issue.html_url, | ||
| }; |
There was a problem hiding this comment.
Empty footer leaves items open
Medium Severity
After confirming the issue was opened by the bot, a missing footer causes the webhook to be ignored entirely, including closed, deleted, and transferred. Those events never reach showIssueItem, so an open Inbox item is not closed. An edited body that removes the footer can leave assignees with a live item for a gone issue.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit f4517eb. Configure here.
There was a problem hiding this comment.
Not changing this here. The footer is the only link from an issue to its Conversations, and the plugin reads only the Conversations it names, so an edited body cannot reach an item that it does not own. To close an item with no footer, core would need a new lookup by subject across Conversations, which is a new plugin contract for a case that needs a person to delete Junior's footer. The assignee can still dismiss the item: the dismiss unassigns them on GitHub, and a gone issue (404 or 410) counts as nothing left to remove.
Two first asks at once both find no open item. The insert that loses now runs the upsert again, so its person joins the item that the other added.
|
Found 3 test failures on Blacksmith runners: Failures
|
…at/github-issue-assignee-items
… migrations Also give the issue and annotation-name test tools the hasParent field that the Conversation kind merge added.
| // An issue that Junior created before it saved the issue id on its card | ||
| // has no owner, so it gets no item. | ||
| const owner = await issueOwner(args.annotations, event); | ||
| if (!owner) return; |
There was a problem hiding this comment.
Issue assignee webhooks can be dropped
Medium Severity
An assigned webhook that arrives before the owner Conversation has saved the issue card is ignored with no log and a 202, so GitHub never retries. Upsert then only adds people in askedIdentityIds, so a later event that lists that assignee still leaves them off the item unless they are assigned again. Auto-assign-on-open and a first assignment that races the card write can permanently omit that person.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 9b083b5. Configure here.
There was a problem hiding this comment.
Not changing this. The gap is a few milliseconds wide. github_createIssue takes no assignees, so the create sends no assigned event. Core saves the issue card in the same tool call, right after GitHub answers the POST (annotateToolResult runs on the tool result before the call ends). For an assigned event to land before the card, a person or an Action would have to assign the issue within that window. An Action that assigns on opened starts seconds later. A fix would need a retry queue or a new core rule that puts every listed assignee on the item, and that rule would push the item again to everyone on each event. That is more than this window needs.
…kage The dashboard QA fixture stores its pull requests as object Annotations since #4351, and the sidebar now names them by title alone, so the e2e link lookup is scoped to the reply. The Linear card tests load the plugin by package name, so the junior package depends on it like the other plugins it tests.
| from: z.object({ | ||
| organization: login.optional(), | ||
| user: login.optional(), | ||
| }), | ||
| }) | ||
| .optional(), | ||
| repository: z | ||
| .object({ name: z.object({ from: z.string().min(1) }) }) | ||
| .optional(), | ||
| }), | ||
| repository: z.object({ | ||
| full_name: z.string().min(1), | ||
| name: z.string().min(1), | ||
| owner: login, | ||
| }), | ||
| }); | ||
|
|
||
| /** Return the old and the new full name of a moved repository, if any. */ | ||
| function movedRepository( | ||
| body: unknown, | ||
| ): { from: string; to: string } | undefined { | ||
| const parsed = repositoryMoveSchema.safeParse(body); | ||
| if (!parsed.success) return undefined; | ||
| const { changes, repository } = parsed.data; | ||
| const owner = | ||
| changes.owner?.from.organization?.login ?? | ||
| changes.owner?.from.user?.login ?? | ||
| repository.owner.login; | ||
| const name = changes.repository?.name.from ?? repository.name; | ||
| const from = `${owner}/${name}`; | ||
| return from.toLowerCase() === repository.full_name.toLowerCase() | ||
| ? undefined | ||
| : { from, to: repository.full_name }; |
There was a problem hiding this comment.
transferred webhook never moves annotations: owner.from.login ignored
GitHub sends the previous owner as changes.owner.from.login, but this schema looks for from.organization|user.login, so transfers fall back to the new owner, compute from===to, and skip objectsMoved.
Evidence
- GitHub
repository.transferredpayloads usechanges.owner.fromas a user/org object with top-levellogin(OpenAPIoneOfuser|organization), not{ organization?: {login}, user?: {login} }. repositoryMoveSchemadefinesfromwith optional nestedorganization/useronly; Zod strips the reallogin, leavingfrom: {}.movedRepositorythen doeschanges.owner?.from.organization?.login ?? changes.owner?.from.user?.login ?? repository.owner.login, so owner is the new login,fromequalsrepository.full_name, and the function returnsundefined.moveGitHubRepositoryAnnotationstherefore never callsannotations.objectsMovedon transfer; rename still works because it useschanges.repository.name.from.
Identified by Warden · code-review · TV3-R8L
There was a problem hiding this comment.
Leaving this as is. GitHub's own webhook schema (webhook-repository-transferred in github/rest-api-description) types changes.owner.from as { organization?: Organization, user?: User }, each with login. That is the shape this schema parses. A transfer from an org reads from.organization.login, and one from a user reads from.user.login. There is no top-level login on from.
Since #4332 the server reads the cards of a row's Annotations, so the Conversations list reads only the links in row text. The lazy read test now waits for one of those. Co-Authored-By: BYK <[email protected]>
Linear's issue priority 3 is Medium, as its schema and priorityLabel say. Co-Authored-By: BYK <[email protected]>
A role on the object puts its holder on the item, as assigneeRoles says. An upsert now assigns every role holder, also on a new item, so an item that opens after a close has the co-assignees who are still on the issue. askedIdentityIds only picks whom Junior pushes the item to. Nobody can take such an item: a take cannot change the roles on the provider, so it would leave role holders off the item, and a later dismiss could close it while they still hold their role. Co-Authored-By: BYK <[email protected]>
The core rule that a person joins only with an ask holds again for assigneeRoles items. A pull request item has people on it without a role, such as the requester on Ready to merge, and joining every assignee brought back a requester who dismissed it. A closed issue item now comes back on a reopen, with everyone still assigned, so a later assignment adds to it. Co-Authored-By: BYK <[email protected]>
…at/github-issue-assignee-items Co-Authored-By: BYK <[email protected]> # Conflicts: # design/README.md # packages/junior-github/src/webhooks/object-cache.ts # packages/junior-plugin-api/src/hooks.ts # packages/junior/src/api/conversations/list.ts # packages/junior/src/api/inbox-items/routes.ts # packages/junior/src/api/objects/resolve.ts # packages/junior/src/chat/conversations/pending-cards.ts # packages/junior/src/chat/inbox-items/search.ts # packages/junior/src/chat/plugins/agent-hooks.ts # packages/junior/src/chat/plugins/annotations.ts # packages/junior/src/chat/tools/search-conversations.ts # packages/junior/tests/integration/scheduled-automation-tools.test.ts
…at/github-issue-assignee-items Co-Authored-By: BYK <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
There are 4 total unresolved issues (including 2 from previous reviews).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d5f8390. Configure here.
| number: issue.number, | ||
| open: !GONE_ACTIONS.has(action) && issue.state === "open", | ||
| url: issue.html_url, | ||
| }; |
There was a problem hiding this comment.
Reopen recreates closed issue items
Medium Severity
A GitHub reopened webhook treats the issue as a new ask for every remaining assignee and upserts. Core only finds open items, so a closed item is left in Done and a new open one is created. That brings the ask back after a close, even though a reopen is not supposed to restore it and only a later assignment should.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit d5f8390. Configure here.
There was a problem hiding this comment.
Leaving this as is on purpose. design/github.md says an issue that Junior opened is an Inbox item for its linked GitHub assignees, and the item closes when the issue closes. It does not say that a reopen leaves the item closed. A reopened issue has assignees again, so the item comes back for the people still assigned. That came out of the Warden thread on recreating closed items, so co-assignees are not left off. The scenario covers it.
…at/github-issue-assignee-items Co-Authored-By: BYK <[email protected]> # Conflicts: # packages/junior/src/chat/inbox-items/plugin.ts # packages/junior/tests/integration/plugin-inbox-items.test.ts
An attached link can carry the subject of an object once the naming job fills it. Core picked the earliest row of any kind, so an older link in another Conversation could own the item while the GitHub webhook reads only object cards, and the first assign failed the insert.


![Fix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/fix-with-codesmith-light-v2-3x.png)
Replaces #4100. Instead of a
review_byargument and a reaction poll, the GitHub assignees of an issue that Junior opened get its Inbox item. GitHub stays the source of truth: the item follows the assignees, and a dismiss changes GitHub.Stacked on #4164 (
{kind, id}subjects).Behavior
github:issue+ GitHub's numeric issue id, so a repo rename keeps the item.issueswebhooks on a bot-opened issue sync the item:assignedadds that person, andunassignedremoves them.closedcloses it. It also closes when no assignee with a linked account is left. A reopen does not bring a closed item back, but a new assignment does.DELETE /issues/{n}/assigneesfor the dismisser's linked login first. If GitHub refuses, the dismiss fails with a 409 and the person stays. If others are still on the item, only the dismisser leaves. If they were the last one, the item closes as dismissed, also when the last two dismiss at once.objectIdon their card, so they get no item.Core and plugin API
objectAnnotationSchemagets an optionalobjectId, the provider's own id for the object.github_createIssueandgithub_updateIssueset it on the issue card."annotation": the owner is the Conversation that first saved an object Annotation of the plugin whoseobjectIdis the subject id. The owner is ordered bycreated_at, thenconversation_id. A partial expression index (plugin,annotation_json->>'objectId',created_at) serves the lookup, and it is createdCONCURRENTLY. No new table copies GitHub state.assigneeRolesand hookinboxItemDismissed. With the flag, each assignee holds a role on the object: the role puts them on the item without the owner Conversation, an item with nobody Junior knows on it is not added, and a dismiss removes only the dismisser. The hook removes their role on the provider, and gets the owner Conversation's Annotations, the subject, and the dismisser's handle.PluginInboxItemOwnerErrorwhen a plugin changes an item through a Conversation that does not own it.rootConversationId,addedByTurnId, or linked Conversations. Only items of anassigneeRoleskind need that access read. The dashboard then shows no Conversation link, and the item's own row stands in for its owner path. A pull request row takes its repo name from the subject's card.Design
Two confirmed lines are added to
design/github.md## Rules, and adesign/inbox.mdrule is split into two. A dismiss now closes the item for everyone unless the subject gives each assignee their own place, such as a GitHub assignee or reviewer.design/inbox.mdalso gets the confirmed line: "A person whose role on a provider object puts them on its item sees the item and the object, but not its owner Conversation unless they can see it." The reviewer half of these rules comes in the stacked follow-up PR, #4312.Screenshots
A review request card for a viewer who can see its Conversation (before), and for one whose role on the pull request is their only way in (after). The after card has no Conversation button, its title opens the item's own Inbox row, and it leaves the Conversation's stack. These after shots were taken before 89ec9eb, which brings back the repo name, so the subtitle now reads
payments#91there too.via @BYK.
--
View Session [Sentry]