Skip to content

feat(annotations): Read each Annotation's object live for its viewer - #4332

Merged
BYK merged 6 commits into
feat/github-issue-assignee-itemsfrom
feat/annotation-live-cards
Nov 25, 2026
Merged

BYK merged 6 commits into
feat/github-issue-assignee-itemsfrom
feat/annotation-live-cards

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

Conversation Annotation cards now read their object's title and state live for each viewer. They no longer use the facts Junior saved when the tool ran. Cards also stop reading the stored label. The plugin makes the label from the object.

Design

design/annotations.md now says that an Annotation stores the title and a link (for search and for a card while the provider is down), and that the plugin makes the short label from the object. That change is its own commit.

One resolver for subjects

Inbox items and Annotations share one subject → link → card path: resolveObjectCards(viewer, sources) in api/objects/subject-cards.ts.

  • Link: a source's link is its subject link from readSubjectLinks, so a code change follows a renamed repository. Without a subject link, the stored url is used.
  • Batching: one call reads a whole page through resolveObjectLinks, and GitHub still batches the page into one GraphQL query, so the existing request budgets hold.
  • Owner check: an Annotation names its owner, the plugin and object type. Only a link type of that plugin that opens that type reads its card. A card from another link type doesn't count, such as the web page fallback for a link the viewer can't open.
  • Inbox: api/inbox-items/resolve-subjects.ts is now a thin wrapper over this.

api/objects/live-annotations.ts applies the cards:

  • Live card: it replaces the saved facts, including the label. The Annotation keeps its key, plugin, subject, and timestamps, so legacy Slack digest refs and {plugin, key} Message refs still find it.
  • No access or failed read: a viewer who can't read the object, or a read that fails, gets only the link and the label that its link type makes from the link.
  • No matching link type: the Annotation keeps its saved facts until its resolver lands. Examples are Linear, automations, and links saved before they had a type.

The object-link cache entry is now staleIfError, so a failed read keeps the last good card.

Labels from the link

Link types get an optional label(url) method (PluginObjectLinkDefinition.label). GitHub issue and pull request links return owner/repo#n. A link type without label shows the host of the link.

Surfaces

  • Dashboard sidebar chips (api/conversations/list.ts): one live read for the whole page of rows, child-agent rollup included.
  • Conversation detail (api/conversations/detail.ts): annotations are read live, and only for a viewer who can see private content. previewImages come from the live card. The GitHub card carries facts.previewImageUrls from the PR body.
  • Slack card details (chat/slack/annotation-details.ts): read live for the Slack viewer. The posted card keeps its copy.
  • Delivered Message cards (chat/conversations/pending-cards.ts): these have no single viewer. At delivery, each selected object is read once with the access of the person who started the root Conversation (actorIdentityId → User). Junior stores nothing extra. If that read can't happen, the card shows the saved facts with the label from the link. That covers system-started Conversations and failed reads.

Dashboard

  • liveAnnotations.ts is removed. It held the client-side /api/objects overlays on sidebar chips, Inbox rows, and home cards. Those components now render the server's annotations directly.
  • savedObjects.ts becomes objectPreviews.ts. It now holds only the preview images of the Conversation's objects, taken from the live detail annotations.
  • The full object card no longer shows "Last fetched …", because its facts are now current.
Desktop Mobile
Light light desktop light mobile
Dark dark desktop dark mobile

Not in this change

  • The webhook status writes, the preview refresh, and the saved JSON facts and columns all stay. Later changes remove them.

Note for the reviewer

  • Head: 293c4fb48. It includes c8aef83a0 (the design line) and 293c4fb48 (labels made by the plugin from the object or link, never the stored label).
  • ETag risk: the Conversation detail ETag doesn't include live provider state. A poll returns 304 until the database changes. Webhook writes still cause that today, but once they go, live changes won't show until something else changes the Conversation.

via @BYK.

--

View Session [Sentry]

sentry-junior Bot and others added 6 commits November 25, 2026 14:27
An Annotation now stores the subject of its object, in the Inbox form
(`<plugin>:<kind>` or a core kind), and what the Conversation did to it:
created, changed, or attached. Tool and hook results name the subject and
the action, with the kinds that the plugin registers in `inboxSubjects`.
The subject replaces `objectId`, and the Inbox owner lookup reads it. A
trigger fills both columns for rows that old workers write, and for
objects whose provider id is not known.

Also adds the Annotations design doc and its terms.

Co-Authored-By: BYK <[email protected]>
Sidebar chips, the Conversation detail, and Slack card details now read
each object's title and state live, through the same subject-to-link-to-
card resolver as the Inbox. A viewer who cannot read the object, or a
failed read, gets only the stored label and link. A delivered Message
card reads its object once with the access of the person who started the
Conversation, and falls back to the saved facts.

The dashboard drops its client-side annotation overlays and renders the
server's cards. Preview images come from the live card.

Co-Authored-By: BYK <[email protected]>
…' into feat/annotation-live-cards

