context-drop 0.3.0 → 0.3.2
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.
- package/app/assets/javascripts/context_drop/context_drop.js +488 -11
- package/dist/app/javascript/context_drop/api-client.d.ts +2 -1
- package/dist/app/javascript/context_drop/api-client.js +25 -0
- package/dist/app/javascript/context_drop/icons.d.ts +1 -0
- package/dist/app/javascript/context_drop/icons.js +1 -0
- package/dist/app/javascript/context_drop/styles.d.ts +1 -1
- package/dist/app/javascript/context_drop/styles.js +130 -0
- package/dist/app/javascript/context_drop/types.d.ts +44 -3
- package/dist/app/javascript/context_drop/widget.d.ts +5 -0
- package/dist/app/javascript/context_drop/widget.js +303 -12
- package/dist/src/mcp/dispatcher.js +29 -2
- package/dist/src/server/handler.js +128 -2
- package/dist/src/server/storage/local.js +175 -4
- package/dist/src/server/storage/memory.js +72 -0
- package/dist/src/server/storage/postgres.js +116 -6
- package/dist/src/server/types.d.ts +28 -2
- package/dist/src/server/types.js +3 -2
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MANDATORY_EXCLUDED_SELECTORS, describeSmartComponent } from "./sanitizer.js";
|
|
2
|
-
import { ICON_CAMERA, ICON_CHECK, ICON_CHEVRON_DOWN, ICON_CHEVRON_RIGHT, ICON_CHEVRON_UP, ICON_CLOSE, ICON_CODE_PROMPT, ICON_EDIT, ICON_EXPAND, ICON_FILE_CODE, ICON_GRIP, ICON_IMAGE, ICON_INBOX, ICON_KEY, ICON_MINIMIZE, ICON_PIN, ICON_PLUS, ICON_PUSH_LAYOUT, ICON_SCROLL_VERTICAL, ICON_SEND, ICON_SHIELD, ICON_SIDEBAR, ICON_SUN, ICON_MOON, ICON_TRASH, ICON_UNDO } from "./icons.js";
|
|
2
|
+
import { ICON_CAMERA, ICON_CHECK, ICON_CHEVRON_DOWN, ICON_CHEVRON_RIGHT, ICON_CHEVRON_UP, ICON_CLOSE, ICON_CODE_PROMPT, ICON_COMMENT, ICON_EDIT, ICON_EXPAND, ICON_FILE_CODE, ICON_GRIP, ICON_IMAGE, ICON_INBOX, ICON_KEY, ICON_MINIMIZE, ICON_PIN, ICON_PLUS, ICON_PUSH_LAYOUT, ICON_SCROLL_VERTICAL, ICON_SEND, ICON_SHIELD, ICON_SIDEBAR, ICON_SUN, ICON_MOON, ICON_TRASH, ICON_UNDO } from "./icons.js";
|
|
3
3
|
import { WIDGET_SHADOW_STYLES } from "./styles.js";
|
|
4
4
|
import { ContextDropApiClient } from "./api-client.js";
|
|
5
5
|
import { ElementPicker } from "./element-picker.js";
|
|
@@ -134,6 +134,8 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
134
134
|
ownFeedbacksLoaded = false;
|
|
135
135
|
inFlightOwnFeedbacksPromise = null;
|
|
136
136
|
editingFeedbackId = null;
|
|
137
|
+
commentingFeedbackId = null;
|
|
138
|
+
reviewingFeedbackId = null;
|
|
137
139
|
confirmingDeleteId = null;
|
|
138
140
|
deletingFeedbackId = null;
|
|
139
141
|
stashedDraftBeforeEdit = null;
|
|
@@ -568,6 +570,29 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
568
570
|
: existingEntry?.elements
|
|
569
571
|
? structuredClone(existingEntry.elements)
|
|
570
572
|
: [];
|
|
573
|
+
const mappedComments = Array.isArray(record.comments)
|
|
574
|
+
? record.comments.map((c) => ({
|
|
575
|
+
id: c.id,
|
|
576
|
+
author_label: c.author_label || "You",
|
|
577
|
+
author_type: c.author_type ?? null,
|
|
578
|
+
body: c.body ?? null,
|
|
579
|
+
createdAt: this.formatTimestampLabel(c.created_at),
|
|
580
|
+
rawCreatedAt: c.created_at,
|
|
581
|
+
attachments: Array.isArray(c.attachments)
|
|
582
|
+
? c.attachments.map((att) => ({
|
|
583
|
+
id: `srv-catt-${att.id}`,
|
|
584
|
+
server_id: att.id,
|
|
585
|
+
label: att.filename || "image.png",
|
|
586
|
+
preview_url: this.apiClient.buildAttachmentPreviewUrl(record.id, att.id, token),
|
|
587
|
+
attachment_type: att.attachment_type || "image",
|
|
588
|
+
filename: att.filename,
|
|
589
|
+
metadata: att.metadata || {}
|
|
590
|
+
}))
|
|
591
|
+
: []
|
|
592
|
+
}))
|
|
593
|
+
: existingEntry?.comments
|
|
594
|
+
? structuredClone(existingEntry.comments)
|
|
595
|
+
: [];
|
|
571
596
|
return {
|
|
572
597
|
id: record.id,
|
|
573
598
|
message: displayMessage,
|
|
@@ -579,7 +604,8 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
579
604
|
status: record.status,
|
|
580
605
|
ownershipToken: token,
|
|
581
606
|
elements,
|
|
582
|
-
attachments: mappedAttachments
|
|
607
|
+
attachments: mappedAttachments,
|
|
608
|
+
comments: mappedComments
|
|
583
609
|
};
|
|
584
610
|
}
|
|
585
611
|
async refreshOwnFeedbacks() {
|
|
@@ -640,9 +666,12 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
640
666
|
const entry = this.sessionHistory.find((item) => String(item.id) === targetKey);
|
|
641
667
|
if (!entry)
|
|
642
668
|
return false;
|
|
669
|
+
if (this.commentingFeedbackId !== null) {
|
|
670
|
+
this.cancelCommentingFeedback();
|
|
671
|
+
}
|
|
643
672
|
this.confirmingDeleteId = null;
|
|
644
673
|
this.hideStatus();
|
|
645
|
-
if (this.editingFeedbackId === null) {
|
|
674
|
+
if (this.editingFeedbackId === null && this.commentingFeedbackId === null) {
|
|
646
675
|
this.stashedDraftBeforeEdit = {
|
|
647
676
|
message: this.textareaEl?.value || "",
|
|
648
677
|
elementReferences: [...this.elementReferences],
|
|
@@ -717,6 +746,91 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
717
746
|
this.renderChatThread();
|
|
718
747
|
this.syncUiStates();
|
|
719
748
|
}
|
|
749
|
+
startCommentingFeedback(feedbackId) {
|
|
750
|
+
const targetKey = String(feedbackId);
|
|
751
|
+
const entry = this.sessionHistory.find((item) => String(item.id) === targetKey);
|
|
752
|
+
if (!entry)
|
|
753
|
+
return false;
|
|
754
|
+
if (this.editingFeedbackId !== null) {
|
|
755
|
+
this.cancelEditingFeedback();
|
|
756
|
+
}
|
|
757
|
+
this.confirmingDeleteId = null;
|
|
758
|
+
this.hideStatus();
|
|
759
|
+
if (this.commentingFeedbackId === null && this.editingFeedbackId === null) {
|
|
760
|
+
this.stashedDraftBeforeEdit = {
|
|
761
|
+
message: this.textareaEl?.value || "",
|
|
762
|
+
elementReferences: [...this.elementReferences],
|
|
763
|
+
elementDomNodes: new Map(this.elementDomNodes),
|
|
764
|
+
attachments: [...this.attachments]
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
this.commentingFeedbackId = targetKey;
|
|
768
|
+
if (this.textareaEl) {
|
|
769
|
+
this.textareaEl.value = "";
|
|
770
|
+
}
|
|
771
|
+
this.elementReferences = [];
|
|
772
|
+
this.elementDomNodes.clear();
|
|
773
|
+
this.attachments = [];
|
|
774
|
+
this.picker?.hideExternalPreview();
|
|
775
|
+
this.picker?.refreshPinnedMarkers();
|
|
776
|
+
this.renderTray();
|
|
777
|
+
this.renderChatThread();
|
|
778
|
+
this.syncUiStates();
|
|
779
|
+
this.textareaEl?.focus();
|
|
780
|
+
return true;
|
|
781
|
+
}
|
|
782
|
+
cancelCommentingFeedback() {
|
|
783
|
+
if (this.commentingFeedbackId === null)
|
|
784
|
+
return;
|
|
785
|
+
this.commentingFeedbackId = null;
|
|
786
|
+
if (this.stashedDraftBeforeEdit) {
|
|
787
|
+
if (this.textareaEl) {
|
|
788
|
+
this.textareaEl.value = this.stashedDraftBeforeEdit.message;
|
|
789
|
+
}
|
|
790
|
+
this.elementReferences = this.stashedDraftBeforeEdit.elementReferences;
|
|
791
|
+
this.elementDomNodes = this.stashedDraftBeforeEdit.elementDomNodes;
|
|
792
|
+
this.attachments = this.stashedDraftBeforeEdit.attachments;
|
|
793
|
+
this.stashedDraftBeforeEdit = null;
|
|
794
|
+
}
|
|
795
|
+
else {
|
|
796
|
+
if (this.textareaEl) {
|
|
797
|
+
this.textareaEl.value = "";
|
|
798
|
+
}
|
|
799
|
+
this.elementReferences = [];
|
|
800
|
+
this.elementDomNodes.clear();
|
|
801
|
+
this.attachments = [];
|
|
802
|
+
}
|
|
803
|
+
this.renderTray();
|
|
804
|
+
this.renderChatThread();
|
|
805
|
+
this.syncUiStates();
|
|
806
|
+
}
|
|
807
|
+
async markFeedbackReviewed(feedbackId) {
|
|
808
|
+
if (this.reviewingFeedbackId !== null || this.isSubmitting)
|
|
809
|
+
return;
|
|
810
|
+
const targetKey = String(feedbackId);
|
|
811
|
+
const entry = this.sessionHistory.find((item) => String(item.id) === targetKey);
|
|
812
|
+
if (!entry)
|
|
813
|
+
return;
|
|
814
|
+
this.reviewingFeedbackId = targetKey;
|
|
815
|
+
this.renderChatThread();
|
|
816
|
+
try {
|
|
817
|
+
const res = await this.apiClient.updateFeedback(entry.id, { status: "reviewed" }, entry.ownershipToken);
|
|
818
|
+
entry.status = res?.status || "reviewed";
|
|
819
|
+
if (res?.ownership_token) {
|
|
820
|
+
entry.ownershipToken = res.ownership_token;
|
|
821
|
+
}
|
|
822
|
+
this.reviewingFeedbackId = null;
|
|
823
|
+
this.renderChatThread();
|
|
824
|
+
this.showStatus("Fix marked as reviewed.", "success");
|
|
825
|
+
this.emitWidgetEvent("context-drop:update", { response: res, id: entry.id });
|
|
826
|
+
}
|
|
827
|
+
catch (err) {
|
|
828
|
+
this.reviewingFeedbackId = null;
|
|
829
|
+
this.renderChatThread();
|
|
830
|
+
const msg = err instanceof Error ? err.message : "Failed to mark feedback as reviewed.";
|
|
831
|
+
this.showStatus(msg, "error");
|
|
832
|
+
}
|
|
833
|
+
}
|
|
720
834
|
requestDeleteFeedback(feedbackId) {
|
|
721
835
|
const targetKey = String(feedbackId);
|
|
722
836
|
if (!this.sessionHistory.some((item) => String(item.id) === targetKey))
|
|
@@ -1713,7 +1827,12 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
1713
1827
|
cancelEditBtn.setAttribute("aria-label", "Cancel editing feedback");
|
|
1714
1828
|
cancelEditBtn.textContent = "Cancel";
|
|
1715
1829
|
cancelEditBtn.addEventListener("click", () => {
|
|
1716
|
-
this.
|
|
1830
|
+
if (this.commentingFeedbackId !== null) {
|
|
1831
|
+
this.cancelCommentingFeedback();
|
|
1832
|
+
}
|
|
1833
|
+
else {
|
|
1834
|
+
this.cancelEditingFeedback();
|
|
1835
|
+
}
|
|
1717
1836
|
});
|
|
1718
1837
|
editBanner.appendChild(cancelEditBtn);
|
|
1719
1838
|
this.editBannerEl = editBanner;
|
|
@@ -1734,6 +1853,9 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
1734
1853
|
if (this.confirmingDeleteId !== null) {
|
|
1735
1854
|
this.cancelDeleteFeedback();
|
|
1736
1855
|
}
|
|
1856
|
+
else if (this.commentingFeedbackId !== null) {
|
|
1857
|
+
this.cancelCommentingFeedback();
|
|
1858
|
+
}
|
|
1737
1859
|
else if (this.editingFeedbackId !== null) {
|
|
1738
1860
|
this.cancelEditingFeedback();
|
|
1739
1861
|
}
|
|
@@ -2849,12 +2971,22 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
2849
2971
|
if (this.composerModeSwitchWrap) {
|
|
2850
2972
|
this.composerModeSwitchWrap.hidden = !this.config.agent?.enabled;
|
|
2851
2973
|
}
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2974
|
+
const isCommenting = this.commentingFeedbackId !== null;
|
|
2975
|
+
if (this.textareaEl) {
|
|
2976
|
+
if (isCommenting) {
|
|
2977
|
+
this.textareaEl.placeholder = "Write a comment... (attach or paste images below)";
|
|
2978
|
+
}
|
|
2979
|
+
else if (!this.customPlaceholderSet) {
|
|
2980
|
+
this.textareaEl.placeholder = smartMode
|
|
2981
|
+
? DEFAULT_SMART_PLACEHOLDER
|
|
2982
|
+
: DEFAULT_VERBOSE_PLACEHOLDER;
|
|
2983
|
+
}
|
|
2984
|
+
}
|
|
2985
|
+
if (this.cornerPinBtn) {
|
|
2986
|
+
this.cornerPinBtn.hidden = isCommenting;
|
|
2856
2987
|
}
|
|
2857
2988
|
if (this.composerToolbarPickBtn) {
|
|
2989
|
+
this.composerToolbarPickBtn.hidden = isCommenting;
|
|
2858
2990
|
if (smartMode) {
|
|
2859
2991
|
this.composerToolbarPickBtn.title = "Highlight an area on the page";
|
|
2860
2992
|
this.composerToolbarPickBtn.setAttribute("aria-label", "Highlight an area on the page");
|
|
@@ -2867,7 +2999,7 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
2867
2999
|
}
|
|
2868
3000
|
}
|
|
2869
3001
|
if (this.composerToolbarScreenshotBtn) {
|
|
2870
|
-
this.composerToolbarScreenshotBtn.hidden = smartMode;
|
|
3002
|
+
this.composerToolbarScreenshotBtn.hidden = smartMode && !isCommenting;
|
|
2871
3003
|
}
|
|
2872
3004
|
if (this.composerToolbarUploadBtn) {
|
|
2873
3005
|
this.composerToolbarUploadBtn.innerHTML = smartMode
|
|
@@ -2891,6 +3023,22 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
2891
3023
|
this.editBannerInfoEl.appendChild(idSpan);
|
|
2892
3024
|
}
|
|
2893
3025
|
}
|
|
3026
|
+
else if (this.commentingFeedbackId !== null) {
|
|
3027
|
+
this.editBannerEl.hidden = false;
|
|
3028
|
+
this.editBannerInfoEl.innerHTML = "";
|
|
3029
|
+
const iconSpan = document.createElement("span");
|
|
3030
|
+
iconSpan.innerHTML = ICON_COMMENT;
|
|
3031
|
+
const labelSpan = document.createElement("span");
|
|
3032
|
+
labelSpan.textContent = smartMode ? "Commenting on feedback" : "Commenting on";
|
|
3033
|
+
this.editBannerInfoEl.appendChild(iconSpan);
|
|
3034
|
+
this.editBannerInfoEl.appendChild(labelSpan);
|
|
3035
|
+
if (!smartMode) {
|
|
3036
|
+
const idSpan = document.createElement("span");
|
|
3037
|
+
idSpan.className = "cd-edit-banner-id";
|
|
3038
|
+
idSpan.textContent = `#${this.commentingFeedbackId}`;
|
|
3039
|
+
this.editBannerInfoEl.appendChild(idSpan);
|
|
3040
|
+
}
|
|
3041
|
+
}
|
|
2894
3042
|
else {
|
|
2895
3043
|
this.editBannerEl.hidden = true;
|
|
2896
3044
|
}
|
|
@@ -2900,6 +3048,10 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
2900
3048
|
this.submitBtn.setAttribute("aria-label", "Save feedback changes");
|
|
2901
3049
|
this.submitBtn.innerHTML = `${ICON_CHECK}<span>Save</span>`;
|
|
2902
3050
|
}
|
|
3051
|
+
else if (this.commentingFeedbackId !== null) {
|
|
3052
|
+
this.submitBtn.setAttribute("aria-label", "Submit comment");
|
|
3053
|
+
this.submitBtn.innerHTML = `${ICON_SEND}<span>Comment</span>`;
|
|
3054
|
+
}
|
|
2903
3055
|
else {
|
|
2904
3056
|
this.submitBtn.setAttribute("aria-label", "Submit feedback");
|
|
2905
3057
|
this.submitBtn.innerHTML = `${ICON_SEND}<span>Send</span>`;
|
|
@@ -3107,10 +3259,17 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
3107
3259
|
for (const entry of this.sessionHistory) {
|
|
3108
3260
|
const entryIdStr = String(entry.id);
|
|
3109
3261
|
const isEditingThis = this.editingFeedbackId === entryIdStr;
|
|
3262
|
+
const isCommentingThis = this.commentingFeedbackId === entryIdStr;
|
|
3263
|
+
const isReviewingThis = this.reviewingFeedbackId === entryIdStr;
|
|
3110
3264
|
const isConfirmingDelete = this.confirmingDeleteId === entryIdStr;
|
|
3111
3265
|
const isDeletingThis = this.deletingFeedbackId === entryIdStr;
|
|
3266
|
+
const statusName = entry.status || "new";
|
|
3112
3267
|
const msgCard = document.createElement("div");
|
|
3113
|
-
msgCard.className = isEditingThis
|
|
3268
|
+
msgCard.className = isEditingThis
|
|
3269
|
+
? "cd-chat-msg is-editing"
|
|
3270
|
+
: isCommentingThis
|
|
3271
|
+
? "cd-chat-msg is-commenting"
|
|
3272
|
+
: "cd-chat-msg";
|
|
3114
3273
|
msgCard.setAttribute("data-feedback-id", entryIdStr);
|
|
3115
3274
|
if (entry.elements.length > 0 || entry.attachments.length > 0) {
|
|
3116
3275
|
const pills = document.createElement("div");
|
|
@@ -3140,10 +3299,60 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
3140
3299
|
textP.textContent = entry.message;
|
|
3141
3300
|
msgCard.appendChild(textP);
|
|
3142
3301
|
}
|
|
3302
|
+
if (entry.comments && entry.comments.length > 0) {
|
|
3303
|
+
const commentsList = document.createElement("div");
|
|
3304
|
+
commentsList.className = "cd-comments-list";
|
|
3305
|
+
for (const comment of entry.comments) {
|
|
3306
|
+
const cItem = document.createElement("div");
|
|
3307
|
+
cItem.className = "cd-comment-item";
|
|
3308
|
+
const cHeader = document.createElement("div");
|
|
3309
|
+
cHeader.className = "cd-comment-header";
|
|
3310
|
+
const cAuthor = document.createElement("span");
|
|
3311
|
+
cAuthor.className = "cd-comment-author";
|
|
3312
|
+
cAuthor.textContent = comment.author_label || "You";
|
|
3313
|
+
const cTime = document.createElement("span");
|
|
3314
|
+
cTime.textContent = comment.createdAt;
|
|
3315
|
+
cHeader.appendChild(cAuthor);
|
|
3316
|
+
cHeader.appendChild(cTime);
|
|
3317
|
+
cItem.appendChild(cHeader);
|
|
3318
|
+
if (comment.body) {
|
|
3319
|
+
const cBody = document.createElement("p");
|
|
3320
|
+
cBody.className = "cd-comment-body";
|
|
3321
|
+
cBody.textContent = comment.body;
|
|
3322
|
+
cItem.appendChild(cBody);
|
|
3323
|
+
}
|
|
3324
|
+
if (comment.attachments && comment.attachments.length > 0) {
|
|
3325
|
+
const cImgs = document.createElement("div");
|
|
3326
|
+
cImgs.className = "cd-comment-images";
|
|
3327
|
+
for (const att of comment.attachments) {
|
|
3328
|
+
if (att.preview_url) {
|
|
3329
|
+
const imgLink = document.createElement("a");
|
|
3330
|
+
imgLink.href = att.preview_url;
|
|
3331
|
+
imgLink.target = "_blank";
|
|
3332
|
+
imgLink.rel = "noopener noreferrer";
|
|
3333
|
+
const img = document.createElement("img");
|
|
3334
|
+
img.src = att.preview_url;
|
|
3335
|
+
img.alt = att.label || "Comment image";
|
|
3336
|
+
img.className = "cd-comment-thumb";
|
|
3337
|
+
imgLink.appendChild(img);
|
|
3338
|
+
cImgs.appendChild(imgLink);
|
|
3339
|
+
}
|
|
3340
|
+
}
|
|
3341
|
+
if (cImgs.childNodes.length > 0) {
|
|
3342
|
+
cItem.appendChild(cImgs);
|
|
3343
|
+
}
|
|
3344
|
+
}
|
|
3345
|
+
commentsList.appendChild(cItem);
|
|
3346
|
+
}
|
|
3347
|
+
msgCard.appendChild(commentsList);
|
|
3348
|
+
}
|
|
3143
3349
|
const meta = document.createElement("div");
|
|
3144
3350
|
meta.className = "cd-chat-msg-meta";
|
|
3145
3351
|
const metaInfo = document.createElement("div");
|
|
3146
3352
|
metaInfo.className = "cd-chat-msg-meta-info";
|
|
3353
|
+
const statusBadge = document.createElement("span");
|
|
3354
|
+
statusBadge.className = `cd-msg-status-badge is-${statusName}`;
|
|
3355
|
+
statusBadge.textContent = statusName;
|
|
3147
3356
|
const idSpan = document.createElement("span");
|
|
3148
3357
|
const baseLabel = smartMode ? "Feedback sent" : `Dropped #${entry.id}`;
|
|
3149
3358
|
idSpan.textContent = entry.isEdited ? `${baseLabel} · edited` : baseLabel;
|
|
@@ -3152,11 +3361,41 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
3152
3361
|
sepSpan.textContent = "·";
|
|
3153
3362
|
const timeSpan = document.createElement("span");
|
|
3154
3363
|
timeSpan.textContent = entry.createdAt;
|
|
3364
|
+
metaInfo.appendChild(statusBadge);
|
|
3155
3365
|
metaInfo.appendChild(idSpan);
|
|
3156
3366
|
metaInfo.appendChild(sepSpan);
|
|
3157
3367
|
metaInfo.appendChild(timeSpan);
|
|
3158
3368
|
const actions = document.createElement("div");
|
|
3159
3369
|
actions.className = "cd-chat-msg-actions";
|
|
3370
|
+
if (statusName === "fixed") {
|
|
3371
|
+
const reviewBtn = document.createElement("button");
|
|
3372
|
+
reviewBtn.type = "button";
|
|
3373
|
+
reviewBtn.className = "cd-review-btn";
|
|
3374
|
+
reviewBtn.title = "Confirm fix was tested and reviewed";
|
|
3375
|
+
reviewBtn.setAttribute("aria-label", "Mark fix as reviewed");
|
|
3376
|
+
reviewBtn.disabled = isReviewingThis || this.isSubmitting || this.deletingFeedbackId !== null;
|
|
3377
|
+
reviewBtn.innerHTML = `${ICON_CHECK}<span>${isReviewingThis ? "Saving..." : "Mark Reviewed"}</span>`;
|
|
3378
|
+
reviewBtn.addEventListener("click", () => {
|
|
3379
|
+
void this.markFeedbackReviewed(entry.id);
|
|
3380
|
+
});
|
|
3381
|
+
actions.appendChild(reviewBtn);
|
|
3382
|
+
}
|
|
3383
|
+
const commentBtn = document.createElement("button");
|
|
3384
|
+
commentBtn.type = "button";
|
|
3385
|
+
commentBtn.className = `cd-msg-action-btn${isCommentingThis ? " is-active" : ""}`;
|
|
3386
|
+
commentBtn.title = isCommentingThis ? "Cancel comment" : "Add comment";
|
|
3387
|
+
commentBtn.setAttribute("aria-label", "Add comment");
|
|
3388
|
+
commentBtn.setAttribute("aria-pressed", String(isCommentingThis));
|
|
3389
|
+
commentBtn.disabled = this.isSubmitting || this.deletingFeedbackId !== null;
|
|
3390
|
+
commentBtn.innerHTML = ICON_COMMENT;
|
|
3391
|
+
commentBtn.addEventListener("click", () => {
|
|
3392
|
+
if (this.commentingFeedbackId === entryIdStr) {
|
|
3393
|
+
this.cancelCommentingFeedback();
|
|
3394
|
+
}
|
|
3395
|
+
else {
|
|
3396
|
+
this.startCommentingFeedback(entry.id);
|
|
3397
|
+
}
|
|
3398
|
+
});
|
|
3160
3399
|
const editBtn = document.createElement("button");
|
|
3161
3400
|
editBtn.type = "button";
|
|
3162
3401
|
editBtn.className = `cd-msg-action-btn${isEditingThis ? " is-active" : ""}`;
|
|
@@ -3183,6 +3422,7 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
3183
3422
|
deleteBtn.addEventListener("click", () => {
|
|
3184
3423
|
this.requestDeleteFeedback(entry.id);
|
|
3185
3424
|
});
|
|
3425
|
+
actions.appendChild(commentBtn);
|
|
3186
3426
|
actions.appendChild(editBtn);
|
|
3187
3427
|
actions.appendChild(deleteBtn);
|
|
3188
3428
|
meta.appendChild(metaInfo);
|
|
@@ -3546,11 +3786,18 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
3546
3786
|
return;
|
|
3547
3787
|
const smartMode = this.isSmartSelectionMode();
|
|
3548
3788
|
const editingId = this.editingFeedbackId;
|
|
3789
|
+
const commentingId = this.commentingFeedbackId;
|
|
3549
3790
|
if (this.pendingSmartCaptures.size > 0) {
|
|
3550
3791
|
await Promise.allSettled(Array.from(this.pendingSmartCaptures));
|
|
3551
3792
|
}
|
|
3552
3793
|
const message = (this.textareaEl?.value || "").trim();
|
|
3553
|
-
if (
|
|
3794
|
+
if (commentingId !== null) {
|
|
3795
|
+
if (message.length === 0 && this.attachments.length === 0) {
|
|
3796
|
+
this.showStatus("Write a comment or attach an image first.", "error");
|
|
3797
|
+
return;
|
|
3798
|
+
}
|
|
3799
|
+
}
|
|
3800
|
+
else if (message.length === 0 &&
|
|
3554
3801
|
this.attachments.length === 0 &&
|
|
3555
3802
|
this.elementReferences.length === 0) {
|
|
3556
3803
|
this.showStatus(smartMode
|
|
@@ -3562,7 +3809,11 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
3562
3809
|
if (this.submitBtn) {
|
|
3563
3810
|
this.submitBtn.disabled = true;
|
|
3564
3811
|
this.submitBtn.innerHTML =
|
|
3565
|
-
editingId !== null
|
|
3812
|
+
editingId !== null
|
|
3813
|
+
? `<span>Saving...</span>`
|
|
3814
|
+
: commentingId !== null
|
|
3815
|
+
? `<span>Posting...</span>`
|
|
3816
|
+
: `<span>Sending...</span>`;
|
|
3566
3817
|
}
|
|
3567
3818
|
try {
|
|
3568
3819
|
const submittedElements = structuredClone(this.elementReferences);
|
|
@@ -3588,6 +3839,46 @@ export class ContextDropWidgetElement extends BaseHTMLElement {
|
|
|
3588
3839
|
},
|
|
3589
3840
|
locale: typeof navigator !== "undefined" ? navigator.language : "en"
|
|
3590
3841
|
};
|
|
3842
|
+
if (commentingId !== null) {
|
|
3843
|
+
const existingIdx = this.sessionHistory.findIndex((item) => String(item.id) === commentingId);
|
|
3844
|
+
const existingEntry = existingIdx >= 0 ? this.sessionHistory[existingIdx] : undefined;
|
|
3845
|
+
const commentPayload = {
|
|
3846
|
+
body: message,
|
|
3847
|
+
attachments: this.attachments.map((att) => ({
|
|
3848
|
+
attachment_type: att.attachment_type,
|
|
3849
|
+
filename: att.filename,
|
|
3850
|
+
signed_blob_id: att.signed_blob_id,
|
|
3851
|
+
data_url: att.signed_blob_id ? undefined : att.data_url,
|
|
3852
|
+
metadata: att.metadata
|
|
3853
|
+
}))
|
|
3854
|
+
};
|
|
3855
|
+
const commentRes = await this.apiClient.createComment(existingEntry?.id ?? commentingId, commentPayload, existingEntry?.ownershipToken);
|
|
3856
|
+
if (commentRes?.feedback) {
|
|
3857
|
+
const updatedEntry = this.mapOwnRecordToSessionEntry(commentRes.feedback, existingEntry);
|
|
3858
|
+
if (existingIdx >= 0) {
|
|
3859
|
+
this.sessionHistory[existingIdx] = updatedEntry;
|
|
3860
|
+
}
|
|
3861
|
+
}
|
|
3862
|
+
else if (existingEntry) {
|
|
3863
|
+
existingEntry.status = commentRes?.status || "updated";
|
|
3864
|
+
if (!existingEntry.comments)
|
|
3865
|
+
existingEntry.comments = [];
|
|
3866
|
+
existingEntry.comments.push({
|
|
3867
|
+
id: commentRes?.id ?? Date.now(),
|
|
3868
|
+
author_label: commentRes?.comment?.author_label || "You",
|
|
3869
|
+
body: message || null,
|
|
3870
|
+
createdAt: this.formatTimestampLabel(commentRes?.created_at),
|
|
3871
|
+
attachments: submittedAttachments
|
|
3872
|
+
});
|
|
3873
|
+
}
|
|
3874
|
+
this.cancelCommentingFeedback();
|
|
3875
|
+
this.showStatus("Comment added.", "success");
|
|
3876
|
+
this.emitWidgetEvent("context-drop:comment", {
|
|
3877
|
+
response: commentRes,
|
|
3878
|
+
payload: commentPayload
|
|
3879
|
+
});
|
|
3880
|
+
return;
|
|
3881
|
+
}
|
|
3591
3882
|
if (editingId !== null) {
|
|
3592
3883
|
const existingIdx = this.sessionHistory.findIndex((item) => String(item.id) === editingId);
|
|
3593
3884
|
const existingEntry = existingIdx >= 0 ? this.sessionHistory[existingIdx] : undefined;
|
|
@@ -102,7 +102,7 @@ const TOOL_DEFINITIONS = [
|
|
|
102
102
|
},
|
|
103
103
|
{
|
|
104
104
|
name: "update_feedback_status",
|
|
105
|
-
description: "Transition a ContextDrop feedback record's status ('new', '
|
|
105
|
+
description: "Transition a ContextDrop feedback record's status ('new', 'updated', 'fixed', 'reviewed', 'dismissed') in local or remote environments.",
|
|
106
106
|
inputSchema: {
|
|
107
107
|
type: "object",
|
|
108
108
|
required: ["id", "status"],
|
|
@@ -237,6 +237,21 @@ function serializeFullFeedback(record, router) {
|
|
|
237
237
|
content_type: att.content_type,
|
|
238
238
|
byte_size: att.byte_size,
|
|
239
239
|
created_at: att.created_at
|
|
240
|
+
})),
|
|
241
|
+
comments: (record.comments ?? []).map((comment) => ({
|
|
242
|
+
id: comment.id,
|
|
243
|
+
author_label: comment.author_label,
|
|
244
|
+
author_type: comment.author_type ?? null,
|
|
245
|
+
body: comment.body,
|
|
246
|
+
attachments: (comment.attachments ?? []).map((att) => ({
|
|
247
|
+
id: att.id,
|
|
248
|
+
attachment_type: att.attachment_type,
|
|
249
|
+
filename: att.filename,
|
|
250
|
+
content_type: att.content_type,
|
|
251
|
+
byte_size: att.byte_size,
|
|
252
|
+
created_at: att.created_at
|
|
253
|
+
})),
|
|
254
|
+
created_at: comment.created_at
|
|
240
255
|
}))
|
|
241
256
|
};
|
|
242
257
|
}
|
|
@@ -584,6 +599,18 @@ export class ContextDropMcpDispatcher {
|
|
|
584
599
|
});
|
|
585
600
|
}
|
|
586
601
|
}
|
|
602
|
+
for (const comment of feedback.comments ?? []) {
|
|
603
|
+
for (const att of comment.attachments ?? []) {
|
|
604
|
+
const bytes = await this.storage.getAttachmentBytes(att.id);
|
|
605
|
+
if (bytes && bytes.byteLength > 0 && bytes.byteLength <= MAX_INLINE_IMAGE_BYTES) {
|
|
606
|
+
contentBlocks.push({
|
|
607
|
+
type: "image",
|
|
608
|
+
data: Buffer.from(bytes).toString("base64"),
|
|
609
|
+
mimeType: att.content_type || "image/png"
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
}
|
|
587
614
|
}
|
|
588
615
|
return {
|
|
589
616
|
content: contentBlocks,
|
|
@@ -851,7 +878,7 @@ export class ContextDropMcpDispatcher {
|
|
|
851
878
|
`1. Locate the page route corresponding to \`${pageUrl}\` (in Next.js \`app/**/page.tsx\` / \`pages/**\`, React router, or Rails \`config/routes.rb\` & \`app/views/\`).`,
|
|
852
879
|
`2. Search components and templates for the attached DOM selectors (\`${selectorsList || "N/A"}\`) and data-testid / class / text landmarks.`,
|
|
853
880
|
`3. Inspect any attached screenshots (\`get_feedback\` with \`id: "${qualified}"\`) to verify the visual layout or behavior issue.`,
|
|
854
|
-
`4. Implement and verify the fix locally, then call \`update_feedback_status\` (\`id: "${qualified}"\`, \`status: "
|
|
881
|
+
`4. Implement and verify the fix locally, then call \`update_feedback_status\` (\`id: "${qualified}"\`, \`status: "fixed"\`) once complete.`
|
|
855
882
|
].join("\n");
|
|
856
883
|
const imageBlocks = res.content.filter((b) => b.type === "image");
|
|
857
884
|
const messageContent = [{ type: "text", text: instructions }, ...imageBlocks];
|