feat: add session auto-cleanup settings and functionality
This commit is contained in:
@@ -653,13 +653,19 @@ export const useSessionStore = create<SessionStore>()(
|
||||
}
|
||||
},
|
||||
|
||||
deleteSessions: async (ids: string[], options) => {
|
||||
deleteSessions: async (
|
||||
ids: string[],
|
||||
options?: { archiveWorktree?: boolean; deleteRemoteBranch?: boolean; remoteName?: string; silent?: boolean }
|
||||
) => {
|
||||
const uniqueIds = Array.from(new Set(ids.filter((id): id is string => typeof id === "string" && id.length > 0)));
|
||||
if (uniqueIds.length === 0) {
|
||||
return { deletedIds: [], failedIds: [] };
|
||||
}
|
||||
|
||||
set({ isLoading: true, error: null });
|
||||
const silent = options?.silent === true;
|
||||
if (!silent) {
|
||||
set({ isLoading: true, error: null });
|
||||
}
|
||||
const deletedIds: string[] = [];
|
||||
const failedIds: string[] = [];
|
||||
const archivedIds = new Set<string>();
|
||||
@@ -743,10 +749,9 @@ export const useSessionStore = create<SessionStore>()(
|
||||
return {
|
||||
sessions: filteredSessions,
|
||||
currentSessionId: nextCurrentId,
|
||||
isLoading: false,
|
||||
...(silent ? {} : { isLoading: false, error: errorMessage }),
|
||||
worktreeMetadata: nextMetadata,
|
||||
availableWorktrees: nextAvailableWorktrees,
|
||||
error: errorMessage,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ export interface SessionStore {
|
||||
createSessionFromAssistantMessage: (sourceMessageId: string) => Promise<void>;
|
||||
|
||||
deleteSession: (id: string, options?: { archiveWorktree?: boolean; deleteRemoteBranch?: boolean; remoteName?: string }) => Promise<boolean>;
|
||||
deleteSessions: (ids: string[], options?: { archiveWorktree?: boolean; deleteRemoteBranch?: boolean; remoteName?: string }) => Promise<{ deletedIds: string[]; failedIds: string[] }>;
|
||||
deleteSessions: (ids: string[], options?: { archiveWorktree?: boolean; deleteRemoteBranch?: boolean; remoteName?: string; silent?: boolean }) => Promise<{ deletedIds: string[]; failedIds: string[] }>;
|
||||
updateSessionTitle: (id: string, title: string) => Promise<void>;
|
||||
shareSession: (id: string) => Promise<Session | null>;
|
||||
unshareSession: (id: string) => Promise<Session | null>;
|
||||
|
||||
@@ -33,6 +33,9 @@ interface UIStore {
|
||||
eventStreamStatus: EventStreamStatus;
|
||||
eventStreamHint: string | null;
|
||||
showReasoningTraces: boolean;
|
||||
autoDeleteEnabled: boolean;
|
||||
autoDeleteAfterDays: number;
|
||||
autoDeleteLastRunAt: number | null;
|
||||
|
||||
toolCallExpansion: 'collapsed' | 'activity' | 'detailed';
|
||||
fontSize: number;
|
||||
@@ -66,6 +69,9 @@ interface UIStore {
|
||||
setSidebarSection: (section: SidebarSection) => void;
|
||||
setEventStreamStatus: (status: EventStreamStatus, hint?: string | null) => void;
|
||||
setShowReasoningTraces: (value: boolean) => void;
|
||||
setAutoDeleteEnabled: (value: boolean) => void;
|
||||
setAutoDeleteAfterDays: (days: number) => void;
|
||||
setAutoDeleteLastRunAt: (timestamp: number | null) => void;
|
||||
setToolCallExpansion: (value: 'collapsed' | 'activity' | 'detailed') => void;
|
||||
setFontSize: (size: number) => void;
|
||||
setPadding: (size: number) => void;
|
||||
@@ -102,6 +108,9 @@ export const useUIStore = create<UIStore>()(
|
||||
eventStreamStatus: 'idle',
|
||||
eventStreamHint: null,
|
||||
showReasoningTraces: false,
|
||||
autoDeleteEnabled: false,
|
||||
autoDeleteAfterDays: 30,
|
||||
autoDeleteLastRunAt: null,
|
||||
toolCallExpansion: 'collapsed',
|
||||
fontSize: 100,
|
||||
padding: 100,
|
||||
@@ -222,6 +231,19 @@ export const useUIStore = create<UIStore>()(
|
||||
set({ showReasoningTraces: value });
|
||||
},
|
||||
|
||||
setAutoDeleteEnabled: (value) => {
|
||||
set({ autoDeleteEnabled: value });
|
||||
},
|
||||
|
||||
setAutoDeleteAfterDays: (days) => {
|
||||
const clampedDays = Math.max(1, Math.min(365, days));
|
||||
set({ autoDeleteAfterDays: clampedDays });
|
||||
},
|
||||
|
||||
setAutoDeleteLastRunAt: (timestamp) => {
|
||||
set({ autoDeleteLastRunAt: timestamp });
|
||||
},
|
||||
|
||||
setToolCallExpansion: (value) => {
|
||||
set({ toolCallExpansion: value });
|
||||
},
|
||||
@@ -399,6 +421,9 @@ export const useUIStore = create<UIStore>()(
|
||||
isSessionCreateDialogOpen: state.isSessionCreateDialogOpen,
|
||||
isSettingsDialogOpen: state.isSettingsDialogOpen,
|
||||
showReasoningTraces: state.showReasoningTraces,
|
||||
autoDeleteEnabled: state.autoDeleteEnabled,
|
||||
autoDeleteAfterDays: state.autoDeleteAfterDays,
|
||||
autoDeleteLastRunAt: state.autoDeleteLastRunAt,
|
||||
toolCallExpansion: state.toolCallExpansion,
|
||||
fontSize: state.fontSize,
|
||||
padding: state.padding,
|
||||
|
||||
Reference in New Issue
Block a user