Repository navigation
feat(compare): require a comparison configuration for the hand-off - #7294
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | -6 |
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
🟢 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
silentmessage 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.
More templates
algoliasearch-helper
instantsearch-ui-components
instantsearch.css
instantsearch.js
react-instantsearch
react-instantsearch-core
react-instantsearch-nextjs
react-instantsearch-router-nextjs
vue-instantsearch
commit: |
|
Size Change: -258 B (-0.02%) Total Size: 1.04 MB 📦 View Changed
ℹ️ View Unchanged
|
There was a problem hiding this comment.
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>
19af515 to
89c6d1d
Compare
Haroenv
left a comment
There was a problem hiding this comment.
great! let's just put real configs on the examples
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
compareBarsent when aconfigurationIdwas 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:getComparisonMessageandgetDefaultComparisonMessageare gone;compare()always sends__ALGOLIA_COMPARISON_<id>__withselected_productsandcomparison_configuration_idin the turn context.configurationIdis 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 callinguseCompare()/ reading thecomparerender state without it.compare()throws a usage error when no widget of the instance set one.configurationId.BREAKING CHANGE:
compareBarand<CompareBar>requireconfigurationId; thegetComparisonMessageoption andgetDefaultComparisonMessageexport 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…onlatency, 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
Connector tests cover: the placeholder is sent tagged as a pending prompt shortcut; a toggle without
configurationIdstarts 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 withturnContext.selected_products+comparison_configuration_id, no console errors.