Skip to content

fix(chat): stop streaming when you clear#6955

Open
shaejaz wants to merge 5 commits intomasterfrom
fix/chat-clear-disable
Open

fix(chat): stop streaming when you clear#6955
shaejaz wants to merge 5 commits intomasterfrom
fix/chat-clear-disable

Conversation

@shaejaz
Copy link
Copy Markdown
Contributor

@shaejaz shaejaz commented Apr 8, 2026

Currently, the user is able to click on the clear button while messages are streaming, resulting in weird message states. This prevents the chat to be cleared until the chat is back in a ready state.

image

@codacy-production
Copy link
Copy Markdown

codacy-production bot commented Apr 8, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 duplication

Metric Results
Duplication 0

View in Codacy

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

@shaejaz shaejaz changed the title Fix/chat clear disable fix(chat): disable clear button when chat status is not ready Apr 8, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 8, 2026

More templates

algoliasearch-helper

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

instantsearch-ui-components

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

instantsearch.css

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

instantsearch.js

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

react-instantsearch

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

react-instantsearch-core

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

react-instantsearch-nextjs

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

react-instantsearch-router-nextjs

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

vue-instantsearch

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

commit: 1b342a2

@Haroenv
Copy link
Copy Markdown
Contributor

Haroenv commented Apr 8, 2026

instead, should clear maybe stop the streaming too? good catch though

@shaejaz shaejaz force-pushed the fix/chat-clear-disable branch from 2ebac09 to 15b4a5d Compare April 9, 2026 11:16
@shaejaz shaejaz changed the base branch from feat/streaming-tools to master April 9, 2026 11:16
@shaejaz
Copy link
Copy Markdown
Contributor Author

shaejaz commented Apr 9, 2026

instead, should clear maybe stop the streaming too? good catch though

that could be possible yes, but would it not be a bit unclear to the user that pressing clear somehow also stops it? Maybe we change the text to 'Stop'? Seems redundant due to a stop button already being present.

@shaejaz shaejaz marked this pull request as ready for review April 9, 2026 11:27
@shaejaz shaejaz requested review from a team, Haroenv, aymeric-giraudet and Copilot and removed request for a team April 9, 2026 11:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Prevents users from clearing chat messages while the chat is generating a response, to avoid inconsistent UI/message states during streaming.

Changes:

  • Disable the Chat “Clear” button when chat status is not ready (React InstantSearch + InstantSearch.js widget wrapper).
  • Add a widget options test asserting the Clear button becomes disabled while the chat is streaming.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
tests/common/widgets/chat/options.tsx Adds regression test for Clear button disabling during in-progress chat.
packages/react-instantsearch/src/widgets/Chat.tsx Gates canClear on status === 'ready' in React widget header props.
packages/instantsearch.js/src/widgets/chat/chat.tsx Gates canClear on chatStatus === 'ready' in InstantSearch.js widget wrapper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Haroenv
Copy link
Copy Markdown
Contributor

Haroenv commented Apr 9, 2026

I think if you want to clear the input while it's busy rendering, it's likely because you want to send a new request, no? so stopping makes sense to me with the same clear text already there @shaejaz

Copy link
Copy Markdown
Contributor

@Haroenv Haroenv left a comment

Choose a reason for hiding this comment

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

I think instead, we should make clear stop the current request too.

@Haroenv Haroenv changed the title fix(chat): disable clear button when chat status is not ready fix(chat): stop streaming when you clear Apr 10, 2026
Copy link
Copy Markdown
Contributor

@Haroenv Haroenv left a comment

Choose a reason for hiding this comment

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

might also be interesting to set the messages to empty array already before the transition? not sure if that matters or why the connector knows about the transition. Good to go though

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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