chore: Refactor thread state management #4350
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe Your Changes
• Combined isGeneratingResponseAtom & isWaitingForResponse with isBlockingSendAtom
• Update dependencies in ChatBody, ChatInput, and MessageToolbar components
• Remove unused code and variables
• Avoid unnecessary rerendering
Changes made
This pull request includes several changes to improve the handling of thread states and reduce unnecessary re-renders in the application. The most important changes involve replacing individual state atoms with a combined state atom and updating various components to use this new combined state.
Changes to thread state handling:
web/helpers/atoms/Thread.atom.ts
: AddedisWaitingForResponseAtom
andisBlockingSendAtom
to combine thread states and reduce re-renders.web/containers/Providers/ModelHandler.tsx
: UpdatedsubscribedGeneratingMessage
to useuseAtomValue
instead ofuseAtom
.Updates to components to use combined state:
web/screens/Thread/ThreadCenterPanel/ChatBody/index.tsx
: ReplacedisGeneratingResponse
andthreadStates
withisBlockingSend
in various places to simplify state management. [1] [2] [3] [4] [5]web/screens/Thread/ThreadCenterPanel/ChatInput/index.tsx
: Updated to useisBlockingSend
instead of individual state atoms for better performance. [1] [2] [3]web/screens/Thread/ThreadCenterPanel/MessageToolbar/index.tsx
: Modified to useisBlockingSend
to control the visibility of certain actions. [1] [2] [3]