Co-Authored-By: BYK <[email protected]>

# Conflicts:
#	packages/junior/tests/integration/annotation-cards.test.ts
…ved label

A card no longer shows an Annotation's stored label. It shows the label
of the live card, or, when Junior cannot read the object, the label
that its link type makes from the link. Link types get an optional
`label(url)` method. GitHub issue and pull request links make
`owner/repo#n`. A link type without one shows the host of the link.

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 25, 2026 4:01pm UTC

Request Review

@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 25, 2026 3:58pm UTC

Request Review

@BYK BYK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One thing I'm concerned here: we keep saying "live" but we cannot do this without some caching like we do for GitHub objects. So we need to have a centralized HTTP cache with proper TTLs and same or similar rules for what we decided for GitHub objects and use that to avoid too many external requests and also avoid fetching the same thing over and over again.

In this context, I think "last fetched" also has a place to show the freshness, right?

@sentry-junior

sentry-junior Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Agreed, "live" here means "read through a cache", and the caching is uneven right now:

  • Core card cache (api/objects/resolve.ts): one entry per viewer and URL, 60s TTL. This PR makes it staleIfError. Google, Notion and Sentry link types use it.
  • GitHub opts out of that cache (cacheCards: false). It reads its own shared object cache in junior-github/src/object-cache.ts: pull requests 1h and issues 60s, kept fresh by webhooks, with ETag-conditional requests saved for 6h (conditional-requests.ts).

So there's no shared HTTP layer. Every non-GitHub plugin refetches each viewer's card once a minute, and nothing tells the UI how old a card is.

Proposal, as a follow-up PR on top of this stack:

  1. Move GitHub's conditional-request cache into core as one HTTP cache that plugin egress uses. Entries are keyed by URL and credential scope, and each link type or plugin sets its TTL. It sends If-None-Match/If-Modified-Since on revalidation and serves stale on error. GitHub then uses that cache, and its object cache keeps only the webhook-driven invalidation.
  2. Have each card carry fetchedAt, the time its cache entry was stored. Then put "Last fetched …" back on the full card, shown when the card is older than its link type's TTL, which is when it's being served stale.

I'd keep both out of #4332 since it's approved and the cache change touches every plugin's egress. Want me to open that as the next PR in the stack, or fold it in here?

@sentry-junior
sentry-junior Bot requested a review from BYK November 25, 2026 21:28

@BYK BYK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yup let's file that as a follow up.

@sentry-junior

sentry-junior Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Filed as #4374.

@BYK
BYK merged commit 6729e6c into feat/github-issue-assignee-items Nov 25, 2026
8 checks passed
@BYK
BYK deleted the feat/annotation-live-cards branch November 25, 2026 21:53
BYK added a commit that referenced this pull request Nov 25, 2026
…anges (#4334)

Cards now read their object live (#4332), so a merge or
close at the provider no longer needs to touch the Annotation. This PR
deletes those writes. A change at the provider now writes nothing to
Annotations.

**Removed**
- Pull request outcomes: `pull-request-outcomes/apply.ts`,
`reconcile.ts` and `apply-task.ts` no longer update the GitHub
Annotation's status.
- The issue-close footer path: deleted `webhooks/issue-outcome.ts` and
its call in `webhooks/handler.ts`.
- The preview refresh: deleted `webhooks/pull-request-preview.ts`. The
live PR card already includes the preview images from the PR body.
- `updateGitHubAnnotations`, `githubAnnotationChange` and
`githubStatusAnnotation` from `junior-github/src/annotations.ts`.
- `ConversationChangeBatch.annotations` and
`ConversationAnnotationChange` from the plugin API, and the core code
that applied them (`chat/plugins/conversation-changes.ts`). The batch
section of `build-a-plugin.md` is updated.

**Open pages stay current**
Before, the webhook write moved the Conversation's version, so an open
page and the versions poll read the new state. Without the write, they
kept the old card.
- New plugin API: `ctx.annotations.objectChanged(subject)`. Core moves
`detail_version` of each Conversation that annotates that subject
(`touchAnnotatedConversations`, which uses the subject index). The
detail ETag and the versions token then change, and the page reads the
live card again. It writes no Annotation.
- GitHub calls it from `issues` and `pull_request` webhooks, with
GitHub's id from the payload, only when the cached object changed. A
redelivery moves nothing.
- Rows without a provider id (old `link` subjects) aren't matched until
the rename backfill gives them one.
- `build-a-plugin.md` documents the call next to `cacheCards: false`.

**Also**
- `annotationFromRow` returns the subject of core Annotations
(`automation`) too. It used to drop it because their `subject_kind` has
no plugin prefix.
- The detail annotation tests move to `detail-annotations.test.ts`, to
keep `detail.test.ts` under the file length limit.

The saved JSON copy stays until the facts-drop PR, so the "keeps a copy"
Gap line stays for now.

<!-- 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 added a commit that referenced this pull request Nov 26, 2026
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]>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 293c4fb4 Deployed Nov 25, 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.

1 participant