context-drop 0.3.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.
@@ -885,6 +885,7 @@
885
885
  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>`;
886
886
  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>`;
887
887
  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>`;
888
+ 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>`;
888
889
 
889
890
  // --- Module: markdown.ts ---
890
891
  /**
@@ -2196,6 +2197,136 @@
2196
2197
  font-weight: 500;
2197
2198
  }
2198
2199
 
2200
+ .cd-chat-msg.is-commenting {
2201
+ border-color: var(--cd-accent);
2202
+ box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.12);
2203
+ }
2204
+
2205
+ .cd-msg-status-badge {
2206
+ display: inline-flex;
2207
+ align-items: center;
2208
+ padding: 1px 6px;
2209
+ border-radius: 999px;
2210
+ font-size: 10px;
2211
+ font-weight: 600;
2212
+ text-transform: capitalize;
2213
+ letter-spacing: 0.01em;
2214
+ border: 1px solid transparent;
2215
+ line-height: 1.4;
2216
+ }
2217
+
2218
+ .cd-msg-status-badge.is-new {
2219
+ background: #eff6ff;
2220
+ border-color: #bfdbfe;
2221
+ color: #1d4ed8;
2222
+ }
2223
+
2224
+ .cd-msg-status-badge.is-updated {
2225
+ background: #fffbeb;
2226
+ border-color: #fde68a;
2227
+ color: #b45309;
2228
+ }
2229
+
2230
+ .cd-msg-status-badge.is-fixed {
2231
+ background: #eef2ff;
2232
+ border-color: #c7d2fe;
2233
+ color: #4338ca;
2234
+ }
2235
+
2236
+ .cd-msg-status-badge.is-reviewed {
2237
+ background: #f0fdf4;
2238
+ border-color: #bbf7d0;
2239
+ color: #15803d;
2240
+ }
2241
+
2242
+ .cd-msg-status-badge.is-dismissed {
2243
+ background: #f8fafc;
2244
+ border-color: #e2e8f0;
2245
+ color: #64748b;
2246
+ }
2247
+
2248
+ .cd-review-btn {
2249
+ display: inline-flex;
2250
+ align-items: center;
2251
+ gap: 4px;
2252
+ padding: 2px 7px;
2253
+ border-radius: 5px;
2254
+ border: 1px solid #bbf7d0;
2255
+ background: #f0fdf4;
2256
+ color: #15803d;
2257
+ font-family: inherit;
2258
+ font-size: 10.5px;
2259
+ font-weight: 600;
2260
+ cursor: pointer;
2261
+ transition: background 0.12s ease, border-color 0.12s ease;
2262
+ }
2263
+
2264
+ .cd-review-btn:hover:not(:disabled) {
2265
+ background: #dcfce7;
2266
+ border-color: #86efac;
2267
+ }
2268
+
2269
+ .cd-review-btn:disabled {
2270
+ opacity: 0.5;
2271
+ cursor: default;
2272
+ }
2273
+
2274
+ .cd-comments-list {
2275
+ display: flex;
2276
+ flex-direction: column;
2277
+ gap: 6px;
2278
+ margin-top: 6px;
2279
+ padding-top: 6px;
2280
+ border-top: 1px dashed var(--cd-border-subtle);
2281
+ }
2282
+
2283
+ .cd-comment-item {
2284
+ background: var(--cd-surface-recessed);
2285
+ border: 1px solid var(--cd-border-subtle);
2286
+ border-radius: 6px;
2287
+ padding: 6px 8px;
2288
+ }
2289
+
2290
+ .cd-comment-header {
2291
+ display: flex;
2292
+ align-items: center;
2293
+ justify-content: space-between;
2294
+ gap: 6px;
2295
+ font-size: 10.5px;
2296
+ color: var(--cd-muted);
2297
+ margin-bottom: 2px;
2298
+ }
2299
+
2300
+ .cd-comment-author {
2301
+ font-weight: 600;
2302
+ color: var(--cd-ink);
2303
+ }
2304
+
2305
+ .cd-comment-body {
2306
+ margin: 0;
2307
+ font-size: 11.5px;
2308
+ line-height: 1.42;
2309
+ color: var(--cd-ink);
2310
+ white-space: pre-wrap;
2311
+ word-break: break-word;
2312
+ }
2313
+
2314
+ .cd-comment-images {
2315
+ display: flex;
2316
+ flex-wrap: wrap;
2317
+ gap: 5px;
2318
+ margin-top: 5px;
2319
+ }
2320
+
2321
+ .cd-comment-thumb {
2322
+ width: 48px;
2323
+ height: 48px;
2324
+ object-fit: cover;
2325
+ border-radius: 4px;
2326
+ border: 1px solid var(--cd-border);
2327
+ display: block;
2328
+ }
2329
+
2199
2330
  /* ==========================================================================
2200
2331
  4. LOCAL BYOK AGENTIC CODING SIDEBAR (.cd-agent-sidebar)
2201
2332
  ========================================================================== */
