MCPcopy Create free account
hub / github.com/agent0ai/agent-zero / createAnnotationDraft

Function createAnnotationDraft

plugins/_browser/webui/browser-store.js:2132–2176  ·  view source on GitHub ↗
(payload, fallbackRect)

Source from the content-addressed store, hash-verified

2130 },
2131
2132 async createAnnotationDraft(payload, fallbackRect) {
2133 const contextId = this.normalizeContextId(this.activeBrowserContextId || this.contextId);
2134 if (!this.activeBrowserId || !contextId) return;
2135 const sequence = this._annotationSequence + 1;
2136 const browserId = this.activeBrowserId;
2137 const url = this.activeAnnotationUrl();
2138 const title = this.activeTitle;
2139 this._annotationSequence = sequence;
2140 this.annotationBusy = true;
2141 this.annotationError = "";
2142 try {
2143 const response = await websocket.request(
2144 "browser_viewer_annotation",
2145 {
2146 context_id: contextId,
2147 browser_id: browserId,
2148 viewer_id: this._viewerToken,
2149 payload,
2150 },
2151 { timeoutMs: 10000 },
2152 );
2153 if (sequence !== this._annotationSequence) return;
2154 const data = firstOk(response);
2155 const metadata = data.annotation || {};
2156 this.annotationDraft = {
2157 id: makeViewerToken(),
2158 browserId,
2159 contextId,
2160 url,
2161 title,
2162 kind: metadata.kind || payload.kind,
2163 rect: this.annotationRectFromMetadata(metadata, fallbackRect),
2164 metadata,
2165 createdAt: Date.now(),
2166 };
2167 this.annotationDraftText = "";
2168 } catch (error) {
2169 this.annotationError = error instanceof Error ? error.message : String(error);
2170 this.error = this.annotationError;
2171 } finally {
2172 if (sequence === this._annotationSequence) {
2173 this.annotationBusy = false;
2174 }
2175 }
2176 },
2177
2178 annotationRectFromMetadata(metadata = {}, fallbackRect = {}) {
2179 const targetRect = metadata?.target?.rect || metadata?.rect || null;

Callers

nothing calls this directly

Calls 4

requestMethod · 0.80
firstOkFunction · 0.70
makeViewerTokenFunction · 0.70
nowMethod · 0.45

Tested by

no test coverage detected