🌿 feat: Fork Messages/Conversations (#2617)

* typedef for ImportBatchBuilder

* feat: first pass, fork conversations

* feat: fork - getMessagesUpToTargetLevel

* fix: additional tests and fix getAllMessagesUpToParent

* chore: arrow function return

* refactor: fork 3 options

* chore: remove unused genbuttons

* chore: remove unused hover buttons code

* feat: fork first pass

* wip: fork remember setting

* style: user icon

* chore: move clear chats to data tab

* WIP: fork UI options

* feat: data-provider fork types/services/vars and use generic MutationOptions

* refactor: use single param for fork option, use enum, fix mongo errors, use Date.now(), add records flag for testing, use endpoint from original convo and messages, pass originalConvo to finishConversation

* feat: add fork mutation hook and consolidate type imports

* refactor: use enum

* feat: first pass, fork mutation

* chore: add enum for target level fork option

* chore: add enum for target level fork option

* show toast when checking remember selection

* feat: splitAtTarget

* feat: split at target option

* feat: navigate to new fork, show toasts, set result query data

* feat: hover info for all fork options

* refactor: add Messages settings tab

* fix(Fork): remember text info

* ci: test for single message and is target edge case

* feat: additional tests for getAllMessagesUpToParent

* ci: additional tests and cycle detection for getMessagesUpToTargetLevel

* feat: circular dependency checks for getAllMessagesUpToParent

* fix: getMessagesUpToTargetLevel circular dep. check

* ci: more tests for getMessagesForConversation

* style: hover text for checkbox fork items

* refactor: add statefulness to conversation import
This commit is contained in:
Danny Avila 2024-05-05 11:48:20 -04:00 committed by GitHub
parent c8baceac76
commit 25fceb78b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
37 changed files with 1831 additions and 523 deletions

View file

@ -1,5 +1,5 @@
import { atom } from 'recoil';
import { SettingsViews } from 'librechat-data-provider';
import { SettingsViews, LocalStorageKeys } from 'librechat-data-provider';
import type { TOptionSettings } from '~/common';
const abortScroll = atom<boolean>({
@ -137,6 +137,63 @@ const LaTeXParsing = atom<boolean>({
] as const,
});
const forkSetting = atom<string>({
key: LocalStorageKeys.FORK_SETTING,
default: '',
effects: [
({ setSelf, onSet }) => {
const savedValue = localStorage.getItem(LocalStorageKeys.FORK_SETTING);
if (savedValue != null) {
setSelf(savedValue);
}
onSet((newValue: unknown) => {
if (typeof newValue === 'string') {
localStorage.setItem(LocalStorageKeys.FORK_SETTING, newValue.toString());
}
});
},
] as const,
});
const rememberForkOption = atom<boolean>({
key: LocalStorageKeys.REMEMBER_FORK_OPTION,
default: false,
effects: [
({ setSelf, onSet }) => {
const savedValue = localStorage.getItem(LocalStorageKeys.REMEMBER_FORK_OPTION);
if (savedValue != null) {
setSelf(savedValue === 'true');
}
onSet((newValue: unknown) => {
if (typeof newValue === 'boolean') {
localStorage.setItem(LocalStorageKeys.REMEMBER_FORK_OPTION, newValue.toString());
}
});
},
] as const,
});
const splitAtTarget = atom<boolean>({
key: LocalStorageKeys.FORK_SPLIT_AT_TARGET,
default: false,
effects: [
({ setSelf, onSet }) => {
const savedValue = localStorage.getItem(LocalStorageKeys.FORK_SPLIT_AT_TARGET);
if (savedValue != null) {
setSelf(savedValue === 'true');
}
onSet((newValue: unknown) => {
if (typeof newValue === 'boolean') {
localStorage.setItem(LocalStorageKeys.FORK_SPLIT_AT_TARGET, newValue.toString());
}
});
},
] as const,
});
const UsernameDisplay = atom<boolean>({
key: 'UsernameDisplay',
default: localStorage.getItem('UsernameDisplay') === 'true',
@ -191,4 +248,7 @@ export default {
modularChat,
LaTeXParsing,
UsernameDisplay,
forkSetting,
splitAtTarget,
rememberForkOption,
};