MCPcopy Create free account
hub / github.com/backnotprop/plannotator / getContext

Method getContext

packages/shared/pr-context-live.ts:134–148  ·  view source on GitHub ↗

Return the latest context, sharing any in-flight provider refresh.

(url: string, ref: PRRef)

Source from the content-addressed store, hash-verified

132
133 /** Return the latest context, sharing any in-flight provider refresh. */
134 async getContext(url: string, ref: PRRef): Promise<PRContext> {
135 const entry = this.ensureEntry(url, ref);
136 if (!this.shouldRefresh(entry)) {
137 if (entry.inflight) return entry.inflight;
138 if (entry.context) return entry.context;
139 throw new Error(entry.error ?? "PR context is unavailable");
140 }
141
142 try {
143 return await this.refresh(url, ref, "poll");
144 } catch (cause: unknown) {
145 if (entry.context) return entry.context;
146 throw cause;
147 }
148 }
149
150 /** Subscribe to live updates for a PR URL until the returned cleanup runs. */
151 watch(url: string, ref: PRRef, subscriber: PRContextSubscriber): () => void {

Callers

nothing calls this directly

Calls 3

ensureEntryMethod · 0.95
shouldRefreshMethod · 0.95
refreshMethod · 0.95

Tested by

no test coverage detected