Delete a GUI chat session and its messages.
(user_id: str, session_id: str)
| 487 | |
| 488 | |
| 489 | def delete_chat_session(user_id: str, session_id: str) -> bool: |
| 490 | """Delete a GUI chat session and its messages.""" |
| 491 | normalized_user_id = _normalize_identifier(user_id) |
| 492 | normalized_session_id = _normalize_identifier(session_id) |
| 493 | if not normalized_user_id or not normalized_session_id: |
| 494 | raise ValueError("user_id and session_id are required") |
| 495 | |
| 496 | ensure_chat_tables() |
| 497 | conn = get_connection() |
| 498 | cursor = conn.cursor() |
| 499 | cursor.execute( |
| 500 | "DELETE FROM chat_messages WHERE user_id = ? AND session_id = ?", |
| 501 | (normalized_user_id, normalized_session_id), |
| 502 | ) |
| 503 | cursor.execute( |
| 504 | "DELETE FROM chat_sessions WHERE user_id = ? AND session_id = ?", |
| 505 | (normalized_user_id, normalized_session_id), |
| 506 | ) |
| 507 | deleted = cursor.rowcount > 0 |
| 508 | conn.commit() |
| 509 | conn.close() |
| 510 | return deleted |
| 511 | |
| 512 | |
| 513 | def clear_chat_sessions(user_id: str) -> int: |
nothing calls this directly
no test coverage detected