2024-10-19 14:30:52 +02:00
|
|
|
import React, { useState } from 'react';
|
|
|
|
|
import { useClearConversationsMutation } from 'librechat-data-provider/react-query';
|
|
|
|
|
import { Label, Button, OGDialog, OGDialogTrigger, Spinner } from '~/components';
|
2025-01-12 12:57:10 -05:00
|
|
|
import { useLocalize, useNewConvo } from '~/hooks';
|
2024-10-19 14:30:52 +02:00
|
|
|
import OGDialogTemplate from '~/components/ui/OGDialogTemplate';
|
|
|
|
|
|
|
|
|
|
export const ClearChats = () => {
|
|
|
|
|
const localize = useLocalize();
|
|
|
|
|
const [open, setOpen] = useState(false);
|
2025-01-12 12:57:10 -05:00
|
|
|
const { newConversation } = useNewConvo();
|
2024-10-19 14:30:52 +02:00
|
|
|
const clearConvosMutation = useClearConversationsMutation();
|
|
|
|
|
|
|
|
|
|
const clearConvos = () => {
|
|
|
|
|
clearConvosMutation.mutate(
|
|
|
|
|
{},
|
|
|
|
|
{
|
|
|
|
|
onSuccess: () => {
|
|
|
|
|
newConversation();
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
};
|
🌿 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
2024-05-05 11:48:20 -04:00
|
|
|
|
|
|
|
|
return (
|
2024-10-19 14:30:52 +02:00
|
|
|
<div className="flex items-center justify-between">
|
|
|
|
|
<Label className="font-light">{localize('com_nav_clear_all_chats')}</Label>
|
|
|
|
|
<OGDialog open={open} onOpenChange={setOpen}>
|
|
|
|
|
<OGDialogTrigger asChild>
|
|
|
|
|
<Button
|
|
|
|
|
variant="destructive"
|
|
|
|
|
className="flex items-center justify-center rounded-lg transition-colors duration-200"
|
|
|
|
|
onClick={() => setOpen(true)}
|
|
|
|
|
>
|
|
|
|
|
{localize('com_ui_delete')}
|
|
|
|
|
</Button>
|
|
|
|
|
</OGDialogTrigger>
|
|
|
|
|
<OGDialogTemplate
|
|
|
|
|
showCloseButton={false}
|
|
|
|
|
title={localize('com_nav_confirm_clear')}
|
|
|
|
|
className="max-w-[450px]"
|
|
|
|
|
main={
|
|
|
|
|
<Label className="text-left text-sm font-medium">
|
|
|
|
|
{localize('com_nav_clear_conversation_confirm_message')}
|
|
|
|
|
</Label>
|
|
|
|
|
}
|
|
|
|
|
selection={{
|
|
|
|
|
selectHandler: clearConvos,
|
|
|
|
|
selectClasses:
|
|
|
|
|
'bg-destructive text-white transition-all duration-200 hover:bg-destructive/80',
|
|
|
|
|
selectText: clearConvosMutation.isLoading ? <Spinner /> : localize('com_ui_delete'),
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</OGDialog>
|
|
|
|
|
</div>
|
🌿 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
2024-05-05 11:48:20 -04:00
|
|
|
);
|
|
|
|
|
};
|