@@ -3670,6 +3801,41 @@
3670
3801
  return response;
3671
3802
  }
3672
3803
 
3804
+ async createComment(
3805
+ id ,
3806
+ payload ,
3807
+ ownershipToken
3808
+ ) {
3809
+ const resolvedToken = ownershipToken || this.getOwnershipToken(id);
3810
+ const makeRequest = async (csrfToken ) => {
3811
+ const headers = this.buildJsonHeaders(csrfToken);
3812
+ if (resolvedToken) {
3813
+ headers["X-Context-Drop-Ownership-Token"] = resolvedToken;
3814
+ }
3815
+ const bodyPayload = { comment: payload };
3816
+ if (resolvedToken) {
3817
+ bodyPayload.ownership_token = resolvedToken;
3818
+ }
3819
+ return fetch(`${this.baseUrl}/feedback/${encodeURIComponent(String(id))}/comments`, {
3820
+ method: "POST",
3821
+ credentials: this.credentials,
3822
+ headers,
3823
+ body: JSON.stringify(bodyPayload)
3824
+ });
3825
+ };
3826
+
3827
+ const response = await this.executeWithCsrfRetry (
3828
+ makeRequest,
3829
+ "Comment failed"
3830
+ );
3831
+
3832
+ const nextToken = response?.feedback?.ownership_token;
3833
+ if (response?.feedback?.id !== undefined && nextToken) {
3834
+ this.setOwnershipToken(response.feedback.id, nextToken);
3835
+ }
3836
+ return response;
3837
+ }
3838
+
3673
3839
  async deleteFeedback(
3674
3840
  id ,
3675
3841
  ownershipToken
@@ -5826,6 +5992,8 @@
5826
5992
  ownFeedbacksLoaded = false;
5827
5993
  inFlightOwnFeedbacksPromise = null;
5828
5994
  editingFeedbackId = null;
5995
+ commentingFeedbackId = null;
5996
+ reviewingFeedbackId = null;
5829
5997
  confirmingDeleteId = null;
5830
5998
  deletingFeedbackId = null;
5831
5999
  stashedDraftBeforeEdit
@@ -6324,6 +6492,30 @@
6324
6492
  ? structuredClone(existingEntry.elements)
6325
6493
  : [];
6326
6494
 
6495
+ const mappedComments = Array.isArray(record.comments)
6496
+ ? record.comments.map((c) => ({
6497
+ id: c.id,
6498
+ author_label: c.author_label || "You",
6499
+ author_type: c.author_type ?? null,
6500
+ body: c.body ?? null,
6501
+ createdAt: this.formatTimestampLabel(c.created_at),
6502
+ rawCreatedAt: c.created_at,
6503
+ attachments: Array.isArray(c.attachments)
6504
+ ? c.attachments.map((att) => ({
6505
+ id: `srv-catt-${att.id}`,
6506
+ server_id: att.id,
6507
+ label: att.filename || "image.png",
6508
+ preview_url: this.apiClient.buildAttachmentPreviewUrl(record.id, att.id, token),
6509
+ attachment_type: att.attachment_type || "image",
6510
+ filename: att.filename,
6511
+ metadata: att.metadata || {}
6512
+ }))
6513
+ : []
6514
+ }))
6515
+ : existingEntry?.comments
6516
+ ? structuredClone(existingEntry.comments)
6517
+ : [];
6518
+
6327
6519
  return {
6328
6520
  id: record.id,
6329
6521
  message: displayMessage,
@@ -6335,7 +6527,8 @@
6335
6527
  status: record.status,
6336
6528
  ownershipToken: token,
6337
6529
  elements,
6338
- attachments: mappedAttachments
6530
+ attachments: mappedAttachments,
6531
+ comments: mappedComments
6339
6532
  };
6340
6533
  }
6341
6534
 
@@ -6402,10 +6595,13 @@
6402
6595
  const entry = this.sessionHistory.find((item) => String(item.id) === targetKey);
6403
6596
  if (!entry) return false;
6404
6597
 
6598
+ if (this.commentingFeedbackId !== null) {
6599
+ this.cancelCommentingFeedback();
6600
+ }
6405
6601
  this.confirmingDeleteId = null;
6406
6602
  this.hideStatus();
6407
6603
 
6408
- if (this.editingFeedbackId === null) {
6604
+ if (this.editingFeedbackId === null && this.commentingFeedbackId === null) {
6409
6605
  this.stashedDraftBeforeEdit = {
6410
6606
  message: this.textareaEl?.value || "",
6411
6607
  elementReferences: [...this.elementReferences],
@@ -6485,6 +6681,100 @@
6485
6681
  this.syncUiStates();
6486
6682
  }
6487
6683
 
6684
+ startCommentingFeedback(feedbackId ) {
6685
+ const targetKey = String(feedbackId);
6686
+ const entry = this.sessionHistory.find((item) => String(item.id) === targetKey);
6687
+ if (!entry) return false;
6688
+
6689
+ if (this.editingFeedbackId !== null) {
6690
+ this.cancelEditingFeedback();
6691
+ }
6692
+ this.confirmingDeleteId = null;
6693
+ this.hideStatus();
6694
+
6695
+ if (this.commentingFeedbackId === null && this.editingFeedbackId === null) {
6696
+ this.stashedDraftBeforeEdit = {
6697
+ message: this.textareaEl?.value || "",
6698
+ elementReferences: [...this.elementReferences],
6699
+ elementDomNodes: new Map(this.elementDomNodes),
6700
+ attachments: [...this.attachments]
6701
+ };
6702
+ }
6703
+
6704
+ this.commentingFeedbackId = targetKey;
6705
+ if (this.textareaEl) {
6706
+ this.textareaEl.value = "";
6707
+ }
6708
+ this.elementReferences = [];
6709
+ this.elementDomNodes.clear();
6710
+ this.attachments = [];
6711
+
6712
+ this.picker?.hideExternalPreview();
6713
+ this.picker?.refreshPinnedMarkers();
6714
+ this.renderTray();
6715
+ this.renderChatThread();
6716
+ this.syncUiStates();
6717
+ this.textareaEl?.focus();
6718
+ return true;
6719
+ }
6720
+
6721
+ cancelCommentingFeedback() {
6722
+ if (this.commentingFeedbackId === null) return;
6723
+ this.commentingFeedbackId = null;
6724
+
6725
+ if (this.stashedDraftBeforeEdit) {
6726
+ if (this.textareaEl) {
6727
+ this.textareaEl.value = this.stashedDraftBeforeEdit.message;
6728
+ }
6729
+ this.elementReferences = this.stashedDraftBeforeEdit.elementReferences;
6730
+ this.elementDomNodes = this.stashedDraftBeforeEdit.elementDomNodes;
6731
+ this.attachments = this.stashedDraftBeforeEdit.attachments;
6732
+ this.stashedDraftBeforeEdit = null;
6733
+ } else {
6734
+ if (this.textareaEl) {
6735
+ this.textareaEl.value = "";
6736
+ }
6737
+ this.elementReferences = [];
6738
+ this.elementDomNodes.clear();
6739
+ this.attachments = [];
6740
+ }
6741
+
6742
+ this.renderTray();
6743
+ this.renderChatThread();
6744
+ this.syncUiStates();
6745
+ }
6746
+
6747
+ async markFeedbackReviewed(feedbackId ) {
6748
+ if (this.reviewingFeedbackId !== null || this.isSubmitting) return;
6749
+ const targetKey = String(feedbackId);
6750
+ const entry = this.sessionHistory.find((item) => String(item.id) === targetKey);
6751
+ if (!entry) return;
6752
+
6753
+ this.reviewingFeedbackId = targetKey;
6754
+ this.renderChatThread();
6755
+
6756
+ try {
6757
+ const res = await this.apiClient.updateFeedback(
6758
+ entry.id,
6759
+ { status: "reviewed" },
6760
+ entry.ownershipToken
6761
+ );
6762
+ entry.status = res?.status || "reviewed";
6763
+ if (res?.ownership_token) {
6764
+ entry.ownershipToken = res.ownership_token;
6765
+ }
6766
+ this.reviewingFeedbackId = null;
6767
+ this.renderChatThread();
6768
+ this.showStatus("Fix marked as reviewed.", "success");
6769
+ this.emitWidgetEvent("context-drop:update", { response: res, id: entry.id });
6770
+ } catch (err) {
6771
+ this.reviewingFeedbackId = null;
6772
+ this.renderChatThread();
6773
+ const msg = err instanceof Error ? err.message : "Failed to mark feedback as reviewed.";
6774
+ this.showStatus(msg, "error");
6775
+ }
6776
+ }
6777
+
6488
6778
  requestDeleteFeedback(feedbackId ) {
6489
6779
  const targetKey = String(feedbackId);
6490
6780
  if (!this.sessionHistory.some((item) => String(item.id) === targetKey)) return;
@@ -7607,7 +7897,11 @@
7607
7897
  cancelEditBtn.setAttribute("aria-label", "Cancel editing feedback");
7608
7898
  cancelEditBtn.textContent = "Cancel";
7609
7899
  cancelEditBtn.addEventListener("click", () => {
7610
- this.cancelEditingFeedback();
7900
+ if (this.commentingFeedbackId !== null) {
7901
+ this.cancelCommentingFeedback();
7902
+ } else {
7903
+ this.cancelEditingFeedback();
7904
+ }
7611
7905
  });
7612
7906
  editBanner.appendChild(cancelEditBtn);
7613
7907
  this.editBannerEl = editBanner;
@@ -7626,6 +7920,8 @@
7626
7920
  ev.preventDefault();
7627
7921
  if (this.confirmingDeleteId !== null) {
7628
7922
  this.cancelDeleteFeedback();
7923
+ } else if (this.commentingFeedbackId !== null) {
7924
+ this.cancelCommentingFeedback();
7629
7925
  } else if (this.editingFeedbackId !== null) {
7630
7926
  this.cancelEditingFeedback();
7631
7927
  } else {
@@ -8885,12 +9181,21 @@
8885
9181
  if (this.composerModeSwitchWrap) {
8886
9182
  this.composerModeSwitchWrap.hidden = !this.config.agent?.enabled;
8887
9183
  }
8888
- if (this.textareaEl && !this.customPlaceholderSet) {
8889
- this.textareaEl.placeholder = smartMode
8890
- ? DEFAULT_SMART_PLACEHOLDER
8891
- : DEFAULT_VERBOSE_PLACEHOLDER;
9184
+ const isCommenting = this.commentingFeedbackId !== null;
9185
+ if (this.textareaEl) {
9186
+ if (isCommenting) {
9187
+ this.textareaEl.placeholder = "Write a comment... (attach or paste images below)";
9188
+ } else if (!this.customPlaceholderSet) {
9189
+ this.textareaEl.placeholder = smartMode
9190
+ ? DEFAULT_SMART_PLACEHOLDER
9191
+ : DEFAULT_VERBOSE_PLACEHOLDER;
9192
+ }
9193
+ }
9194
+ if (this.cornerPinBtn) {
9195
+ this.cornerPinBtn.hidden = isCommenting;
8892
9196
  }
8893
9197
  if (this.composerToolbarPickBtn) {
9198
+ this.composerToolbarPickBtn.hidden = isCommenting;
8894
9199
  if (smartMode) {
8895
9200
  this.composerToolbarPickBtn.title = "Highlight an area on the page";
8896
9201
  this.composerToolbarPickBtn.setAttribute("aria-label", "Highlight an area on the page");
@@ -8905,7 +9210,7 @@
8905
9210
  }
8906
9211
  }
8907
9212
  if (this.composerToolbarScreenshotBtn) {
8908
- this.composerToolbarScreenshotBtn.hidden = smartMode;
9213
+ this.composerToolbarScreenshotBtn.hidden = smartMode && !isCommenting;
8909
9214
  }
8910
9215
  if (this.composerToolbarUploadBtn) {
8911
9216
  this.composerToolbarUploadBtn.innerHTML = smartMode
@@ -8928,6 +9233,21 @@
8928
9233
  idSpan.textContent = `#${this.editingFeedbackId}`;
8929
9234
  this.editBannerInfoEl.appendChild(idSpan);
8930
9235
  }
9236
+ } else if (this.commentingFeedbackId !== null) {
9237
+ this.editBannerEl.hidden = false;
9238
+ this.editBannerInfoEl.innerHTML = "";
9239
+ const iconSpan = document.createElement("span");
9240
+ iconSpan.innerHTML = ICON_COMMENT;
9241
+ const labelSpan = document.createElement("span");
9242
+ labelSpan.textContent = smartMode ? "Commenting on feedback" : "Commenting on";
9243
+ this.editBannerInfoEl.appendChild(iconSpan);
9244
+ this.editBannerInfoEl.appendChild(labelSpan);
9245
+ if (!smartMode) {
9246
+ const idSpan = document.createElement("span");
9247
+ idSpan.className = "cd-edit-banner-id";
9248
+ idSpan.textContent = `#${this.commentingFeedbackId}`;
9249
+ this.editBannerInfoEl.appendChild(idSpan);
9250
+ }
8931
9251
  } else {
8932
9252
  this.editBannerEl.hidden = true;
8933
9253
  }
@@ -8936,6 +9256,9 @@
8936
9256
  if (this.editingFeedbackId !== null) {
8937
9257
  this.submitBtn.setAttribute("aria-label", "Save feedback changes");
8938
9258
  this.submitBtn.innerHTML = `${ICON_CHECK}<span>Save</span>`;
9259
+ } else if (this.commentingFeedbackId !== null) {
9260
+ this.submitBtn.setAttribute("aria-label", "Submit comment");
9261
+ this.submitBtn.innerHTML = `${ICON_SEND}<span>Comment</span>`;
8939
9262
  } else {
8940
9263
  this.submitBtn.setAttribute("aria-label", "Submit feedback");
8941
9264
  this.submitBtn.innerHTML = `${ICON_SEND}<span>Send</span>`;
@@ -9178,11 +9501,18 @@
9178
9501
  for (const entry of this.sessionHistory) {
9179
9502
  const entryIdStr = String(entry.id);
9180
9503
  const isEditingThis = this.editingFeedbackId === entryIdStr;
9504
+ const isCommentingThis = this.commentingFeedbackId === entryIdStr;
9505
+ const isReviewingThis = this.reviewingFeedbackId === entryIdStr;
9181
9506
  const isConfirmingDelete = this.confirmingDeleteId === entryIdStr;
9182
9507
  const isDeletingThis = this.deletingFeedbackId === entryIdStr;
9508
+ const statusName = entry.status || "new";
9183
9509
 
9184
9510
  const msgCard = document.createElement("div");
9185
- msgCard.className = isEditingThis ? "cd-chat-msg is-editing" : "cd-chat-msg";
9511
+ msgCard.className = isEditingThis
9512
+ ? "cd-chat-msg is-editing"
9513
+ : isCommentingThis
9514
+ ? "cd-chat-msg is-commenting"
9515
+ : "cd-chat-msg";
9186
9516
  msgCard.setAttribute("data-feedback-id", entryIdStr);
9187
9517
 
9188
9518
  if (entry.elements.length > 0 || entry.attachments.length > 0) {
@@ -9216,12 +9546,68 @@
9216
9546
  msgCard.appendChild(textP);
9217
9547
  }
9218
9548
 
9549
+ if (entry.comments && entry.comments.length > 0) {
9550
+ const commentsList = document.createElement("div");
9551
+ commentsList.className = "cd-comments-list";
9552
+ for (const comment of entry.comments) {
9553
+ const cItem = document.createElement("div");
9554
+ cItem.className = "cd-comment-item";
9555
+
9556
+ const cHeader = document.createElement("div");
9557
+ cHeader.className = "cd-comment-header";
9558
+ const cAuthor = document.createElement("span");
9559
+ cAuthor.className = "cd-comment-author";
9560
+ cAuthor.textContent = comment.author_label || "You";
9561
+ const cTime = document.createElement("span");
9562
+ cTime.textContent = comment.createdAt;
9563
+ cHeader.appendChild(cAuthor);
9564
+ cHeader.appendChild(cTime);
9565
+ cItem.appendChild(cHeader);
9566
+
9567
+ if (comment.body) {
9568
+ const cBody = document.createElement("p");
9569
+ cBody.className = "cd-comment-body";
9570
+ cBody.textContent = comment.body;
9571
+ cItem.appendChild(cBody);
9572
+ }
9573
+
9574
+ if (comment.attachments && comment.attachments.length > 0) {
9575
+ const cImgs = document.createElement("div");
9576
+ cImgs.className = "cd-comment-images";
9577
+ for (const att of comment.attachments) {
9578
+ if (att.preview_url) {
9579
+ const imgLink = document.createElement("a");
9580
+ imgLink.href = att.preview_url;
9581
+ imgLink.target = "_blank";
9582
+ imgLink.rel = "noopener noreferrer";
9583
+ const img = document.createElement("img");
9584
+ img.src = att.preview_url;
9585
+ img.alt = att.label || "Comment image";
9586
+ img.className = "cd-comment-thumb";
9587
+ imgLink.appendChild(img);
9588
+ cImgs.appendChild(imgLink);
9589
+ }
9590
+ }
9591
+ if (cImgs.childNodes.length > 0) {
9592
+ cItem.appendChild(cImgs);
9593
+ }
9594
+ }
9595
+
9596
+ commentsList.appendChild(cItem);
9597
+ }
9598
+ msgCard.appendChild(commentsList);
9599
+ }
9600
+
9219
9601
  const meta = document.createElement("div");
9220
9602
  meta.className = "cd-chat-msg-meta";
9221
9603
 
9222
9604
  const metaInfo = document.createElement("div");
9223
9605
  metaInfo.className = "cd-chat-msg-meta-info";
9224
9606
 
9607
+ const statusBadge = document.createElement("span");
9608
+ statusBadge.className = `cd-msg-status-badge is-${statusName}`;
9609
+ statusBadge.textContent = statusName;
9610
+
9225
9611
  const idSpan = document.createElement("span");
9226
9612
  const baseLabel = smartMode ? "Feedback sent" : `Dropped #${entry.id}`;
9227
9613
  idSpan.textContent = entry.isEdited ? `${baseLabel} · edited` : baseLabel;
@@ -9233,6 +9619,7 @@
9233
9619
  const timeSpan = document.createElement("span");
9234
9620
  timeSpan.textContent = entry.createdAt;
9235
9621
 
9622
+ metaInfo.appendChild(statusBadge);
9236
9623
  metaInfo.appendChild(idSpan);
9237
9624
  metaInfo.appendChild(sepSpan);
9238
9625
  metaInfo.appendChild(timeSpan);
@@ -9240,6 +9627,36 @@
9240
9627
  const actions = document.createElement("div");
9241
9628
  actions.className = "cd-chat-msg-actions";
9242
9629
 
9630
+ if (statusName === "fixed") {
9631
+ const reviewBtn = document.createElement("button");
9632
+ reviewBtn.type = "button";
9633
+ reviewBtn.className = "cd-review-btn";
9634
+ reviewBtn.title = "Confirm fix was tested and reviewed";
9635
+ reviewBtn.setAttribute("aria-label", "Mark fix as reviewed");
9636
+ reviewBtn.disabled = isReviewingThis || this.isSubmitting || this.deletingFeedbackId !== null;
9637
+ reviewBtn.innerHTML = `${ICON_CHECK}<span>${isReviewingThis ? "Saving..." : "Mark Reviewed"}</span>`;
9638
+ reviewBtn.addEventListener("click", () => {
9639
+ void this.markFeedbackReviewed(entry.id);
9640
+ });
9641
+ actions.appendChild(reviewBtn);
9642
+ }
9643
+
9644
+ const commentBtn = document.createElement("button");
9645
+ commentBtn.type = "button";
9646
+ commentBtn.className = `cd-msg-action-btn${isCommentingThis ? " is-active" : ""}`;
9647
+ commentBtn.title = isCommentingThis ? "Cancel comment" : "Add comment";
9648
+ commentBtn.setAttribute("aria-label", "Add comment");
9649
+ commentBtn.setAttribute("aria-pressed", String(isCommentingThis));
9650
+ commentBtn.disabled = this.isSubmitting || this.deletingFeedbackId !== null;
9651
+ commentBtn.innerHTML = ICON_COMMENT;
9652
+ commentBtn.addEventListener("click", () => {
9653
+ if (this.commentingFeedbackId === entryIdStr) {
9654
+ this.cancelCommentingFeedback();
9655
+ } else {
9656
+ this.startCommentingFeedback(entry.id);
9657
+ }
9658
+ });
9659
+
9243
9660
  const editBtn = document.createElement("button");
9244
9661
  editBtn.type = "button";
9245
9662
  editBtn.className = `cd-msg-action-btn${isEditingThis ? " is-active" : ""}`;
@@ -9267,6 +9684,7 @@
9267
9684
  this.requestDeleteFeedback(entry.id);
9268
9685
  });
9269
9686
 
9687
+ actions.appendChild(commentBtn);
9270
9688
  actions.appendChild(editBtn);
9271
9689
  actions.appendChild(deleteBtn);
9272
9690
 
@@ -9703,13 +10121,19 @@
9703
10121
  if (this.isSubmitting) return;
9704
10122
  const smartMode = this.isSmartSelectionMode();
9705
10123
  const editingId = this.editingFeedbackId;
10124
+ const commentingId = this.commentingFeedbackId;
9706
10125
 
9707
10126
  if (this.pendingSmartCaptures.size > 0) {
9708
10127
  await Promise.allSettled(Array.from(this.pendingSmartCaptures));
9709
10128
  }
9710
10129
 
9711
10130
  const message = (this.textareaEl?.value || "").trim();
9712
- if (
10131
+ if (commentingId !== null) {
10132
+ if (message.length === 0 && this.attachments.length === 0) {
10133
+ this.showStatus("Write a comment or attach an image first.", "error");
10134
+ return;
10135
+ }
10136
+ } else if (
9713
10137
  message.length === 0 &&
9714
10138
  this.attachments.length === 0 &&
9715
10139
  this.elementReferences.length === 0
@@ -9727,7 +10151,11 @@
9727
10151
  if (this.submitBtn) {
9728
10152
  this.submitBtn.disabled = true;
9729
10153
  this.submitBtn.innerHTML =
9730
- editingId !== null ? `<span>Saving...</span>` : `<span>Sending...</span>`;
10154
+ editingId !== null
10155
+ ? `<span>Saving...</span>`
10156
+ : commentingId !== null
10157
+ ? `<span>Posting...</span>`
10158
+ : `<span>Sending...</span>`;
9731
10159
  }
9732
10160
 
9733
10161
  try {
@@ -9756,6 +10184,55 @@
9756
10184
  locale: typeof navigator !== "undefined" ? navigator.language : "en"
9757
10185
  };
9758
10186
 
10187
+ if (commentingId !== null) {
10188
+ const existingIdx = this.sessionHistory.findIndex(
10189
+ (item) => String(item.id) === commentingId
10190
+ );
10191
+ const existingEntry = existingIdx >= 0 ? this.sessionHistory[existingIdx] : undefined;
10192
+
10193
+ const commentPayload = {
10194
+ body: message,
10195
+ attachments: this.attachments.map((att) => ({
10196
+ attachment_type: att.attachment_type,
10197
+ filename: att.filename,
10198
+ signed_blob_id: att.signed_blob_id,
10199
+ data_url: att.signed_blob_id ? undefined : att.data_url,
10200
+ metadata: att.metadata
10201
+ }))
10202
+ };
10203
+
10204
+ const commentRes = await this.apiClient.createComment(
10205
+ existingEntry?.id ?? commentingId,
10206
+ commentPayload,
10207
+ existingEntry?.ownershipToken
10208
+ );
10209
+
10210
+ if (commentRes?.feedback) {
10211
+ const updatedEntry = this.mapOwnRecordToSessionEntry(commentRes.feedback, existingEntry);
10212
+ if (existingIdx >= 0) {
10213
+ this.sessionHistory[existingIdx] = updatedEntry;
10214
+ }
10215
+ } else if (existingEntry) {
10216
+ existingEntry.status = commentRes?.status || "updated";
10217
+ if (!existingEntry.comments) existingEntry.comments = [];
10218
+ existingEntry.comments.push({
10219
+ id: commentRes?.id ?? Date.now(),
10220
+ author_label: commentRes?.comment?.author_label || "You",
10221
+ body: message || null,
10222
+ createdAt: this.formatTimestampLabel(commentRes?.created_at),
10223
+ attachments: submittedAttachments
10224
+ });
10225
+ }
10226
+
10227
+ this.cancelCommentingFeedback();
10228
+ this.showStatus("Comment added.", "success");
10229
+ this.emitWidgetEvent("context-drop:comment", {
10230
+ response: commentRes,
10231
+ payload: commentPayload
10232
+ });
10233
+ return;
10234
+ }
10235
+
9759
10236
  if (editingId !== null) {
9760
10237
  const existingIdx = this.sessionHistory.findIndex(
9761
10238
  (item) => String(item.id) === editingId
@@ -1,4 +1,4 @@
1
- import type { AgentChatRequestPayload, AgentChatResponse, AgentKeysUpdatePayload, AgentKeysUpdateResponse, AgentStatusResponse, ContextDropApiClientOptions, CrossEnvFeedbackListResponse, FeedbackDeleteResponse, FeedbackSubmissionPayload, FeedbackSubmissionResponse, FeedbackUpdatePayload, FeedbackUpdateResponse, OwnFeedbackListResponse, ProposedFileEdit, WidgetConfig } from "./types.js";
1
+ import type { AgentChatRequestPayload, AgentChatResponse, AgentKeysUpdatePayload, AgentKeysUpdateResponse, AgentStatusResponse, ContextDropApiClientOptions, CrossEnvFeedbackListResponse, CreateCommentPayload, CreateCommentResponse, FeedbackDeleteResponse, FeedbackSubmissionPayload, FeedbackSubmissionResponse, FeedbackUpdatePayload, FeedbackUpdateResponse, OwnFeedbackListResponse, ProposedFileEdit, WidgetConfig } from "./types.js";
2
2
  export declare class ContextDropApiClient {
3
3
  private baseUrl;
4
4
  private credentials;
@@ -35,6 +35,7 @@ export declare class ContextDropApiClient {
35
35
  submitFeedback(payload: FeedbackSubmissionPayload): Promise<FeedbackSubmissionResponse>;
36
36
  fetchOwnFeedbacks(limit?: number): Promise<OwnFeedbackListResponse>;
37
37
  updateFeedback(id: number | string, payload: FeedbackUpdatePayload, ownershipToken?: string | null): Promise<FeedbackUpdateResponse>;
38
+ createComment(id: number | string, payload: CreateCommentPayload, ownershipToken?: string | null): Promise<CreateCommentResponse>;
38
39
  deleteFeedback(id: number | string, ownershipToken?: string | null): Promise<FeedbackDeleteResponse>;
39
40
  fetchAgentStatus(): Promise<AgentStatusResponse>;
40
41
  saveAgentKeys(payload: AgentKeysUpdatePayload): Promise<AgentKeysUpdateResponse>;