Skip to content

Onboarding: add the picker step and its native messages - #3241

Open
spapaseit wants to merge 14 commits into
mainfrom
spapaseit/onboarding-picker-poc
Open

spapaseit wants to merge 14 commits into
mainfrom
spapaseit/onboarding-picker-poc

Conversation

@spapaseit

@spapaseit spapaseit commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Asana Task/Github Issue: https://app.asana.com/1/137249556945/task/1218157738560967

Description

To pin down the page↔native messages early, this adds a picker onboarding step where the user picks suggested sites to add as favorites. The site list is the one the experiment ships with. This PR does not include icons on purpose.

  • topSitesPicker is opt-in and sits after customize. It shows only when native lists it in init.steps.
  • Right before the picker, the page asks native with a new shouldShowTopSitesPicker request. The response is { show: boolean, existingFavorites?: string[] }. I chose a page-side ask over native pushing exclude after the import, because native then decides at the moment the user reaches the step, including users who skipped the import.
  • The page asks once, when the user leaves the step before picker. A failed request, an answer without show: true, or no answer within 2 seconds skips the picker, and a late answer is ignored. While it waits, the page sits in the reducer's executing status, so Next and the row controls are disabled and other actions are dropped.
  • A skipped picker lowers the step total by one, since picker stays in the order until the answer arrives.
  • stepDefinitions.topSitesPicker carries sites (id, url, title, section). Schema in messages/types/picker-step.json. existingFavorites arrives in the answer, not in onConfigUpdate. The generic exclude in onConfigUpdate still works for other steps.
  • The default list has 3 email sites and 7 popular ones, hard-coded in app/v4/data/data.js. Gmail and Outlook save mail.google.com and outlook.live.com, where gmail.com and outlook.com redirect, so they match the favorites people import.
  • Amazon and Wikipedia depend on where the user is. Native sends the OS region as a new optional init.region (ISO 3166-1 alpha-2, e.g. GB). A picker site can carry a urlByRegion table keyed on that region, or a urlTemplate whose {locale} comes from the page language. Amazon lists its stores in urlByRegion and falls back to amazon.com. Wikipedia uses https://{locale}.wikipedia.org, so every edition works without a list. I put the variants in the site data rather than in page code, so the list can move to native or remote config without the page naming a site. A sites list that native sends is resolved the same way.
  • I match existing favorites page-side rather than having native pre-filter, so the rule lives once in C-S-S instead of twice in macOS and Windows. Matching sites, compared by hostname without a leading www., show as picked and locked. I chose that over hiding them so a user who just imported YouTube sees it there.
  • Add sends one addFavorites notify, { favorites: [{ id, url, title }] }, without the existing favorites. Skip sends nothing.
  • With reduced motion, the second click of a double-click on Add lands on the address bar step. It used to crash the page with "unhandled title-complete" (app/global.js), and it could silently pick "Search Only". The reducer now accepts title-complete while a value saves, and the address bar options ignore a click with event.detail > 1.

Mock URL params

Previews run against the mock transport, which these params steer. readme.md lists them all.

Param Effect
existingFavorites=<url>,<url> The mock answers yes with these favorites. Matching sites show as picked and locked.
topSitesPicker=hide The mock answers show: false, so the page skips the picker.
region=<code> Overrides init.region. Unlisted codes get amazon.com.
locale=<lang> Page language, which also picks the Wikipedia subdomain.
steps=<id> (repeatable) Acts as init.steps. picker must be listed.
page=<id> The step to start on. page=picker opens the picker without asking native, which suits styling work only.
platform=windows Windows layout.
debugState Shows the page state, where the picker's site URLs can be read.

There is no param for a slow or missing answer. The 2-second timeout is covered by Playwright on Windows, which holds the request.

