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.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/context_drop/context_drop.js +488 -11
  3. data/app/controllers/context_drop/dashboard/feedbacks_controller.rb +87 -6
  4. data/app/controllers/context_drop/feedbacks_controller.rb +172 -19
  5. data/app/helpers/context_drop/dashboard_helper.rb +4 -0
  6. data/app/javascript/context_drop/api-client.ts +37 -0
  7. data/app/javascript/context_drop/icons.ts +2 -0
  8. data/app/javascript/context_drop/styles.ts +130 -0
  9. data/app/javascript/context_drop/types.ts +48 -3
  10. data/app/javascript/context_drop/widget.ts +325 -11
  11. data/app/models/context_drop/attachment.rb +5 -0
  12. data/app/models/context_drop/comment.rb +50 -0
  13. data/app/models/context_drop/feedback.rb +19 -6
  14. data/app/views/context_drop/dashboard/feedbacks/index.html.erb +6 -0
  15. data/app/views/context_drop/dashboard/feedbacks/show.html.erb +160 -2
  16. data/app/views/layouts/context_drop/application.html.erb +126 -7
  17. data/config/routes.rb +5 -1
  18. data/db/migrate/20261116000001_create_context_drop_comments_and_update_statuses.rb +44 -0
  19. data/lib/context_drop/agent/orchestrator.rb +1 -1
  20. data/lib/context_drop/mcp/dispatcher.rb +2 -1
  21. data/lib/context_drop/mcp/prompts/investigate_feedback.rb +2 -2
  22. data/lib/context_drop/mcp/server.rb +1 -0
  23. data/lib/context_drop/mcp/tools/add_feedback_comment.rb +139 -0
  24. data/lib/context_drop/mcp/tools/get_feedback.rb +29 -1
  25. data/lib/context_drop/mcp/tools/list_feedbacks.rb +1 -1
  26. data/lib/context_drop/mcp/tools/update_feedback_status.rb +2 -2
  27. data/lib/context_drop/version.rb +1 -1
  28. metadata +5 -2
@@ -60,9 +60,11 @@
60
60
  </div>
61
61
 
62
62
  <div style="display: flex; gap: 0.375rem; flex-wrap: wrap; align-items: center;">
63
+ <% primary_status = @feedback.status == "fixed" ? "reviewed" : "fixed" %>
63
64
  <% [
64
- ["reviewed", "Mark Reviewed", ""],
65
- ["resolved", "Mark Resolved", "cd-btn-primary"],
65
+ ["updated", "Mark Updated", primary_status == "updated" ? "cd-btn-primary" : ""],
66
+ ["fixed", "Mark Fixed", primary_status == "fixed" ? "cd-btn-primary" : ""],
67
+ ["reviewed", "Mark Reviewed", primary_status == "reviewed" ? "cd-btn-primary" : ""],
66
68
  ["dismissed", "Dismiss", ""]
67
69
  ].each do |target_status, label, extra_class| %>
68
70
  <%= form_with url: dashboard_feedback_path(@feedback), method: :patch, local: true, style: "display: inline;" do %>
@@ -231,8 +233,164 @@
231
233
  <% end %>
232
234
  </div>
233
235
 
236
+ <div class="cd-card">
237
+ <div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.875rem;">
238
+ <h2 style="margin: 0; font-size: 0.9375rem; font-weight: 600; display: inline-flex; align-items: center; gap: 0.4rem;">
239
+ <%= cd_icon_comment(size: 14) %>
240
+ <span>Comments</span>
241
+ <span class="cd-tab-count"><%= @feedback.comments.size %></span>
242
+ </h2>
243
+ <span style="font-size: 0.75rem; color: var(--cd-muted);">Adding a comment sets status to <strong>Updated</strong></span>
244
+ </div>
245
+
246
+ <% if @feedback.comments.empty? %>
247
+ <p style="color: var(--cd-muted); margin: 0 0 1rem 0; font-size: 0.8125rem;">No comments yet. Add a note or screenshot below to follow up.</p>
248
+ <% else %>
249
+ <div class="cd-comment-list">
250
+ <% @feedback.comments.each do |comment| %>
251
+ <div class="cd-comment-item" id="comment-<%= comment.id %>">
252
+ <div class="cd-comment-header">
253
+ <span class="cd-comment-author">
254
+ <%= cd_icon_user(size: 12) %>
255
+ <span><%= comment.display_author_label %></span>
256
+ </span>
257
+ <span class="cd-comment-time"><%= comment.created_at&.strftime("%Y-%m-%d %H:%M:%S UTC") %></span>
258
+ </div>
259
+ <% if comment.body.present? %>
260
+ <p class="cd-comment-body"><%= comment.body %></p>
261
+ <% end %>
262
+ <% if comment.attachments.any? %>
263
+ <div class="cd-comment-images">
264
+ <% comment.attachments.each do |att| %>
265
+ <% if att.respond_to?(:file) && att.file.attached? && main_app.respond_to?(:url_for) %>
266
+ <a href="<%= main_app.url_for(att.file) %>" target="_blank" rel="noopener noreferrer" title="<%= att.file.filename %>">
267
+ <img src="<%= main_app.url_for(att.file) %>"
268
+ alt="Comment attachment #<%= att.id %>"
269
+ class="cd-comment-thumb" />
270
+ </a>
271
+ <% end %>
272
+ <% end %>
273
+ </div>
274
+ <% end %>
275
+ </div>
276
+ <% end %>
277
+ </div>
278
+ <% end %>
279
+
280
+ <%= form_with url: comments_dashboard_feedback_path(@feedback), method: :post, multipart: true, local: true, class: "cd-comment-form", id: "cd-dashboard-comment-form" do %>
281
+ <textarea name="body"
282
+ id="cd-dashboard-comment-body"
283
+ class="cd-comment-textarea"
284
+ placeholder="Write a comment... (You can paste or attach images below)"
285
+ aria-label="Comment body"></textarea>
286
+ <div class="cd-comment-previews" id="cd-dashboard-comment-previews" hidden></div>
287
+ <div class="cd-comment-toolbar">
288
+ <div style="display: flex; align-items: center; gap: 0.5rem;">
289
+ <label for="cd-dashboard-comment-images" class="cd-btn cd-btn-sm" style="cursor: pointer;">
290
+ <%= cd_icon_attachment(size: 13) %>
291
+ <span>Attach Images</span>
292
+ </label>
293
+ <input type="file"
294
+ id="cd-dashboard-comment-images"
295
+ name="images[]"
296
+ multiple
297
+ accept="image/png,image/jpeg,image/webp,image/gif"
298
+ style="display: none;">
299
+ <span style="font-size: 0.75rem; color: var(--cd-muted);" id="cd-dashboard-comment-files-label"></span>
300
+ </div>
301
+ <button type="submit" class="cd-btn cd-btn-sm cd-btn-primary">Post Comment</button>
302
+ </div>
303
+ <% end %>
304
+ </div>
305
+
234
306
  <script>
235
307
  (function() {
308
+ var form = document.getElementById("cd-dashboard-comment-form");
309
+ var textarea = document.getElementById("cd-dashboard-comment-body");
310
+ var fileInput = document.getElementById("cd-dashboard-comment-images");
311
+ var previews = document.getElementById("cd-dashboard-comment-previews");
312
+ var filesLabel = document.getElementById("cd-dashboard-comment-files-label");
313
+ var selectedFiles = [];
314
+
315
+ function syncFileInput() {
316
+ if (!fileInput || typeof DataTransfer === "undefined") return;
317
+ var dt = new DataTransfer();
318
+ selectedFiles.forEach(function(f) { dt.items.add(f); });
319
+ fileInput.files = dt.files;
320
+ renderPreviews();
321
+ }
322
+
323
+ function renderPreviews() {
324
+ if (!previews || !filesLabel) return;
325
+ previews.innerHTML = "";
326
+ if (selectedFiles.length === 0) {
327
+ previews.hidden = true;
328
+ filesLabel.textContent = "";
329
+ return;
330
+ }
331
+ previews.hidden = false;
332
+ filesLabel.textContent = selectedFiles.length + " image(s) selected";
333
+ selectedFiles.forEach(function(file, idx) {
334
+ var chip = document.createElement("span");
335
+ chip.className = "cd-comment-preview-chip";
336
+ var img = document.createElement("img");
337
+ img.alt = file.name;
338
+ var reader = new FileReader();
339
+ reader.onload = function(ev) { img.src = ev.target.result; };
340
+ reader.readAsDataURL(file);
341
+ var nameSpan = document.createElement("span");
342
+ nameSpan.textContent = file.name.length > 24 ? file.name.slice(0, 21) + "..." : file.name;
343
+ var rmBtn = document.createElement("button");
344
+ rmBtn.type = "button";
345
+ rmBtn.textContent = "×";
346
+ rmBtn.setAttribute("aria-label", "Remove image");
347
+ rmBtn.style.cssText = "border:none;background:none;cursor:pointer;font-size:14px;color:var(--cd-muted);padding:0 2px;";
348
+ rmBtn.addEventListener("click", function() {
349
+ selectedFiles.splice(idx, 1);
350
+ syncFileInput();
351
+ });
352
+ chip.appendChild(img);
353
+ chip.appendChild(nameSpan);
354
+ chip.appendChild(rmBtn);
355
+ previews.appendChild(chip);
356
+ });
357
+ }
358
+
359
+ if (fileInput) {
360
+ fileInput.addEventListener("change", function() {
361
+ if (fileInput.files && fileInput.files.length > 0) {
362
+ Array.prototype.forEach.call(fileInput.files, function(f) { selectedFiles.push(f); });
363
+ syncFileInput();
364
+ }
365
+ });
366
+ }
367
+
368
+ if (textarea) {
369
+ textarea.addEventListener("keydown", function(e) {
370
+ if ((e.metaKey || e.ctrlKey) && e.key === "Enter" && form) {
371
+ e.preventDefault();
372
+ form.submit();
373
+ }
374
+ });
375
+ textarea.addEventListener("paste", function(e) {
376
+ var items = e.clipboardData && e.clipboardData.items;
377
+ if (!items) return;
378
+ var added = false;
379
+ for (var i = 0; i < items.length; i++) {
380
+ if (items[i].type && items[i].type.indexOf("image/") === 0) {
381
+ var file = items[i].getAsFile();
382
+ if (file) {
383
+ selectedFiles.push(file);
384
+ added = true;
385
+ }
386
+ }
387
+ }
388
+ if (added) {
389
+ syncFileInput();
390
+ }
391
+ });
392
+ }
393
+
236
394
  window.addEventListener("keydown", function(e) {
237
395
  if (e.target && (e.target.tagName === "INPUT" || e.target.tagName === "TEXTAREA" || e.target.tagName === "SELECT" || e.target.isContentEditable)) {
238
396
  return;
@@ -26,13 +26,17 @@
26
26
  --cd-new-border: #bfdbfe;
27
27
  --cd-new-text: #1d4ed8;
28
28
 
29
- --cd-reviewed-bg: #fffbeb;
30
- --cd-reviewed-border: #fde68a;
31
- --cd-reviewed-text: #b45309;
29
+ --cd-updated-bg: #fffbeb;
30
+ --cd-updated-border: #fde68a;
31
+ --cd-updated-text: #b45309;
32
32
 
33
- --cd-resolved-bg: #f0fdf4;
34
- --cd-resolved-border: #bbf7d0;
35
- --cd-resolved-text: #15803d;
33
+ --cd-fixed-bg: #eef2ff;
34
+ --cd-fixed-border: #c7d2fe;
35
+ --cd-fixed-text: #4338ca;
36
+
37
+ --cd-reviewed-bg: #f0fdf4;
38
+ --cd-reviewed-border: #bbf7d0;
39
+ --cd-reviewed-text: #15803d;
36
40
 
37
41
  --cd-dismissed-bg: #f8fafc;
38
42
  --cd-dismissed-border: #e2e8f0;
@@ -373,11 +377,126 @@
373
377
  letter-spacing: 0.01em;
374
378
  }
375
379
  .cd-badge-new { background: var(--cd-new-bg); border-color: var(--cd-new-border); color: var(--cd-new-text); }
380
+ .cd-badge-updated { background: var(--cd-updated-bg); border-color: var(--cd-updated-border); color: var(--cd-updated-text); }
381
+ .cd-badge-fixed { background: var(--cd-fixed-bg); border-color: var(--cd-fixed-border); color: var(--cd-fixed-text); }
376
382
  .cd-badge-reviewed { background: var(--cd-reviewed-bg); border-color: var(--cd-reviewed-border); color: var(--cd-reviewed-text); }
377
- .cd-badge-resolved { background: var(--cd-resolved-bg); border-color: var(--cd-resolved-border); color: var(--cd-resolved-text); }
378
383
  .cd-badge-dismissed { background: var(--cd-dismissed-bg); border-color: var(--cd-dismissed-border); color: var(--cd-dismissed-text); }
379
384
  .cd-badge-deleted { background: var(--cd-deleted-bg); border-color: var(--cd-deleted-border); color: var(--cd-deleted-text); }
380
385
 
386
+ /* Comments Thread & Composer */
387
+ .cd-comment-list {
388
+ display: flex;
389
+ flex-direction: column;
390
+ gap: 0.75rem;
391
+ margin-bottom: 1.25rem;
392
+ }
393
+ .cd-comment-item {
394
+ border: 1px solid var(--cd-border-subtle);
395
+ border-radius: 0.5rem;
396
+ padding: 0.875rem 1rem;
397
+ background: var(--cd-surface-recessed);
398
+ }
399
+ .cd-comment-header {
400
+ display: flex;
401
+ align-items: center;
402
+ justify-content: space-between;
403
+ gap: 0.5rem;
404
+ margin-bottom: 0.45rem;
405
+ font-size: 0.75rem;
406
+ }
407
+ .cd-comment-author {
408
+ font-weight: 600;
409
+ color: var(--cd-text);
410
+ display: inline-flex;
411
+ align-items: center;
412
+ gap: 0.35rem;
413
+ }
414
+ .cd-comment-time {
415
+ font-family: var(--cd-font-mono);
416
+ font-size: 0.6875rem;
417
+ color: var(--cd-muted);
418
+ font-variant-numeric: tabular-nums;
419
+ }
420
+ .cd-comment-body {
421
+ font-size: 0.875rem;
422
+ line-height: 1.55;
423
+ color: var(--cd-text);
424
+ white-space: pre-wrap;
425
+ margin: 0;
426
+ }
427
+ .cd-comment-images {
428
+ display: flex;
429
+ flex-wrap: wrap;
430
+ gap: 0.625rem;
431
+ margin-top: 0.625rem;
432
+ }
433
+ .cd-comment-thumb {
434
+ max-width: 220px;
435
+ max-height: 150px;
436
+ object-fit: cover;
437
+ border-radius: 0.375rem;
438
+ border: 1px solid var(--cd-border);
439
+ display: block;
440
+ background: var(--cd-surface);
441
+ }
442
+ .cd-comment-form {
443
+ border: 1px solid var(--cd-border);
444
+ border-radius: 0.5rem;
445
+ background: var(--cd-surface);
446
+ padding: 0.75rem;
447
+ transition: border-color 0.15s ease, box-shadow 0.15s ease;
448
+ }
449
+ .cd-comment-form:focus-within {
450
+ border-color: var(--cd-primary);
451
+ box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.08);
452
+ }
453
+ .cd-comment-textarea {
454
+ width: 100%;
455
+ min-height: 76px;
456
+ border: none;
457
+ outline: none;
458
+ resize: vertical;
459
+ font-family: inherit;
460
+ font-size: 0.875rem;
461
+ line-height: 1.5;
462
+ color: var(--cd-text);
463
+ background: transparent;
464
+ padding: 0.125rem 0.25rem;
465
+ }
466
+ .cd-comment-previews {
467
+ display: flex;
468
+ flex-wrap: wrap;
469
+ gap: 0.5rem;
470
+ margin-top: 0.5rem;
471
+ }
472
+ .cd-comment-preview-chip {
473
+ position: relative;
474
+ display: inline-flex;
475
+ align-items: center;
476
+ gap: 0.375rem;
477
+ padding: 0.25rem 0.5rem 0.25rem 0.25rem;
478
+ border: 1px solid var(--cd-border);
479
+ border-radius: 0.375rem;
480
+ background: var(--cd-surface-recessed);
481
+ font-size: 0.75rem;
482
+ color: var(--cd-text-secondary);
483
+ }
484
+ .cd-comment-preview-chip img {
485
+ width: 28px;
486
+ height: 28px;
487
+ object-fit: cover;
488
+ border-radius: 0.25rem;
489
+ }
490
+ .cd-comment-toolbar {
491
+ display: flex;
492
+ align-items: center;
493
+ justify-content: space-between;
494
+ gap: 0.75rem;
495
+ margin-top: 0.625rem;
496
+ padding-top: 0.625rem;
497
+ border-top: 1px solid var(--cd-border-subtle);
498
+ }
499
+
381
500
  .cd-mono {
382
501
  font-family: var(--cd-font-mono);
383
502
  font-size: 0.75rem;
data/config/routes.rb CHANGED
@@ -5,6 +5,7 @@ ContextDrop::Engine.routes.draw do
5
5
  match "attachments", to: "configs#cors_preflight", via: :options
6
6
  match "feedback", to: "configs#cors_preflight", via: :options
7
7
  match "feedback/:id", to: "configs#cors_preflight", via: :options
8
+ match "feedback/:id/comments", to: "configs#cors_preflight", via: :options
8
9
  match "feedback/:feedback_id/attachments/:id", to: "configs#cors_preflight", via: :options
9
10
  match "health", to: "configs#cors_preflight", via: :options
10
11
 
@@ -15,6 +16,7 @@ ContextDrop::Engine.routes.draw do
15
16
  post "feedback", to: "feedbacks#create"
16
17
  match "feedback/:id", to: "feedbacks#update", via: %i[patch put]
17
18
  delete "feedback/:id", to: "feedbacks#destroy"
19
+ post "feedback/:id/comments", to: "feedbacks#create_comment"
18
20
  get "feedback/:feedback_id/attachments/:id", to: "feedbacks#attachment"
19
21
  get "health", to: "health#show"
20
22
  post "mcp", to: "mcp#create"
@@ -32,7 +34,9 @@ ContextDrop::Engine.routes.draw do
32
34
 
33
35
  namespace :dashboard do
34
36
  root to: "feedbacks#index"
35
- resources :feedbacks, only: %i[index show update]
37
+ resources :feedbacks, only: %i[index show update] do
38
+ post :comments, on: :member, action: :create_comment
39
+ end
36
40
  end
37
41
 
38
42
  root to: "dashboard/feedbacks#index"
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateContextDropCommentsAndUpdateStatuses < ActiveRecord::Migration[7.1]
4
+ def up
5
+ json_type = connection.adapter_name.downcase.include?("postgres") ? :jsonb : :json
6
+
7
+ create_table :context_drop_comments do |t|
8
+ t.references :feedback,
9
+ null: false,
10
+ foreign_key: { to_table: :context_drop_feedbacks, on_delete: :cascade },
11
+ index: { name: "idx_context_drop_comments_on_feedback_id" }
12
+ t.string :author_type, null: true
13
+ t.string :author_id, null: true
14
+ t.string :author_label, null: true
15
+ t.text :body, null: true
16
+ t.public_send(json_type, :metadata, null: false, default: {})
17
+
18
+ t.timestamps
19
+ end
20
+
21
+ add_reference :context_drop_attachments,
22
+ :comment,
23
+ null: true,
24
+ foreign_key: { to_table: :context_drop_comments, on_delete: :cascade },
25
+ index: { name: "idx_context_drop_attachments_on_comment_id" }
26
+
27
+ execute <<~SQL.squish
28
+ UPDATE context_drop_feedbacks
29
+ SET status = 'fixed'
30
+ WHERE status = 'resolved'
31
+ SQL
32
+ end
33
+
34
+ def down
35
+ execute <<~SQL.squish
36
+ UPDATE context_drop_feedbacks
37
+ SET status = 'resolved'
38
+ WHERE status = 'fixed'
39
+ SQL
40
+
41
+ remove_reference :context_drop_attachments, :comment, foreign_key: { to_table: :context_drop_comments }
42
+ drop_table :context_drop_comments
43
+ end
44
+ end
@@ -53,7 +53,7 @@ module ContextDrop
53
53
  type: "object",
54
54
  properties: {
55
55
  environment: { type: "string", description: "Environment filter: 'all' (default), 'local', 'staging', 'production', etc." },
56
- status: { type: "string", enum: %w[new reviewed resolved dismissed], description: "Workflow status filter." },
56
+ status: { type: "string", enum: %w[new updated fixed reviewed dismissed], description: "Workflow status filter." },
57
57
  page_url: { type: "string", description: "Originating page URL substring filter." },
58
58
  query: { type: "string", description: "Free-text search across message and DOM selectors." },
59
59
  limit: { type: "integer", description: "Max items (default 15)." }
@@ -12,7 +12,8 @@ module ContextDrop
12
12
  "list_feedbacks" => ContextDrop::MCP::Tools::ListFeedbacks,
13
13
  "get_feedback" => ContextDrop::MCP::Tools::GetFeedback,
14
14
  "get_feedback_attachment" => ContextDrop::MCP::Tools::GetFeedbackAttachment,
15
- "update_feedback_status" => ContextDrop::MCP::Tools::UpdateFeedbackStatus
15
+ "update_feedback_status" => ContextDrop::MCP::Tools::UpdateFeedbackStatus,
16
+ "add_feedback_comment" => ContextDrop::MCP::Tools::AddFeedbackComment
16
17
  }.freeze
17
18
 
18
19
  PROMPTS = {
@@ -77,7 +77,7 @@ module ContextDrop
77
77
  1. Locate the Rails route and controller action corresponding to `#{feedback.page_url}` in `config/routes.rb` and `app/controllers/`.
78
78
  2. Search the view templates (`app/views/`, ViewComponents, or frontend components) for the attached DOM selectors (`#{feedback.element_references.map(&:selector).join(', ')}`) and structural DOM paths (`#{feedback.element_references.map(&:dom_path).compact.join(', ')}`).
79
79
  3. Inspect any attached screenshots (`get_feedback` with `id: "#{qualified}"`) to verify the visual layout issue.
80
- 4. Propose and verify a fix, then call `update_feedback_status` (`id: "#{qualified}"`, `status: "resolved"`) once complete.
80
+ 4. Propose and verify a fix, then call `update_feedback_status` (`id: "#{qualified}"`, `status: "fixed"`) once complete.
81
81
  PROMPT
82
82
 
83
83
  message_content = [{ type: "text", text: instructions }]
@@ -142,7 +142,7 @@ module ContextDrop
142
142
  1. Locate the Rails route and controller action corresponding to `#{fb['page_url']}` in `config/routes.rb` and `app/controllers/`.
143
143
  2. Search the view templates (`app/views/`, ViewComponents, or frontend components) for the attached DOM selectors (`#{els.map { |e| e['selector'] }.join(', ')}`).
144
144
  3. Inspect any attached screenshots (`get_feedback` with `id: "#{qualified}"`) to verify the visual layout issue.
145
- 4. Propose and verify a fix locally, then call `update_feedback_status` (`id: "#{qualified}"`, `status: "resolved"`) once complete.
145
+ 4. Propose and verify a fix locally, then call `update_feedback_status` (`id: "#{qualified}"`, `status: "fixed"`) once complete.
146
146
  PROMPT
147
147
 
148
148
  image_blocks = Array(tool_res[:content]).select { |b| b.is_a?(Hash) && b[:type].to_s == "image" }
@@ -7,6 +7,7 @@ require_relative "tools/list_feedbacks"
7
7
  require_relative "tools/get_feedback"
8
8
  require_relative "tools/get_feedback_attachment"
9
9
  require_relative "tools/update_feedback_status"
10
+ require_relative "tools/add_feedback_comment"
10
11
  require_relative "prompts/investigate_feedback"
11
12
  require_relative "dispatcher"
12
13
  require_relative "stdio_runner"
@@ -0,0 +1,139 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ContextDrop
4
+ module MCP
5
+ module Tools
6
+ class AddFeedbackComment
7
+ DEFINITION = {
8
+ name: "add_feedback_comment",
9
+ description: "Add a follow-up comment to a ContextDrop feedback record (optionally transitioning its status, defaulting to 'updated' unless specified).",
10
+ inputSchema: {
11
+ type: "object",
12
+ required: %w[id body],
13
+ properties: {
14
+ id: {
15
+ type: %w[integer string],
16
+ description: "The ID of the ContextDrop::Feedback record, or a qualified '<environment>:<id>' string."
17
+ },
18
+ environment: {
19
+ type: "string",
20
+ description: "Optional environment name ('local', 'staging', 'production', etc.)."
21
+ },
22
+ body: {
23
+ type: "string",
24
+ description: "Comment text."
25
+ },
26
+ author_label: {
27
+ type: "string",
28
+ description: "Optional display label for the comment author (defaults to 'AI Agent')."
29
+ },
30
+ status: {
31
+ type: "string",
32
+ enum: %w[new updated fixed reviewed dismissed],
33
+ description: "Optional target workflow status (defaults to 'updated')."
34
+ }
35
+ }
36
+ }
37
+ }.freeze
38
+
39
+ def self.call(args = {})
40
+ params = args.is_a?(Hash) ? args.transform_keys(&:to_s) : {}
41
+ raw_id = params["id"] || params["feedback_id"]
42
+ body = params["body"].to_s.strip
43
+ author_label = params["author_label"].to_s.strip.presence || "AI Agent"
44
+ next_status = params["status"].to_s.strip.presence || "updated"
45
+
46
+ return error_result("Missing required parameter: id") if raw_id.nil? || raw_id.to_s.strip.empty?
47
+ return error_result("Missing required parameter: body") if body.empty?
48
+
49
+ unless ContextDrop::Feedback::STATUSES.include?(next_status)
50
+ return error_result(
51
+ "Invalid status '#{next_status}'. Must be one of: #{ContextDrop::Feedback::STATUSES.join(', ')}"
52
+ )
53
+ end
54
+
55
+ target_env, feedback_id = ContextDrop::MCP::EnvironmentRouter.parse_target(raw_id, params["environment"])
56
+
57
+ unless ContextDrop::MCP::EnvironmentRouter.local_target?(target_env)
58
+ remote_cfg = ContextDrop::MCP::EnvironmentRouter.remote_config_for(target_env)
59
+ return error_result("Unknown remote environment '#{target_env}'") unless remote_cfg
60
+
61
+ begin
62
+ remote_args = {
63
+ "id" => feedback_id,
64
+ "body" => body,
65
+ "author_label" => author_label,
66
+ "status" => next_status
67
+ }
68
+ res = ContextDrop::MCP::RemoteClient.call_tool(target_env, remote_cfg, "add_feedback_comment", remote_args)
69
+ return res if res[:isError]
70
+
71
+ updated_blocks = Array(res[:content]).map do |block|
72
+ if block.is_a?(Hash) && block[:type].to_s == "text"
73
+ begin
74
+ parsed = JSON.parse(block[:text].to_s)
75
+ if parsed.is_a?(Hash)
76
+ parsed["environment"] = target_env
77
+ parsed["qualified_id"] = ContextDrop::MCP::EnvironmentRouter.qualify_id(target_env, parsed["feedback_id"] || feedback_id)
78
+ next block.merge(text: JSON.pretty_generate(parsed))
79
+ end
80
+ rescue JSON::ParserError
81
+ # Keep original block
82
+ end
83
+ end
84
+ block
85
+ end
86
+ return { content: updated_blocks, isError: false }
87
+ rescue ContextDrop::MCP::RemoteClient::RemoteError => e
88
+ return error_result(e.message)
89
+ end
90
+ end
91
+
92
+ feedback = ContextDrop::Feedback.find_by(id: feedback_id)
93
+ if !feedback || (feedback.respond_to?(:deleted?) && feedback.deleted?)
94
+ return error_result("Feedback ##{feedback_id} not found")
95
+ end
96
+
97
+ comment = nil
98
+ ContextDrop::Feedback.transaction do
99
+ comment = feedback.comments.create!(
100
+ author_type: "Agent",
101
+ author_label: author_label,
102
+ body: body,
103
+ metadata: {}
104
+ )
105
+ feedback.update!(status: next_status)
106
+ end
107
+
108
+ env_name = ContextDrop::MCP::EnvironmentRouter.record_environment(feedback)
109
+
110
+ {
111
+ content: [
112
+ {
113
+ type: "text",
114
+ text: JSON.pretty_generate(
115
+ id: comment.id,
116
+ feedback_id: feedback.id,
117
+ qualified_id: ContextDrop::MCP::EnvironmentRouter.qualify_id(env_name, feedback.id),
118
+ environment: env_name,
119
+ author_label: comment.display_author_label,
120
+ body: comment.body,
121
+ status: feedback.status,
122
+ created_at: comment.created_at&.iso8601
123
+ )
124
+ }
125
+ ],
126
+ isError: false
127
+ }
128
+ end
129
+
130
+ def self.error_result(msg)
131
+ {
132
+ content: [{ type: "text", text: JSON.generate(error: msg) }],
133
+ isError: true
134
+ }
135
+ end
136
+ end
137
+ end
138
+ end
139
+ end
@@ -52,7 +52,7 @@ module ContextDrop
52
52
  end
53
53
 
54
54
  feedback = ContextDrop::Feedback
55
- .includes(:submitter, :element_references, :attachments)
55
+ .includes(:submitter, :element_references, :attachments, comments: :attachments)
56
56
  .find_by(id: feedback_id)
57
57
 
58
58
  if !feedback || (!include_deleted && feedback.respond_to?(:deleted?) && feedback.deleted?)
@@ -72,6 +72,14 @@ module ContextDrop
72
72
  img_block = build_image_content_block(att)
73
73
  content_blocks << img_block if img_block
74
74
  end
75
+ if feedback.respond_to?(:comments)
76
+ feedback.comments.each do |comment|
77
+ comment.attachments.each do |att|
78
+ img_block = build_image_content_block(att)
79
+ content_blocks << img_block if img_block
80
+ end
81
+ end
82
+ end
75
83
  end
76
84
 
77
85
  {
@@ -158,6 +166,26 @@ module ContextDrop
158
166
  byte_size: attached ? att.file.byte_size : nil,
159
167
  created_at: att.created_at&.iso8601
160
168
  }
169
+ end,
170
+ comments: (feedback.respond_to?(:comments) ? feedback.comments : []).map do |comment|
171
+ {
172
+ id: comment.id,
173
+ author_label: comment.display_author_label,
174
+ author_type: comment.author_type,
175
+ body: comment.body,
176
+ attachments: comment.attachments.map do |att|
177
+ attached = att.respond_to?(:file) && att.file.attached?
178
+ {
179
+ id: att.id,
180
+ attachment_type: att.attachment_type,
181
+ filename: attached ? att.file.filename.to_s : nil,
182
+ content_type: attached ? att.file.content_type : nil,
183
+ byte_size: attached ? att.file.byte_size : nil,
184
+ created_at: att.created_at&.iso8601
185
+ }
186
+ end,
187
+ created_at: comment.created_at&.iso8601
188
+ }
161
189
  end
162
190
  }
163
191
  end
@@ -19,7 +19,7 @@ module ContextDrop
19
19
  },
20
20
  status: {
21
21
  type: "string",
22
- enum: %w[new reviewed resolved dismissed],
22
+ enum: %w[new updated fixed reviewed dismissed],
23
23
  description: "Filter feedback by workflow status."
24
24
  },
25
25
  page_url: {
@@ -6,7 +6,7 @@ module ContextDrop
6
6
  class UpdateFeedbackStatus
7
7
  DEFINITION = {
8
8
  name: "update_feedback_status",
9
- description: "Transition a ContextDrop feedback record's status ('new', 'reviewed', 'resolved', 'dismissed') in local or remote environments.",
9
+ description: "Transition a ContextDrop feedback record's status ('new', 'updated', 'fixed', 'reviewed', 'dismissed') in local or remote environments.",
10
10
  inputSchema: {
11
11
  type: "object",
12
12
  required: %w[id status],
@@ -21,7 +21,7 @@ module ContextDrop
21
21
  },
22
22
  status: {
23
23
  type: "string",
24
- enum: %w[new reviewed resolved dismissed],
24
+ enum: %w[new updated fixed reviewed dismissed],
25
25
  description: "Target workflow status."
26
26
  }
27
27
  }