Skip to content

feat(compare): require a comparison configuration for the hand-off - #7294

Merged
Haroenv merged 3 commits into
masterfrom
feat/silent-compare-handoff
Oct 16, 2026
Merged

Haroenv merged 3 commits into
masterfrom
feat/silent-compare-handoff

Conversation

@afrencalg

@afrencalg afrencalg commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #7275 (FX-3811, "comparison: no user message in shortcuts"). On the deployed default-theme example the Compare button still showed a user bubble ("Compare these products: … (objectID: …) vs …"): #7275 only hid the prompt-shortcut sentinel, which compareBar sent when a configurationId was set; without one it fell back to a prose message that went out as an ordinary typed message.

Per the review, instead of hiding the prose, the fallback is removed and a comparison configuration is required. There is now one hand-off path, the sentinel, which the chat already hides as a pending prompt shortcut (#7275), so no new hiding mechanism is needed.

  • connectCompare: getComparisonMessage and getDefaultComparisonMessage are gone; compare() always sends __ALGOLIA_COMPARISON_<id>__ with selected_products and comparison_configuration_id in the turn context.
  • The configurationId is set on the widget that triggers the hand-off, compareBar / <CompareBar> (required in their types), and shared through the selection store, so per-hit toggles keep calling useCompare() / reading the compare render state without it. compare() throws a usage error when no widget of the instance set one.
  • Examples (js/react default-theme, showcase) pass a configurationId.

BREAKING CHANGE: compareBar and <CompareBar> require configurationId; the getComparisonMessage option and getDefaultComparisonMessage export are removed.

Open point: the examples currently carry the placeholder algolia_comparison_REPLACE_ME. It has to be the ID of the comparison configuration on the demo agent (eedef238… on latency, Components > Comparison in the dashboard), which I can't read with the example's search key. I'll swap it in as soon as I have it; until then the demo agent receives an unresolved token.

Result

yarn jest packages/instantsearch.js/src/connectors/compare packages/instantsearch.js/src/widgets/compare-bar packages/react-instantsearch/src/widgets/__tests__/CompareBar.test.tsx packages/instantsearch.js/src/lib/chat/__tests__/openChat.test.ts
yarn lint:changed
npx tsc --noEmit  # plus examples/js/showcase against the rebuilt es/

Connector tests cover: the placeholder is sent tagged as a pending prompt shortcut; a toggle without configurationId starts the comparison through the bar's; the usage error when none is set; internal _ metadata stripping; the min-items / no-chat / busy guards.

Default-theme example against the rebuilt packages (headless Chromium): tick two hits, Compare → no [data-role="user"] bubble at any point, no raw token flashes, wire user message is the sentinel with turnContext.selected_products + comparison_configuration_id, no console errors.

Copilot AI balanced review requested due to automatic review settings October 14, 2026 12:13
@codacy-production

codacy-production Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics -6 complexity

Metric Results
Complexity -6

View in Codacy

TIP This summary will be updated as you push new changes.

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.

🟢 Approval recommended

The connector, transport, rendering behavior, documentation, and relevant tests are consistently updated.

0 open findings

What changed in this PR

Makes Compare hand-offs consistently silent while preserving agent context across configured and prose paths.

Changes:

  • Adds and propagates silent message metadata.
  • Removes local-only metadata from outbound requests.
  • Hides silent messages and expands coverage across connector and UI layers.
File Description
packages/​instantsearch.js/​src/​lib/​chat/​openChat.ts Adds the silent option and metadata.
packages/​instantsearch.js/​src/​lib/​chat/​__tests__/​openChat.test.ts Tests silent message tagging.
packages/​instantsearch.js/​src/​connectors/​compare/​connectCompare.ts Makes every comparison hand-off silent.
packages/​instantsearch.js/​src/​connectors/​compare/​__tests__/​connectCompare-test.ts Covers all comparison message paths.
packages/​instantsearch.js/​src/​connectors/​chat/​connectChat.ts Strips silent metadata from requests.
packages/​instantsearch.js/​src/​connectors/​chat/​__tests__/​connectChat-test.ts Verifies local and outbound metadata.
packages/​instantsearch-ui-components/​src/​lib/​utils/​chat.ts Recognizes explicitly silent messages.
packages/​instantsearch-ui-components/​src/​lib/​utils/​__tests__/​chat-test.ts Tests silent-message detection.
packages/​instantsearch-ui-components/​src/​components/​chat/​__tests__/​ChatMessages.test.tsx Verifies prose hand-offs render no bubble.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@pkg-pr-new

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

Copy link
Copy Markdown
More templates

algoliasearch-helper

npm i https://pkg.pr.new/algolia/instantsearch/algoliasearch-helper@7294

instantsearch-ui-components

npm i https://pkg.pr.new/algolia/instantsearch/instantsearch-ui-components@7294

instantsearch.css

npm i https://pkg.pr.new/algolia/instantsearch/instantsearch.css@7294

instantsearch.js

npm i https://pkg.pr.new/algolia/instantsearch/instantsearch.js@7294

react-instantsearch

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch@7294

react-instantsearch-core

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch-core@7294

react-instantsearch-nextjs

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch-nextjs@7294

react-instantsearch-router-nextjs

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch-router-nextjs@7294

vue-instantsearch

npm i https://pkg.pr.new/algolia/instantsearch/vue-instantsearch@7294

commit: 3a7bdff

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Size Change: -258 B (-0.02%)

Total Size: 1.04 MB

📦 View Changed
Filename Size Change
packages/instantsearch.js/dist/instantsearch.development.js 334 kB -231 B (-0.07%)
packages/instantsearch.js/dist/instantsearch.production.min.js 152 kB -27 B (-0.02%)
ℹ️ View Unchanged
Filename Size Change
packages/algoliasearch-helper/dist/algoliasearch.helper.js 44.5 kB 0 B
packages/algoliasearch-helper/dist/algoliasearch.helper.min.js 14.1 kB -1 B (-0.01%)
packages/instantsearch.css/components/ai-mode-button.css 1.76 kB 0 B
packages/instantsearch.css/components/autocomplete-min.css 4.33 kB 0 B
packages/instantsearch.css/components/autocomplete.css 4.68 kB 0 B
packages/instantsearch.css/components/button.css 1.98 kB 0 B
packages/instantsearch.css/components/chat-min.css 7.4 kB 0 B
packages/instantsearch.css/components/chat.css 7.91 kB 0 B
packages/instantsearch.css/components/filter-suggestions.css 1.89 kB 0 B
packages/instantsearch.css/themes/algolia-min.css 11.9 kB 0 B
packages/instantsearch.css/themes/algolia.css 12.6 kB 0 B
packages/instantsearch.css/themes/nova-min.css 12 kB 0 B
packages/instantsearch.css/themes/nova.css 12.8 kB 0 B
packages/instantsearch.css/themes/reset-min.css 1.3 kB 0 B
packages/instantsearch.css/themes/reset.css 1.38 kB 0 B
packages/instantsearch.css/themes/satellite-min.css 12.8 kB 0 B
packages/instantsearch.css/themes/satellite.css 13.7 kB 0 B
packages/react-instantsearch-core/dist/umd/ReactInstantSearchCore.min.js 73.8 kB -7 B (-0.01%)
packages/react-instantsearch/dist/umd/ReactInstantSearch.min.js 125 kB -5 B (0%)
packages/vue-instantsearch/vue2/cjs/index.js 19.9 kB 0 B
packages/vue-instantsearch/vue2/umd/index.js 74.3 kB -4 B (-0.01%)
packages/vue-instantsearch/vue3/cjs/index.js 20.6 kB 0 B
packages/vue-instantsearch/vue3/umd/index.js 74.7 kB -6 B (-0.01%)

compressed-size-action

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.

I still see this message being sent (not displayed), as part of not having the comparison configuration id not required. I think we can simplify this whole flow by making comparison id required and removing the frontend message fallback code altogether. Potentially then also be able to remove the "silent message" code introduced in this PR. what do you think?

The compare hand-off always sends the configured comparison's
placeholder now; the prose fallback (getDefaultComparisonMessage,
getComparisonMessage) is gone, so there is only one path and the chat
hides it as a prompt shortcut. The configurationId is set on the widget
that triggers the hand-off (compareBar, <CompareBar>) and shared through
the selection, so per-hit toggles keep calling useCompare() without it.
compare() throws a usage error when no widget set one.

BREAKING CHANGE: compareBar and <CompareBar> require configurationId;
the getComparisonMessage option and getDefaultComparisonMessage are
removed.

Co-authored-by: Cursor <cursoragent@cursor.com>
@afrencalg
afrencalg force-pushed the feat/silent-compare-handoff branch from 19af515 to 89c6d1d Compare October 15, 2026 09:49
@afrencalg afrencalg changed the title feat(compare): show no user message for the hand-off on every path feat(compare)!: require a comparison configuration for the hand-off Oct 15, 2026
@afrencalg
afrencalg requested a review from Haroenv October 15, 2026 09:50
@Haroenv Haroenv changed the title feat(compare)!: require a comparison configuration for the hand-off feat(compare): require a comparison configuration for the hand-off Oct 15, 2026

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

great! let's just put real configs on the examples

Comment thread examples/js/default-theme/src/app.js Outdated
Comment thread examples/js/default-theme/src/app.js Outdated
Comment thread examples/js/showcase/src/components/widgets/WidgetCompareBar.tsx Outdated
Comment thread examples/js/showcase/src/components/widgets/WidgetCompareBar.tsx Outdated
Comment thread examples/react/default-theme/src/App.tsx Outdated
Comment thread examples/js/default-theme/src/app.js Outdated
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Haroenv
Haroenv enabled auto-merge (squash) October 16, 2026 14:15
@Haroenv
Haroenv merged commit aa9944b into master Oct 16, 2026
19 checks passed
@Haroenv
Haroenv deleted the feat/silent-compare-handoff branch October 16, 2026 14:28
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.

3 participants