Review notes, unfixed

  • Known gap from before this change: toggling a row after Next but before the step's exit fade ends puts the page in executing for that toggle, and an advance landing then throws. It affects every settings step, so it belongs in its own change.
  • While the page waits for the picker answer it drops every action, error-boundary included, so a render error in that window wouldn't reach fatal.
  • If native excludes the picker through onConfigUpdate during the wait and then answers yes, stepCompleted reports next: 'picker'.
  • The ask starts after the exit fade, so the fade and the wait run back to back. With native answering straight away that is a blink. At the timeout it reads as a hang.
  • A picker listed first, or opened with page=picker, shows without native being asked. Real orders start with welcome.
  • The double-click guard covers only the address bar options. A shared guard that ignores detail > 1 clicks for a moment after any step change would cover every step, including Next and Start Browsing. That belongs in its own change.
  • The address bar double-click test proves the guard only where the second click lands on "Search Only", which holds on one of the two desktop layouts.
  • Nits: ?region= with an empty value hides init.region (?? rather than ||). withResolvedSiteUrls takes an object, unlike the other with* methods. A two-letter language with no Wikipedia edition gives a favorite that doesn't open. config-update pushes don't resolve site URLs, though native doesn't send sites that way today. onboarding.md doesn't list init.region yet. The isBusy comment in SettingsContent.js and the comment on locks in PickerContent.js predate the ask. New tests inline locators rather than adding page-object helpers.
  • Already on main: a leftover console.log('KV', ...) in Settings.withStepDefinitions, and a "Side effects" comment in app/global.js that no longer matches its branch.

Testing Steps

  • npm run build && npm run lint
  • cd special-pages && npm run test-unit
  • cd special-pages && npx playwright test pages/onboarding --reporter list

Each preview starts on customize. Skip its three rows, then click Next.

  • Yes, no favorites. The picker shows with nothing locked, at 2 of 3.
  • Yes, with YouTube and Gmail as favorites. YouTube and Gmail show as picked and locked.
  • No. Next leads straight to the address bar step, and the total drops from 3 to 2.
  • Region GB. In the state panel, Amazon's URL is https://www.amazon.co.uk.
  • Region DE, German. The page is in German, Amazon is https://www.amazon.de and Wikipedia is https://de.wikipedia.org.
  • Unlisted region. Amazon falls back to https://www.amazon.com.
  • Windows. Same as the favorites preview, in the Windows layout.

Checklist

Please tick all that apply:

  • I have tested this change locally
  • I have tested this change locally in all supported browsers
  • This change will be visible to users
  • I have added automated tests that cover this change
  • I have ensured the change is gated by config
  • This change was covered by a ship review
  • This change was covered by a tech design
  • Any dependent config has been merged

@github-actions github-actions Bot added the semver-minor New feature — triggers minor version bump label Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

[Beta] Generated file diff

Time updated: Thu, 26 Nov 2026 12:32:52 GMT

Apple
    - apple/pages/onboarding/dist/index.css
  • apple/pages/onboarding/dist/index.js
  • apple/pages/onboarding/locales/en/onboarding.json

File has changed

Integration
    - integration/pages/onboarding/dist/index.css
  • integration/pages/onboarding/dist/index.js
  • integration/pages/onboarding/locales/en/onboarding.json

File has changed

Windows
    - windows/pages/onboarding/dist/index.css
  • windows/pages/onboarding/dist/index.js
  • windows/pages/onboarding/locales/en/onboarding.json

File has changed

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Build Branch

Branch pr-releases/spapaseit/onboarding-picker-poc
Commit fade465d98
Updated November 26, 2026 at 12:31:59 PM UTC

Static preview entry points

QR codes (mobile preview)
Entry point QR code
Docs QR for docs preview
Static pages QR for static pages preview
Integration pages QR for integration pages preview

Integration commands

npm (Android / Extension):

npm i github:duckduckgo/content-scope-scripts#pr-releases/spapaseit/onboarding-picker-poc

Swift Package Manager (Apple):

.package(url: "https://github.com/duckduckgo/content-scope-scripts.git", branch: "pr-releases/spapaseit/onboarding-picker-poc")

git submodule (Windows):

git -C submodules/content-scope-scripts fetch origin pr-releases/spapaseit/onboarding-picker-poc
git -C submodules/content-scope-scripts checkout origin/pr-releases/spapaseit/onboarding-picker-poc
Pin to exact commit

npm (Android / Extension):

npm i github:duckduckgo/content-scope-scripts#fade465d98ec6d1208c6a5c16f22b8379bf3555c

Swift Package Manager (Apple):

.package(url: "https://github.com/duckduckgo/content-scope-scripts.git", revision: "fade465d98ec6d1208c6a5c16f22b8379bf3555c")

git submodule (Windows):

