liteagents 2.6.1 → 2.8.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 (64) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/README.md +4 -2
  3. package/installer/cli.js +4 -1
  4. package/package.json +1 -1
  5. package/packages/ampcode/commands/live-canvas/README.md +38 -47
  6. package/packages/{claude/skills/live-canvas/templates/demo → ampcode/commands/live-canvas/dev}/post-variants.html +8 -3
  7. package/packages/ampcode/commands/live-canvas/templates/lab-banner.html +6 -0
  8. package/packages/ampcode/commands/live-canvas/templates/overlay-vanilla.js +64 -6
  9. package/packages/ampcode/commands/live-canvas.md +140 -161
  10. package/packages/ampcode/commands/security.md +50 -12
  11. package/packages/ampcode/commands/ship.md +33 -11
  12. package/packages/claude/commands/git-commit.md +1 -1
  13. package/packages/claude/commands/security.md +50 -12
  14. package/packages/claude/commands/ship.md +33 -11
  15. package/packages/claude/plugins/live-canvas-marketplace/plugins/live-canvas-channel/.claude-plugin/plugin.json +1 -1
  16. package/packages/claude/plugins/live-canvas-marketplace/plugins/live-canvas-channel/README.md +2 -2
  17. package/packages/claude/plugins/live-canvas-marketplace/plugins/live-canvas-channel/package.json +1 -1
  18. package/packages/claude/plugins/live-canvas-marketplace/plugins/live-canvas-channel/schema.json +1 -1
  19. package/packages/claude/plugins/live-canvas-marketplace/plugins/live-canvas-channel/server.js +320 -27
  20. package/packages/claude/plugins/live-canvas-marketplace/setup.sh +83 -24
  21. package/packages/claude/skills/live-canvas/README.md +53 -57
  22. package/packages/claude/skills/live-canvas/SKILL.md +122 -158
  23. package/packages/{ampcode/commands/live-canvas/templates/demo → claude/skills/live-canvas/dev}/post-variants.html +8 -3
  24. package/packages/claude/skills/live-canvas/templates/lab-banner.html +6 -0
  25. package/packages/claude/skills/live-canvas/templates/overlay-vanilla.js +64 -6
  26. package/packages/droid/commands/live-canvas/README.md +38 -47
  27. package/packages/droid/commands/live-canvas/{templates/demo → dev}/post-variants.html +8 -3
  28. package/packages/droid/commands/live-canvas/templates/lab-banner.html +6 -0
  29. package/packages/droid/commands/live-canvas/templates/overlay-vanilla.js +64 -6
  30. package/packages/droid/commands/live-canvas.md +140 -161
  31. package/packages/droid/commands/security.md +50 -12
  32. package/packages/droid/commands/ship.md +33 -11
  33. package/packages/opencode/command/live-canvas/README.md +38 -47
  34. package/packages/opencode/command/live-canvas/{templates/demo → dev}/post-variants.html +8 -3
  35. package/packages/opencode/command/live-canvas/templates/lab-banner.html +6 -0
  36. package/packages/opencode/command/live-canvas/templates/overlay-vanilla.js +64 -6
  37. package/packages/opencode/command/live-canvas.md +140 -161
  38. package/packages/opencode/command/security.md +50 -12
  39. package/packages/opencode/command/ship.md +33 -11
  40. package/packages/ampcode/commands/live-canvas/templates/.claude/settings.local.json +0 -8
  41. package/packages/ampcode/commands/live-canvas/templates/feedback-react/FeedbackOverlay.tsx +0 -1299
  42. package/packages/ampcode/commands/live-canvas/templates/feedback-react/format-utils.ts +0 -283
  43. package/packages/ampcode/commands/live-canvas/templates/feedback-react/index.ts +0 -62
  44. package/packages/ampcode/commands/live-canvas/templates/feedback-react/selector-utils.ts +0 -423
  45. package/packages/ampcode/commands/live-canvas/templates/feedback-react/types.ts +0 -118
  46. package/packages/claude/skills/live-canvas/INTEGRATION_NOTES.md +0 -210
  47. package/packages/claude/skills/live-canvas/templates/.claude/settings.local.json +0 -8
  48. package/packages/claude/skills/live-canvas/templates/feedback-react/FeedbackOverlay.tsx +0 -1299
  49. package/packages/claude/skills/live-canvas/templates/feedback-react/format-utils.ts +0 -283
  50. package/packages/claude/skills/live-canvas/templates/feedback-react/index.ts +0 -62
  51. package/packages/claude/skills/live-canvas/templates/feedback-react/selector-utils.ts +0 -423
  52. package/packages/claude/skills/live-canvas/templates/feedback-react/types.ts +0 -118
  53. package/packages/droid/commands/live-canvas/templates/.claude/settings.local.json +0 -8
  54. package/packages/droid/commands/live-canvas/templates/feedback-react/FeedbackOverlay.tsx +0 -1299
  55. package/packages/droid/commands/live-canvas/templates/feedback-react/format-utils.ts +0 -283
  56. package/packages/droid/commands/live-canvas/templates/feedback-react/index.ts +0 -62
  57. package/packages/droid/commands/live-canvas/templates/feedback-react/selector-utils.ts +0 -423
  58. package/packages/droid/commands/live-canvas/templates/feedback-react/types.ts +0 -118
  59. package/packages/opencode/command/live-canvas/templates/.claude/settings.local.json +0 -8
  60. package/packages/opencode/command/live-canvas/templates/feedback-react/FeedbackOverlay.tsx +0 -1299
  61. package/packages/opencode/command/live-canvas/templates/feedback-react/format-utils.ts +0 -283
  62. package/packages/opencode/command/live-canvas/templates/feedback-react/index.ts +0 -62
  63. package/packages/opencode/command/live-canvas/templates/feedback-react/selector-utils.ts +0 -423
  64. package/packages/opencode/command/live-canvas/templates/feedback-react/types.ts +0 -118
