context_drop 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +149 -12
  3. data/Rakefile +110 -1
  4. data/app/assets/javascripts/context_drop/context_drop.js +1759 -105
  5. data/app/controllers/context_drop/application_controller.rb +52 -3
  6. data/app/controllers/context_drop/configs_controller.rb +10 -1
  7. data/app/controllers/context_drop/dashboard/feedbacks_controller.rb +99 -14
  8. data/app/controllers/context_drop/feedbacks_controller.rb +536 -17
  9. data/app/helpers/context_drop/dashboard_helper.rb +4 -0
  10. data/app/javascript/context_drop/__tests__/api-client.test.ts +255 -0
  11. data/app/javascript/context_drop/__tests__/widget.test.ts +355 -1
  12. data/app/javascript/context_drop/api-client.ts +343 -22
  13. data/app/javascript/context_drop/element-picker.ts +1 -1
  14. data/app/javascript/context_drop/icons.ts +6 -0
  15. data/app/javascript/context_drop/screenshot.ts +1 -1
  16. data/app/javascript/context_drop/styles.ts +311 -0
  17. data/app/javascript/context_drop/types.ts +141 -6
  18. data/app/javascript/context_drop/widget.ts +1072 -35
  19. data/app/models/context_drop/attachment.rb +5 -0
  20. data/app/models/context_drop/comment.rb +50 -0
  21. data/app/models/context_drop/feedback.rb +81 -11
  22. data/app/services/context_drop/ownership_token.rb +114 -0
  23. data/app/views/context_drop/dashboard/feedbacks/index.html.erb +14 -0
  24. data/app/views/context_drop/dashboard/feedbacks/show.html.erb +169 -2
  25. data/app/views/layouts/context_drop/application.html.erb +131 -7
  26. data/config/routes.rb +16 -1
  27. data/db/migrate/20261113000005_add_deleted_at_to_context_drop_feedbacks.rb +11 -0
  28. data/db/migrate/20261116000001_create_context_drop_comments_and_update_statuses.rb +44 -0
  29. data/lib/context_drop/agent/orchestrator.rb +1 -1
  30. data/lib/context_drop/configuration.rb +26 -0
  31. data/lib/context_drop/mcp/dispatcher.rb +2 -1
  32. data/lib/context_drop/mcp/prompts/investigate_feedback.rb +5 -3
  33. data/lib/context_drop/mcp/server.rb +1 -0
  34. data/lib/context_drop/mcp/tools/add_feedback_comment.rb +139 -0
  35. data/lib/context_drop/mcp/tools/get_feedback.rb +45 -6
  36. data/lib/context_drop/mcp/tools/get_feedback_attachment.rb +3 -0
  37. data/lib/context_drop/mcp/tools/list_feedbacks.rb +23 -3
  38. data/lib/context_drop/mcp/tools/update_feedback_status.rb +5 -3
  39. data/lib/context_drop/version.rb +1 -1
  40. metadata +7 -2
@@ -4,20 +4,87 @@ import type {
4
4
  AgentKeysUpdatePayload,
5
5
  AgentKeysUpdateResponse,
6
6
  AgentStatusResponse,
7
+ ContextDropApiClientOptions,
7
8
  CrossEnvFeedbackListResponse,
9
+ CreateCommentPayload,
10
+ CreateCommentResponse,
11
+ FeedbackDeleteResponse,
8
12
  FeedbackSubmissionPayload,
9
13
  FeedbackSubmissionResponse,
14
+ FeedbackUpdatePayload,
15
+ FeedbackUpdateResponse,
16
+ OwnFeedbackListResponse,
10
17
  ProposedFileEdit,
11
18
  WidgetConfig
12
19
  } from "./types.ts";
13
20
 
21
+ const OWNERSHIP_STORAGE_KEY = "context_drop_ownership_tokens";
22
+ const MAX_STORED_OWNERSHIP_TOKENS = 50;
23
+
24
+ function getBrowserLocalStorage(): Storage | null {
25
+ try {
26
+ if (typeof window !== "undefined" && "localStorage" in window) {
27
+ const store = window.localStorage;
28
+ if (store && typeof store.getItem === "function" && typeof store.setItem === "function") {
29
+ return store;
30
+ }
31
+ }
32
+ } catch {
33
+ // Storage unavailable or restricted by browser privacy policy
34
+ }
35
+ return null;
36
+ }
37
+
14
38
  export class ContextDropApiClient {
15
39
  private baseUrl: string;
40
+ private credentials: RequestCredentials;
41
+ private customHeaders: Record<string, string>;
16
42
  private cachedCsrfToken: string | null = null;
43
+ private configFetched: boolean = false;
17
44
  private inFlightConfigPromise: Promise<WidgetConfig> | null = null;
45
+ private memoryOwnershipTokens: Map<string, string> = new Map();
18
46
 
19
- constructor(baseUrl: string = "/context_drop") {
47
+ constructor(baseUrl: string = "/context_drop", options: ContextDropApiClientOptions = {}) {
20
48
  this.baseUrl = baseUrl.replace(/\/+$/, "") || "/context_drop";
49
+ this.credentials = options.credentials || "same-origin";
50
+ this.customHeaders = options.headers ? { ...options.headers } : {};
51
+ }
52
+
53
+ public getBaseUrl(): string {
54
+ return this.baseUrl;
55
+ }
56
+
57
+ public setCredentials(credentials: RequestCredentials): void {
58
+ this.credentials = credentials;
59
+ }
60
+
61
+ public setHeaders(headers: Record<string, string>): void {
62
+ this.customHeaders = { ...headers };
63
+ }
64
+
65
+ private isCrossOriginEndpoint(): boolean {
66
+ if (!/^https?:\/\//i.test(this.baseUrl)) {
67
+ return false;
68
+ }
69
+ if (typeof window === "undefined" || !window.location || !window.location.origin) {
70
+ return true;
71
+ }
72
+ try {
73
+ return new URL(this.baseUrl, window.location.origin).origin !== window.location.origin;
74
+ } catch {
75
+ return false;
76
+ }
77
+ }
78
+
79
+ private mergeClientHeaders(base: Record<string, string>): Record<string, string> {
80
+ const merged: Record<string, string> = {
81
+ ...this.customHeaders,
82
+ ...base
83
+ };
84
+ if (this.isCrossOriginEndpoint()) {
85
+ merged["X-Context-Drop-Client"] = "1";
86
+ }
87
+ return merged;
21
88
  }
22
89
 
23
90
  public getCsrfToken(): string | null {
@@ -48,10 +115,10 @@ export class ContextDropApiClient {
48
115
  try {
49
116
  const response = await fetch(`${this.baseUrl}/config`, {
50
117
  method: "GET",
51
- credentials: "same-origin",
52
- headers: {
118
+ credentials: this.credentials,
119
+ headers: this.mergeClientHeaders({
53
120
  Accept: "application/json"
54
- }
121
+ })
55
122
  });
56
123
 
57
124
  if (!response.ok) {
@@ -59,6 +126,7 @@ export class ContextDropApiClient {
59
126
  }
60
127
 
61
128
  const config = (await response.json()) as WidgetConfig;
129
+ this.configFetched = true;
62
130
  if (config && typeof config.csrf_token === "string" && config.csrf_token.trim().length > 0) {
63
131
  this.cachedCsrfToken = config.csrf_token.trim();
64
132
  if (typeof document !== "undefined") {
@@ -86,6 +154,9 @@ export class ContextDropApiClient {
86
154
  if (this.cachedCsrfToken) {
87
155
  return this.cachedCsrfToken;
88
156
  }
157
+ if (this.configFetched) {
158
+ return null;
159
+ }
89
160
  }
90
161
 
91
162
  try {
@@ -130,7 +201,8 @@ export class ContextDropApiClient {
130
201
 
131
202
  const errorMessage = parsedError || rawText || "";
132
203
  const shouldRetryCsrf =
133
- this.isCsrfError(response.status, errorMessage) || (!csrfToken && response.status === 422);
204
+ this.isCsrfError(response.status, errorMessage) ||
205
+ (!csrfToken && !this.configFetched && response.status === 422);
134
206
 
135
207
  if (shouldRetryCsrf) {
136
208
  csrfToken = await this.resolveCsrfToken(true);
@@ -161,7 +233,7 @@ export class ContextDropApiClient {
161
233
  if (csrfToken) {
162
234
  headers["X-CSRF-Token"] = csrfToken;
163
235
  }
164
- return headers;
236
+ return this.mergeClientHeaders(headers);
165
237
  }
166
238
 
167
239
  public async uploadAttachment(file: Blob, filename: string): Promise<{ signed_blob_id: string }> {
@@ -178,8 +250,8 @@ export class ContextDropApiClient {
178
250
 
179
251
  return fetch(`${this.baseUrl}/attachments`, {
180
252
  method: "POST",
181
- credentials: "same-origin",
182
- headers,
253
+ credentials: this.credentials,
254
+ headers: this.mergeClientHeaders(headers),
183
255
  body: formData
184
256
  });
185
257
  };
@@ -187,25 +259,274 @@ export class ContextDropApiClient {
187
259
  return this.executeWithCsrfRetry(makeRequest, "Upload failed");
188
260
  }
189
261
 
262
+ private ownershipScopedKey(id: number | string): string {
263
+ return `${this.baseUrl}::${String(id)}`;
264
+ }
265
+
266
+ private readStoredTokenMap(): Record<string, string> {
267
+ const store = getBrowserLocalStorage();
268
+ if (!store) {
269
+ const out: Record<string, string> = {};
270
+ for (const [k, v] of this.memoryOwnershipTokens.entries()) {
271
+ out[k] = v;
272
+ }
273
+ return out;
274
+ }
275
+
276
+ try {
277
+ const raw = store.getItem(OWNERSHIP_STORAGE_KEY);
278
+ if (!raw) return {};
279
+ const parsed = JSON.parse(raw) as unknown;
280
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
281
+ return {};
282
+ }
283
+ const clean: Record<string, string> = {};
284
+ for (const [k, v] of Object.entries(parsed as Record<string, unknown>)) {
285
+ if (typeof v === "string" && v.trim().length > 0) {
286
+ clean[k] = v.trim();
287
+ }
288
+ }
289
+ return clean;
290
+ } catch {
291
+ return {};
292
+ }
293
+ }
294
+
295
+ private writeStoredTokenMap(map: Record<string, string>): void {
296
+ const entries = Object.entries(map);
297
+ const trimmedEntries =
298
+ entries.length > MAX_STORED_OWNERSHIP_TOKENS
299
+ ? entries.slice(entries.length - MAX_STORED_OWNERSHIP_TOKENS)
300
+ : entries;
301
+
302
+ this.memoryOwnershipTokens.clear();
303
+ const bounded: Record<string, string> = {};
304
+ for (const [k, v] of trimmedEntries) {
305
+ bounded[k] = v;
306
+ this.memoryOwnershipTokens.set(k, v);
307
+ }
308
+
309
+ const store = getBrowserLocalStorage();
310
+ if (store) {
311
+ try {
312
+ store.setItem(OWNERSHIP_STORAGE_KEY, JSON.stringify(bounded));
313
+ } catch {
314
+ // Non-fatal if storage quota exceeded
315
+ }
316
+ }
317
+ }
318
+
319
+ public getOwnershipToken(id: number | string): string | null {
320
+ const map = this.readStoredTokenMap();
321
+ const scoped = map[this.ownershipScopedKey(id)];
322
+ if (scoped) return scoped;
323
+ const plain = map[String(id)];
324
+ return plain || null;
325
+ }
326
+
327
+ public setOwnershipToken(id: number | string, token: string): void {
328
+ const trimmed = typeof token === "string" ? token.trim() : "";
329
+ if (!trimmed) return;
330
+ const map = this.readStoredTokenMap();
331
+ const key = this.ownershipScopedKey(id);
332
+ delete map[key];
333
+ map[key] = trimmed;
334
+ this.writeStoredTokenMap(map);
335
+ }
336
+
337
+ public removeOwnershipToken(id: number | string): void {
338
+ const map = this.readStoredTokenMap();
339
+ const scopedKey = this.ownershipScopedKey(id);
340
+ const plainKey = String(id);
341
+ if (!(scopedKey in map) && !(plainKey in map)) return;
342
+ delete map[scopedKey];
343
+ delete map[plainKey];
344
+ this.writeStoredTokenMap(map);
345
+ }
346
+
347
+ public getAllOwnershipTokens(): string[] {
348
+ const map = this.readStoredTokenMap();
349
+ const prefix = `${this.baseUrl}::`;
350
+ const tokens: string[] = [];
351
+ for (const [k, v] of Object.entries(map)) {
352
+ if ((k.startsWith(prefix) || !k.includes("::")) && v && !tokens.includes(v)) {
353
+ tokens.push(v);
354
+ }
355
+ }
356
+ return tokens;
357
+ }
358
+
359
+ public buildAttachmentPreviewUrl(
360
+ feedbackId: number | string,
361
+ attachmentId: number | string,
362
+ ownershipToken?: string | null
363
+ ): string {
364
+ const token = ownershipToken || this.getOwnershipToken(feedbackId);
365
+ const base = `${this.baseUrl}/feedback/${encodeURIComponent(String(feedbackId))}/attachments/${encodeURIComponent(String(attachmentId))}`;
366
+ return token ? `${base}?ownership_token=${encodeURIComponent(token)}` : base;
367
+ }
368
+
190
369
  public async submitFeedback(payload: FeedbackSubmissionPayload): Promise<FeedbackSubmissionResponse> {
191
370
  const makeRequest = async (csrfToken: string | null) =>
192
371
  fetch(`${this.baseUrl}/feedback`, {
193
372
  method: "POST",
194
- credentials: "same-origin",
373
+ credentials: this.credentials,
195
374
  headers: this.buildJsonHeaders(csrfToken),
196
375
  body: JSON.stringify({ feedback: payload })
197
376
  });
198
377
 
199
- return this.executeWithCsrfRetry(makeRequest, "Submission failed");
378
+ const response = await this.executeWithCsrfRetry<FeedbackSubmissionResponse>(
379
+ makeRequest,
380
+ "Submission failed"
381
+ );
382
+
383
+ const token = response?.ownership_token || response?.feedback?.ownership_token;
384
+ if (response?.id !== undefined && token) {
385
+ this.setOwnershipToken(response.id, token);
386
+ }
387
+ return response;
388
+ }
389
+
390
+ public async fetchOwnFeedbacks(limit: number = 30): Promise<OwnFeedbackListResponse> {
391
+ const headers: Record<string, string> = {
392
+ Accept: "application/json"
393
+ };
394
+ const tokens = this.getAllOwnershipTokens();
395
+ if (tokens.length > 0) {
396
+ headers["X-Context-Drop-Ownership-Tokens"] = tokens.join(",");
397
+ }
398
+
399
+ const qs = limit > 0 ? `?limit=${encodeURIComponent(String(limit))}` : "";
400
+ const response = await fetch(`${this.baseUrl}/feedback${qs}`, {
401
+ method: "GET",
402
+ credentials: this.credentials,
403
+ headers: this.mergeClientHeaders(headers)
404
+ });
405
+
406
+ if (!response.ok) {
407
+ const errBody = await response.json().catch(() => ({}));
408
+ throw new Error(
409
+ (errBody as { error?: string }).error || `Failed to load own feedbacks (${response.status})`
410
+ );
411
+ }
412
+
413
+ const parsed = (await response.json().catch(() => ({}))) as Partial<OwnFeedbackListResponse>;
414
+ const feedbacks = Array.isArray(parsed?.feedbacks) ? parsed.feedbacks : [];
415
+ for (const item of feedbacks) {
416
+ if (item && item.id !== undefined && typeof item.ownership_token === "string") {
417
+ this.setOwnershipToken(item.id, item.ownership_token);
418
+ }
419
+ }
420
+
421
+ return {
422
+ total_count: typeof parsed?.total_count === "number" ? parsed.total_count : feedbacks.length,
423
+ feedbacks
424
+ };
425
+ }
426
+
427
+ public async updateFeedback(
428
+ id: number | string,
429
+ payload: FeedbackUpdatePayload,
430
+ ownershipToken?: string | null
431
+ ): Promise<FeedbackUpdateResponse> {
432
+ const resolvedToken = ownershipToken || this.getOwnershipToken(id);
433
+ const makeRequest = async (csrfToken: string | null) => {
434
+ const headers = this.buildJsonHeaders(csrfToken);
435
+ if (resolvedToken) {
436
+ headers["X-Context-Drop-Ownership-Token"] = resolvedToken;
437
+ }
438
+ const bodyPayload: Record<string, unknown> = { feedback: payload };
439
+ if (resolvedToken) {
440
+ bodyPayload.ownership_token = resolvedToken;
441
+ }
442
+ return fetch(`${this.baseUrl}/feedback/${encodeURIComponent(String(id))}`, {
443
+ method: "PATCH",
444
+ credentials: this.credentials,
445
+ headers,
446
+ body: JSON.stringify(bodyPayload)
447
+ });
448
+ };
449
+
450
+ const response = await this.executeWithCsrfRetry<FeedbackUpdateResponse>(
451
+ makeRequest,
452
+ "Update failed"
453
+ );
454
+
455
+ const nextToken = response?.ownership_token || response?.feedback?.ownership_token;
456
+ if (response?.id !== undefined && nextToken) {
457
+ this.setOwnershipToken(response.id, nextToken);
458
+ }
459
+ return response;
460
+ }
461
+
462
+ public async createComment(
463
+ id: number | string,
464
+ payload: CreateCommentPayload,
465
+ ownershipToken?: string | null
466
+ ): Promise<CreateCommentResponse> {
467
+ const resolvedToken = ownershipToken || this.getOwnershipToken(id);
468
+ const makeRequest = async (csrfToken: string | null) => {
469
+ const headers = this.buildJsonHeaders(csrfToken);
470
+ if (resolvedToken) {
471
+ headers["X-Context-Drop-Ownership-Token"] = resolvedToken;
472
+ }
473
+ const bodyPayload: Record<string, unknown> = { comment: payload };
474
+ if (resolvedToken) {
475
+ bodyPayload.ownership_token = resolvedToken;
476
+ }
477
+ return fetch(`${this.baseUrl}/feedback/${encodeURIComponent(String(id))}/comments`, {
478
+ method: "POST",
479
+ credentials: this.credentials,
480
+ headers,
481
+ body: JSON.stringify(bodyPayload)
482
+ });
483
+ };
484
+
485
+ const response = await this.executeWithCsrfRetry<CreateCommentResponse>(
486
+ makeRequest,
487
+ "Comment failed"
488
+ );
489
+
490
+ const nextToken = response?.feedback?.ownership_token;
491
+ if (response?.feedback?.id !== undefined && nextToken) {
492
+ this.setOwnershipToken(response.feedback.id, nextToken);
493
+ }
494
+ return response;
495
+ }
496
+
497
+ public async deleteFeedback(
498
+ id: number | string,
499
+ ownershipToken?: string | null
500
+ ): Promise<FeedbackDeleteResponse> {
501
+ const resolvedToken = ownershipToken || this.getOwnershipToken(id);
502
+ const makeRequest = async (csrfToken: string | null) => {
503
+ const headers = this.buildJsonHeaders(csrfToken);
504
+ if (resolvedToken) {
505
+ headers["X-Context-Drop-Ownership-Token"] = resolvedToken;
506
+ }
507
+ return fetch(`${this.baseUrl}/feedback/${encodeURIComponent(String(id))}`, {
508
+ method: "DELETE",
509
+ credentials: this.credentials,
510
+ headers
511
+ });
512
+ };
513
+
514
+ const response = await this.executeWithCsrfRetry<FeedbackDeleteResponse>(
515
+ makeRequest,
516
+ "Delete failed"
517
+ );
518
+
519
+ this.removeOwnershipToken(id);
520
+ return response;
200
521
  }
201
522
 
202
523
  public async fetchAgentStatus(): Promise<AgentStatusResponse> {
203
524
  const response = await fetch(`${this.baseUrl}/agent/status`, {
204
525
  method: "GET",
205
- credentials: "same-origin",
206
- headers: {
526
+ credentials: this.credentials,
527
+ headers: this.mergeClientHeaders({
207
528
  Accept: "application/json"
208
- }
529
+ })
209
530
  });
210
531
 
211
532
  if (!response.ok) {
@@ -222,7 +543,7 @@ export class ContextDropApiClient {
222
543
  const makeRequest = async (csrfToken: string | null) =>
223
544
  fetch(`${this.baseUrl}/agent/keys`, {
224
545
  method: "POST",
225
- credentials: "same-origin",
546
+ credentials: this.credentials,
226
547
  headers: this.buildJsonHeaders(csrfToken),
227
548
  body: JSON.stringify(payload)
228
549
  });
@@ -234,7 +555,7 @@ export class ContextDropApiClient {
234
555
  const makeRequest = async (csrfToken: string | null) =>
235
556
  fetch(`${this.baseUrl}/agent/keys?provider=${encodeURIComponent(provider)}`, {
236
557
  method: "DELETE",
237
- credentials: "same-origin",
558
+ credentials: this.credentials,
238
559
  headers: this.buildJsonHeaders(csrfToken)
239
560
  });
240
561
 
@@ -248,10 +569,10 @@ export class ContextDropApiClient {
248
569
  const qs = `environment=${encodeURIComponent(environment)}&status=${encodeURIComponent(status)}`;
249
570
  const response = await fetch(`${this.baseUrl}/agent/feedbacks?${qs}`, {
250
571
  method: "GET",
251
- credentials: "same-origin",
252
- headers: {
572
+ credentials: this.credentials,
573
+ headers: this.mergeClientHeaders({
253
574
  Accept: "application/json"
254
- }
575
+ })
255
576
  });
256
577
 
257
578
  if (!response.ok) {
@@ -268,7 +589,7 @@ export class ContextDropApiClient {
268
589
  const makeRequest = async (csrfToken: string | null) =>
269
590
  fetch(`${this.baseUrl}/agent/chat`, {
270
591
  method: "POST",
271
- credentials: "same-origin",
592
+ credentials: this.credentials,
272
593
  headers: this.buildJsonHeaders(csrfToken),
273
594
  body: JSON.stringify(payload)
274
595
  });
@@ -280,7 +601,7 @@ export class ContextDropApiClient {
280
601
  const makeRequest = async (csrfToken: string | null) =>
281
602
  fetch(`${this.baseUrl}/agent/edits/${encodeURIComponent(editId)}/apply`, {
282
603
  method: "POST",
283
- credentials: "same-origin",
604
+ credentials: this.credentials,
284
605
  headers: this.buildJsonHeaders(csrfToken)
285
606
  });
286
607
 
@@ -291,7 +612,7 @@ export class ContextDropApiClient {
291
612
  const makeRequest = async (csrfToken: string | null) =>
292
613
  fetch(`${this.baseUrl}/agent/edits/${encodeURIComponent(editId)}/reject`, {
293
614
  method: "POST",
294
- credentials: "same-origin",
615
+ credentials: this.credentials,
295
616
  headers: this.buildJsonHeaders(csrfToken)
296
617
  });
297
618
 
@@ -302,7 +623,7 @@ export class ContextDropApiClient {
302
623
  const makeRequest = async (csrfToken: string | null) =>
303
624
  fetch(`${this.baseUrl}/agent/edits/${encodeURIComponent(editId)}/revert`, {
304
625
  method: "POST",
305
- credentials: "same-origin",
626
+ credentials: this.credentials,
306
627
  headers: this.buildJsonHeaders(csrfToken)
307
628
  });
308
629
 
@@ -1007,7 +1007,7 @@ export class ElementPicker {
1007
1007
  }
1008
1008
 
1009
1009
  private renderScrubbingHudContent(
1010
- currentCandidate: ElementCandidateInfo,
1010
+ _currentCandidate: ElementCandidateInfo,
1011
1011
  rect: { width: number; height: number }
1012
1012
  ): void {
1013
1013
  if (!this.hudEl) return;
@@ -59,3 +59,9 @@ export const ICON_SUN = `<svg viewBox="0 0 20 20" width="14" height="14" fill="n
59
59
 
60
60
  export const ICON_MOON = `<svg viewBox="0 0 20 20" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17.2 12.8A7.5 7.5 0 0 1 7.2 2.8a7.5 7.5 0 1 0 10 10z"/></svg>`;
61
61
 
62
+ export const ICON_EDIT = `<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M11.2 2.5a1.5 1.5 0 0 1 2.1 2.1L5.8 12.1 2.7 13l.9-3.1 7.6-7.4z"/></svg>`;
63
+
64
+ export const ICON_TRASH = `<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2.8 4.5h10.4"/><path d="M6.2 4.5V3.2a.9.9 0 0 1 .9-.9h1.8a.9.9 0 0 1 .9.9v1.3"/><path d="M4.2 4.5l.6 8.3a1.2 1.2 0 0 0 1.2 1.1h4a1.2 1.2 0 0 0 1.2-1.1l.6-8.3"/></svg>`;
65
+
66
+ export const ICON_COMMENT = `<svg viewBox="0 0 16 16" width="13" height="13" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M13.5 10.2a1.3 1.3 0 0 1-1.3 1.3H5.4L2.5 14V3.8A1.3 1.3 0 0 1 3.8 2.5h8.4a1.3 1.3 0 0 1 1.3 1.3v6.4z"/></svg>`;
67
+
@@ -118,7 +118,7 @@ export async function captureViewportScreenshot(
118
118
 
119
119
  // Paint page background
120
120
  const bodyBg =
121
- window.getComputedStyle && document.body
121
+ typeof window.getComputedStyle === "function" && document.body
122
122
  ? window.getComputedStyle(document.body).backgroundColor
123
123
  : "#ffffff";
124
124
  ctx.fillStyle = bodyBg && bodyBg !== "rgba(0, 0, 0, 0)" ? bodyBg : "#ffffff";