git -C submodules/content-scope-scripts fetch origin pr-releases/spapaseit/onboarding-picker-poc
git -C submodules/content-scope-scripts checkout fade465d98ec6d1208c6a5c16f22b8379bf3555c

@spapaseit
spapaseit force-pushed the spapaseit/onboarding-picker-poc branch from 8b994f0 to 4532b1d Compare November 24, 2026 16:10
@spapaseit
spapaseit marked this pull request as ready for review November 26, 2026 09:03
@spapaseit
spapaseit requested review from a team and daxtheduck as code owners November 26, 2026 09:03

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@spapaseit spapaseit self-assigned this Nov 26, 2026
@spapaseit
spapaseit requested a review from shakyShane November 26, 2026 09:04
@spapaseit

Copy link
Copy Markdown
Contributor Author

/cc @kamte for visibility

@spapaseit

Copy link
Copy Markdown
Contributor Author

@claude review

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Findings marked 🟡 are optional suggestions and need no follow-up push.

Additional findings (outside the current diff — GitHub can't attach inline comments there):

  • 🟡 special-pages/pages/onboarding/app/v4/data/existing-favorites.js — Users with any bbc.com favorite, such as the homepage or bbc.com/sport, see BBC News already ticked and locked, so they cannot add it. existingSiteIds compares hostnames only. That is enough for sites that live at a host root. It is not enough for bbcNews, whose URL is https://www.bbc.com/news (data.js). Fix: when the suggested site's URL has a path beyond /, also require the favorite's path to start with that path, keeping the hostname-only rule for root URLs such as YouTube and Gmail.

    Why this was flagged

    Native answers shouldShowTopSitesPicker with show: true and existingFavorites: ["https://www.bbc.com"], for example after the user imported the BBC homepage. applyPickerAnswer (global.js:200) copies the list into the picker step. existingSiteIds (existing-favorites.js:25-31) turns both URLs into hostKey 'bbc.com', so the bbcNews site matches. PickerContent.js:568-585 then renders BBC News with aria-checked true and disabled. It also leaves BBC News out of picks, so the user can never send it in addFavorites, although they do not have BBC News as a favorite. The base branch has no picker, so this is new. Nothing guards against it: the unit tests cover only root-URL sites, and the docs in onboarding.md and picker-step.json describe the hostname-only rule without mentioning sites that carry a path.

    Verification: nit. hostKey (existing-favorites.js:12-18) reduces a URL to new URL(url).hostname.replace(/^www\./, '') and drops the path. data.js:338 defines { id: 'bbcNews', url: 'https://www.bbc.com/news', ... }, so any bbc.com favorite matches bbcNews. PickerContent.js:96-97 and 113 render it with aria-checked true and disabled={done || existing}, so it never goes out in addFavorites.

@shakyShane shakyShane 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.

Thanks! there's a couple of small questions in there, but then a larger ask to be much more ruthless with regards to agent generated code.

  • trim integration test count down to just a handful (avoid trying to enumerate every failure case ever and just focus on common flows)
  • question if the unit tests have any additional value at all, or if they are just the LLM's reasoning record... feel free to drop them all or just leave ones that are genuinely capturing an algorithm not exercised seen in the integration tests
  • trim almost all comments, leaving the minimum where they have genuine value (most are just the LLM recording it's own work/thoughts)

Nice work!

});
});

