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:
duanshuwen
2026-04-21 21:41:18 +08:00
parent db93888921
commit f9c331315b
7 changed files with 188 additions and 820 deletions

View File

@@ -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 {