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.
This is an attempt to break up our nearly 900-line redux file into smaller, targeted files, grouped by type (selectors, thunks). We still export a single
index.ts
file in theaichat/redux
directory so other components can still just import fromaichat/redux
directly.Details:
redux/thunks
folder, with a separate file per thunk. Some of the thunks are quite large, so this helps organize things (even if others are pretty small)redux/thunks/helpers
subdirectoryredux/selectors/index.ts
file. I opted to keep these in one file since they're individually pretty small.aichatRedux
is just the state schema and slice definition, so I renamed itslice.ts
. It's still not that small, but is focused on just defining the state and actions. I debated pulling outAichatState
into a separate file too but kept it there for now. Happy to reconsider though.redux/index.ts
file.Like #63710 this is mostly copy+paste only, but there were a few minor changes needed to get everything working correctly:
aichat/redux
instead ofaichat/redux/aichatRedux
waitingForResponse: boolean
state value, and instead just compute this based on the presence of achatMessagePending
. This was primarily so I could get rid of theextraReducers
in the slice and avoid a circular dependency between the thunk file and the slice file. We setwaitingForResponse
totrue
only when we're in the process of sending a chat message, which is also only whenchatMessagePending
is defined, so I felt this made sense.Testing story
Tested locally. No functional/behavioral changes.
Follow-up work
I'd like to clean up the
utils.ts
file too, but I'll leave this for a separate change that tackles all the various util files together - there's a bunch of util files spread out across these three files that all kind of get used in different places.