test.describe('Given I am on the Top Sites picker step', () => {

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.

can we scrutinize if every one of these tests is needed - probably a handful would cover most cases and won't lock us too tightly into the implementation.

Remember it's close to impossible to enumerate every failure case there'll ever be, so I'd prefer to see a smaller set of well known paths through.

I'd work with an agent with a goal of covering most flows through that a user can make and aim for roughly 5 to 8 tests

Comment on lines +336 to +358
// handle 'top-sites-picker-ask': ask native, then advance past the step before the picker with its answer applied.
// A no with nothing after the picker finishes onboarding, since there is no step left to advance to.
useEffect(() => {
if (state.status.kind !== 'executing' || state.status.action.kind !== 'top-sites-picker-ask') return;
const order = state.order;
askTopSitesPicker(messaging)
// eslint-disable-next-line promise/prefer-await-to-then
.then((answer) => {
const nextOrder = answer.show ? order : order.filter((id) => id !== 'topSitesPicker');
dispatch({ kind: 'top-sites-picker-answer', ...answer });
if (nextStepId(nextOrder, state.activeStep) !== null) {
dispatch({ kind: 'advance' });
reportStepCompleted(state, nextOrder, messaging);
} else {
// Like Start Browsing on a last step, this sends no stepCompleted
messaging.dismissToAddressBar();
}
})
// eslint-disable-next-line promise/prefer-await-to-then
.catch((e) => console.warn('handling the picker answer failed', e));
// eslint-disable-next-line react-hooks/exhaustive-deps -- runs once per ask, like the update-system-value effect below
}, [state.status.kind, messaging]);

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.

this is one of the cases where the original version (the one below this) was wrong (it's a user-trigger effect so does NOT belong in a useEffect).

since you're adding this directly next to the other one I don't think we should block this for a sake of experiment, but as mentioned in 'you dont need an effect' in react docs, this is a mistake I put in place that I'd like us to avoid if this moves past experiment.

@spapaseit spapaseit Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I couldn't agree more, and this one slipped completely past me. I ended up putting a link to the "you might not need an effect" page in a React skill a made a while ago. Worked so well I forgot about it... and now that skill is not on this laptop and it came back to bite me

Comment on lines +257 to +262
/**
* Right before the picker, ask native whether to show it. Native enrolls the user at this point, so
* the page asks only when the user is about to reach the step, and drops it if the answer is no.
* The ask runs in the effect below, and its answer advances the page.
*/
if (msg.kind === 'advance' && nextStepId(state.order, state.activeStep) === 'topSitesPicker') {

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.

can you ask an agent to do a brutal trim of every comment added in this PR - spot things that are LLM reasoning or justifications left over in the code and cut as much of them as possible. Any that are left over need to be justified

Comment on lines +14 to +16
export function hostKey(url) {
return urlKey(url)?.host ?? null;
}

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.

this isn't called anywhere but tests, delete it and the tests can go too

Comment on lines +21 to +42
test('existingSiteIds returns the ids of matching sites only', () => {
assert.deepEqual(existingSiteIds([gmail, youtube], ['https://youtube.com/feed']), ['youtube']);
assert.deepEqual(existingSiteIds([gmail, youtube], ['https://google.com']), []);
});

test('existingSiteIds skips malformed favorites', () => {
assert.deepEqual(existingSiteIds([gmail, youtube], ['::', '', 'https://www.youtube.com']), ['youtube']);
});

test('m. hosts are a known miss', () => {
assert.deepEqual(existingSiteIds([youtube], ['https://m.youtube.com']), []);
});

test('a site with a path needs the favorite under that path', () => {
/** @type {import('../types/onboarding.ts').TopSitesPickerSite} */
const bbcNews = { id: 'bbcNews', url: 'https://www.bbc.com/news', title: 'BBC News', section: 'popular' };
assert.deepEqual(existingSiteIds([bbcNews], ['https://www.bbc.com']), []);
assert.deepEqual(existingSiteIds([bbcNews], ['https://www.bbc.com/sport']), []);
assert.deepEqual(existingSiteIds([bbcNews], ['https://www.bbc.com/newsround']), []);
assert.deepEqual(existingSiteIds([bbcNews], ['https://bbc.com/news/']), ['bbcNews']);
assert.deepEqual(existingSiteIds([bbcNews], ['https://www.bbc.com/news/world']), ['bbcNews']);
});

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.

can you double check every test here is justified, some look like an agent was recording its decisions

Comment on lines +41 to +43
test('resolveSiteUrl ignores keys inherited from Object.prototype', () => {
assert.equal(resolveSiteUrl(store, { region: '__proto__' }), 'https://store.example');
});

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.

we don't get outside data sources here, this is probably the agent being over cautious or logging it's decisions - just delete it

Comment on lines +39 to +41
// The second click of a double-click on the previous step's button can land here when the step switches
// instantly (reduced motion). It must not change the setting.
if (event.detail > 1) return;

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.

something is off here that I can't put my finger on - if it's down to whether animations fire their ending events or not, then this logic should be near that code (a genuine use-case for a useEffect since it can get react to sync with the animation events)

This branch has not been deployed

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

Labels

semver-minor New feature — triggers minor version bump

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants