Skip to content

feat(github): Add an Inbox item for the assignees of an issue Junior opened - #4308

Open
sentry-junior[bot] wants to merge 45 commits into
ref/inbox-item-subjectsfrom
feat/github-issue-assignee-items
Open

sentry-junior[bot] wants to merge 45 commits into
ref/inbox-item-subjectsfrom
feat/github-issue-assignee-items

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Replaces #4100. Instead of a review_by argument 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

  • Subject github:issue + GitHub's numeric issue id, so a repo rename keeps the item.
  • issues webhooks on a bot-opened issue sync the item:
    • assigned adds that person, and unassigned removes them.
    • closed closes 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.
    • Assignees without a linked GitHub account are skipped. If nobody on the issue has one, the issue gets no item: it is never up for grabs.
    • When the issue footer no longer names the owner Conversation, the webhook logs a warning and skips the item.
  • A linked assignee gets the item even when they are not in the owner Conversation. They can already see the issue on GitHub. Their card shows the item and the issue, but not the Conversation unless they can see it.
  • Dismiss calls DELETE /issues/{n}/assignees for 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.
  • Issues opened before this ships have no objectId on their card, so they get no item.

Core and plugin API

  • objectAnnotationSchema gets an optional objectId, the provider's own id for the object. github_createIssue and github_updateIssue set it on the issue card.
  • New subject owner "annotation": the owner is the Conversation that first saved an object Annotation of the plugin whose objectId is the subject id. The owner is ordered by created_at, then conversation_id. A partial expression index (plugin, annotation_json->>'objectId', created_at) serves the lookup, and it is created CONCURRENTLY. No new table copies GitHub state.
  • New subject flag assigneeRoles and hook inboxItemDismissed. 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.
  • Core throws PluginInboxItemOwnerError when a plugin changes an item through a Conversation that does not own it.
  • For a viewer who cannot see an item's owner Conversation, the Inbox payload names no rootConversationId, addedByTurnId, or linked Conversations. Only items of an assigneeRoles kind 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 a design/inbox.md rule 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.md also 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#91 there too.

Before After
Light desktop
Light mobile
Dark desktop
Dark mobile

via @BYK.

--

View Session [Sentry]

sentry-junior Bot and others added 3 commits November 25, 2026 13:24
…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]>
@vercel

vercel Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 26, 2026 1:09pm UTC

Request Review

@sentry-junior
sentry-junior Bot requested a review from BYK November 25, 2026 13:29
@sentry-junior
sentry-junior Bot added this pull request to stack #4309 November 25, 2026 13:29
@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 25, 2026

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

…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]>
@blacksmith-sh

This comment has been minimized.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

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]>
sentry-junior Bot and others added 2 commits November 25, 2026 20:29
…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]>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

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.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

number: issue.number,
open: !GONE_ACTIONS.has(action) && issue.state === "open",
url: issue.html_url,
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f4517eb. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@blacksmith-sh

blacksmith-sh Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Found 3 test failures on Blacksmith runners:

Failures

Test View Logs
packages/junior-dashboard/e2e/inbox/
conversations.spec.ts:297:3 › new UI › reads the card of each link once, for rows near
the screen
View Logs
money-units/money-units View Logs
provider-state/provider-state View Logs

Fix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

… migrations

Also give the issue and annotation-name test tools the hasParent field
that the Conversation kind merge added.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

// 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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9b083b5. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Comment on lines +17 to +49
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 };

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.transferred payloads use changes.owner.from as a user/org object with top-level login (OpenAPI oneOf user|organization), not { organization?: {login}, user?: {login} }.
  • repositoryMoveSchema defines from with optional nested organization/user only; Zod strips the real login, leaving from: {}.
  • movedRepository then does changes.owner?.from.organization?.login ?? changes.owner?.from.user?.login ?? repository.owner.login, so owner is the new login, from equals repository.full_name, and the function returns undefined.
  • moveGitHubRepositoryAnnotations therefore never calls annotations.objectsMoved on transfer; rename still works because it uses changes.repository.name.from.

Identified by Warden · code-review · TV3-R8L

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

sentry-junior Bot and others added 3 commits November 26, 2026 10:45
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]>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

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

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Fix All in Cursor

❌ 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,
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d5f8390. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 9ab51c38 Deployed Nov 26, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants