feat: Add delete session in the sessions menu. (#1557)
Signed-off-by: Paolo Insogna <paolo@cowtech.it> Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
This commit is contained in:
committed by
GitHub
co-authored by
Bohdan Triapitsyn
parent
a0597b1065
commit
b1810013e5
@@ -81,7 +81,7 @@ type Props = {
|
||||
addSessionToFolder: (scopeKey: string, folderId: string, sessionId: string) => void;
|
||||
createFolderAndStartRename: (scopeKey: string, parentId?: string | null) => { id: string } | null;
|
||||
openContextPanelTab: (directory: string, options: { mode: 'chat'; dedupeKey: string; label: string; readOnly?: boolean }) => void;
|
||||
handleDeleteSession: (session: Session, source?: { archivedBucket?: boolean }) => void;
|
||||
handleDeleteSession: (session: Session, source?: { archivedBucket?: boolean; hardDelete?: boolean }) => void;
|
||||
mobileVariant: boolean;
|
||||
alwaysShowActions: boolean;
|
||||
renderSessionNode: (node: SessionNode, depth?: number, groupDirectory?: string | null, projectId?: string | null, archivedBucket?: boolean, secondaryMeta?: SecondaryMeta | null, renderContext?: 'project' | 'recent') => React.ReactNode;
|
||||
@@ -849,9 +849,15 @@ function SessionNodeItemComponent(props: Props): React.ReactNode {
|
||||
) : null}
|
||||
|
||||
<Separator />
|
||||
<Item className="text-destructive focus:text-destructive [&>svg]:mr-1" onClick={() => handleDeleteSession(session, { archivedBucket })}>
|
||||
<Icon name={archivedBucket ? "delete-bin" : "archive"} className="mr-1 h-4 w-4" />
|
||||
{archivedBucket ? t('sessions.sidebar.bulkActions.delete') : t('sessions.sidebar.bulkActions.archive')}
|
||||
{!archivedBucket ? (
|
||||
<Item className="[&>svg]:mr-1" onClick={() => handleDeleteSession(session, { archivedBucket })}>
|
||||
<Icon name="inbox-archive" className="mr-1 h-4 w-4" />
|
||||
{t('sessions.sidebar.bulkActions.archive')}
|
||||
</Item>
|
||||
) : null}
|
||||
<Item className="text-destructive focus:text-destructive [&>svg]:mr-1" onClick={() => handleDeleteSession(session, { archivedBucket, hardDelete: true })}>
|
||||
<Icon name="delete-bin" className="mr-1 h-4 w-4" />
|
||||
{t('sessions.sidebar.bulkActions.delete')}
|
||||
</Item>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -12,6 +12,11 @@ type DeleteSessionConfirmSetter = React.Dispatch<React.SetStateAction<{
|
||||
archivedBucket: boolean;
|
||||
} | null>>;
|
||||
|
||||
type DeleteSessionSource = {
|
||||
archivedBucket?: boolean;
|
||||
hardDelete?: boolean;
|
||||
};
|
||||
|
||||
type Args = {
|
||||
activeProjectId: string | null;
|
||||
currentDirectory: string | null;
|
||||
@@ -187,10 +192,10 @@ export const useSessionActions = (args: Args) => {
|
||||
const executeDeleteSession = React.useCallback(
|
||||
async (
|
||||
session: Session,
|
||||
source?: { archivedBucket?: boolean },
|
||||
source?: DeleteSessionSource,
|
||||
precomputed?: { descendantIds: string[] },
|
||||
) => {
|
||||
const shouldHardDelete = source?.archivedBucket === true;
|
||||
const shouldHardDelete = source?.archivedBucket === true || source?.hardDelete === true;
|
||||
// Use the snapshot taken when the dialog opened (if any) so the
|
||||
// executed list matches what the user was told. Fall back to a fresh
|
||||
// collection for direct-execute (no-dialog) callers.
|
||||
@@ -246,8 +251,8 @@ export const useSessionActions = (args: Args) => {
|
||||
);
|
||||
|
||||
const handleDeleteSession = React.useCallback(
|
||||
(session: Session, source?: { archivedBucket?: boolean }) => {
|
||||
const shouldHardDelete = source?.archivedBucket === true;
|
||||
(session: Session, source?: DeleteSessionSource) => {
|
||||
const shouldHardDelete = source?.archivedBucket === true || source?.hardDelete === true;
|
||||
const effectiveDescendantIds = filterDescendantsForAction(
|
||||
collectDescendants(session.id),
|
||||
shouldHardDelete,
|
||||
|
||||
Reference in New Issue
Block a user