context_drop 0.1.3 → 0.1.4
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.
- checksums.yaml +4 -4
- data/README.md +101 -9
- data/app/assets/javascripts/context_drop/context_drop.js +117 -12
- data/app/controllers/context_drop/dashboard/feedbacks_controller.rb +62 -2
- data/app/helpers/context_drop/dashboard_helper.rb +52 -0
- data/app/javascript/context_drop/__tests__/widget.test.ts +70 -3
- data/app/javascript/context_drop/element-picker.ts +66 -1
- data/app/javascript/context_drop/widget.ts +51 -11
- data/app/models/context_drop/feedback.rb +11 -5
- data/app/views/context_drop/dashboard/feedbacks/index.html.erb +161 -60
- data/app/views/context_drop/dashboard/feedbacks/show.html.erb +168 -47
- data/app/views/layouts/context_drop/application.html.erb +415 -70
- data/lib/context_drop/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6f47ccd912edd4803adfe23aac2346e3ff6e34ad115c109f0982fe2e715af3d9
|
|
4
|
+
data.tar.gz: 0be0fbda77adbc5f6e655be40d940aa4ba1dd967299a4ffbca323fd5abbade93
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c7c52b647c0b16dba94ecffe2546db1bb944b91280d41099bd55e097d63b02081e7910678c77e2a0cae5a4e9f3471cf3d61bdafb183f27b64456982d2a1b3524
|
|
7
|
+
data.tar.gz: f76d7bffc1455cedfe99391be70923907b2eec123ea714a4ce7816aed3502854b7ba696c81846bbd5f9e673878a8e6071714cac4e60d152ad01ada436447e78b
|
data/README.md
CHANGED
|
@@ -223,14 +223,109 @@ ContextDrop ships with a built-in **Model Context Protocol (MCP)** server (`Cont
|
|
|
223
223
|
|
|
224
224
|
---
|
|
225
225
|
|
|
226
|
-
###
|
|
226
|
+
### Recommended Setup (Local + Remote)
|
|
227
|
+
|
|
228
|
+
For day-to-day development, register **both** a local `stdio` server and a remote Streamable HTTP server side-by-side in your MCP configuration (`mcp_config.json` in **Antigravity**, `~/.cursor/mcp.json` in **Cursor**, **Claude Desktop** / `.mcp.json` in **Claude Code**, **Windsurf**, or **VS Code**):
|
|
229
|
+
|
|
230
|
+
- **`context-drop-local` (`stdio`):** Runs `./bin/rails context_drop:mcp` directly against your local development database and Active Storage (no running `bin/rails server` required). Wrapped with `/bin/zsh -c`, `cd`, `exec`, and an explicit `PATH` so it boots reliably inside strict agent sandboxes and GUI-launched IDEs.
|
|
231
|
+
- **`context-drop-remote` (`Streamable HTTP`):** Connects to your deployed staging or production Rails app (`POST <mount_path>/mcp` with `CONTEXT_DROP_MCP_ENABLED=true` and `CONTEXT_DROP_MCP_API_KEY=<your-secret-token>` configured on the server) so your agent can pull real bug reports, pinned selectors, and screenshots submitted by QA or users, fix the code locally, and mark the remote feedback resolved.
|
|
232
|
+
|
|
233
|
+
```json
|
|
234
|
+
{
|
|
235
|
+
"mcpServers": {
|
|
236
|
+
"context-drop-local": {
|
|
237
|
+
"command": "/bin/zsh",
|
|
238
|
+
"args": [
|
|
239
|
+
"-c",
|
|
240
|
+
"cd /absolute/path/to/your-rails-app && exec /Users/<you>/.rbenv/shims/bundle exec ./bin/rails context_drop:mcp"
|
|
241
|
+
],
|
|
242
|
+
"env": {
|
|
243
|
+
"PATH": "/Users/<you>/.rbenv/shims:/Users/<you>/.rbenv/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
"context-drop-remote": {
|
|
247
|
+
"url": "https://staging.example.com/context_drop/mcp",
|
|
248
|
+
"headers": {
|
|
249
|
+
"Authorization": "Bearer <your-secret-token>"
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
> [!NOTE]
|
|
257
|
+
> **Custom route prefixes:** Match the `context-drop-remote` URL to wherever `ContextDrop::Engine` is mounted in `config/routes.rb` plus `/mcp` (for example, `https://staging.example.com/rails/context_drop/mcp` when mounted under `/rails/context_drop`).
|
|
258
|
+
|
|
259
|
+
Naming the servers `context-drop-local` and `context-drop-remote` lets you target either environment explicitly in your IDE prompts without toggling config files:
|
|
260
|
+
- *"Check `context-drop-remote` for new feedbacks, inspect the pinned element selector and screenshot, diagnose the root cause in our local Rails views/CSS, and mark the feedback resolved."*
|
|
261
|
+
- *"Inspect the latest feedback I just pinned on `context-drop-local` and verify the layout fix."*
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
### Multi-Environment & Multiple Remote Servers (`local` + `staging` + `production`)
|
|
266
|
+
|
|
267
|
+
MCP clients support registering any number of ContextDrop servers simultaneously. If your team triages feedback across **Staging / QA** and **Production** (or across multiple Rails services), register each remote endpoint under an explicit environment-scoped key:
|
|
268
|
+
|
|
269
|
+
```json
|
|
270
|
+
{
|
|
271
|
+
"mcpServers": {
|
|
272
|
+
"context-drop-local": {
|
|
273
|
+
"command": "/bin/zsh",
|
|
274
|
+
"args": [
|
|
275
|
+
"-c",
|
|
276
|
+
"cd /absolute/path/to/your-rails-app && exec /Users/<you>/.rbenv/shims/bundle exec ./bin/rails context_drop:mcp"
|
|
277
|
+
],
|
|
278
|
+
"env": {
|
|
279
|
+
"PATH": "/Users/<you>/.rbenv/shims:/Users/<you>/.rbenv/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
"context-drop-staging": {
|
|
283
|
+
"url": "https://staging.example.com/context_drop/mcp",
|
|
284
|
+
"headers": {
|
|
285
|
+
"Authorization": "Bearer <staging-mcp-secret-token>"
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
"context-drop-production": {
|
|
289
|
+
"url": "https://app.example.com/context_drop/mcp",
|
|
290
|
+
"headers": {
|
|
291
|
+
"Authorization": "Bearer <production-mcp-secret-token>"
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
#### Recommended Environment Matrix
|
|
299
|
+
|
|
300
|
+
| Environment | MCP Transport | `CONTEXT_DROP_ENABLED` (Widget & Dashboard) | `CONTEXT_DROP_MCP_ENABLED` (HTTP `/mcp`) | Token & Access Strategy |
|
|
301
|
+
|---|---|---|---|---|
|
|
302
|
+
| **Local (`development`)** | `stdio` (`context_drop:mcp`) | `true` | `false` *(not needed for `stdio`)* | Direct local DB & Active Storage access; zero network exposure. |
|
|
303
|
+
| **Staging / QA** | Streamable HTTP | `true` | `true` | Dedicated `staging` token (`bin/rails secret`); open to QA & preview testers. |
|
|
304
|
+
| **Production** | Streamable HTTP | `true` *(or scoped via `authorize_submission`)* | `true` | Separate `production` token (rotated independently) + optional gateway headers / `authorize_mcp`. |
|
|
305
|
+
|
|
306
|
+
#### Multi-Environment Best Practices
|
|
307
|
+
|
|
308
|
+
- **Namespace server keys clearly (especially across multiple Rails apps):** In global IDE configs (`mcp_config.json` in Antigravity or `~/.cursor/mcp.json`), prefix keys by service and environment—such as `checkout-local`, `checkout-staging`, `checkout-prod`, and `admin-prod`—so your agent never confuses tools from different repositories or databases.
|
|
309
|
+
- **Isolate secrets per environment:** Generate a distinct high-entropy `CONTEXT_DROP_MCP_API_KEY` (`bin/rails secret` or `openssl rand -hex 32`) in each environment's Rails encrypted credentials or secret manager. Never share a single Bearer token between staging and production.
|
|
310
|
+
- **Keep live tokens out of version control:** Place configs containing live `Authorization` headers in user-level MCP files (e.g., Antigravity `mcp_config.json`, `~/.cursor/mcp.json`) or gitignore workspace `.mcp.json` overrides.
|
|
311
|
+
- **Independent Widget vs. MCP switches:** `config.enabled` and `config.mcp_enabled` are decoupled—`ContextDrop::McpController` remains reachable whenever `CONTEXT_DROP_MCP_ENABLED=true`, even if you temporarily set `CONTEXT_DROP_ENABLED=false` in production to pause new widget submissions while finishing triage.
|
|
312
|
+
- **Stamp environment & release SHA into widget metadata:** Pass `metadata: { env: Rails.env, release: ENV["GIT_COMMIT_SHA"] }` to `<%= context_drop_widget(...) %>` so every feedback record pulled by your agent explicitly carries the environment and commit SHA it came from.
|
|
313
|
+
- **Layer zero-trust proxy headers when needed:** If your remote MCP endpoints sit behind Cloudflare Access, Google IAP, or an internal MCP gateway, pass additional proxy headers inside `"headers"` alongside `Authorization` (or validate custom JWT/header claims in `config.authorize_mcp`).
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
### Individual Transport Options & Environment Reference
|
|
318
|
+
|
|
319
|
+
If you only need a single transport or use a different Ruby version manager (`mise`, `asdf`, `rvm`, Homebrew) or Docker setup, see the reference configurations below.
|
|
320
|
+
|
|
321
|
+
#### Option 1: Project-Scoped Local `stdio` (Inherited Shell Environment)
|
|
227
322
|
|
|
228
323
|
When using a workspace-scoped MCP file (e.g., `.mcp.json` in Claude Code or `.cursor/mcp.json` launched from a terminal) where your IDE already runs inside the Rails root and inherits your Ruby shell `PATH`:
|
|
229
324
|
|
|
230
325
|
```json
|
|
231
326
|
{
|
|
232
327
|
"mcpServers": {
|
|
233
|
-
"context-drop": {
|
|
328
|
+
"context-drop-local": {
|
|
234
329
|
"command": "bundle",
|
|
235
330
|
"args": ["exec", "./bin/rails", "context_drop:mcp"]
|
|
236
331
|
}
|
|
@@ -238,7 +333,7 @@ When using a workspace-scoped MCP file (e.g., `.mcp.json` in Claude Code or `.cu
|
|
|
238
333
|
}
|
|
239
334
|
```
|
|
240
335
|
|
|
241
|
-
|
|
336
|
+
#### Option 2: Strict Sandboxes, Global IDE Configs & Ruby Version Managers (`rbenv`, `mise`, `asdf`, `rvm`)
|
|
242
337
|
|
|
243
338
|
Strict sandboxed coding agents and GUI-launched desktop IDEs (such as **Antigravity** `mcp_config.json`, **Claude Desktop**, global `~/.cursor/mcp.json`, **Windsurf**, or VS Code launched from macOS Finder / Linux desktop) typically spawn MCP subprocesses with:
|
|
244
339
|
1. **A non-project working directory** (often `/` or `$HOME`, causing relative `./bin/rails` or `Gemfile` lookup to fail), and
|
|
@@ -249,7 +344,7 @@ To make `stdio` work reliably in strict sandboxes, wrap the launch command with
|
|
|
249
344
|
```json
|
|
250
345
|
{
|
|
251
346
|
"mcpServers": {
|
|
252
|
-
"context-drop": {
|
|
347
|
+
"context-drop-local": {
|
|
253
348
|
"command": "/bin/zsh",
|
|
254
349
|
"args": [
|
|
255
350
|
"-c",
|
|
@@ -277,14 +372,14 @@ To make `stdio` work reliably in strict sandboxes, wrap the launch command with
|
|
|
277
372
|
| **`rvm`** (macOS / Linux) | `/Users/<you>/.rvm/wrappers/default/bundle` | `/Users/<you>/.rvm/gems/default/bin:/Users/<you>/.rvm/bin` |
|
|
278
373
|
| **Homebrew / Linux `/usr/local`** | `/opt/homebrew/opt/ruby/bin/bundle` or `/usr/local/bin/bundle` | `/opt/homebrew/opt/ruby/bin:/opt/homebrew/bin:/usr/local/bin` |
|
|
279
374
|
|
|
280
|
-
|
|
375
|
+
#### Option 3: Streamable HTTP Transport (Docker, Isolated Sandboxes, Staging & Production)
|
|
281
376
|
|
|
282
377
|
If your Rails app runs inside **Docker / Devcontainers**, if your agent sandbox blocks host binary execution outside the workspace, or if you want to triage feedback directly from **staging or production**, enable the HTTP endpoint with a bearer token (`CONTEXT_DROP_MCP_ENABLED=true` and `CONTEXT_DROP_MCP_API_KEY=<your-secret-token>`) and point your MCP client to `POST /context_drop/mcp`:
|
|
283
378
|
|
|
284
379
|
```json
|
|
285
380
|
{
|
|
286
381
|
"mcpServers": {
|
|
287
|
-
"context-drop-
|
|
382
|
+
"context-drop-remote": {
|
|
288
383
|
"url": "https://staging.example.com/context_drop/mcp",
|
|
289
384
|
"headers": {
|
|
290
385
|
"Authorization": "Bearer <your-secret-token>"
|
|
@@ -296,9 +391,6 @@ If your Rails app runs inside **Docker / Devcontainers**, if your agent sandbox
|
|
|
296
391
|
|
|
297
392
|
*(For local Docker or strict-sandbox setups, use `"url": "http://localhost:3000/context_drop/mcp"` against your running `bin/rails server`.)*
|
|
298
393
|
|
|
299
|
-
Once connected, prompt your coding agent directly in your IDE:
|
|
300
|
-
> *"Check the `context-drop` MCP server for new feedbacks, inspect the pinned element selector and screenshot, diagnose the root cause in our Rails views/CSS, and mark the feedback resolved."*
|
|
301
|
-
|
|
302
394
|
---
|
|
303
395
|
|
|
304
396
|
## Zero-Trust Privacy & Redaction
|
|
@@ -1666,6 +1666,7 @@
|
|
|
1666
1666
|
boundMouseMove ;
|
|
1667
1667
|
boundClickCapture ;
|
|
1668
1668
|
boundPointerCapture ;
|
|
1669
|
+
boundBlurSuppression ;
|
|
1669
1670
|
boundWheelCapture ;
|
|
1670
1671
|
boundKeyDown ;
|
|
1671
1672
|
boundScrollOrResize ;
|
|
@@ -1675,6 +1676,7 @@
|
|
|
1675
1676
|
this.boundMouseMove = this.handleMouseMove.bind(this);
|
|
1676
1677
|
this.boundClickCapture = this.handleClickCapture.bind(this);
|
|
1677
1678
|
this.boundPointerCapture = this.handlePointerSuppression.bind(this);
|
|
1679
|
+
this.boundBlurSuppression = this.handleBlurSuppression.bind(this);
|
|
1678
1680
|
this.boundWheelCapture = this.handleWheelCapture.bind(this);
|
|
1679
1681
|
this.boundKeyDown = this.handleKeyDown.bind(this);
|
|
1680
1682
|
this.boundScrollOrResize = this.handleViewportScrollOrResize.bind(this);
|
|
@@ -1729,6 +1731,8 @@
|
|
|
1729
1731
|
window.addEventListener("mousedown", this.boundPointerCapture, { capture: true });
|
|
1730
1732
|
window.addEventListener("mouseup", this.boundPointerCapture, { capture: true });
|
|
1731
1733
|
window.addEventListener("click", this.boundClickCapture, { capture: true });
|
|
1734
|
+
window.addEventListener("blur", this.boundBlurSuppression, { capture: true });
|
|
1735
|
+
window.addEventListener("focusout", this.boundBlurSuppression, { capture: true });
|
|
1732
1736
|
window.addEventListener("wheel", this.boundWheelCapture, { capture: true, passive: false });
|
|
1733
1737
|
window.addEventListener("keydown", this.boundKeyDown, { capture: true });
|
|
1734
1738
|
window.addEventListener("scroll", this.boundScrollOrResize, { capture: true, passive: true });
|
|
@@ -1756,6 +1760,8 @@
|
|
|
1756
1760
|
window.removeEventListener("mousedown", this.boundPointerCapture, { capture: true });
|
|
1757
1761
|
window.removeEventListener("mouseup", this.boundPointerCapture, { capture: true });
|
|
1758
1762
|
window.removeEventListener("click", this.boundClickCapture, { capture: true });
|
|
1763
|
+
window.removeEventListener("blur", this.boundBlurSuppression, { capture: true });
|
|
1764
|
+
window.removeEventListener("focusout", this.boundBlurSuppression, { capture: true });
|
|
1759
1765
|
window.removeEventListener("wheel", this.boundWheelCapture, { capture: true });
|
|
1760
1766
|
window.removeEventListener("keydown", this.boundKeyDown, { capture: true });
|
|
1761
1767
|
window.removeEventListener("scroll", this.boundScrollOrResize, { capture: true });
|
|
@@ -1767,6 +1773,13 @@
|
|
|
1767
1773
|
this.callbacks.onExit();
|
|
1768
1774
|
}
|
|
1769
1775
|
|
|
1776
|
+
highlightAtPoint(x , y ) {
|
|
1777
|
+
if (!this.active || typeof document === "undefined") return;
|
|
1778
|
+
this.lastPointerX = x;
|
|
1779
|
+
this.lastPointerY = y;
|
|
1780
|
+
this.updateCandidatesFromPoint(x, y);
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1770
1783
|
focusCandidateElement(el ) {
|
|
1771
1784
|
if (!this.active) return;
|
|
1772
1785
|
const excluded = this.callbacks.getExcludedSelectors();
|
|
@@ -2375,6 +2388,9 @@
|
|
|
2375
2388
|
].join(";");
|
|
2376
2389
|
|
|
2377
2390
|
const clickHint = document.createElement("span");
|
|
2391
|
+
clickHint.style.cssText = "display: inline-flex; align-items: center; gap: 4px;";
|
|
2392
|
+
clickHint.appendChild(this.createKbdEl("Space"));
|
|
2393
|
+
clickHint.appendChild(this.createSpanEl("or"));
|
|
2378
2394
|
const clickStrong = document.createElement("strong");
|
|
2379
2395
|
clickStrong.style.cssText = pinnedInfo
|
|
2380
2396
|
? "color: #ffedd5; font-weight: 600;"
|
|
@@ -2405,6 +2421,8 @@
|
|
|
2405
2421
|
|
|
2406
2422
|
const escHint = document.createElement("span");
|
|
2407
2423
|
escHint.style.cssText = "display: inline-flex; align-items: center; gap: 4px;";
|
|
2424
|
+
escHint.appendChild(this.createKbdEl("⌥⇧P"));
|
|
2425
|
+
escHint.appendChild(this.createSpanEl("freeze · "));
|
|
2408
2426
|
escHint.appendChild(this.createKbdEl("Esc"));
|
|
2409
2427
|
escHint.appendChild(this.createSpanEl("done"));
|
|
2410
2428
|
coachRow.appendChild(escHint);
|
|
@@ -2634,8 +2652,10 @@
|
|
|
2634
2652
|
|
|
2635
2653
|
const keysHint = document.createElement("span");
|
|
2636
2654
|
keysHint.style.cssText = "display: inline-flex; align-items: center; gap: 4px;";
|
|
2637
|
-
keysHint.appendChild(this.createKbdEl("
|
|
2655
|
+
keysHint.appendChild(this.createKbdEl("Space"));
|
|
2638
2656
|
keysHint.appendChild(this.createSpanEl("pin · "));
|
|
2657
|
+
keysHint.appendChild(this.createKbdEl("⌥⇧P"));
|
|
2658
|
+
keysHint.appendChild(this.createSpanEl("freeze · "));
|
|
2639
2659
|
keysHint.appendChild(this.createKbdEl("Esc"));
|
|
2640
2660
|
keysHint.appendChild(this.createSpanEl("done"));
|
|
2641
2661
|
|
|
@@ -2909,6 +2929,20 @@
|
|
|
2909
2929
|
}
|
|
2910
2930
|
}
|
|
2911
2931
|
|
|
2932
|
+
handleBlurSuppression(event ) {
|
|
2933
|
+
if (!this.active) return;
|
|
2934
|
+
if (this.isInternalUiEvent(event)) {
|
|
2935
|
+
return;
|
|
2936
|
+
}
|
|
2937
|
+
|
|
2938
|
+
// Freeze DOM states: suppress blur / focusout on host elements while picker is active
|
|
2939
|
+
// so transient popovers, tooltips, flyout menus, and modals remain open
|
|
2940
|
+
event.stopPropagation();
|
|
2941
|
+
if (typeof event.stopImmediatePropagation === "function") {
|
|
2942
|
+
event.stopImmediatePropagation();
|
|
2943
|
+
}
|
|
2944
|
+
}
|
|
2945
|
+
|
|
2912
2946
|
handleClickCapture(event ) {
|
|
2913
2947
|
if (!this.active) return;
|
|
2914
2948
|
if (this.isInternalUiEvent(event)) {
|
|
@@ -2941,6 +2975,37 @@
|
|
|
2941
2975
|
return;
|
|
2942
2976
|
}
|
|
2943
2977
|
|
|
2978
|
+
// Alt+Shift+P / Option+Shift+P toggle / exit Freeze & Pin mode
|
|
2979
|
+
if (
|
|
2980
|
+
event.altKey &&
|
|
2981
|
+
event.shiftKey &&
|
|
2982
|
+
(event.code === "KeyP" || event.key.toLowerCase() === "p")
|
|
2983
|
+
) {
|
|
2984
|
+
event.preventDefault();
|
|
2985
|
+
event.stopPropagation();
|
|
2986
|
+
this.stop();
|
|
2987
|
+
return;
|
|
2988
|
+
}
|
|
2989
|
+
|
|
2990
|
+
// Space key freezes & pins the currently hovered element without triggering mouse clicks
|
|
2991
|
+
if (event.key === " " || event.key === "Spacebar" || event.code === "Space") {
|
|
2992
|
+
if (this.isInternalUiEvent(event)) return;
|
|
2993
|
+
const candidate = this.getActiveCandidate();
|
|
2994
|
+
if (candidate) {
|
|
2995
|
+
event.preventDefault();
|
|
2996
|
+
event.stopPropagation();
|
|
2997
|
+
if (typeof event.stopImmediatePropagation === "function") {
|
|
2998
|
+
event.stopImmediatePropagation();
|
|
2999
|
+
}
|
|
3000
|
+
this.commitCandidateSelection(
|
|
3001
|
+
candidate.element,
|
|
3002
|
+
this.lastPointerX || 80,
|
|
3003
|
+
this.lastPointerY || 80
|
|
3004
|
+
);
|
|
3005
|
+
}
|
|
3006
|
+
return;
|
|
3007
|
+
}
|
|
3008
|
+
|
|
2944
3009
|
if (event.key === "ArrowUp" || event.key === "[") {
|
|
2945
3010
|
event.preventDefault();
|
|
2946
3011
|
event.stopPropagation();
|
|
@@ -3032,6 +3097,10 @@
|
|
|
3032
3097
|
statusEl = null;
|
|
3033
3098
|
fileInputEl = null;
|
|
3034
3099
|
submitBtn = null;
|
|
3100
|
+
lastPointerX = 0;
|
|
3101
|
+
lastPointerY = 0;
|
|
3102
|
+
boundTrackPointer ;
|
|
3103
|
+
boundGlobalKeyDown ;
|
|
3035
3104
|
|
|
3036
3105
|
connectedCallback() {
|
|
3037
3106
|
if (!this.shadow) {
|
|
@@ -3040,6 +3109,32 @@
|
|
|
3040
3109
|
this.readDataAttributes();
|
|
3041
3110
|
this.renderShadowDom();
|
|
3042
3111
|
|
|
3112
|
+
this.boundTrackPointer = (ev ) => {
|
|
3113
|
+
this.lastPointerX = ev.clientX;
|
|
3114
|
+
this.lastPointerY = ev.clientY;
|
|
3115
|
+
};
|
|
3116
|
+
|
|
3117
|
+
this.boundGlobalKeyDown = (ev ) => {
|
|
3118
|
+
// Alt+Shift+P / Option+Shift+P toggles Freeze & Pin mode from anywhere on the host page
|
|
3119
|
+
if (
|
|
3120
|
+
ev.altKey &&
|
|
3121
|
+
ev.shiftKey &&
|
|
3122
|
+
(ev.code === "KeyP" || (typeof ev.key === "string" && ev.key.toLowerCase() === "p"))
|
|
3123
|
+
) {
|
|
3124
|
+
ev.preventDefault();
|
|
3125
|
+
ev.stopPropagation();
|
|
3126
|
+
if (typeof ev.stopImmediatePropagation === "function") {
|
|
3127
|
+
ev.stopImmediatePropagation();
|
|
3128
|
+
}
|
|
3129
|
+
this.togglePinSelection();
|
|
3130
|
+
}
|
|
3131
|
+
};
|
|
3132
|
+
|
|
3133
|
+
if (typeof window !== "undefined") {
|
|
3134
|
+
window.addEventListener("mousemove", this.boundTrackPointer, { capture: true, passive: true });
|
|
3135
|
+
window.addEventListener("keydown", this.boundGlobalKeyDown, { capture: true });
|
|
3136
|
+
}
|
|
3137
|
+
|
|
3043
3138
|
this.picker = new ElementPicker({
|
|
3044
3139
|
onSelect: (snapshot, el) => {
|
|
3045
3140
|
const added = this.addElementReference(snapshot, el);
|
|
@@ -3088,6 +3183,11 @@
|
|
|
3088
3183
|
this.picker.stop();
|
|
3089
3184
|
}
|
|
3090
3185
|
this.picker?.hideExternalPreview();
|
|
3186
|
+
|
|
3187
|
+
if (typeof window !== "undefined") {
|
|
3188
|
+
window.removeEventListener("mousemove", this.boundTrackPointer, { capture: true });
|
|
3189
|
+
window.removeEventListener("keydown", this.boundGlobalKeyDown, { capture: true });
|
|
3190
|
+
}
|
|
3091
3191
|
}
|
|
3092
3192
|
|
|
3093
3193
|
getConfig() {
|
|
@@ -3159,6 +3259,9 @@
|
|
|
3159
3259
|
}
|
|
3160
3260
|
this.minimizeToCompactBar();
|
|
3161
3261
|
this.picker.start();
|
|
3262
|
+
if (this.lastPointerX > 0 && this.lastPointerY > 0) {
|
|
3263
|
+
this.picker.highlightAtPoint(this.lastPointerX, this.lastPointerY);
|
|
3264
|
+
}
|
|
3162
3265
|
this.syncUiStates();
|
|
3163
3266
|
}
|
|
3164
3267
|
|
|
@@ -3392,7 +3495,8 @@
|
|
|
3392
3495
|
const compactPinBtn = document.createElement("button");
|
|
3393
3496
|
compactPinBtn.type = "button";
|
|
3394
3497
|
compactPinBtn.className = "cd-pin-corner-btn is-active";
|
|
3395
|
-
compactPinBtn.
|
|
3498
|
+
compactPinBtn.title = "Toggle Freeze & Pin (⌥⇧P)";
|
|
3499
|
+
compactPinBtn.setAttribute("aria-label", "Toggle element pin mode (Option+Shift+P)");
|
|
3396
3500
|
compactPinBtn.innerHTML = `${ICON_PIN}<span>Pinning</span>`;
|
|
3397
3501
|
compactPinBtn.addEventListener("click", () => this.togglePinSelection());
|
|
3398
3502
|
this.compactPinBtn = compactPinBtn;
|
|
@@ -3475,8 +3579,8 @@
|
|
|
3475
3579
|
const cornerPinBtn = document.createElement("button");
|
|
3476
3580
|
cornerPinBtn.type = "button";
|
|
3477
3581
|
cornerPinBtn.className = "cd-pin-corner-btn";
|
|
3478
|
-
cornerPinBtn.title = "
|
|
3479
|
-
cornerPinBtn.setAttribute("aria-label", "Select DOM element on page");
|
|
3582
|
+
cornerPinBtn.title = "Freeze & Pin element (⌥⇧P)";
|
|
3583
|
+
cornerPinBtn.setAttribute("aria-label", "Select DOM element on page (Option+Shift+P)");
|
|
3480
3584
|
cornerPinBtn.innerHTML = `${ICON_PIN}<span>Pin Element</span>`;
|
|
3481
3585
|
cornerPinBtn.addEventListener("click", () => this.startPinSelection());
|
|
3482
3586
|
this.cornerPinBtn = cornerPinBtn;
|
|
@@ -3583,8 +3687,9 @@
|
|
|
3583
3687
|
const pickBtn = document.createElement("button");
|
|
3584
3688
|
pickBtn.type = "button";
|
|
3585
3689
|
pickBtn.className = "cd-btn";
|
|
3586
|
-
pickBtn.
|
|
3587
|
-
pickBtn.
|
|
3690
|
+
pickBtn.title = "Freeze & Pin element (⌥⇧P)";
|
|
3691
|
+
pickBtn.setAttribute("aria-label", "Pin HTML element as context (Option+Shift+P)");
|
|
3692
|
+
pickBtn.innerHTML = `${ICON_PIN}<span>Pin</span><kbd class="cd-kbd">⌥⇧P</kbd>`;
|
|
3588
3693
|
pickBtn.addEventListener("click", () => this.startPinSelection());
|
|
3589
3694
|
actions.appendChild(pickBtn);
|
|
3590
3695
|
}
|
|
@@ -3640,8 +3745,8 @@
|
|
|
3640
3745
|
const floatingPinBtn = document.createElement("button");
|
|
3641
3746
|
floatingPinBtn.type = "button";
|
|
3642
3747
|
floatingPinBtn.className = "cd-floating-pin-btn";
|
|
3643
|
-
floatingPinBtn.title = "Pin
|
|
3644
|
-
floatingPinBtn.setAttribute("aria-label", "Pin element on page");
|
|
3748
|
+
floatingPinBtn.title = "Freeze & Pin element (⌥⇧P, or drag to move)";
|
|
3749
|
+
floatingPinBtn.setAttribute("aria-label", "Freeze & Pin element on page (Option+Shift+P)");
|
|
3645
3750
|
floatingPinBtn.innerHTML = `${ICON_PIN}<span>Pin</span>`;
|
|
3646
3751
|
this.attachDragHandle(floatingPinBtn, () => this.startPinSelection());
|
|
3647
3752
|
this.floatingPinBtn = floatingPinBtn;
|
|
@@ -3740,7 +3845,7 @@
|
|
|
3740
3845
|
if (pinnedCount === 0) {
|
|
3741
3846
|
const coach = document.createElement("span");
|
|
3742
3847
|
coach.className = "cd-compact-coach-text";
|
|
3743
|
-
coach.innerHTML = `<strong>
|
|
3848
|
+
coach.innerHTML = `<strong>Space</strong><span>or click to pin</span><span>·</span><span class="cd-compact-wheel-icon">${ICON_SCROLL_VERTICAL}</span><strong>Scroll</strong><span>layers</span><span>·</span><kbd class="cd-kbd">⌥⇧P</kbd><span>freeze</span>`;
|
|
3744
3849
|
this.compactStatusEl.appendChild(coach);
|
|
3745
3850
|
} else {
|
|
3746
3851
|
const latest = this.elementReferences[pinnedCount - 1];
|
|
@@ -3774,7 +3879,7 @@
|
|
|
3774
3879
|
|
|
3775
3880
|
const addMore = document.createElement("span");
|
|
3776
3881
|
addMore.className = "cd-compact-coach-text";
|
|
3777
|
-
addMore.
|
|
3882
|
+
addMore.innerHTML = `<strong>Space</strong><span>or click to add more</span>`;
|
|
3778
3883
|
this.compactStatusEl.appendChild(addMore);
|
|
3779
3884
|
}
|
|
3780
3885
|
|
|
@@ -3825,8 +3930,8 @@
|
|
|
3825
3930
|
|
|
3826
3931
|
const p2 = document.createElement("p");
|
|
3827
3932
|
p2.className = "cd-chat-empty-hint";
|
|
3828
|
-
p2.
|
|
3829
|
-
"
|
|
3933
|
+
p2.innerHTML =
|
|
3934
|
+
"Press <kbd class=\"cd-kbd\">⌥⇧P</kbd> anywhere or click Pin to freeze & pin, scroll to cycle layers, and press <kbd class=\"cd-kbd\">Space</kbd> to pin instantly.";
|
|
3830
3935
|
|
|
3831
3936
|
emptyBox.appendChild(p1);
|
|
3832
3937
|
emptyBox.appendChild(p2);
|
|
@@ -4,8 +4,10 @@ module ContextDrop
|
|
|
4
4
|
module Dashboard
|
|
5
5
|
class FeedbacksController < ApplicationController
|
|
6
6
|
layout "context_drop/application"
|
|
7
|
+
helper ContextDrop::DashboardHelper
|
|
7
8
|
|
|
8
9
|
before_action :enforce_dashboard_authorization!
|
|
10
|
+
before_action :resolve_navigation_shortcuts
|
|
9
11
|
|
|
10
12
|
PER_PAGE = 25
|
|
11
13
|
|
|
@@ -18,7 +20,7 @@ module ContextDrop
|
|
|
18
20
|
"dismissed" => ContextDrop::Feedback.dismissed.count
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
scope = ContextDrop::Feedback.includes(:
|
|
23
|
+
scope = ContextDrop::Feedback.includes(:element_references, :attachments).recent
|
|
22
24
|
|
|
23
25
|
@current_status = params[:status].to_s.strip
|
|
24
26
|
if ContextDrop::Feedback::STATUSES.include?(@current_status)
|
|
@@ -48,12 +50,35 @@ module ContextDrop
|
|
|
48
50
|
@page = [params[:page].to_i, 1].max
|
|
49
51
|
@total_pages = [(@total_filtered.to_f / PER_PAGE).ceil, 1].max
|
|
50
52
|
@feedbacks = scope.limit(PER_PAGE).offset((@page - 1) * PER_PAGE)
|
|
53
|
+
|
|
54
|
+
session[:context_drop_dashboard_index_url] = request.fullpath if respond_to?(:session) && request&.get?
|
|
51
55
|
end
|
|
52
56
|
|
|
53
57
|
def show
|
|
54
58
|
@feedback = ContextDrop::Feedback
|
|
55
|
-
.includes(:
|
|
59
|
+
.includes(:element_references, :attachments)
|
|
56
60
|
.find(params[:id])
|
|
61
|
+
|
|
62
|
+
# Newer feedback (previous in chronological newest-first list) and older feedback (next in list)
|
|
63
|
+
@newer_feedback = ContextDrop::Feedback
|
|
64
|
+
.where(
|
|
65
|
+
"created_at > :ts OR (created_at = :ts AND id > :id)",
|
|
66
|
+
ts: @feedback.created_at,
|
|
67
|
+
id: @feedback.id
|
|
68
|
+
)
|
|
69
|
+
.order(created_at: :asc, id: :asc)
|
|
70
|
+
.select(:id, :status)
|
|
71
|
+
.first
|
|
72
|
+
|
|
73
|
+
@older_feedback = ContextDrop::Feedback
|
|
74
|
+
.where(
|
|
75
|
+
"created_at < :ts OR (created_at = :ts AND id < :id)",
|
|
76
|
+
ts: @feedback.created_at,
|
|
77
|
+
id: @feedback.id
|
|
78
|
+
)
|
|
79
|
+
.order(created_at: :desc, id: :desc)
|
|
80
|
+
.select(:id, :status)
|
|
81
|
+
.first
|
|
57
82
|
end
|
|
58
83
|
|
|
59
84
|
def update
|
|
@@ -102,6 +127,41 @@ module ContextDrop
|
|
|
102
127
|
rescue StandardError
|
|
103
128
|
str.to_s.gsub(/[%_\\]/) { |m| "\\#{m}" }
|
|
104
129
|
end
|
|
130
|
+
|
|
131
|
+
def resolve_navigation_shortcuts
|
|
132
|
+
@host_app_path = resolve_host_app_path
|
|
133
|
+
@triage_index_back_path = if respond_to?(:session) && session[:context_drop_dashboard_index_url].present?
|
|
134
|
+
session[:context_drop_dashboard_index_url]
|
|
135
|
+
else
|
|
136
|
+
dashboard_feedbacks_path
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def resolve_host_app_path
|
|
141
|
+
engine_prefix = (request.respond_to?(:script_name) && request.script_name.presence) || "/context_drop"
|
|
142
|
+
if respond_to?(:session) && request&.referer.present?
|
|
143
|
+
begin
|
|
144
|
+
ref_uri = URI.parse(request.referer)
|
|
145
|
+
same_host = ref_uri.host.nil? || (request.respond_to?(:host) && ref_uri.host == request.host)
|
|
146
|
+
if same_host && ref_uri.path.present? && !ref_uri.path.start_with?(engine_prefix)
|
|
147
|
+
full_ref = [ref_uri.path, ref_uri.query].compact.join("?")
|
|
148
|
+
session[:context_drop_return_to] = full_ref
|
|
149
|
+
end
|
|
150
|
+
rescue URI::InvalidURIError
|
|
151
|
+
# Ignore malformed referer headers
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
return session[:context_drop_return_to] if respond_to?(:session) && session[:context_drop_return_to].present?
|
|
156
|
+
|
|
157
|
+
if respond_to?(:main_app) && main_app.respond_to?(:root_path)
|
|
158
|
+
main_app.root_path
|
|
159
|
+
else
|
|
160
|
+
"/"
|
|
161
|
+
end
|
|
162
|
+
rescue StandardError
|
|
163
|
+
"/"
|
|
164
|
+
end
|
|
105
165
|
end
|
|
106
166
|
end
|
|
107
167
|
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "uri"
|
|
4
|
+
|
|
5
|
+
module ContextDrop
|
|
6
|
+
module DashboardHelper
|
|
7
|
+
def url_path_and_host(raw_url)
|
|
8
|
+
return ["/", nil] if raw_url.blank?
|
|
9
|
+
|
|
10
|
+
uri = URI.parse(raw_url.to_s)
|
|
11
|
+
host = uri.host.presence
|
|
12
|
+
path = uri.path.presence || "/"
|
|
13
|
+
query = uri.query.present? ? "?#{uri.query}" : ""
|
|
14
|
+
[path + query, host]
|
|
15
|
+
rescue URI::InvalidURIError
|
|
16
|
+
[raw_url.to_s, nil]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def cd_icon_arrow_left(size: 14)
|
|
20
|
+
%(<svg width="#{size}" height="#{size}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>).html_safe
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def cd_icon_arrow_right(size: 14)
|
|
24
|
+
%(<svg width="#{size}" height="#{size}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>).html_safe
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def cd_icon_search(size: 14)
|
|
28
|
+
%(<svg width="#{size}" height="#{size}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>).html_safe
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def cd_icon_link(size: 14)
|
|
32
|
+
%(<svg width="#{size}" height="#{size}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>).html_safe
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def cd_icon_external_link(size: 13)
|
|
36
|
+
%(<svg width="#{size}" height="#{size}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg>).html_safe
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def cd_icon_pin(size: 13)
|
|
40
|
+
%(<svg width="#{size}" height="#{size}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 2a8 8 0 0 0-8 8c0 5.25 8 12 8 12s8-6.75 8-12a8 8 0 0 0-8-8z"></path><circle cx="12" cy="10" r="3"></circle></svg>).html_safe
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def cd_icon_attachment(size: 13)
|
|
44
|
+
%(<svg width="#{size}" height="#{size}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"></path></svg>).html_safe
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def cd_icon_user(size: 13)
|
|
48
|
+
%(<svg width="#{size}" height="#{size}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path><circle cx="12" cy="7" r="4"></circle></svg>).html_safe
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|