@gengage/assistant-fe 0.6.49 → 0.6.50

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.
@@ -86,6 +86,22 @@ export declare class GengageChat extends BaseWidget<ChatWidgetConfig> {
86
86
  private _pdpLaunched;
87
87
  private _plpLaunched;
88
88
  private _homepageLaunched;
89
+ /**
90
+ * True ONLY when this widget actually restored a non-empty thread that now owns the
91
+ * surface. When set, the generic page-context auto-launch (homepage/PLP greeting) is
92
+ * suppressed so the restored thread — and its in-flight continuation — are not
93
+ * clobbered by a "Merhaba!" welcome. See R1 (yataş store-finder nav clobber).
94
+ *
95
+ * INVARIANT (regression #1 fix): this flag is tied to ACTUAL restored on-screen
96
+ * content, never to mere restore-KEY presence. If a restore no-ops (stale/missing
97
+ * session, cross-SKU guard, IDB absent, empty thread, rejected freshness token) the
98
+ * flag stays/returns false so the NORMAL greeting/auto-launch fires — the surface is
99
+ * never left blank.
100
+ */
101
+ private _restorePending;
102
+ /** One-shot gate for an assistant-driven soft navigation update in the same document. */
103
+ private _assistantSoftNavigationPending;
104
+ private _assistantSoftNavigationTimer;
89
105
  private _entryContextPrimed;
90
106
  /** True while a silent context-prime launch (PDP/PLP/homepage) is in flight. */
91
107
  private _contextPrimingInFlight;
@@ -177,6 +193,42 @@ export declare class GengageChat extends BaseWidget<ChatWidgetConfig> {
177
193
  }): void;
178
194
  close(): void;
179
195
  saveSession(sessionId: string, sku: string): void;
196
+ /**
197
+ * Set the restore handoff marker for an assistant-driven PAGE navigation that has
198
+ * no associated product (R1, e.g. the store-finder redirect). Mirrors saveSession()
199
+ * but without a SKU — the destination is not a PDP, so there is nothing to gate the
200
+ * restore on. The restore session id alone tells the re-mounted widget "the chat
201
+ * navigated you here; restore the thread and continue, do not auto-launch a greeting".
202
+ *
203
+ * Only stamps the marker when there is a real session id to restore; otherwise it is
204
+ * a no-op (a user/site navigation should stay a fresh session).
205
+ */
206
+ saveSessionForNavigation(): void;
207
+ /** Read the persisted same-document nav sequence (0 when absent/corrupt). */
208
+ private _readNavSeq;
209
+ /**
210
+ * Stamp the freshness token onto the current restore marker: bump the nav seq and
211
+ * record it (with a timestamp) so the immediately-following mount can recognize this
212
+ * marker as fresh. Best-effort — non-fatal if sessionStorage is unavailable.
213
+ */
214
+ private _stampRestoreFreshnessToken;
215
+ /**
216
+ * True when the current restore marker was produced by the immediately-preceding
217
+ * navigation (its token's seq matches the current nav seq). A stale/stranded marker
218
+ * — or one with no/corrupt token (e.g. an empty-SKU saveSession) — is NOT fresh.
219
+ */
220
+ private _isRestoreMarkerFresh;
221
+ /**
222
+ * Clear the restore marker and its freshness token in one place — the single
223
+ * guaranteed-consume point so a marker never strands. Called on mount (onInit, after
224
+ * the freshness decision) and on any state reset (_resetForNewPage / soft-nav).
225
+ * Leaves gengage_nav_seq intact: it is the monotonic clock, not part of the marker.
226
+ */
227
+ private _clearRestoreMarker;
228
+ private _markAssistantSoftNavigationPending;
229
+ private _clearAssistantSoftNavigationPending;
230
+ private _expireAssistantSoftNavigationIfUnclaimed;
231
+ private _scheduleAssistantSoftNavigationExpiry;
180
232
  get isOpen(): boolean;
181
233
  /**
182
234
  * Register a callback for integration events (e.g. 'gengage-cart-add', 'gengage-product-favorite').
@@ -339,11 +391,29 @@ export declare class GengageChat extends BaseWidget<ChatWidgetConfig> {
339
391
  private _hasUnavailableProductContext;
340
392
  private _ensureAssistantMessageRendered;
341
393
  private _saveSessionAndOpenURL;
394
+ /**
395
+ * Assistant-driven page navigation (R1): persist the thread, stamp the restore
396
+ * handoff marker, then navigate. On the SPA re-mount the widget restores the thread
397
+ * and continues its flow — the homepage/PLP auto-launch greeting is suppressed
398
+ * (see _restorePending / _primeOpenPageContext) so the assistant's answer is not
399
+ * clobbered by a generic welcome. Same-origin only; cross-origin/new-tab callers
400
+ * keep the raw navigation since the current page (and its thread) is not replaced.
401
+ *
402
+ * The restore-key stamp is the durable "the chat initiated this navigation" marker
403
+ * across the navigation boundary — we distinguish assistant-vs-user navigation by
404
+ * WHO called this (an assistant action handler), never by inspecting the URL.
405
+ */
406
+ private _navigateAssistantDriven;
342
407
  private _loadPayload;
343
408
  /**
344
409
  * Attempt to restore chat session from IndexedDB.
345
- * Always restores when IDB has session data for the current sessionId.
410
+ * Restores when IDB has non-empty session data for the current sessionId AND an
411
+ * explicit handoff is pending.
346
412
  * Best-effort — failures are silently ignored.
413
+ *
414
+ * @returns true ONLY when a non-empty thread was actually replayed onto the surface.
415
+ * Every no-op/early-return path returns false so the caller leaves the normal
416
+ * greeting/auto-launch enabled (regression #1: never suppress launch over nothing).
347
417
  */
348
418
  private _restoreFromIndexedDB;
349
419
  /**
@@ -1,4 +1,4 @@
1
- import { c as e, d as t, f as r, i as s, l as n, n as i, r as l, s as C, t as c, u as d } from "./runtime-COLQGOkl.js";
1
+ import { c as e, d as t, f as r, i as s, l as n, n as i, r as l, s as C, t as c, u as d } from "./runtime-9f9SB4WE.js";
2
2
  export {
3
3
  d as CHAT_SCROLL_ELEMENT_ID,
4
4
  s as ChatPresentationState,