Skip to content

feat(demo-schema-react): restore searches with browser back and forward j:KIT-6460 - #8783

Merged
fbeaudoincoveo merged 3 commits into
feat/KIT-6459-mock-restore-statefrom
feat/KIT-6460-demo-restore-state
Oct 30, 2026
Merged

fbeaudoincoveo merged 3 commits into
feat/KIT-6459-mock-restore-statefrom
feat/KIT-6460-demo-restore-state

Conversation

@fbeaudoincoveo

Copy link
Copy Markdown
Contributor

Jira

https://coveord.atlassian.net/browse/KIT-6460

Motivation

A shopper could not get back to a previous search: the demo never built or sent a restoreState snapshot. This uses the browser history, so back and forward step through the searches of a commerce-search surface. A reload is out of scope here: the demo starts a new server session, which has no search surface to restore into.

Changes

demo-schema-react

  • buildRestoreSnapshot builds the restoreState payload from a surface's state: the query summary's query, the pagination's page and page size, the applied sort, and each facet's active selection by field. That covers selected regular values, selected and custom numeric ranges, and the selected category path.
  • The CommerceSearch root records each search the surface settles on as a history entry. A snapshot is taken only once the session is free and the surface's state has changed, so one answer makes one entry, and the other surfaces don't add entries.
  • On back or forward to one of its entries, the surface dispatches restoreState once the session is free. The answer updates that entry in place, so the entries ahead of it stay reachable.

Dependencies

  • @coveo/thermidor-schema 1.0.0-beta.33 → 1.0.0-beta.34, which adds FacetRestore.path.

Validation

  • Demo tests pass (438), including new ones for the snapshot and the history hook. @coveo/thermidor tests pass (363) with beta.34. The demo typechecks.
  • Checked in the demo against the mock converse service: a search, then a category, then a sub-category made three entries. Back restored the category; forward sent restoreState with the path ["Surfing", "Surfboards"] and selected it again, with no new entry.
  • Not checked against a live Agent Gateway.

🤖 Generated with Claude Code

@changeset-bot

changeset-bot Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 7f68b4d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@svcsnykcoveo

svcsnykcoveo commented Oct 29, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@pkg-pr-new

pkg-pr-new Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
@coveo/atomic

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/atomic@8783

@coveo/atomic-hosted-page

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/atomic-hosted-page@8783

@coveo/atomic-legacy

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/atomic-legacy@8783

@coveo/atomic-react

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/atomic-react@8783

@coveo/auth

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/auth@8783

@coveo/bueno

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/bueno@8783

coveo.analytics

npm i https://pkg.pr.new/coveo/ui-kit/coveo.analytics@8783

@coveo/create-atomic

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/create-atomic@8783

@coveo/create-atomic-component

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/create-atomic-component@8783

@coveo/create-atomic-component-project

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/create-atomic-component-project@8783

@coveo/create-atomic-result-component

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/create-atomic-result-component@8783

@coveo/create-atomic-rollup-plugin

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/create-atomic-rollup-plugin@8783

@coveo/create-ui

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/create-ui@8783

@coveo/headless

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/headless@8783

@coveo/headless-react

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/headless-react@8783

@coveo/quantic

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/quantic@8783

@coveo/relay

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/relay@8783

@coveo/shopify

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/shopify@8783

@coveo/thermidor

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/thermidor@8783

@coveo/atomic-angular

npm i https://pkg.pr.new/coveo/ui-kit/@coveo/atomic-angular@8783

commit: 7f68b4d

@chromatic-com

chromatic-com Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Tip

All tests passed and all changes approved!

🟢 UI Tests: 440 tests unchanged
🟢 UI Review: No changes
Storybook icon Storybook Publish: 472 stories published

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🔗 Scratch Orgs ready to test this PR:

This comment was marked as resolved.

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.

🔵 Needs a closer look

An in-flight page or facet response can still call pushState after Back navigation, allowing an abandoned request to erase saved searches in the Forward history.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Invalidate in-flight requests after navigation

samples/​thermidor/​demo-schema-react/​src/​a2ui/​CommerceSearch/​use-search-history.ts:110

If a page or facet request is in flight when the shopper goes Back to an untagged entry or another surface's entry, this guard leaves its answer eligible for recording. Once the session is free, that answer can call pushState from the navigated-to entry and delete the saved searches in the Forward branch. Track navigation invalidation for ordinary requests as well as restores, and suppress abandoned answers without suppressing new searches started after navigation.

2 resolved since last review
1 file not reviewed
  • pnpm-lock.yaml: Generated file

Review effort: Balanced

@jfcere-coveo jfcere-coveo 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.

The snapshot follows the schema contract, and deduplicating against the current entry keeps it to one entry per search. The two earlier Copilot fixes look right and are covered.

One thing before approving: the last Copilot finding (an in-flight action pushing after Back) is still open and holds up. Details inline.

Outside this PR: NumericFacetValue doesn't expose endInclusive, so the snapshot can't carry it, and the gateway's restoreState defaults it to true, while toggleSelect keeps the value the Commerce API returned. If the API returns exclusive ranges, a restore against the live gateway would include boundary products and might not match the listed value. Since this wasn't checked against a live gateway, worth confirming, and possibly exposing endInclusive in the schema or having the gateway match the restored range against its listed values.

@fbeaudoincoveo
fbeaudoincoveo force-pushed the feat/KIT-6460-demo-restore-state branch from fb07199 to d8a6e20 Compare October 30, 2026 13:06
@fbeaudoincoveo

fbeaudoincoveo commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor Author

@jfcere-coveo

Outside this PR: NumericFacetValue doesn't expose endInclusive, so the snapshot can't carry it, and the gateway's restoreState defaults it to true, while toggleSelect keeps the value the Commerce API returned. If the API returns exclusive ranges, a restore against the live gateway would include boundary products and might not match the listed value. Since this wasn't checked against a live gateway, worth confirming, and possibly exposing endInclusive in the schema or having the gateway match the restored range against its listed values.


thermidor-schema doesn't expose endInclusive on numeric facet values, so the snapshot has nothing to carry, and the demo only sends start and end. The only place it appears is the optional field on NumericRangeRestore, which the gateway defaults to true. Whether that default matches the ranges the Commerce API returns is a gateway question, outside these PRs.

fbeaudoincoveo and others added 3 commits October 30, 2026 09:55
…rd j:KIT-6460

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… abandoned or fails j:KIT-6460

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… after the browser moved away j:KIT-6460

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fbeaudoincoveo
fbeaudoincoveo added this pull request to the merge queue Oct 30, 2026
Merged via the queue into main with commit b4adbd3 Oct 30, 2026
104 of 137 checks passed
@fbeaudoincoveo
fbeaudoincoveo deleted the feat/KIT-6460-demo-restore-state branch October 30, 2026 14:34

This branch was successfully deployed

1 active and 1 inactive deployments
PR Artifacts — 7f68b4d8 Deployed Oct 30, 2026 by fbeaudoincoveo via Merge Quantic Playwright reports #20603
pr-workflows — 7f68b4d8 Deployed Oct 30, 2026 by fbeaudoincoveo via label #10181
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants