Skip to content

Followups#506

Open
henyaGreenberg wants to merge 7 commits into
mainfrom
followups
Open

Followups#506
henyaGreenberg wants to merge 7 commits into
mainfrom
followups

Conversation

@henyaGreenberg

@henyaGreenberg henyaGreenberg commented May 27, 2026

Copy link
Copy Markdown
Contributor

Thank you page - only for activated
https://github.com/Bring-Web3-LTD/TODO/issues/162

- 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)
Copilot AI review requested due to automatic review settings May 27, 2026 07:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 followups through iframe loader data → UI ACTIVATE messages → 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; removes postPurchaseUrls caching 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.

Comment thread extension-files/bringweb3-sdk/utils/background/handleTabEvents.ts
Comment thread extension-files/bringweb3-sdk/utils/background/activate.ts Outdated
Comment thread extension-files/bringweb3-sdk/utils/background/followups.ts
Comment thread extension-files/bringweb3-sdk/utils/background/followups.ts Outdated
Comment thread extension-files/bringweb3-sdk/utils/apiEndpoint.ts Outdated
# Conflicts:
#	extension-files/bringweb3-sdk/utils/background/handleTabEvents.ts

@kalfada kalfada left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread extension-files/bringweb3-sdk/utils/api/validateDomain.ts Outdated
Comment thread extension-files/bringweb3-sdk/utils/api/validateDomain.ts Outdated
Comment thread extension-files/bringweb3-sdk/utils/background/activate.ts Outdated
Comment thread iframe-frontend/src/templates/b/OneStep/OneStep.tsx
Comment thread extension-files/bringweb3-sdk/types.d.ts Outdated
Comment thread extension-files/bringweb3-sdk/utils/background/followups.ts Outdated
Comment thread extension-files/bringweb3-sdk/utils/background/followups.ts Outdated
Comment thread extension-files/bringweb3-sdk/utils/background/followups.ts Outdated
Comment thread extension-files/bringweb3-sdk/utils/background/followups.ts Outdated
Comment thread extension-files/bringweb3-sdk/utils/background/followups.ts
@Bring-Web3-LTD Bring-Web3-LTD deleted a comment from kalfada Jun 10, 2026
- 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>
Comment thread extension-files/bringweb3-sdk/types.d.ts Outdated
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] }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(() => { })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please confirm you don't need to wait here and in other places you call this function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants