MCPcopy Create free account
hub / github.com/enowdev/enowX-Coder / handleNewSession

Function handleNewSession

src/components/sidebar/SessionList.tsx:38–54  ·  view source on GitHub ↗
(e: React.MouseEvent, projectId: string)

Source from the content-addressed store, hash-verified

36 };
37
38 const handleNewSession = async (e: React.MouseEvent, projectId: string) => {
39 e.stopPropagation();
40 const now = new Date().toISOString();
41 const session = { id: generateId(), projectId, title: 'New Chat', createdAt: now, updatedAt: now };
42 addSession(session);
43 setActiveSessionId(session.id);
44 setExpandedProjects((prev) => new Set(prev).add(projectId));
45
46 try {
47 const createdSession = await invoke<Session>('create_session', { projectId, title: 'New Chat' });
48 const currentSessions = useSessionStore.getState().sessions;
49 setSessions(currentSessions.map((existing) => (existing.id === session.id ? createdSession : existing)));
50 setActiveSessionId(createdSession.id);
51 } catch (error) {
52 console.error('Failed to persist session creation:', error);
53 }
54 };
55
56 const handleDeleteSession = (e: React.MouseEvent, sessionId: string) => {
57 e.stopPropagation();

Callers 1

SessionListFunction · 0.85

Calls 1

generateIdFunction · 0.90

Tested by

no test coverage detected