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.
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 +23 -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 +115 -89
  15. data/app/views/context_drop/dashboard/feedbacks/show.html.erb +176 -18
  16. data/app/views/layouts/context_drop/application.html.erb +431 -118
  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
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
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ContextDrop
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: context_drop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kemal Elmizan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-11-13 00:00:00.000000000 Z
11
+ date: 2026-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -192,6 +192,7 @@ files:
192
192
  - app/javascript/context_drop/widget.ts
193
193
  - app/models/context_drop/application_record.rb
194
194
  - app/models/context_drop/attachment.rb
195
+ - app/models/context_drop/comment.rb
195
196
  - app/models/context_drop/element_reference.rb
196
197
  - app/models/context_drop/feedback.rb
197
198
  - app/services/context_drop/metadata_sanitizer.rb
@@ -206,6 +207,7 @@ files:
206
207
  - db/migrate/20261109000003_create_context_drop_attachments.rb
207
208
  - db/migrate/20261112000004_add_environment_to_context_drop_feedbacks.rb
208
209
  - db/migrate/20261113000005_add_deleted_at_to_context_drop_feedbacks.rb
210
+ - db/migrate/20261116000001_create_context_drop_comments_and_update_statuses.rb
209
211
  - lib/context_drop.rb
210
212
  - lib/context_drop/agent/key_store.rb
211
213
  - lib/context_drop/agent/llm_client.rb
@@ -220,6 +222,7 @@ files:
220
222
  - lib/context_drop/mcp/remote_client.rb
221
223
  - lib/context_drop/mcp/server.rb
222
224
  - lib/context_drop/mcp/stdio_runner.rb
225
+ - lib/context_drop/mcp/tools/add_feedback_comment.rb
223
226
  - lib/context_drop/mcp/tools/get_feedback.rb
224
227
  - lib/context_drop/mcp/tools/get_feedback_attachment.rb
225
228
  - lib/context_drop/mcp/tools/list_environments.rb