feat: add CronDeleteDialog component and integrate it into CronPage for job deletion
- Implemented a new CronDeleteDialog component for confirming job deletions. - Integrated the CronDeleteDialog into the CronPage, allowing users to delete cron jobs with confirmation. - Refactored job deletion logic to handle state updates and loading indicators during deletion. - Removed unused delivery channel related code from CronPage and CronTaskDialog. - Cleaned up chat store session deletion logic to improve state management and ensure proper session handling.
This commit is contained in:
@@ -656,31 +656,32 @@ function selectAgent(agentId: string): void {
|
||||
}
|
||||
|
||||
async function deleteSession(sessionKey: string): Promise<void> {
|
||||
if (sessionKey === state.currentSessionKey) {
|
||||
const currentState = state;
|
||||
const isDeletingCurrentSession = sessionKey === currentState.currentSessionKey;
|
||||
|
||||
if (isDeletingCurrentSession) {
|
||||
resetPendingStreamingDelta();
|
||||
}
|
||||
|
||||
try {
|
||||
await gatewayRpc('session.delete', { sessionKey });
|
||||
} catch {
|
||||
// keep local cleanup even if gateway delete fails
|
||||
}
|
||||
historyLoadInFlight.delete(sessionKey);
|
||||
lastHistoryLoadAtBySession.delete(sessionKey);
|
||||
|
||||
const remaining = state.sessions.filter((session) => session.key !== sessionKey);
|
||||
const remaining = currentState.sessions.filter((session) => session.key !== sessionKey);
|
||||
const basePatch: Partial<ChatStoreState> = {
|
||||
sessions: remaining,
|
||||
sessionLabels: clearSessionEntryFromMap(state.sessionLabels, sessionKey),
|
||||
sessionLastActivity: clearSessionEntryFromMap(state.sessionLastActivity, sessionKey),
|
||||
sessionLabels: clearSessionEntryFromMap(currentState.sessionLabels, sessionKey),
|
||||
sessionLastActivity: clearSessionEntryFromMap(currentState.sessionLastActivity, sessionKey),
|
||||
};
|
||||
|
||||
if (state.currentSessionKey === sessionKey) {
|
||||
const nextSession = remaining[0]?.key ?? getDefaultMainSessionKey();
|
||||
const hasRemainingSessions = remaining.length > 0;
|
||||
if (isDeletingCurrentSession) {
|
||||
const nextAgentId = getAgentIdFromSessionKey(sessionKey);
|
||||
patchState({
|
||||
...basePatch,
|
||||
currentSessionKey: nextSession,
|
||||
currentAgentId: getAgentIdFromSessionKey(nextSession),
|
||||
currentSessionKey: buildNewSessionKey(nextAgentId),
|
||||
currentAgentId: nextAgentId,
|
||||
messages: [],
|
||||
loading: false,
|
||||
sending: false,
|
||||
streamingMessage: null,
|
||||
streamingTools: [],
|
||||
activeRunId: null,
|
||||
@@ -688,14 +689,15 @@ async function deleteSession(sessionKey: string): Promise<void> {
|
||||
pendingFinal: false,
|
||||
lastUserMessageAt: null,
|
||||
});
|
||||
|
||||
if (hasRemainingSessions && nextSession) {
|
||||
await loadHistory(nextSession);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
patchState(basePatch);
|
||||
}
|
||||
|
||||
patchState(basePatch);
|
||||
try {
|
||||
await gatewayRpc('session.delete', { sessionKey });
|
||||
} catch {
|
||||
// keep local cleanup even if gateway delete fails
|
||||
}
|
||||
}
|
||||
|
||||
function renameSession(sessionKey: string, nextLabel: string): void {
|
||||
|
||||
Reference in New Issue
Block a user