chat sessions in project view

This commit is contained in:
Storme-bit
2026-04-14 01:52:11 -07:00
parent cdd74b5902
commit c892f54a04
9 changed files with 223 additions and 15 deletions

View File

@@ -7,6 +7,7 @@ import Sidebar from './components/Sidebar';
import AllChatsView from './components/AllChatsView';
import AllProjectsView from './components/AllProjectsView';
import SettingsView from './components/SettingsView';
import ProjectView from './components/ProjectView';
/**** useHooks **** */
import { useSession } from './hooks/useSession';
@@ -19,6 +20,7 @@ export default function App() {
const [rightOpen, setRightOpen] = useState(false);
const { models, selectedModel, setSelectedModel } = useModels();
const [view, setView] = useState('chat')
const [activeProject, setActiveProject] = useState(null);
const {projects, refreshProjects} = useProjects();
const {
@@ -42,7 +44,7 @@ export default function App() {
} = useChat({ activeSession, appendMessage, updateLastMessage, refreshSessions });
function handleSendMessage(text) {
sendMessage(text, selectedModel);
sendMessage(text, selectedModel, activeSession?.project_id ?? null);
}
function handleSessionsChange(deletedSession){
@@ -52,6 +54,20 @@ export default function App() {
refreshSessions();
}
async function handleNewProjectChat() {
const newSession = {
external_id: uuidv4(),
metadata: null,
isNew: true,
project_id: activeProject?.id ?? null,
};
// Optimistically set active session then navigate
setSessions(prev => [newSession, ...prev]);
selectSession(newSession);
setView('chat');
// After first message saves, project assignment will be written via updateSession
}
return (
<div style={{
display: 'flex',
@@ -70,6 +86,7 @@ export default function App() {
onNavigate={setView}
projects={projects}
onProjectsChange={refreshProjects}
onSelectProject={setActiveProject}
/>
@@ -96,6 +113,15 @@ export default function App() {
)}
{view === 'settings' && <SettingsView />}
{view === 'project' && activeProject && (
<ProjectView
project={activeProject}
onNavigate={setView}
onSelectSession={selectSession}
onNewProjectChat={handleNewProjectChat}
/>
)}
<InfoPanel