From c892f54a0494ddd7ed6bda4c5c815205080c2c80 Mon Sep 17 00:00:00 2001 From: Storme-bit Date: Tue, 14 Apr 2026 01:52:11 -0700 Subject: [PATCH] chat sessions in project view --- packages/chat-client/src/App.jsx | 28 +++- packages/chat-client/src/api/orchestration.js | 8 +- .../src/components/ProjectModal.jsx | 30 +++- .../src/components/ProjectView.jsx | 146 ++++++++++++++++++ .../chat-client/src/components/Sidebar.jsx | 3 +- packages/chat-client/src/hooks/useChat.js | 8 +- packages/chat-client/src/hooks/useSession.js | 1 + packages/memory-service/src/db/projects.js | 10 +- .../src/routes/projects.js | 4 +- 9 files changed, 223 insertions(+), 15 deletions(-) create mode 100644 packages/chat-client/src/components/ProjectView.jsx diff --git a/packages/chat-client/src/App.jsx b/packages/chat-client/src/App.jsx index 3824fdd..982dbd2 100644 --- a/packages/chat-client/src/App.jsx +++ b/packages/chat-client/src/App.jsx @@ -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 (
@@ -96,6 +113,15 @@ export default function App() { )} {view === 'settings' && } + + {view === 'project' && activeProject && ( + + )} { @@ -15,7 +16,7 @@ export default function ProjectModal({ project, mode, onSave, onDelete, onClose function handleSubmit() { const trimmed = name.trim(); if (!trimmed) return; - onSave({ name: trimmed, description: description.trim() || null, colour, icon: null }); + onSave({ name: trimmed, description: description.trim() || null, colour, icon: null, projectOnly }); onClose(); } @@ -122,6 +123,33 @@ export default function ProjectModal({ project, mode, onSave, onDelete, onClose
+ {/* Project-Only toggle */} +
+
+ + Limit context to this project only +
+ +
+
+ +
+ + {/* Content */} +
+ + {/* Project title + meta */} +
+
+

+ {project.name} +

+ {project.projectOnly === 1 && ( + + Project Only + + )} +
+ {project.description && ( +

+ {project.description} +

+ )} +
+ + {/* Sessions list */} +
+

Conversations

+ {loading ? ( +
Loading...
+ ) : sessions.length === 0 ? ( +
+

No conversations in this project yet

+

+ Click "+ New Chat" to start one +

+
+ ) : ( +
+ {sessions.map((session, i) => ( + + ))} +
+ )} +
+
+ + ); +} \ No newline at end of file diff --git a/packages/chat-client/src/components/Sidebar.jsx b/packages/chat-client/src/components/Sidebar.jsx index e38cd08..3b1c41b 100644 --- a/packages/chat-client/src/components/Sidebar.jsx +++ b/packages/chat-client/src/components/Sidebar.jsx @@ -16,6 +16,7 @@ export default function Sidebar({ onNavigate, projects, onProjectsChange, + onSelectProject }) { const [chatsOpen, setChatsOpen] = useState(true); const [projectsOpen, setProjectsOpen] = useState(true); @@ -158,7 +159,7 @@ export default function Sidebar({ {projects.slice(0, 6).map(project => (