@mushi-mushi/web 1.19.0 → 1.19.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CONTRIBUTING.md CHANGED
@@ -27,12 +27,24 @@ pnpm build
27
27
 
28
28
  ```bash
29
29
  pnpm dev # Start all dev servers (admin on :6464)
30
+ ```
31
+
32
+ | Surface | URL |
33
+ | --- | --- |
34
+ | Admin console | http://localhost:6464 |
35
+ | Docs site | http://localhost:3000 |
36
+ | CLI console override | `MUSHI_CONSOLE_URL=http://localhost:6464` |
37
+
38
+ ```bash
30
39
  pnpm test # Run Vitest across all packages
31
40
  pnpm typecheck # TypeScript checks
32
41
  pnpm lint # ESLint
33
42
  pnpm format # Prettier
43
+ pnpm smoke:cli-setup # Playwright: onboarding ?setup=cli + success panel (skips headless if unsigned)
34
44
  ```
35
45
 
46
+ Set `CLI_SETUP_SMOKE_STRICT=1` to fail the smoke script when Playwright is not signed in (CI gate).
47
+
36
48
  Ad-hoc screenshots captured during UI reviews can live temporarily at the repo
37
49
  root, but root-level `*.png` files are intentionally ignored. Canonical
38
50
  screenshots that should be versioned belong under `docs/screenshots/`.
package/README.md CHANGED
@@ -30,6 +30,7 @@ Browser SDK for Mushi Mushi — embeddable bug reporting widget with Shadow DOM
30
30
  - **Repro timeline** (0.10+) — auto-captures route changes, clicks, and SDK lifecycle into a normalised `MushiReport.timeline`; pair with `Mushi.setScreen({ name, route, feature })` for screen-level grouping in the admin
31
31
  - **Session replay** (1.11+) — opt-in `capture.replay: 'rrweb' | 'lite' | 'sentry' | 'off'` records a rolling buffer that attaches to the report on submit. rrweb masks all text and inputs by default, records continuously from init, and trims while preserving the most recent full snapshot so replays stay playable. Default `'off'`
32
32
  - **Screenshot annotation** (1.11+) — a "Mark up" button in the panel opens an interactive overlay (highlight / blur / arrow) so reporters can circle the problem and redact sensitive regions before submitting
33
+ - **Screenshot preview & consent** (1.19+) — the details step renders the attached screenshot as a visible `<img>` preview (not just a checkmark label) with a **Remove** control and a configurable privacy caption (`widget.screenshotSensitiveHint`: `true` = localized default, `string` = custom copy, `false` = hide caption). Preview stays in sync through the annotate flow. See [`docs/SDK_SCREENSHOT_PREVIEW.md`](../../docs/SDK_SCREENSHOT_PREVIEW.md)
33
34
  - **Payload size guard** (1.11+) — reports are size-checked client-side; oversized payloads are progressively degraded (drop replay buffer → drop screenshot) and dropped with a `report:failed` event if still too large, so a single large report can never wedge the offline queue
34
35
  - **Two-way replies** (0.11+) — the panel ships a "Your reports" view that polls comments authored by the dev team and lets the reporter reply, all signed with HMAC against the public API key (no auth user required)
35
36
  - **Passive inventory discovery** (0.12+) — opt-in `capture.discoverInventory` ships throttled, PII-free observations (route template, page title, `[data-testid]` values, recent fetch paths, query-param **keys** only, sha256 of user/session id) to `POST /v1/sdk/discovery`. The Mushi server aggregates them into a 30-day `discovery_observed_inventory` view and Claude Sonnet drafts a first-pass `inventory.yaml` proposal you can accept on `/inventory ▸ Discovery`. See `MushiDiscoverInventoryConfig` in [`@mushi-mushi/core`](../core)
package/dist/index.cjs CHANGED
@@ -2022,7 +2022,13 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
2022
2022
  .mushi-account-info strong{font:700 14px/1.3 inherit;color:${ink}}
2023
2023
  .mushi-account-rank,.mushi-xapp-app-name,.mushi-label{font-size:12px;color:${inkDim};font-family:${fontMono}}
2024
2024
  .mushi-account-rank{display:block}
2025
- .mushi-xapp-app-name{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.06em;margin:0 0 6px}
2025
+ .mushi-xapp-app-head{display:flex;align-items:center;gap:8px;margin:0 0 6px}
2026
+ .mushi-xapp-app-name{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.06em;margin:0}
2027
+ .mushi-app-icon{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;border-radius:6px;border:1px solid ${isDark ? "rgba(255,255,255,0.12)" : "rgba(0,0,0,0.1)"};background:#fff;overflow:hidden;flex-shrink:0}
2028
+ .mushi-app-icon-img{display:block;width:16px;height:16px;object-fit:contain}
2029
+ .mushi-app-icon-initials{font-size:9px;font-weight:700;color:${inkDim};line-height:1}
2030
+ .mushi-app-icon-initials-only{background:${isDark ? "rgba(255,255,255,0.06)" : "rgba(0,0,0,0.04)"}}
2031
+ .mushi-header-host-icon{display:block;width:20px;height:20px;border-radius:4px;object-fit:contain}
2026
2032
  .mushi-xapp-group{margin-bottom:14px}
2027
2033
  .mushi-label{display:block;font-weight:600;margin-bottom:6px}
2028
2034
 
@@ -2051,9 +2057,7 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
2051
2057
 
2052
2058
  // src/version.ts
2053
2059
  var MUSHI_SDK_PACKAGE = "@mushi-mushi/web";
2054
- var MUSHI_SDK_VERSION = "1.19.0" ;
2055
-
2056
- // src/widget-helpers.ts
2060
+ var MUSHI_SDK_VERSION = "1.19.2" ;
2057
2061
  var CATEGORY_ICONS = {
2058
2062
  bug: "\u26A0\uFE0F",
2059
2063
  slow: "\u{1F40C}",
@@ -2173,6 +2177,56 @@ function isSubmitShortcut(e) {
2173
2177
  function escapeHtml(value) {
2174
2178
  return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
2175
2179
  }
2180
+ function renderAppIconHtml(opts) {
2181
+ const domain = opts.appDomain ?? core.resolveProjectDomain({
2182
+ project_id: opts.projectId,
2183
+ project_name: opts.appName,
2184
+ project_slug: opts.appSlug ?? ""
2185
+ });
2186
+ const initials = escapeHtml(core.projectInitials(opts.appName));
2187
+ const candidates = core.projectFaviconUrlCandidates({
2188
+ project_id: opts.projectId,
2189
+ project_name: opts.appName,
2190
+ project_slug: opts.appSlug ?? "",
2191
+ sdk_origin: opts.appDomain ? `https://${opts.appDomain}` : null
2192
+ });
2193
+ if (!candidates.length) {
2194
+ return `<span class="mushi-app-icon mushi-app-icon-initials-only" aria-hidden="true">${initials}</span>`;
2195
+ }
2196
+ const encoded = escapeHtml(JSON.stringify(candidates));
2197
+ return `<span class="mushi-app-icon" data-mushi-favicon data-candidates="${encoded}" data-initials="${initials}" aria-hidden="true" title="${escapeHtml(domain ?? opts.appName)}">
2198
+ <img class="mushi-app-icon-img" src="${escapeHtml(candidates[0])}" alt="" referrerpolicy="no-referrer" width="16" height="16" />
2199
+ <span class="mushi-app-icon-initials" hidden>${initials}</span>
2200
+ </span>`;
2201
+ }
2202
+ function bindFaviconFallbacks(root) {
2203
+ root.querySelectorAll("[data-mushi-favicon]").forEach((wrap) => {
2204
+ const img = wrap.querySelector(".mushi-app-icon-img");
2205
+ const fallback = wrap.querySelector(".mushi-app-icon-initials");
2206
+ if (!img || !fallback) return;
2207
+ let candidates = [];
2208
+ try {
2209
+ candidates = JSON.parse(wrap.dataset.candidates ?? "[]");
2210
+ } catch {
2211
+ candidates = [];
2212
+ }
2213
+ let index = 0;
2214
+ const tryNext = () => {
2215
+ index += 1;
2216
+ if (index < candidates.length) {
2217
+ img.src = candidates[index];
2218
+ } else {
2219
+ img.remove();
2220
+ fallback.hidden = false;
2221
+ wrap.classList.add("mushi-app-icon-initials-only");
2222
+ }
2223
+ };
2224
+ img.onerror = tryNext;
2225
+ img.onload = () => {
2226
+ if (core.isLikelyGenericFavicon(img)) tryNext();
2227
+ };
2228
+ });
2229
+ }
2176
2230
 
2177
2231
  // src/widget-render.ts
2178
2232
  function renderStep(ctx) {
@@ -2258,7 +2312,7 @@ function renderHeader(ctx, opts) {
2258
2312
  const counterHtml = step ? `<span class="mushi-step-counter" aria-label="Step ${step} of ${TOTAL_STEPS}"><b>${pad2(step)}</b> / ${pad2(TOTAL_STEPS)}</span>` : "";
2259
2313
  return `
2260
2314
  <div class="mushi-header">
2261
- <div class="mushi-header-mark" aria-hidden="true">\u866B</div>
2315
+ <div class="mushi-header-mark" aria-hidden="true">${ctx.pageFaviconHref ? `<img class="mushi-header-host-icon" src="${escapeHtml(ctx.pageFaviconHref)}" alt="" referrerpolicy="no-referrer" width="20" height="20" />` : "\u866B"}</div>
2262
2316
  <div class="mushi-header-titles">
2263
2317
  ${eyebrowHtml}
2264
2318
  <h3>${title}</h3>
@@ -2564,24 +2618,42 @@ function renderCrossAppReportsStep(ctx) {
2564
2618
  const grouped = /* @__PURE__ */ new Map();
2565
2619
  for (const r of reports) {
2566
2620
  const key = r.project_id ?? "unknown";
2567
- if (!grouped.has(key)) grouped.set(key, { name: r.app_name ?? "Unknown App", reports: [] });
2621
+ if (!grouped.has(key)) {
2622
+ grouped.set(key, {
2623
+ name: r.app_name ?? "Unknown App",
2624
+ slug: r.app_slug ?? null,
2625
+ domain: r.app_domain ?? null,
2626
+ reports: []
2627
+ });
2628
+ }
2568
2629
  grouped.get(key).reports.push(r);
2569
2630
  }
2570
- const rows = [...grouped.entries()].map(([, group]) => `
2631
+ const rows = [...grouped.entries()].map(([projectId, group]) => {
2632
+ const icon = renderAppIconHtml({
2633
+ projectId,
2634
+ appName: group.name,
2635
+ appSlug: group.slug,
2636
+ appDomain: group.domain
2637
+ });
2638
+ return `
2571
2639
  <div class="mushi-xapp-group">
2572
- <h4 class="mushi-xapp-app-name">${escapeHtml(group.name)}</h4>
2640
+ <div class="mushi-xapp-app-head">
2641
+ ${icon}
2642
+ <h4 class="mushi-xapp-app-name">${escapeHtml(group.name)}</h4>
2643
+ </div>
2573
2644
  ${group.reports.map((r) => {
2574
- const tone = reporterStatusTone(r.status);
2575
- return `
2645
+ const tone = reporterStatusTone(r.status);
2646
+ return `
2576
2647
  <div class="mushi-report-row" data-report-id="${escapeHtml(r.id)}" tabindex="0" role="button">
2577
2648
  <span class="mushi-report-status mushi-status-${tone}">${escapeHtml(reporterStatusShort(r.status))}</span>
2578
2649
  <span class="mushi-report-title">${escapeHtml(r.title ?? r.category)}</span>
2579
2650
  <span class="mushi-report-when">${escapeHtml(formatRelativeTime(r.created_at))}</span>
2580
2651
  </div>
2581
2652
  `;
2582
- }).join("")}
2653
+ }).join("")}
2583
2654
  </div>
2584
- `).join("");
2655
+ `;
2656
+ }).join("");
2585
2657
  return `
2586
2658
  ${renderHeader(ctx, { title: "My reports", showBack: true, eyebrow: "Mushi \xB7 All apps" })}
2587
2659
  <div class="mushi-body">
@@ -4185,11 +4257,13 @@ var MushiWidget = class _MushiWidget {
4185
4257
  assistantTurns: this.assistantTurns,
4186
4258
  assistantSending: this.assistantSending,
4187
4259
  assistantError: this.assistantError,
4188
- showAllCategories: this.showAllCategories
4260
+ showAllCategories: this.showAllCategories,
4261
+ pageFaviconHref: core.readPageFaviconHref()
4189
4262
  };
4190
4263
  }
4191
4264
  attachHandlers(panel) {
4192
4265
  const t = this.locale;
4266
+ bindFaviconFallbacks(panel);
4193
4267
  panel.querySelector('[data-action="close"]')?.addEventListener("click", () => this.close());
4194
4268
  panel.querySelector('[data-action="back"]')?.addEventListener("click", () => {
4195
4269
  if (this.step === "intent") {
@@ -4787,8 +4861,6 @@ function setConsentGranted(projectId, granted) {
4787
4861
  localStorage.removeItem(getConsentKey(projectId));
4788
4862
  }
4789
4863
  optedIn = granted;
4790
- apiClient?.submitActivity(currentUserId ?? "", [], { optedIn: granted }).catch(() => {
4791
- });
4792
4864
  } catch {
4793
4865
  }
4794
4866
  }