@@ -2,17 +2,39 @@
2
2
  name: ship
3
3
  description: Check pre-deployment
4
4
  usage: /ship
5
- allowed-tools: Bash(npm *), Bash(git *)
5
+ allowed-tools: Read, Grep, Glob, Bash(git *), Bash(npm *), Bash(pnpm *), Bash(yarn *), Bash(pytest *), Bash(python *), Bash(go *), Bash(cargo *), Bash(make *)
6
6
  ---
7
- Pre-deploy checklist:
7
+ Pre-deploy / pre-merge gate. **Detect the stack first** (look for
8
+ `package.json`, `pyproject.toml`/`setup.cfg`, `go.mod`, `Cargo.toml`,
9
+ `Makefile`) and run only the checks that actually exist — never assume a
10
+ script (`lint`, `build`, `migrate`) is present. Report each item as
11
+ **pass / fail / N/A**.
8
12
 
9
- - [ ] Tests pass (`npm test`)
10
- - [ ] Lint clean (`npm run lint`)
11
- - [ ] Build succeeds (`npm run build`)
12
- - [ ] No console.log/debugger statements
13
- - [ ] Env vars documented
14
- - [ ] No hardcoded secrets
15
- - [ ] Error handling complete
16
- - [ ] Migrations ready
13
+ ## Checklist
14
+ - [ ] **Tests pass** — run the project's real test command (`npm test`,
15
+ `pytest`, `go test ./...`, `cargo test`, `make test`).
16
+ - [ ] **Lint / format clean** — only if a linter or formatter is configured.
17
+ - [ ] **Build succeeds** — only if the project has a build step.
18
+ - [ ] **No debug leftovers** — stray `console.log` / `print` / `debugger` /
19
+ `dbg!` / commented-out blocks / blocker `TODO`s in the changed files.
20
+ - [ ] **No hardcoded secrets** — scan the diff. Secrets load from env / a
21
+ secret store; `.env` is gitignored and only a value-less `.env.example`
22
+ is tracked.
23
+ - [ ] **Error handling complete** — every new IO / network / DB call has a
24
+ failure path; nothing fails silently; no internal detail leaks to clients.
25
+ - [ ] **Authorization** — new endpoints/actions check **ownership + role**,
26
+ not just authentication (no IDOR via id-swapping).
27
+ - [ ] **Rate limiting** — new externally reachable routes, including
28
+ authenticated writes, are bounded.
29
+ - [ ] **Data access scoped & scales** — new queries are constrained to the
30
+ requesting principal (no cross-tenant leak) and avoid obvious N+1 /
31
+ unindexed scans on hot paths.
32
+ - [ ] **Migrations ready** — only if the project has a schema / migrations.
33
+ - [ ] **Docs & config in sync** — `.env.example`, README, and any
34
+ threat-model / PRD updated for new config or new attack surface.
35
+ - [ ] **Clean tree, correct branch, in sync with `origin`.**
17
36
 
