-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Code refactoring #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code refactoring #140
Conversation
fix: clearConvo will remove all messages
feat: use recoil to replace redux feat: use react-native THIS IS NOT FINISHED. DONT USE THIS
THIS IS NOT FINISHED. DONT USE THIS
THIS IS NOT FINISHED. DONT USE THIS
fix: url can be null in conversationId and query fix: get conversation api should handle not found.
fix: handle 404 of conversation fetch failed
Things to be done:
|
brief of new state structure: here we use recoil to handle global state. please refer to the docs of the usage. (typically, similar to useState) conversation.jsatom conversationThe current conversation, can be an object or null (null means client need to fetch from server) If a new chat is created, conversation is also an object. with conversationId = 'new' When sending new message, {model, chatGptLabel, promptPrefix} is decided by this atom To set particialy, use
atom messagesThe list of current messages of the conversation, must be an array or null
selector messagesTreea readonly selector, from atom messages. same as the old version. to use it:
atom latestMessageThe latest message of the conversation that is showing. useConversationA custom hook, provide { newConversation, switchToConversation, searchPlaceholderConversation } newConversation: a function that will create new conversation and do all clean up work.
if model == null, getDefaultModel will be called, to set the model as the default version. (firstly check localstorage, or select the first one) Use this to create new chat, DONT set conversation and messages and latestmessage by hand, it's dirty. switchToConversation: a function that will switch to given conversation and messages and do all clean up work.
searchPlaceholderConversation: a function that will switch to a search view. conversations.jsHere doesn't storage the conversation list. just a refreshConversationsHint to ask refresh conversation. atom refreshConversationsHintas before hook useConversationsprovides a function { refreshConversations }, to ask for refresh conversation list. eg:
models.jsSave available models here atom customGPTModelsa array of customGPTModels. can be filled by server api. must follow this:
You might not need this, cc availableModels selector models:readonly, equals to default models + customGPTModels You might not need this, cc availableModels atom modelsFilter:an object of available models. in this form:
selector availableModels:readonly, from models. filtered by modelsFilter You might love this submission.jsall things related to a submission. atom submissioncurrent submission object. send a new object to this will submit a new message. atom isSubmittingas the name showing search.jsatom isSearchEnabledif the search is enabled by server atom searchQuerya string contains the search query, can be blank if nothing to search atom searchResultMessagessimilar to messages. the search result of messages selector searchResultMessagesTreesimilar to messagesTree, but from searchResultMessages isSearchingif in search mode actually it check if query is blank user.jsatom usercurrent user. |
fix: set max auth cookie to 7 days
feat: use search result message as single list
help needed, please generate a package-lock.json
My review is done and I've added some fixes to things before merging this to main. Very well done, this was not easy catching it up to latest. |
This PR is created to track the progress of refactoring of the client.
This PR is based on Commit 15486d0.
Here is the summary list of changes:
ui/
andInput/
/api/convos/:conversationId
to retrive a conversation