akseljoonas HF Staff commited on
Commit
1ba32b8
·
1 Parent(s): 2b4acb6

Add delete confirmation dialog and sidebar spacing tweaks

Browse files

Show a confirmation dialog before deleting a conversation. Add
spacing between sidebar chat items and below the section header.
Show fun placeholder in output panel for running tools.

frontend/src/components/SessionSidebar/SessionSidebar.tsx CHANGED
@@ -2,6 +2,12 @@ import { useCallback, useState } from 'react';
2
  import {
3
  Alert,
4
  Box,
 
 
 
 
 
 
5
  IconButton,
6
  Typography,
7
  CircularProgress,
@@ -51,20 +57,30 @@ export default function SessionSidebar({ onClose }: SessionSidebarProps) {
51
  }
52
  }, [isCreatingSession, createSession, setPlan, clearPanel, onClose]);
53
 
54
- const handleDelete = useCallback(
55
- async (sessionId: string, e: React.MouseEvent) => {
 
 
 
56
  e.stopPropagation();
57
- useAgentStore.getState().clearSessionState(sessionId);
58
- try {
59
- await apiFetch(`/api/session/${sessionId}`, { method: 'DELETE' });
60
- deleteSession(sessionId);
61
- } catch {
62
- deleteSession(sessionId);
63
- }
64
  },
65
- [deleteSession],
66
  );
67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  const handleSelect = useCallback(
69
  (sessionId: string) => {
70
  switchSession(sessionId);
@@ -181,6 +197,7 @@ export default function SessionSidebar({ onClose }: SessionSidebarProps) {
181
  px: 1.5,
182
  py: 0.875,
183
  mx: 0.75,
 
184
  borderRadius: '10px',
185
  cursor: 'pointer',
186
  transition: 'background-color 0.12s ease',
@@ -256,7 +273,7 @@ export default function SessionSidebar({ onClose }: SessionSidebarProps) {
256
  <IconButton
257
  className="delete-btn"
258
  size="small"
259
- onClick={(e) => handleDelete(session.id, e)}
260
  sx={{
261
  color: 'var(--muted-text)',
262
  width: 26,
@@ -328,6 +345,81 @@ export default function SessionSidebar({ onClose }: SessionSidebarProps) {
328
  </Box>
329
 
330
  </Box>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
331
  </Box>
332
  );
333
  }
 
2
  import {
3
  Alert,
4
  Box,
5
+ Button,
6
+ Dialog,
7
+ DialogActions,
8
+ DialogContent,
9
+ DialogContentText,
10
+ DialogTitle,
11
  IconButton,
12
  Typography,
13
  CircularProgress,
 
57
  }
58
  }, [isCreatingSession, createSession, setPlan, clearPanel, onClose]);
59
 
60
+ // -- Delete with dialog confirmation ------------------------------------
61
+ const [confirmDeleteId, setConfirmDeleteId] = useState<string | null>(null);
62
+
63
+ const handleDeleteClick = useCallback(
64
+ (sessionId: string, e: React.MouseEvent) => {
65
  e.stopPropagation();
66
+ setConfirmDeleteId(sessionId);
 
 
 
 
 
 
67
  },
68
+ [],
69
  );
70
 
71
+ const handleDeleteConfirm = useCallback(async () => {
72
+ if (!confirmDeleteId) return;
73
+ const sessionId = confirmDeleteId;
74
+ setConfirmDeleteId(null);
75
+ useAgentStore.getState().clearSessionState(sessionId);
76
+ try {
77
+ await apiFetch(`/api/session/${sessionId}`, { method: 'DELETE' });
78
+ deleteSession(sessionId);
79
+ } catch {
80
+ deleteSession(sessionId);
81
+ }
82
+ }, [deleteSession, confirmDeleteId]);
83
+
84
  const handleSelect = useCallback(
85
  (sessionId: string) => {
86
  switchSession(sessionId);
 
197
  px: 1.5,
198
  py: 0.875,
199
  mx: 0.75,
200
+ mb: 0.2,
201
  borderRadius: '10px',
202
  cursor: 'pointer',
203
  transition: 'background-color 0.12s ease',
 
273
  <IconButton
274
  className="delete-btn"
275
  size="small"
276
+ onClick={(e) => handleDeleteClick(session.id, e)}
277
  sx={{
278
  color: 'var(--muted-text)',
279
  width: 26,
 
345
  </Box>
346
 
347
  </Box>
348
+ {/* Delete confirmation dialog */}
349
+ <Dialog
350
+ open={!!confirmDeleteId}
351
+ onClose={() => setConfirmDeleteId(null)}
352
+ slotProps={{
353
+ backdrop: { sx: { backgroundColor: 'rgba(0,0,0,0.5)', backdropFilter: 'blur(4px)' } },
354
+ }}
355
+ PaperProps={{
356
+ sx: {
357
+ bgcolor: 'var(--panel)',
358
+ border: '1px solid var(--border)',
359
+ borderRadius: 'var(--radius-md)',
360
+ boxShadow: 'var(--shadow-1)',
361
+ maxWidth: 340,
362
+ mx: 2,
363
+ },
364
+ }}
365
+ >
366
+ <DialogTitle
367
+ sx={{
368
+ color: 'var(--text)',
369
+ fontWeight: 700,
370
+ fontSize: '0.95rem',
371
+ pb: 0,
372
+ pt: 2.5,
373
+ px: 3,
374
+ }}
375
+ >
376
+ Delete conversation?
377
+ </DialogTitle>
378
+ <DialogContent sx={{ px: 3, pt: 1 }}>
379
+ <DialogContentText
380
+ sx={{
381
+ color: 'var(--muted-text)',
382
+ fontSize: '0.82rem',
383
+ lineHeight: 1.6,
384
+ }}
385
+ >
386
+ This will permanently remove this conversation and its history.
387
+ </DialogContentText>
388
+ </DialogContent>
389
+ <DialogActions sx={{ px: 3, pb: 2.5, gap: 1 }}>
390
+ <Button
391
+ onClick={() => setConfirmDeleteId(null)}
392
+ size="small"
393
+ sx={{
394
+ color: 'var(--muted-text)',
395
+ fontSize: '0.82rem',
396
+ px: 2,
397
+ '&:hover': { bgcolor: 'var(--hover-bg)' },
398
+ }}
399
+ >
400
+ Cancel
401
+ </Button>
402
+ <Button
403
+ onClick={handleDeleteConfirm}
404
+ variant="contained"
405
+ size="small"
406
+ sx={{
407
+ fontSize: '0.82rem',
408
+ px: 2.5,
409
+ bgcolor: 'var(--accent-red)',
410
+ color: '#fff',
411
+ boxShadow: 'none',
412
+ '&:hover': {
413
+ bgcolor: 'var(--accent-red)',
414
+ filter: 'brightness(1.15)',
415
+ boxShadow: 'none',
416
+ },
417
+ }}
418
+ >
419
+ Delete
420
+ </Button>
421
+ </DialogActions>
422
+ </Dialog>
423
  </Box>
424
  );
425
  }