Followups#506
Conversation
- Replace checkPostPurchasePage with generic followups engine (TOF/FOT, browser/tab scope, ttl + cnt budget) - followups.ts: arm from token-bound followups, decrement cnt per in-scope navigation, repost fires to /check/popup - handleTabEvents wires processNavigation in parallel with validateAndInject (fire-and-forget) - handleContentMessages: pass followups through ACTIVATE payload - iframe frontend: forward followups to SDK on activation
…n removal - handlePopupResponse: single entry point for /check/popup responses (normal validate-and-inject path and followup-fire path) - Inline-search dual-flow gated by isInlineSearch param (undefined = followup fire) - processNavigation returns full response; caller interprets isValid/verifiedMatch/followups uniformly - New removeQuietDomain util + top-level removeQuietDomain response field (string | string[]) so backend can clear quiet entries; runs before add/inject to allow single-response replace
- followups.ts: drop FollowupId enum, accept any string id
- ctl.type narrowed to 't' | 'f'; MatchEntry { match, type } shape
- matchTrigger uses searchRegexArray (reverse-host compressed regex)
- armFollowups dedupes by (id, meta, tabId): re-arm replaces, not duplicates
- validateDomain: centralized applyQuietDomainsUpdate (replaces stored list
when quietDomainsChanged===true; normalizes numeric time to [now,now+time])
- handleTabEvents: chain-arm followups returned by fire-response
- Delete removeQuietDomain.ts (replaced by quietDomains v2 protocol)
There was a problem hiding this comment.
Pull request overview
This PR introduces a “followups” mechanism that’s passed from the iframe UI through the content script to the extension background, and adds a background followups engine that can react to navigations and re-query /check/popup when followups fire. It also changes the SDK’s API base path (affecting all API calls) and removes the legacy post-purchase URL checker.
Changes:
- Plumbs
followupsthrough iframe loader data → UIACTIVATEmessages → content script → background activation handling. - Adds a background followups scheduler/state machine persisted in extension storage and wired into tab navigation events.
- Updates API base path and adds server-driven quiet-domain sync in
validateDomain; removespostPurchaseUrlscaching and deletes the old post-purchase checker.
Reviewed changes
Copilot reviewed 13 out of 15 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| iframe-frontend/src/types.d.ts | Adds followups to loader/message typings used by iframe UI. |
| iframe-frontend/src/templates/b/OneStep/OneStep.tsx | Includes followups when sending ACTIVATE message. |
| iframe-frontend/src/pages/Offerbar/Offerbar.tsx | Includes followups when sending ACTIVATE message. |
| iframe-frontend/src/pages/Framed/Framed.tsx | Includes followups when sending ACTIVATE message. |
| iframe-frontend/src/components/Offer/Offer.tsx | Includes followups when sending ACTIVATE message. |
| extension-files/bringweb3-sdk/utils/contentScript/handleIframeMessages.ts | Forwards followups from iframe → background on ACTIVATE. |
| extension-files/bringweb3-sdk/utils/background/updateCache.ts | Removes post-purchase URL caching from domain cache updates. |
| extension-files/bringweb3-sdk/utils/background/handleTabEvents.ts | Wires followups engine into navigation flow; refactors popup injection logic. |
| extension-files/bringweb3-sdk/utils/background/handleContentMessages.ts | Passes followups into activation handler. |
| extension-files/bringweb3-sdk/utils/background/followups.ts | New followups engine: persist, arm, decrement on navigations, fire via validateDomain. |
| extension-files/bringweb3-sdk/utils/background/checkPostPurchasePage.ts | Deletes legacy post-purchase page checker. |
| extension-files/bringweb3-sdk/utils/background/activate.ts | Arms followups during activation. |
| extension-files/bringweb3-sdk/utils/apiEndpoint.ts | Changes API base path used by all requests. |
| extension-files/bringweb3-sdk/utils/api/validateDomain.ts | Adds server-driven quiet-domains sync + supports followups payload. |
| extension-files/bringweb3-sdk/types.d.ts | Adds followups to SDK event typing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
# Conflicts: # extension-files/bringweb3-sdk/utils/background/handleTabEvents.ts
kalfada
left a comment
There was a problem hiding this comment.
Overall the code is structured really good and the implementation is great. I liked the idea of serializing the ops of followups - really make sense
- Move applyQuietDomainsUpdate out of API layer → background util; gate on quietDomainsChanged at call sites - validateDomain: pure API passthrough, drop storage import - handleContentMessages: generic armFollowups trigger at listener level (activate/close/optout); remove from activate.ts - OneStep.tsx: revert followups change (Ready platform, no upgrade path) - types.d.ts: add ambient Followup interface; followups?: Followup[] (was unknown) - helpers.ts: add followups storage helper — compile trigger/ctl.regex to RegExp once on set/get - followups: extend Followup globally (drop local IncomingFollowup/FollowupCtl/FollowupScope) - followups: matchTrigger takes precompiled RegExp; write strips compiled fields; canCompile in isValid - followups: armFollowups uses structuredClone; append not replace; scope gates cnt+trigger Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove `meta` field from Followup wire shape. The retailerId is now encoded
directly in `id` as "${FollowupId}_${retailerId}", eliminating a redundant
field. Update Followup interface and comment accordingly.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| const now = Date.now() | ||
| const normalized = quietDomains.map((entry: any) => | ||
| entry && typeof entry.time === 'number' | ||
| ? { ...entry, time: [now, now + entry.time] } |
There was a problem hiding this comment.
Better way not to use time in two different meaning, but to use offset instead.
Like:
{
if(typeof entry.offset === 'number){
entry.time = Date.now() + entry.offset;
delete entry.offset;
}
return entry;
}| get: buildRegExpArray, | ||
| set: buildRegExpArray | ||
| }, | ||
| followups: { |
There was a problem hiding this comment.
Where do you use these get and set?
| // point (activate | popup close | optout), so arm them at the listener level | ||
| // rather than tying the trigger to a single action handler. | ||
| if (Array.isArray(request.followups) && request.followups.length) { | ||
| armFollowups(request.followups, sender.tab?.id).catch(() => { }) |
There was a problem hiding this comment.
Please confirm you don't need to wait here and in other places you call this function
Thank you page - only for activated
https://github.com/Bring-Web3-LTD/TODO/issues/162