Repository navigation
feat(annotations): Read each Annotation's object live for its viewer - #4332
Conversation
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]>
…' into feat/annotation-subjects 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
Co-Authored-By: BYK <[email protected]>
…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]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
BYK
left a comment
There was a problem hiding this comment.
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?
|
Agreed, "live" here means "read through a cache", and the caching is uneven right now:
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:
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? |
BYK
left a comment
There was a problem hiding this comment.
Yup let's file that as a follow up.
|
Filed as #4374. |
…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]>
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]>
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.mdnow 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)inapi/objects/subject-cards.ts.readSubjectLinks, so a code change follows a renamed repository. Without a subject link, the storedurlis used.resolveObjectLinks, and GitHub still batches the page into one GraphQL query, so the existing request budgets hold.api/inbox-items/resolve-subjects.tsis now a thin wrapper over this.api/objects/live-annotations.tsapplies the cards:{plugin, key}Message refs still find it.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 returnowner/repo#n. A link type withoutlabelshows the host of the link.Surfaces
api/conversations/list.ts): one live read for the whole page of rows, child-agent rollup included.api/conversations/detail.ts): annotations are read live, and only for a viewer who can see private content.previewImagescome from the live card. The GitHub card carriesfacts.previewImageUrlsfrom the PR body.chat/slack/annotation-details.ts): read live for the Slack viewer. The posted card keeps its copy.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.tsis removed. It held the client-side/api/objectsoverlays on sidebar chips, Inbox rows, and home cards. Those components now render the server's annotations directly.savedObjects.tsbecomesobjectPreviews.ts. It now holds only the preview images of the Conversation's objects, taken from the live detail annotations.Not in this change
Note for the reviewer
via @BYK.
--
View Session [Sentry]