Skip to content

fix(compare): find the chat outside the widget's own index - #7305

Draft
Haroenv wants to merge 1 commit into
masterfrom
fix/compare-chat-lookup
Draft

Haroenv wants to merge 1 commit into
masterfrom
fix/compare-chat-lookup

Conversation

@Haroenv

@Haroenv Haroenv commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Summary

compare() resolved the chat only from the render state of the widget's own index, while the selection store is shared across the whole InstantSearch instance. A compareBar in a nested index with the chat at the root (or the reverse) therefore returned false with no feedback.

The lookup now lives in a shared helper, getChatRenderState(instantSearchInstance, indexId) in src/lib/chat/, with a deterministic order: the chat in the widget's own index, then the main index, then the first other index that rendered a chat. compare() emits a dev-mode warning when no chat is mounted.

Result

  • compare() opens the chat and sends the comparison regardless of which index the chat or the compare widget is mounted in.
  • compare() warns in development when no chat is found.
  • Tests cover a nested compare widget with a root chat, the lookup order, and the warning.
  • connectChatTrigger is unchanged.

🤖 Generated with Claude Code

compare() only looked at the chat in the widget's own index, so a compareBar in a nested index with the chat at the root (or the reverse) silently did nothing. Look in the widget's own index first, then the main index, then any other index, and warn in development when no chat is mounted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 15 complexity

Metric Results
Complexity 15

View in Codacy

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

@Haroenv

Haroenv commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up: connectChatTrigger has the same own-index-only lookup (its local getChatRenderState reads renderState[ownIndexId].chat), so a chatTrigger in a nested index won't find a chat mounted at the root. Its open/isChatBusy render state and toggleOpen all go through that lookup, so switching it to the shared lib/chat/getChatRenderState helper changes more than the hand-off. Left out of this PR on purpose.

— via Claude

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant