@mushi-mushi/web 1.22.3 → 1.22.5

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/dist/index.d.cts CHANGED
@@ -146,10 +146,32 @@ declare class MushiWidget {
146
146
  private screenshotCapturing;
147
147
  private screenshotError;
148
148
  private allowScreenshotRemove;
149
+ /**
150
+ * Whether the screenshot / element-select tools are actually usable
151
+ * (capture module present + not disabled by config). Unavailable tools are
152
+ * hidden from the details step — a rendered button whose handler silently
153
+ * no-ops reads as a bug to the reporter.
154
+ */
155
+ private screenshotAvailable;
156
+ private elementAvailable;
157
+ /**
158
+ * In-progress form input preserved across full shadow-DOM re-renders.
159
+ * render() rebuilds the panel with `innerHTML = ''`, which used to destroy
160
+ * whatever the reporter had typed whenever a background refresh (60s inbox
161
+ * poll, visibilitychange refetch, screenshot attach) fired mid-typing.
162
+ * Captured from the live DOM right before teardown, replayed right after.
163
+ */
164
+ private draftDescription;
165
+ private draftEmail;
166
+ private draftReply;
167
+ private draftFocus;
168
+ private draftSelStart;
169
+ private draftSelEnd;
149
170
  /** Data URL of the attached screenshot, rendered as a visible preview. */
150
171
  private screenshotPreview;
151
172
  private elementSelected;
152
173
  private elementCapturing;
174
+ private elementError;
153
175
  private submitting;
154
176
  /** Hint element injected outside the shadow DOM during element selection. */
155
177
  private selectorHint;
@@ -278,7 +300,14 @@ declare class MushiWidget {
278
300
  */
279
301
  private resolveScreenshotHint;
280
302
  setAllowScreenshotRemove(allow: boolean): void;
303
+ /** Show/hide the attachment tools based on what the SDK can actually do. */
304
+ setCaptureAvailability(availability: {
305
+ screenshot?: boolean;
306
+ element?: boolean;
307
+ }): void;
281
308
  setElementSelected(selected: boolean): void;
309
+ /** Surface a failed/cancelled element-selection attempt (mirrors setScreenshotError). */
310
+ setElementError(failed: boolean): void;
282
311
  setScreenshotCapturing(capturing: boolean): void;
283
312
  setScreenshotError(failed: boolean): void;
284
313
  setElementCapturing(capturing: boolean): void;
@@ -367,6 +396,11 @@ declare class MushiWidget {
367
396
  private detectEnvironment;
368
397
  private isRouteHidden;
369
398
  private getTheme;
399
+ /** Snapshot in-progress form input from the live DOM before teardown. */
400
+ private captureFormDrafts;
401
+ /** Replay captured drafts (value + focus + caret) into a freshly built panel. */
402
+ private restoreFormDrafts;
403
+ private clearFormDrafts;
370
404
  private render;
371
405
  /**
372
406
  * Queries each `avoidSelectors` element in the host document and returns
@@ -423,6 +457,8 @@ declare class MushiWidget {
423
457
  private submitReporterReopen;
424
458
  /** Refresh My Reports data for unread badges without opening the inbox panel. */
425
459
  refreshReporterInboxQuiet(): Promise<void>;
460
+ /** Patch the "Your reports (N new)" nav label in place, if it is rendered. */
461
+ private updateReportsBadgeText;
426
462
  private loadReporterReports;
427
463
  private loadReporterComments;
428
464
  private submitReporterFeedback;
package/dist/index.d.ts CHANGED
@@ -146,10 +146,32 @@ declare class MushiWidget {
146
146
  private screenshotCapturing;
147
147
  private screenshotError;
148
148
  private allowScreenshotRemove;
149
+ /**
150
+ * Whether the screenshot / element-select tools are actually usable
151
+ * (capture module present + not disabled by config). Unavailable tools are
152
+ * hidden from the details step — a rendered button whose handler silently
153
+ * no-ops reads as a bug to the reporter.
154
+ */
155
+ private screenshotAvailable;
156
+ private elementAvailable;
157
+ /**
158
+ * In-progress form input preserved across full shadow-DOM re-renders.
159
+ * render() rebuilds the panel with `innerHTML = ''`, which used to destroy
160
+ * whatever the reporter had typed whenever a background refresh (60s inbox
161
+ * poll, visibilitychange refetch, screenshot attach) fired mid-typing.
162
+ * Captured from the live DOM right before teardown, replayed right after.
163
+ */
164
+ private draftDescription;
165
+ private draftEmail;
166
+ private draftReply;
167
+ private draftFocus;
168
+ private draftSelStart;
169
+ private draftSelEnd;
149
170
  /** Data URL of the attached screenshot, rendered as a visible preview. */
150
171
  private screenshotPreview;
151
172
  private elementSelected;
152
173
  private elementCapturing;
174
+ private elementError;
153
175
  private submitting;
154
176
  /** Hint element injected outside the shadow DOM during element selection. */
155
177
  private selectorHint;
@@ -278,7 +300,14 @@ declare class MushiWidget {
278
300
  */
279
301
  private resolveScreenshotHint;
280
302
  setAllowScreenshotRemove(allow: boolean): void;
303
+ /** Show/hide the attachment tools based on what the SDK can actually do. */
304
+ setCaptureAvailability(availability: {
305
+ screenshot?: boolean;
306
+ element?: boolean;
307
+ }): void;
281
308
  setElementSelected(selected: boolean): void;
309
+ /** Surface a failed/cancelled element-selection attempt (mirrors setScreenshotError). */
310
+ setElementError(failed: boolean): void;
282
311
  setScreenshotCapturing(capturing: boolean): void;
283
312
  setScreenshotError(failed: boolean): void;
284
313
  setElementCapturing(capturing: boolean): void;
@@ -367,6 +396,11 @@ declare class MushiWidget {
367
396
  private detectEnvironment;
368
397
  private isRouteHidden;
369
398
  private getTheme;
399
+ /** Snapshot in-progress form input from the live DOM before teardown. */
400
+ private captureFormDrafts;
401
+ /** Replay captured drafts (value + focus + caret) into a freshly built panel. */
402
+ private restoreFormDrafts;
403
+ private clearFormDrafts;
370
404
  private render;
371
405
  /**
372
406
  * Queries each `avoidSelectors` element in the host document and returns
@@ -423,6 +457,8 @@ declare class MushiWidget {
423
457
  private submitReporterReopen;
424
458
  /** Refresh My Reports data for unread badges without opening the inbox panel. */
425
459
  refreshReporterInboxQuiet(): Promise<void>;
460
+ /** Patch the "Your reports (N new)" nav label in place, if it is rendered. */
461
+ private updateReportsBadgeText;
426
462
  private loadReporterReports;
427
463
  private loadReporterComments;
428
464
  private submitReporterFeedback;
package/dist/index.js CHANGED
@@ -99,6 +99,7 @@ var en = {
99
99
  elementButton: "Select Element",
100
100
  elementSelected: "Element selected \u2713",
101
101
  elementCapturing: "Click anything on the page\u2026",
102
+ elementFailed: "Couldn't select \u2014 describe it instead",
102
103
  elementSelectorHint: "Click any element \xB7 Esc to cancel",
103
104
  optional: "(optional)",
104
105
  tooShort: "A bit more detail helps us fix it faster",
@@ -267,6 +268,7 @@ var ja = {
267
268
  elementButton: "\u8981\u7D20\u3092\u9078\u629E",
268
269
  elementSelected: "\u8981\u7D20\u9078\u629E\u6E08\u307F \u2713",
269
270
  elementCapturing: "\u30DA\u30FC\u30B8\u4E0A\u306E\u8981\u7D20\u3092\u30AF\u30EA\u30C3\u30AF\u2026",
271
+ elementFailed: "\u9078\u629E\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F \u2014 \u6587\u5B57\u3067\u6559\u3048\u3066\u304F\u3060\u3055\u3044",
270
272
  elementSelectorHint: "\u8981\u7D20\u3092\u30AF\u30EA\u30C3\u30AF \xB7 Esc \u3067\u30AD\u30E3\u30F3\u30BB\u30EB",
271
273
  optional: "\uFF08\u4EFB\u610F\uFF09",
272
274
  tooShort: "\u3082\u3046\u5C11\u3057\u8A73\u3057\u304F\u6559\u3048\u3066\u304F\u3060\u3055\u3044",
@@ -435,6 +437,7 @@ var th = {
435
437
  elementButton: "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E2D\u0E07\u0E04\u0E4C\u0E1B\u0E23\u0E30\u0E01\u0E2D\u0E1A",
436
438
  elementSelected: "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E2D\u0E07\u0E04\u0E4C\u0E1B\u0E23\u0E30\u0E01\u0E2D\u0E1A\u0E41\u0E25\u0E49\u0E27 \u2713",
437
439
  elementCapturing: "\u0E04\u0E25\u0E34\u0E01\u0E2D\u0E07\u0E04\u0E4C\u0E1B\u0E23\u0E30\u0E01\u0E2D\u0E1A\u0E1A\u0E19\u0E2B\u0E19\u0E49\u0E32\u2026",
440
+ elementFailed: "\u0E44\u0E21\u0E48\u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E44\u0E14\u0E49 \u2014 \u0E42\u0E1B\u0E23\u0E14\u0E2D\u0E18\u0E34\u0E1A\u0E32\u0E22\u0E41\u0E17\u0E19",
438
441
  elementSelectorHint: "\u0E04\u0E25\u0E34\u0E01\u0E2D\u0E07\u0E04\u0E4C\u0E1B\u0E23\u0E30\u0E01\u0E2D\u0E1A\u0E43\u0E14\u0E01\u0E47\u0E44\u0E14\u0E49 \xB7 Esc \u0E40\u0E1E\u0E37\u0E48\u0E2D\u0E22\u0E01\u0E40\u0E25\u0E34\u0E01",
439
442
  optional: "(\u0E44\u0E21\u0E48\u0E1A\u0E31\u0E07\u0E04\u0E31\u0E1A)",
440
443
  tooShort: "\u0E01\u0E23\u0E38\u0E13\u0E32\u0E43\u0E2B\u0E49\u0E23\u0E32\u0E22\u0E25\u0E30\u0E40\u0E2D\u0E35\u0E22\u0E14\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E40\u0E15\u0E34\u0E21",
@@ -603,6 +606,7 @@ var es = {
603
606
  elementButton: "Seleccionar elemento",
604
607
  elementSelected: "Elemento seleccionado \u2713",
605
608
  elementCapturing: "Haz clic en cualquier elemento\u2026",
609
+ elementFailed: "No se pudo seleccionar \u2014 descr\xEDbelo en su lugar",
606
610
  elementSelectorHint: "Clic en cualquier elemento \xB7 Esc para cancelar",
607
611
  optional: "(opcional)",
608
612
  tooShort: "Un poco m\xE1s de detalle nos ayuda a resolverlo",
@@ -2551,7 +2555,7 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
2551
2555
 
2552
2556
  // src/version.ts
2553
2557
  var MUSHI_SDK_PACKAGE = "@mushi-mushi/web";
2554
- var MUSHI_SDK_VERSION = "1.22.3" ;
2558
+ var MUSHI_SDK_VERSION = "1.22.5" ;
2555
2559
  var CATEGORY_ICONS = {
2556
2560
  bug: "\u26A0\uFE0F",
2557
2561
  slow: "\u{1F40C}",
@@ -3280,10 +3284,11 @@ function renderDetailsStep(ctx) {
3280
3284
  ctx.screenshotError ? "error" : "",
3281
3285
  ctx.screenshotCapturing ? "loading" : ""
3282
3286
  ].filter(Boolean).join(" ");
3283
- const elementLabel = ctx.elementCapturing ? t.step3.elementCapturing : ctx.elementSelected ? t.step3.elementSelected : t.step3.elementButton;
3287
+ const elementLabel = ctx.elementCapturing ? t.step3.elementCapturing : ctx.elementError ? t.step3.elementFailed : ctx.elementSelected ? t.step3.elementSelected : t.step3.elementButton;
3284
3288
  const elementClass = [
3285
3289
  "mushi-attach-btn",
3286
3290
  ctx.elementSelected ? "active" : "",
3291
+ ctx.elementError ? "error" : "",
3287
3292
  ctx.elementCapturing ? "loading" : ""
3288
3293
  ].filter(Boolean).join(" ");
3289
3294
  const exampleChips = t.step3.examplePrompts.map((p) => `<button type="button" class="mushi-example-chip" data-example="${escapeHtml(p)}">${escapeHtml(p)}</button>`).join("");
@@ -3304,24 +3309,24 @@ function renderDetailsStep(ctx) {
3304
3309
  </div>
3305
3310
  </div>
3306
3311
  <div class="mushi-attachments">
3307
- <button type="button" class="${screenshotClass}"
3312
+ ${ctx.screenshotAvailable ? `<button type="button" class="${screenshotClass}"
3308
3313
  data-action="screenshot"
3309
3314
  ${ctx.screenshotCapturing ? "disabled" : ""}
3310
3315
  aria-label="${escapeHtml(screenshotLabel)}"
3311
3316
  >
3312
3317
  ${ctx.screenshotCapturing ? '<span class="mushi-spinner" aria-hidden="true"></span>' : "\u{1F4F8}"}
3313
3318
  ${escapeHtml(screenshotLabel)}
3314
- </button>
3319
+ </button>` : ""}
3315
3320
  ${ctx.screenshotAttached && ctx.allowScreenshotRemove ? '<button type="button" class="mushi-attach-btn danger" data-action="remove-screenshot" aria-label="Remove screenshot">\u2715 Remove</button>' : ""}
3316
3321
  ${ctx.screenshotAttached ? '<button type="button" class="mushi-attach-btn" data-action="annotate-screenshot" aria-label="Mark up screenshot">\u270F Mark up</button><div class="mushi-annotate-host" data-role="annotate-host"></div>' : ""}
3317
- <button type="button" class="${elementClass}"
3322
+ ${ctx.elementAvailable ? `<button type="button" class="${elementClass}"
3318
3323
  data-action="element"
3319
3324
  ${ctx.elementCapturing ? "disabled" : ""}
3320
3325
  aria-label="${escapeHtml(elementLabel)}"
3321
3326
  >
3322
3327
  ${ctx.elementCapturing ? '<span class="mushi-spinner" aria-hidden="true"></span>' : "\u{1F3AF}"}
3323
3328
  ${escapeHtml(elementLabel)}
3324
- </button>
3329
+ </button>` : ""}
3325
3330
  </div>
3326
3331
  ${ctx.screenshotAttached && ctx.screenshotPreview ? `<figure class="mushi-screenshot-preview">
3327
3332
  <img src="${escapeHtml(ctx.screenshotPreview)}" alt="${escapeHtml(t.step3.screenshotPreviewAlt)}" />
@@ -3568,10 +3573,32 @@ var MushiWidget = class _MushiWidget {
3568
3573
  screenshotCapturing = false;
3569
3574
  screenshotError = false;
3570
3575
  allowScreenshotRemove = true;
3576
+ /**
3577
+ * Whether the screenshot / element-select tools are actually usable
3578
+ * (capture module present + not disabled by config). Unavailable tools are
3579
+ * hidden from the details step — a rendered button whose handler silently
3580
+ * no-ops reads as a bug to the reporter.
3581
+ */
3582
+ screenshotAvailable = true;
3583
+ elementAvailable = true;
3584
+ /**
3585
+ * In-progress form input preserved across full shadow-DOM re-renders.
3586
+ * render() rebuilds the panel with `innerHTML = ''`, which used to destroy
3587
+ * whatever the reporter had typed whenever a background refresh (60s inbox
3588
+ * poll, visibilitychange refetch, screenshot attach) fired mid-typing.
3589
+ * Captured from the live DOM right before teardown, replayed right after.
3590
+ */
3591
+ draftDescription = "";
3592
+ draftEmail = "";
3593
+ draftReply = "";
3594
+ draftFocus = null;
3595
+ draftSelStart = 0;
3596
+ draftSelEnd = 0;
3571
3597
  /** Data URL of the attached screenshot, rendered as a visible preview. */
3572
3598
  screenshotPreview = null;
3573
3599
  elementSelected = false;
3574
3600
  elementCapturing = false;
3601
+ elementError = false;
3575
3602
  submitting = false;
3576
3603
  /** Hint element injected outside the shadow DOM during element selection. */
3577
3604
  selectorHint = null;
@@ -3754,12 +3781,14 @@ var MushiWidget = class _MushiWidget {
3754
3781
  this.screenshotPreview = null;
3755
3782
  this.elementSelected = false;
3756
3783
  this.elementCapturing = false;
3784
+ this.elementError = false;
3757
3785
  this.submitting = false;
3758
3786
  this.submittedAt = null;
3759
3787
  this.removeSelectorHint();
3760
3788
  this.lastReportId = null;
3761
3789
  this.lastSubmitQueuedOffline = false;
3762
3790
  this.viaFeatureRequest = false;
3791
+ this.clearFormDrafts();
3763
3792
  if (options?.featureRequest) {
3764
3793
  this.selectedCategory = "other";
3765
3794
  this.selectedIntent = FEATURE_REQUEST_INTENT;
@@ -3891,6 +3920,8 @@ var MushiWidget = class _MushiWidget {
3891
3920
  }
3892
3921
  setScreenshotAttached(attached) {
3893
3922
  this.screenshotAttached = attached;
3923
+ this.screenshotCapturing = false;
3924
+ if (attached) this.screenshotError = false;
3894
3925
  if (!attached) this.screenshotPreview = null;
3895
3926
  if (this.isOpen) this.render();
3896
3927
  }
@@ -3915,9 +3946,26 @@ var MushiWidget = class _MushiWidget {
3915
3946
  this.allowScreenshotRemove = allow;
3916
3947
  if (this.isOpen) this.render();
3917
3948
  }
3949
+ /** Show/hide the attachment tools based on what the SDK can actually do. */
3950
+ setCaptureAvailability(availability) {
3951
+ const nextScreenshot = availability.screenshot ?? this.screenshotAvailable;
3952
+ const nextElement = availability.element ?? this.elementAvailable;
3953
+ if (nextScreenshot === this.screenshotAvailable && nextElement === this.elementAvailable) return;
3954
+ this.screenshotAvailable = nextScreenshot;
3955
+ this.elementAvailable = nextElement;
3956
+ if (this.isOpen) this.render();
3957
+ }
3918
3958
  setElementSelected(selected) {
3919
3959
  this.elementSelected = selected;
3920
3960
  this.elementCapturing = false;
3961
+ if (selected) this.elementError = false;
3962
+ this.removeSelectorHint();
3963
+ if (this.isOpen) this.render();
3964
+ }
3965
+ /** Surface a failed/cancelled element-selection attempt (mirrors setScreenshotError). */
3966
+ setElementError(failed) {
3967
+ this.elementError = failed;
3968
+ this.elementCapturing = false;
3921
3969
  this.removeSelectorHint();
3922
3970
  if (this.isOpen) this.render();
3923
3971
  }
@@ -3934,6 +3982,7 @@ var MushiWidget = class _MushiWidget {
3934
3982
  setElementCapturing(capturing) {
3935
3983
  this.elementCapturing = capturing;
3936
3984
  if (capturing) {
3985
+ this.elementError = false;
3937
3986
  this.showSelectorHint();
3938
3987
  } else {
3939
3988
  this.removeSelectorHint();
@@ -4410,10 +4459,70 @@ var MushiWidget = class _MushiWidget {
4410
4459
  }
4411
4460
  return "light";
4412
4461
  }
4462
+ /** Snapshot in-progress form input from the live DOM before teardown. */
4463
+ captureFormDrafts() {
4464
+ const desc = this.shadow.querySelector(
4465
+ 'textarea.mushi-textarea:not([data-role="reporter-reply"])'
4466
+ );
4467
+ const email = this.shadow.querySelector('[data-role="magic-link-email"]');
4468
+ const reply = this.shadow.querySelector(
4469
+ 'textarea[data-role="reporter-reply"]'
4470
+ );
4471
+ if (desc) this.draftDescription = desc.value;
4472
+ if (email) this.draftEmail = email.value;
4473
+ if (reply) this.draftReply = reply.value;
4474
+ const active = this.shadow.activeElement;
4475
+ this.draftFocus = active && active === desc ? "description" : active && active === email ? "email" : active && active === reply ? "reply" : null;
4476
+ if (this.draftFocus && active) {
4477
+ const el = active;
4478
+ this.draftSelStart = el.selectionStart ?? el.value.length;
4479
+ this.draftSelEnd = el.selectionEnd ?? el.value.length;
4480
+ }
4481
+ }
4482
+ /** Replay captured drafts (value + focus + caret) into a freshly built panel. */
4483
+ restoreFormDrafts(panel) {
4484
+ const fields = [
4485
+ {
4486
+ selector: 'textarea.mushi-textarea:not([data-role="reporter-reply"])',
4487
+ value: this.draftDescription,
4488
+ key: "description"
4489
+ },
4490
+ { selector: '[data-role="magic-link-email"]', value: this.draftEmail, key: "email" },
4491
+ { selector: 'textarea[data-role="reporter-reply"]', value: this.draftReply, key: "reply" }
4492
+ ];
4493
+ for (const field of fields) {
4494
+ const el = panel.querySelector(field.selector);
4495
+ if (!el) continue;
4496
+ if (field.value && el.value !== field.value) {
4497
+ el.value = field.value;
4498
+ el.dispatchEvent(new Event("input"));
4499
+ }
4500
+ if (this.draftFocus === field.key) {
4501
+ const applyFocus = () => {
4502
+ el.focus();
4503
+ try {
4504
+ el.setSelectionRange(this.draftSelStart, this.draftSelEnd);
4505
+ } catch {
4506
+ }
4507
+ };
4508
+ if (typeof requestAnimationFrame === "function") requestAnimationFrame(applyFocus);
4509
+ else applyFocus();
4510
+ }
4511
+ }
4512
+ }
4513
+ clearFormDrafts() {
4514
+ this.draftDescription = "";
4515
+ this.draftEmail = "";
4516
+ this.draftReply = "";
4517
+ this.draftFocus = null;
4518
+ this.draftSelStart = 0;
4519
+ this.draftSelEnd = 0;
4520
+ }
4413
4521
  render() {
4414
4522
  const theme = this.getTheme();
4415
4523
  const pos = this.config.position;
4416
4524
  const t = this.locale;
4525
+ if (this.isOpen) this.captureFormDrafts();
4417
4526
  this.bannerResizeObserver?.disconnect();
4418
4527
  this.bannerResizeObserver = null;
4419
4528
  this.shadow.innerHTML = "";
@@ -4491,6 +4600,7 @@ var MushiWidget = class _MushiWidget {
4491
4600
  this.shadow.appendChild(panel);
4492
4601
  this.attachHandlers(panel);
4493
4602
  this.trapFocus(panel);
4603
+ this.restoreFormDrafts(panel);
4494
4604
  this.attachViewportHandlers(panel);
4495
4605
  } else {
4496
4606
  this.teardownViewportHandlers();
@@ -4781,6 +4891,8 @@ var MushiWidget = class _MushiWidget {
4781
4891
  screenshotAttached: this.screenshotAttached,
4782
4892
  screenshotPreview: this.screenshotPreview,
4783
4893
  screenshotHint: this.resolveScreenshotHint(),
4894
+ screenshotAvailable: this.screenshotAvailable,
4895
+ elementAvailable: this.elementAvailable,
4784
4896
  reporterError: this.reporterError,
4785
4897
  magicLinkError: this.magicLinkError,
4786
4898
  elementCapturing: this.elementCapturing,
@@ -4793,6 +4905,7 @@ var MushiWidget = class _MushiWidget {
4793
4905
  globalLeaderboardLoading: this.globalLeaderboardLoading,
4794
4906
  globalLeaderboard: this.globalLeaderboard,
4795
4907
  elementSelected: this.elementSelected,
4908
+ elementError: this.elementError,
4796
4909
  crossAppLoading: this.crossAppLoading,
4797
4910
  callbacks: this.callbacks,
4798
4911
  testerJwt: this.testerJwt,
@@ -5115,6 +5228,7 @@ var MushiWidget = class _MushiWidget {
5115
5228
  this.submitting = false;
5116
5229
  this.step = "success";
5117
5230
  this.render();
5231
+ this.draftDescription = "";
5118
5232
  void outcomeP.then((outcome) => {
5119
5233
  if (this.step !== "success") return;
5120
5234
  if (outcome) {
@@ -5210,10 +5324,23 @@ var MushiWidget = class _MushiWidget {
5210
5324
  async refreshReporterInboxQuiet() {
5211
5325
  try {
5212
5326
  this.reporterReports = await this.callbacks.onReporterReportsRequest?.() ?? [];
5213
- if (this.isOpen) this.render();
5327
+ if (!this.isOpen) return;
5328
+ if (this.step === "reports") {
5329
+ this.render();
5330
+ } else {
5331
+ this.updateReportsBadgeText();
5332
+ }
5214
5333
  } catch {
5215
5334
  }
5216
5335
  }
5336
+ /** Patch the "Your reports (N new)" nav label in place, if it is rendered. */
5337
+ updateReportsBadgeText() {
5338
+ const label = this.shadow.querySelector(".mushi-reports-entry .mushi-option-label");
5339
+ if (!label) return;
5340
+ const mn = this.locale.step1.moreNav;
5341
+ const unread = this.unreadCount();
5342
+ label.textContent = unread ? `${mn.yourReports} (${unread} ${mn.unreadNew})` : mn.yourReports;
5343
+ }
5217
5344
  async loadReporterReports() {
5218
5345
  this.step = "reports";
5219
5346
  this.reporterLoading = true;
@@ -5229,6 +5356,9 @@ var MushiWidget = class _MushiWidget {
5229
5356
  }
5230
5357
  }
5231
5358
  async loadReporterComments(reportId) {
5359
+ if (this.selectedReportId !== reportId) {
5360
+ this.draftReply = "";
5361
+ }
5232
5362
  this.selectedReportId = reportId;
5233
5363
  this.step = "report-detail";
5234
5364
  this.reporterLoading = true;
@@ -5270,6 +5400,7 @@ var MushiWidget = class _MushiWidget {
5270
5400
  try {
5271
5401
  await this.callbacks.onReporterReply?.(reportId, body);
5272
5402
  if (textarea) textarea.value = "";
5403
+ this.draftReply = "";
5273
5404
  await this.loadReporterComments(reportId);
5274
5405
  } catch (err) {
5275
5406
  this.reporterError = err instanceof Error ? err.message : "Could not send reply.";
@@ -5375,6 +5506,64 @@ var MushiWidget = class _MushiWidget {
5375
5506
  }
5376
5507
  };
5377
5508
 
5509
+ // src/runtime-merge.ts
5510
+ function mergeRuntimeCapture(host, runtime) {
5511
+ const merged = { ...host };
5512
+ if (runtime) {
5513
+ for (const [key, value] of Object.entries(runtime)) {
5514
+ if (value !== void 0) merged[key] = value;
5515
+ }
5516
+ }
5517
+ return merged;
5518
+ }
5519
+ function mergeRuntimeConfig(config, runtime) {
5520
+ const nativeTrigger = runtime.native?.triggerMode;
5521
+ const runtimeLauncher = runtime.widget?.launcher;
5522
+ const hostTrigger = config.widget?.trigger;
5523
+ const rawRuntimeTrigger = runtimeLauncher ?? runtime.widget?.trigger;
5524
+ const runtimeTrigger = rawRuntimeTrigger === "auto" && hostTrigger && hostTrigger !== "auto" ? void 0 : rawRuntimeTrigger;
5525
+ const widgetTrigger = runtimeTrigger ?? (nativeTrigger === "none" || nativeTrigger === "shake" ? "manual" : void 0);
5526
+ const explicitHidden = runtimeLauncher === "hidden" || runtime.widget?.trigger === "hidden";
5527
+ const safeWidgetTrigger = widgetTrigger === "hidden" && !explicitHidden && hostTrigger && hostTrigger !== "hidden" ? hostTrigger : widgetTrigger;
5528
+ const runtimeWidget = runtime.widget;
5529
+ const runtimeBannerVariant = runtimeWidget?.bannerVariant;
5530
+ const runtimeBannerPosition = runtimeWidget?.bannerPosition;
5531
+ const runtimeBannerMessage = runtimeWidget?.bannerMessage;
5532
+ const runtimeBannerLabel = runtimeWidget?.bannerLabel;
5533
+ const runtimeBannerBugCta = runtimeWidget?.bannerBugCta;
5534
+ const runtimeBannerFeatureCta = runtimeWidget?.bannerFeatureCta;
5535
+ const derivedBannerConfig = runtimeBannerVariant || runtimeBannerPosition || runtimeBannerMessage != null || runtimeBannerLabel != null || runtimeBannerBugCta != null || runtimeBannerFeatureCta != null ? {
5536
+ ...config.widget?.bannerConfig ?? {},
5537
+ ...runtimeBannerVariant ? { variant: runtimeBannerVariant } : {},
5538
+ ...runtimeBannerPosition ? { position: runtimeBannerPosition } : {},
5539
+ ...runtimeBannerMessage != null ? { message: runtimeBannerMessage } : {},
5540
+ ...runtimeBannerLabel != null ? { label: runtimeBannerLabel === "" ? false : runtimeBannerLabel } : {},
5541
+ ...runtimeBannerBugCta != null ? { bugCta: runtimeBannerBugCta ?? void 0 } : {},
5542
+ ...runtimeBannerFeatureCta != null ? { featureCta: runtimeBannerFeatureCta } : {}
5543
+ } : void 0;
5544
+ const definedRuntimeWidget = {};
5545
+ if (runtime.widget) {
5546
+ for (const [key, value] of Object.entries(runtime.widget)) {
5547
+ if (key === "trigger" || key === "launcher") continue;
5548
+ if (value !== void 0 && value !== null) definedRuntimeWidget[key] = value;
5549
+ }
5550
+ }
5551
+ return {
5552
+ ...config,
5553
+ widget: {
5554
+ ...config.widget,
5555
+ ...definedRuntimeWidget,
5556
+ ...safeWidgetTrigger ? { trigger: safeWidgetTrigger } : {},
5557
+ ...derivedBannerConfig ? { bannerConfig: derivedBannerConfig } : {},
5558
+ ...config.widget?.betaMode ? { betaMode: config.widget.betaMode } : {}
5559
+ },
5560
+ capture: mergeRuntimeCapture(config.capture, runtime.capture),
5561
+ privacy: {
5562
+ ...config.privacy
5563
+ }
5564
+ };
5565
+ }
5566
+
5378
5567
  // src/marketing-recorder.ts
5379
5568
  function centerOf(el) {
5380
5569
  if (!el) return null;
@@ -5719,7 +5908,6 @@ function installActivityListeners(projectId) {
5719
5908
  };
5720
5909
  historyUnsub = subscribeHistory({
5721
5910
  onPush: emitRoute,
5722
- onReplace: emitRoute,
5723
5911
  onPop: emitRoute
5724
5912
  });
5725
5913
  emitRoute();
@@ -7670,7 +7858,12 @@ function createInstance(config) {
7670
7858
  perfCap = null;
7671
7859
  }
7672
7860
  if (activeConfig.capture?.screenshot !== "off") {
7673
- const screenshotOptions = { privacy: activeConfig.privacy };
7861
+ const screenshotOptions = {
7862
+ privacy: activeConfig.privacy,
7863
+ // Surface capture failures (canvas taint, CSP) in the widget UI —
7864
+ // an invisible failure looks identical to a broken button.
7865
+ onFailed: () => widget.setScreenshotError(true)
7866
+ };
7674
7867
  if (activeConfig.capture?.screenshotProvider) {
7675
7868
  screenshotCap = null;
7676
7869
  } else if (screenshotCap) {
@@ -7690,6 +7883,10 @@ function createInstance(config) {
7690
7883
  elementSelector = null;
7691
7884
  pendingElement = null;
7692
7885
  }
7886
+ widget.setCaptureAvailability({
7887
+ screenshot: (!!screenshotCap || !!activeConfig.capture?.screenshotProvider) && activeConfig.capture?.screenshot !== "off",
7888
+ element: !!elementSelector
7889
+ });
7693
7890
  const discoveryRaw = activeConfig.capture?.discoverInventory;
7694
7891
  const discoveryConfig = discoveryRaw === true ? {} : discoveryRaw && typeof discoveryRaw === "object" ? discoveryRaw : null;
7695
7892
  const discoveryEnabled = discoveryConfig != null && discoveryConfig.enabled !== false;
@@ -7894,11 +8091,24 @@ function createInstance(config) {
7894
8091
  },
7895
8092
  onScreenshotRequest: async () => {
7896
8093
  const hasCapture = !!screenshotCap || !!activeConfig.capture?.screenshotProvider;
7897
- if (!hasCapture || activeConfig.capture?.screenshot === "off") return;
8094
+ if (!hasCapture || activeConfig.capture?.screenshot === "off") {
8095
+ log.warn("Screenshot requested but capture is disabled");
8096
+ widget.setScreenshotError(true);
8097
+ return;
8098
+ }
7898
8099
  log.debug("Taking screenshot");
7899
- pendingScreenshot = await takeScreenshotWithoutChrome();
8100
+ widget.setScreenshotCapturing(true);
8101
+ try {
8102
+ pendingScreenshot = await takeScreenshotWithoutChrome();
8103
+ } catch (err) {
8104
+ log.warn("Screenshot capture threw", {
8105
+ error: err instanceof Error ? err.message : String(err)
8106
+ });
8107
+ pendingScreenshot = null;
8108
+ }
7900
8109
  widget.setScreenshotAttached(pendingScreenshot !== null);
7901
8110
  widget.setScreenshotPreview(pendingScreenshot);
8111
+ if (pendingScreenshot === null) widget.setScreenshotError(true);
7902
8112
  },
7903
8113
  onScreenshotRemove: () => {
7904
8114
  log.debug("Screenshot attachment removed");
@@ -7956,7 +8166,11 @@ function createInstance(config) {
7956
8166
  container.insertBefore(toolbar, container.firstChild);
7957
8167
  },
7958
8168
  onElementSelectorRequest: async () => {
7959
- if (!elementSelector || activeConfig.capture?.elementSelector === false) return;
8169
+ if (!elementSelector || activeConfig.capture?.elementSelector === false) {
8170
+ log.warn("Element selector requested but it is disabled/unavailable");
8171
+ widget.setElementError(true);
8172
+ return;
8173
+ }
7960
8174
  log.debug("Element selector activated");
7961
8175
  widget.setElementCapturing(true);
7962
8176
  widget.hidePanel();
@@ -7969,6 +8183,11 @@ function createInstance(config) {
7969
8183
  } else {
7970
8184
  widget.setElementCapturing(false);
7971
8185
  }
8186
+ } catch (err) {
8187
+ log.warn("Element selector threw", {
8188
+ error: err instanceof Error ? err.message : String(err)
8189
+ });
8190
+ widget.setElementError(true);
7972
8191
  } finally {
7973
8192
  widget.showPanel();
7974
8193
  }
@@ -8847,51 +9066,6 @@ function createInstance(config) {
8847
9066
  });
8848
9067
  return isolatePublicApi(sdk);
8849
9068
  }
8850
- function mergeRuntimeConfig(config, runtime) {
8851
- const nativeTrigger = runtime.native?.triggerMode;
8852
- const runtimeLauncher = runtime.widget?.launcher;
8853
- const widgetTrigger = runtimeLauncher ?? runtime.widget?.trigger ?? (nativeTrigger === "none" || nativeTrigger === "shake" ? "manual" : void 0);
8854
- const explicitHidden = runtimeLauncher === "hidden" || runtime.widget?.trigger === "hidden";
8855
- const hostTrigger = config.widget?.trigger;
8856
- const safeWidgetTrigger = widgetTrigger === "hidden" && !explicitHidden && hostTrigger && hostTrigger !== "hidden" ? hostTrigger : widgetTrigger;
8857
- const runtimeWidget = runtime.widget;
8858
- const runtimeBannerVariant = runtimeWidget?.bannerVariant;
8859
- const runtimeBannerPosition = runtimeWidget?.bannerPosition;
8860
- const runtimeBannerMessage = runtimeWidget?.bannerMessage;
8861
- const runtimeBannerLabel = runtimeWidget?.bannerLabel;
8862
- const runtimeBannerBugCta = runtimeWidget?.bannerBugCta;
8863
- const runtimeBannerFeatureCta = runtimeWidget?.bannerFeatureCta;
8864
- const derivedBannerConfig = runtimeBannerVariant || runtimeBannerPosition || runtimeBannerMessage != null || runtimeBannerLabel != null || runtimeBannerBugCta != null || runtimeBannerFeatureCta != null ? {
8865
- ...config.widget?.bannerConfig ?? {},
8866
- ...runtimeBannerVariant ? { variant: runtimeBannerVariant } : {},
8867
- ...runtimeBannerPosition ? { position: runtimeBannerPosition } : {},
8868
- ...runtimeBannerMessage != null ? { message: runtimeBannerMessage } : {},
8869
- // Dashboard sends an empty string to hide the pill (the runtime
8870
- // payload has no way to express the local-config `label: false`).
8871
- ...runtimeBannerLabel != null ? { label: runtimeBannerLabel === "" ? false : runtimeBannerLabel } : {},
8872
- ...runtimeBannerBugCta != null ? { bugCta: runtimeBannerBugCta ?? void 0 } : {},
8873
- ...runtimeBannerFeatureCta != null ? { featureCta: runtimeBannerFeatureCta } : {}
8874
- } : void 0;
8875
- return {
8876
- ...config,
8877
- widget: {
8878
- ...config.widget,
8879
- ...runtime.widget,
8880
- ...safeWidgetTrigger ? { trigger: safeWidgetTrigger } : {},
8881
- ...derivedBannerConfig ? { bannerConfig: derivedBannerConfig } : {},
8882
- // betaMode is local-only: set by the host app, not the dashboard.
8883
- // Restore it after the runtime spread so it is never silently cleared.
8884
- ...config.widget?.betaMode ? { betaMode: config.widget.betaMode } : {}
8885
- },
8886
- capture: {
8887
- ...config.capture,
8888
- ...runtime.capture
8889
- },
8890
- privacy: {
8891
- ...config.privacy
8892
- }
8893
- };
8894
- }
8895
9069
  function applyPresetConfig(config) {
8896
9070
  if (!config.preset) return config;
8897
9071
  const preset = presetDefaults(config.preset);