updated orchestion to handle updating and deleting sessions
This commit is contained in:
@@ -142,4 +142,21 @@ export async function fetchModels() {
|
||||
const res = await fetch(`${BASE_URL}/models`);
|
||||
if(!res.ok) throw new Error(`Failted to fetch models: ${res.status}`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function renameSession(sessionId, name) {
|
||||
const res = await fetch(`${BASE_URL}/sessions/${sessionId}`, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ name }),
|
||||
});
|
||||
if (!res.ok) throw new Error(`Failed to rename session: ${res.status}`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function deleteSession(sessionId) {
|
||||
const res = await fetch(`${BASE_URL}/sessions/${sessionId}`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
if (!res.ok) throw new Error(`Failed to delete session: ${res.status}`);
|
||||
}
|
||||
22
packages/chat-client/src/hooks/useContextMenu.js
Normal file
22
packages/chat-client/src/hooks/useContextMenu.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
|
||||
export function useContextMenu() {
|
||||
const [menu, setMenu] = useState(null); // { x, y, session }
|
||||
|
||||
const open = useCallback((e, session) => {
|
||||
e.preventDefault();
|
||||
setMenu({ x: e.clientX, y: e.clientY, session });
|
||||
}, []);
|
||||
|
||||
const close = useCallback(() => setMenu(null), []);
|
||||
|
||||
// Close on any click outside
|
||||
useEffect(() => {
|
||||
if (!menu) return;
|
||||
const handler = () => close();
|
||||
window.addEventListener('click', handler);
|
||||
return () => window.removeEventListener('click', handler);
|
||||
}, [menu, close]);
|
||||
|
||||
return { menu, open, close };
|
||||
}
|
||||
Reference in New Issue
Block a user