18
- Run checks and report: Ready 🚀 or Blocked 🛑 with issues.
37
+ For any security-sensitive change in the diff, run **`/security`** on the
38
+ changed files before shipping.
39
+
40
+ Report: **Ready 🚀** or **Blocked 🛑** with the specific failing items.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Click-to-annotate UI design tool for Claude Code. Renders N variants of a component or page in your browser, you click an element and type what to change, and Claude edits the variant file while you watch in the browser. No window switching, no pasted JSON.
4
4
 
5
- Ships as a Claude Code skill plus an MCP channel plugin. Works in every tool liteagents supports (Claude, Droid, Amp, Opencode), but **Live mode only works in Claude Code** — other tools run in Batch mode only (see modes below).
5
+ Ships as a Claude Code skill plus an MCP channel plugin. Works in every tool liteagents supports (Claude, Droid, Amp, Opencode), but **Live mode only works in Claude Code** — other tools run in JSON mode only (see modes below).
6
6
 
7
7
  ---
8
8
 
@@ -11,7 +11,7 @@ Ships as a Claude Code skill plus an MCP channel plugin. Works in every tool lit
11
11
  ```
12
12
  ┌──────────────────────┐ POST /feedback ┌─────────────────────┐
13
13
  │ Overlay in browser │ ─────────────────────────► │ live-canvas-channel │
14
- │ (vanilla JS or React)│ │ (Node MCP server) │
14
+ │ (vanilla JS, ~500 lines)│ │ (Node MCP server) │
15
15
  └──────────────────────┘ └──────────┬──────────┘
16
16
  ▲ │
17
17
  │ dev server hot-reloads the page │ notifications/
@@ -31,28 +31,31 @@ Each Save in the overlay streams into the Claude session as a `<channel>` tag wi
31
31
 
32
32
  ## Modes
33
33
 
34
- The overlay auto-selects at runtime, the user never toggles manually.
34
+ The skill asks you which mode you want every time `/live-canvas` runs.
35
35
 
36
- | Mode | Trigger | What happens per Save |
36
+ | Mode | Use when | What happens per Save |
37
37
  |---|---|---|
38
- | **Live** | Channel server answers `GET /health`, session was started with the dev-channels flag | Comment streams into Claude's context; Claude edits the file; dev server hot-reloads. Toast: "Pushed to Claude ✨". |
39
- | **Batch** | No channel, or running under Droid/Amp/Opencode | Comment stays local. On Finish/Submit it writes JSONL (or downloads the file if no endpoint). User pastes or says "check" in the CLI to have the assistant act on the whole batch. |
38
+ | **Live** | You launched the session with `live-claude` and the channel is up | Comment streams into Claude's context; Claude edits the file; dev server hot-reloads. Toast: "Pushed to Claude ✨". |
39
+ | **JSON** | Any session, any tool (Claude, Droid, Amp, Opencode) | Comment stays local. On Finish/Submit it writes JSONL (or downloads the file if no endpoint). User pastes or says "check" in the CLI to have the assistant act on the whole batch. |
40
40
 
41
- Live mode gracefully degrades to Batch if a push ever fails mid-session.
41
+ If you pick Live but the channel doesn't answer, the skill stops and tells you to relaunch with `live-claude` (or fall back to JSON). It doesn't silently downgrade — the user always gets to choose.
42
42
 
43
43
  ---
44
44
 
45
45
  ## One-time setup (Live mode, Claude Code only)
46
46
 
47
- Run this once per machine. Without it, the skill still works in Batch mode.
47
+ Run this once per machine. Without it, the skill still works in JSON mode.
48
48
 
49
- ### 1. Install plugin npm dependencies
49
+ ### 1. Run the installer
50
50
 
51
51
  ```bash
52
- bash ~/.claude/plugins/live-canvas-marketplace/setup.sh
52
+ bash packages/claude/plugins/live-canvas-marketplace/setup.sh
53
53
  ```
54
54
 
55
- Checks Node >= 18, runs `npm install` inside the plugin dir. Idempotent.
55
+ The installer:
56
+ - copies the marketplace into `~/.claude/plugins/live-canvas-marketplace/` (overwrites any prior install)
57
+ - runs `npm install` inside the channel plugin
58
+ - adds a `live-claude` shell function to `~/.zshrc` and `~/.bashrc` (idempotent — re-runs replace in place)
56
59
 
57
60
  ### 2. Register the marketplace in Claude Code
58
61
 
@@ -66,21 +69,9 @@ Checks Node >= 18, runs `npm install` inside the plugin dir. Idempotent.
66
69
  /plugin install live-canvas-channel@live-canvas-marketplace
67
70
  ```
68
71
 
69
- ### 4. Start Claude Code with the dev-channels flag
72
+ ### 4. Open a fresh shell
70
73
 
71
- ```bash
72
- claude --dangerously-load-development-channels plugin:live-canvas-channel@live-canvas-marketplace
73
- ```
74
-
75
- Accept the safety prompt (custom channels are in research preview and not on the default allowlist).
76
-
77
- **Save yourself typing** — add to `~/.bashrc` or `~/.zshrc`:
78
-
79
- ```bash
80
- alias claude-live='claude --dangerously-load-development-channels plugin:live-canvas-channel@live-canvas-marketplace'
81
- ```
82
-
83
- From now on, `claude-live` to enable Live mode, plain `claude` for everything else.
74
+ `live-claude` is now available. Use plain `claude` for everything else; use `live-claude` when you want Live mode for this skill.
84
75
 
85
76
  ---
86
77
 
@@ -88,7 +79,7 @@ From now on, `claude-live` to enable Live mode, plain `claude` for everything el
88
79
 
89
80
  ### Start a session
90
81
 
91
- Either `claude` (Batch only) or `claude-live` (Live available).
82
+ Either `claude` (JSON only) or `live-claude` (Live available).
92
83
 
93
84
  ### Invoke the skill in a project
94
85
 
@@ -96,13 +87,13 @@ Either `claude` (Batch only) or `claude-live` (Live available).
96
87
  /live-canvas
97
88
  ```
98
89
 
99
- Phase 0 probes the channel and decides what to do:
90
+ Phase 0 always asks which mode you want — Live channel or JSON file — then probes the channel if you picked Live:
100
91
 
101
- | State | Skill behavior |
102
- |---|---|
103
- | Channel responding | Announces Live mode, goes straight into the interview |
104
- | Plugin installed but channel not responding (you forgot the dev flag) | AskUserQuestion: Batch now, or close and restart with the flag? |
105
- | Plugin not installed at all (first run) | AskUserQuestion: set up Live, or just use Batch? Prints the 4-step setup. |
92
+ | Choice | Channel up? | Skill behavior |
93
+ |---|---|---|
94
+ | Live | yes | Announces Live mode, starts the interview |
95
+ | Live | no | Tells you to relaunch with `live-claude` (or fall back to JSON) |
96
+ | JSON | n/a | Announces JSON mode, starts the interview |
106
97
 
107
98
  ### Interview & generation
108
99
 
@@ -113,13 +104,15 @@ Skill asks 5 short questions (scope, pain points, inspiration, persona, constrai
113
104
  Open `http://localhost:<dev-port>/__live_canvas`. Click **Add Feedback** (bottom right), click any element in any variant, type a one-liner, Save.
114
105
 
115
106
  - Live mode: toast says "Pushed to Claude ✨", Claude acknowledges and edits the file, dev server hot-reloads.
116
- - Batch mode: toast says "Saved — submit when ready", pin stays on the element, counter in the Submit button ticks up.
107
+ - JSON mode: toast says "Saved — submit when ready", pin stays on the element, counter in the Submit button ticks up.
108
+
109
+ Need the page back? The overlay has a "−" button next to **Add Feedback** that collapses everything to a small circle in the corner — tap to expand again. Useful on mobile where the bar can cover what's underneath.
117
110
 
118
111
  Keep clicking until a winner emerges.
119
112
 
120
113
  ### Finish
121
114
 
122
- Click the pink **Finish** (Live) or **Submit** (Batch) button:
115
+ Click the pink **Finish** (Live) or **Submit** (JSON) button:
123
116
 
124
117
  1. Type the overall direction: e.g. *"Go with B's layout, A's button styling"*
125
118
  2. Click Finish
@@ -142,12 +135,11 @@ packages/claude/
142
135
  ├── skills/live-canvas/
143
136
  │ ├── SKILL.md # Skill instructions (phases, flow)
144
137
  │ ├── DESIGN_PRINCIPLES.md # UX/a11y/motion reference
145
- │ ├── INTEGRATION_NOTES.md # Design-time notes (channel paths explored)
146
138
  │ ├── README.md # This file
139
+ │ ├── dev/post-variants.html # Standalone demo for local QA of the overlay
147
140
  │ └── templates/
148
- │ ├── overlay-vanilla.js # Framework-agnostic overlay (~400 lines)
149
- ├── feedback-react/ # React overlay for React/Next/Vite projects
150
- │ └── demo/post-variants.html # Standalone demo for testing the overlay
141
+ │ ├── overlay-vanilla.js # Framework-agnostic overlay (~500 lines)
142
+ └── lab-banner.html # "This is a temp lab" notice snippet
151
143
  └── plugins/
152
144
  └── live-canvas-marketplace/
153
145
  ├── .claude-plugin/marketplace.json
@@ -188,9 +180,9 @@ The skill checks the cache dir to tell first-time vs returning users apart.
188
180
  <project-root>/
189
181
  └── .claude-design/
190
182
  ├── lab/variants/VariantA.tsx … VariantE.tsx
191
- ├── lab/FeedbackOverlay.tsx (React) OR overlay-vanilla.js (other)
183
+ ├── overlay-vanilla.js (copied into the project's public/static dir)
192
184
  ├── design-brief.json # Structured output from the interview
193
- └── feedback.jsonl # Batch mode only; deleted on Finish
185
+ └── feedback.jsonl # JSON mode only; deleted on Finish
194
186
  ```
195
187
 
196
188
  Plus a temporary route (e.g. `app/__live_canvas/page.tsx` for Next.js App Router). Everything under `.claude-design/` and the temporary route is deleted on Finish or Abort.
@@ -207,12 +199,11 @@ Plus a temporary route (e.g. `app/__live_canvas/page.tsx` for Next.js App Router
207
199
 
208
200
  ## The install pipeline, end to end
209
201
 
210
- 1. **Liteagents installer** copies files:
202
+ 1. **Liteagents installer** copies the skill:
211
203
  - `packages/claude/skills/live-canvas/` → `~/.claude/skills/live-canvas/`
212
- - `packages/claude/plugins/live-canvas-marketplace/` → `~/.claude/plugins/live-canvas-marketplace/`
213
- 2. **User, once:** runs `bash ~/.claude/plugins/live-canvas-marketplace/setup.sh` → installs the plugin's npm deps
204
+ 2. **User, once:** runs `bash packages/claude/plugins/live-canvas-marketplace/setup.sh`copies marketplace to `~/.claude/plugins/`, runs `npm install`, adds `live-claude` function to `~/.zshrc` and `~/.bashrc`
214
205
  3. **User, once:** in a Claude session, runs `/plugin marketplace add ~/.claude/plugins/live-canvas-marketplace` + `/plugin install live-canvas-channel@live-canvas-marketplace`
215
- 4. **User, every session that wants Live mode:** starts Claude with `--dangerously-load-development-channels plugin:live-canvas-channel@live-canvas-marketplace` (or `claude-live` alias)
206
+ 4. **User, every session that wants Live mode:** runs `live-claude` (function installed by step 2)
216
207
  5. **User, whenever:** `/live-canvas` in any project
217
208
 
218
209
  Steps 1, 2, 3 are truly one-time. Step 4 is per-session. Step 5 is per-project-use.
@@ -221,7 +212,7 @@ Steps 1, 2, 3 are truly one-time. Step 4 is per-session. Step 5 is per-project-u
221
212
 
222
213
  ## Troubleshooting
223
214
 
224
- ### "Listening for channel messages…" appears on session start, but skill still says Batch
215
+ ### Channel server starts but skill still routes to JSON
225
216
 
226
217
  Port 8788 is stuck from an earlier session's server process. Kill it:
227
218
 
@@ -236,13 +227,13 @@ Then `/reload-plugins` in the new session.
236
227
 
237
228
  Three common causes, in order of likelihood:
238
229
 
239
- 1. You didn't start this session with the dev flag. Close it, reopen with `claude-live`.
230
+ 1. You didn't start this session with the dev flag. Close it, reopen with `live-claude`.
240
231
  2. The plugin subprocess died on startup. In the session, run `/mcp` — look for `live-canvas` with its status. "Failed to connect" means a node/dep error: check `~/.claude/debug/<session-id>.txt` for the stderr.
241
232
  3. You never ran step 2 of setup. Re-run `bash ~/.claude/plugins/live-canvas-marketplace/setup.sh`.
242
233
 
243
234
  ### Overlay loads in the browser but no pills appear
244
235
 
245
- The overlay script didn't load. Most common cause: you started the Python server inside the wrong directory so the relative `../overlay-vanilla.js` path couldn't resolve. Start the server one level up and navigate with the `/demo/` prefix.
236
+ The overlay script didn't load. Most common cause: you started the Python server inside the wrong directory so the relative `../templates/overlay-vanilla.js` path couldn't resolve. Start the server one level up and navigate with the `/dev/` prefix.
246
237
 
247
238
  ### "Pushed to Claude ✨" toast appears but nothing happens in the terminal
248
239
 
@@ -79,6 +79,9 @@
79
79
  <header>
80
80
  <h1>Live Canvas — Post card demo</h1>
81
81
  <p>5 variations of a social post (likes, retweets, comments). Click <b>Add Feedback</b> bottom-right → click any element → leave a comment. Right-click the pill to submit.</p>
82
+ <div style="background:#fef3c7;border:1px solid #fbbf24;border-radius:8px;padding:10px 14px;margin-top:12px;font-size:13px;color:#78350f;">
83
+ <b>This is an overlay-only demo.</b> Feedback events transit through the Live channel (or JSON file, with <code>?json=1</code>) so you can verify the UI works — but there are no <code>.claude-design/lab/variants/</code> files behind these cards, so the Claude session receiving events <em>cannot</em> edit anything. For the full lifecycle, run <code>/live-canvas</code> in a real project.
84
+ </div>
82
85
  </header>
83
86
 
84
87
  <main>
@@ -193,12 +196,14 @@
193
196
 
194
197
  </main>
195
198
 
196
- <!-- Overlay (relative path works with file://) -->
197
- <script src="../overlay-vanilla.js"></script>
199
+ <!-- Overlay (served from sibling templates/ dir; works under any static server rooted at the skill dir) -->
200
+ <script src="../templates/overlay-vanilla.js"></script>
198
201
  <script>
202
+ // ?json=1 forces JSON mode (skip channel probe); default tries Live first.
203
+ const forceJson = new URLSearchParams(location.search).has('json');
199
204
  LiveCanvas.init({
200
205
  target: 'PostCard',
201
- channelUrl: 'http://localhost:8788',
206
+ ...(forceJson ? {} : { channelUrl: 'http://localhost:8788' }),
202
207
  });
203
208
  </script>
204
209
  </body>
@@ -0,0 +1,6 @@
1
+ <div role="note" style="background:#fefce8;border:1px solid #facc15;border-radius:8px;padding:10px 14px;margin:12px 0;font-size:13px;line-height:1.5;color:#854d0e;">
2
+ <b>This is a temporary design lab.</b> Click any element → leave a comment → Save.
3
+ Your feedback goes to Claude; the lab is deleted on Finish. The overlay
4
+ badge (bottom-right) tells you whether feedback is streaming live or being
5
+ collected as JSON.
6
+ </div>
@@ -23,7 +23,7 @@
23
23
  * Batch — saves accumulate locally; Submit All POSTs JSONL to batchEndpoint
24
24
  * (or downloads the file if no endpoint configured)
25
25
  *
26
- * Payload schema: v1.0, compatible with the upstream React FeedbackOverlay.
26
+ * Payload schema: v1.0 (see live-canvas-channel/schema.json).
27
27
  */
28
28
  (function () {
29
29
  'use strict';
@@ -38,11 +38,16 @@
38
38
  batchEndpoint: null,
39
39
  active: false,
40
40
  picking: false,
41
+ minimized: false, // collapsed to a single bubble?
41
42
  comments: [], // Comment[] — only items pending batch submit
42
43
  overall: '',
43
44
  pinCounts: Object.create(null), // `${variant}|${selector}` → placed-pin count
44
45
  };
45
46
 
47
+ // Persist collapse state across hot reloads / variant switches.
48
+ const MIN_KEY = 'lc-minimized';
49
+ try { state.minimized = sessionStorage.getItem(MIN_KEY) === '1'; } catch (_) {}
50
+
46
51
  // ---------- utilities ----------
47
52
 
48
53
  const uid = () => `c-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
@@ -134,7 +139,8 @@
134
139
  const css = `
135
140
  [${DATA_OVERLAY}] { font-family: system-ui, sans-serif; box-sizing: border-box; }
136
141
  .${PFX}-bar { position: fixed; right: 16px; bottom: 16px; z-index: 2147483646;
137
- display: flex; gap: 8px; }
142
+ display: flex; gap: 8px; align-items: center; }
143
+ .${PFX}-bar[data-hidden='1'] { display: none; }
138
144
  .${PFX}-btn { border: 0; border-radius: 999px; padding: 10px 16px;
139
145
  font-weight: 600; font-size: 13px; cursor: pointer;
140
146
  box-shadow: 0 4px 12px rgba(0,0,0,.25); font-family: inherit; }
@@ -146,9 +152,22 @@
146
152
  .${PFX}-submit .${PFX}-count { display: inline-block; background: #d946ef; color: #fff;
147
153
  border-radius: 999px; min-width: 18px; padding: 0 6px; margin-left: 6px;
148
154
  font-size: 11px; line-height: 18px; text-align: center; }
155
+ .${PFX}-min { width: 32px; height: 32px; padding: 0; border-radius: 50%;
156
+ background: #fff; color: #111; border: 1px solid #e4e4e7; font-size: 16px;
157
+ line-height: 1; display: flex; align-items: center; justify-content: center; }
158
+ .${PFX}-bubble { position: fixed; right: 16px; bottom: 16px; z-index: 2147483646;
159
+ width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
160
+ background: #111; color: #fff; font-size: 14px; font-weight: 700;
161
+ box-shadow: 0 4px 12px rgba(0,0,0,.25); display: none; }
162
+ .${PFX}-bubble[data-show='1'] { display: flex; align-items: center; justify-content: center; }
149
163
  .${PFX}-mode { position: fixed; right: 16px; bottom: 60px; z-index: 2147483646;
150
164
  background: rgba(0,0,0,.75); color: #fff; font-size: 11px;
151
165
  padding: 4px 8px; border-radius: 4px; pointer-events: none; }
166
+ .${PFX}-mode[data-hidden='1'] { display: none; }
167
+ @media (max-width: 640px) {
168
+ .${PFX}-popup { left: 8px !important; right: 8px; width: auto !important; max-width: none; }
169
+ .${PFX}-submit-card { width: 100% !important; max-width: calc(100vw - 24px); }
170
+ }
152
171
  .${PFX}-picking { cursor: crosshair !important; }
153
172
  .${PFX}-hover-outline { outline: 2px solid #d946ef !important; outline-offset: 2px; }
154
173
  .${PFX}-pin { position: absolute; z-index: 2147483645; width: 24px; height: 24px;
@@ -235,9 +254,33 @@
235
254
 
236
255
  // ---------- UI ----------
237
256
 
238
- let toggleBtn, submitBtn, modeBadge, toast, popupNode;
257
+ let toggleBtn, submitBtn, minBtn, bubbleBtn, barNode, modeBadge, toast, popupNode;
239
258
  let hoverEl = null;
240
259
 
260
+ const applyMinimized = () => {
261
+ if (!barNode) return;
262
+ barNode.setAttribute('data-hidden', state.minimized ? '1' : '0');
263
+ modeBadge.setAttribute('data-hidden', state.minimized ? '1' : '0');
264
+ bubbleBtn.setAttribute('data-show', state.minimized ? '1' : '0');
265
+ // state.mode can flip live → batch mid-session if a push fails; refresh
266
+ // the badge each time we re-show it so it doesn't lie.
267
+ if (!state.minimized) {
268
+ modeBadge.textContent = `${state.mode === 'live' ? 'LIVE' : 'JSON'} mode`;
269
+ }
270
+ // Cancel an active pick when collapsing — otherwise clicks land on the page.
271
+ if (state.minimized && state.picking) {
272
+ state.picking = false;
273
+ setPickingCursor(false);
274
+ clearHover();
275
+ toggleBtn.setAttribute('data-active', '0');
276
+ toggleBtn.textContent = 'Add Feedback';
277
+ }
278
+ closePopup();
279
+ try { sessionStorage.setItem(MIN_KEY, state.minimized ? '1' : '0'); } catch (_) {}
280
+ };
281
+
282
+ const setMinimized = (v) => { state.minimized = !!v; applyMinimized(); };
283
+
241
284
  const pendingCount = () => state.comments.filter(c => !c.delivered).length;
242
285
 
243
286
  const refreshSubmitBtn = () => {
@@ -442,14 +485,29 @@
442
485
  submitBtn = el('button', { class: `${PFX}-btn ${PFX}-submit`, on: {
443
486
  click: openSubmitModal,
444
487
  }});
488
+ minBtn = el('button', {
489
+ class: `${PFX}-btn ${PFX}-min`,
490
+ title: 'Hide overlay',
491
+ 'aria-label': 'Hide overlay',
492
+ on: { click: () => setMinimized(true) },
493
+ }, '−');
445
494
  refreshSubmitBtn();
446
- const bar = el('div', { class: `${PFX}-bar` }, [submitBtn, toggleBtn]);
447
- modeBadge = el('div', { class: `${PFX}-mode` }, `${state.mode === 'live' ? 'LIVE' : 'BATCH'} mode`);
495
+ barNode = el('div', { class: `${PFX}-bar` }, [minBtn, submitBtn, toggleBtn]);
496
+ bubbleBtn = el('button', {
497
+ class: `${PFX}-bubble`,
498
+ title: 'Show feedback overlay',
499
+ 'aria-label': 'Show feedback overlay',
500
+ on: { click: () => setMinimized(false) },
501
+ }, '◐');
502
+ modeBadge = el('div', { class: `${PFX}-mode` }, `${state.mode === 'live' ? 'LIVE' : 'JSON'} mode`);
448
503
  toast = el('div', { class: `${PFX}-toast` });
449
- document.body.appendChild(bar);
504
+ document.body.appendChild(barNode);
505
+ document.body.appendChild(bubbleBtn);
450
506
  document.body.appendChild(modeBadge);
451
507
  document.body.appendChild(toast);
452
508
 
509
+ applyMinimized();
510
+
453
511
  document.addEventListener('mousemove', onMouseMove, true);
454
512
  document.addEventListener('click', onClick, true);
455
513
  };