feat: Add functionality to delete session in history list view (#4480)

Signed-off-by: Abhijay007 <Abhijay007j@gmail.com>
Co-authored-by: Zane Staggs <zane@squareup.com>
This commit is contained in:
Abhijay Jain
2025-09-03 21:27:18 +05:30
committed by GitHub
parent 1b59d12a50
commit 96d2b6fa92
4 changed files with 163 additions and 14 deletions
+27
View File
@@ -151,3 +151,30 @@ export function resumeSession(session: SessionDetails | Session) {
resumedSessionId
);
}
/**
* Deletes a specific session
* @param sessionId The ID of the session to delete
* @returns Promise that resolves when the deletion is complete
*/
export async function deleteSession(sessionId: string): Promise<void> {
try {
const url = getApiUrl(`/sessions/${sessionId}/delete`);
const secretKey = await window.electron.getSecretKey();
const response = await fetch(url, {
method: 'DELETE',
headers: {
'X-Secret-Key': secretKey,
},
});
if (!response.ok) {
const errorText = await response.text();
throw new Error(`Failed to delete session: ${response.statusText} - ${errorText}`);
}
} catch (error) {
console.error(`Error deleting session ${sessionId}:`, error);
throw error;
}
}