chat sessions in project view

This commit is contained in:
Storme-bit
2026-04-14 02:03:54 -07:00
parent 996db6d4f1
commit eb702624c3
6 changed files with 18 additions and 18 deletions

View File

@@ -186,21 +186,21 @@ export async function fetchProjects() {
return res.json(); return res.json();
} }
export async function createProject({ name, description, colour, icon, projectOnly }) { export async function createProject({ name, description, colour, icon, isolated }) {
const res = await fetch(`${BASE_URL}/projects`, { const res = await fetch(`${BASE_URL}/projects`, {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name, description, colour, icon, projectOnly: projectOnly ? 1 : 0 }), body: JSON.stringify({ name, description, colour, icon, isolated: isolated ? 1 : 0 }),
}); });
if (!res.ok) throw new Error(`Failed to create project: ${res.status}`); if (!res.ok) throw new Error(`Failed to create project: ${res.status}`);
return res.json(); return res.json();
} }
export async function updateProject(id, { name, description, colour, icon, projectOnly }) { export async function updateProject(id, { name, description, colour, icon, isolated }) {
const res = await fetch(`${BASE_URL}/projects/${id}`, { const res = await fetch(`${BASE_URL}/projects/${id}`, {
method: 'PATCH', method: 'PATCH',
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name, description, colour, icon, projectOnly: projectOnly ? 1 : 0}), body: JSON.stringify({ name, description, colour, icon, isolated: isolated ? 1 : 0}),
}); });
if (!res.ok) throw new Error(`Failed to update project: ${res.status}`); if (!res.ok) throw new Error(`Failed to update project: ${res.status}`);
return res.json(); return res.json();

View File

@@ -6,7 +6,7 @@ export default function ProjectModal({ project, mode, onSave, onDelete, onClose
const [name, setName] = useState(project?.name ?? ''); const [name, setName] = useState(project?.name ?? '');
const [description, setDescription] = useState(project?.description ?? ''); const [description, setDescription] = useState(project?.description ?? '');
const [colour, setColour] = useState(project?.colour ?? COLOURS[0]); const [colour, setColour] = useState(project?.colour ?? COLOURS[0]);
const [projectOnly, setProjectOnly] = useState(project?.projectOnly === 1); const [isolated, setIsolated] = useState(project?.isolated === 1);
const inputRef = useRef(null); const inputRef = useRef(null);
useEffect(() => { useEffect(() => {
@@ -16,7 +16,7 @@ export default function ProjectModal({ project, mode, onSave, onDelete, onClose
function handleSubmit() { function handleSubmit() {
const trimmed = name.trim(); const trimmed = name.trim();
if (!trimmed) return; if (!trimmed) return;
onSave({ name: trimmed, description: description.trim() || null, colour, icon: null, projectOnly }); onSave({ name: trimmed, description: description.trim() || null, colour, icon: null, isolated });
onClose(); onClose();
} }
@@ -131,20 +131,20 @@ export default function ProjectModal({ project, mode, onSave, onDelete, onClose
</div> </div>
<button <button
type="button" type="button"
onClick={() => setProjectOnly(i => !i)} onClick={() => setIsolated(i => !i)}
style={{ style={{
width: '40px', height: '22px', borderRadius: '11px', flexShrink: 0, width: '40px', height: '22px', borderRadius: '11px', flexShrink: 0,
background: projectOnly ? 'var(--accent-hover)' : 'var(--bg-elevated)', background: isolated ? 'var(--accent-hover)' : 'var(--bg-elevated)',
border: '1px solid var(--border)', border: '1px solid var(--border)',
position: 'relative', cursor: 'pointer', transition: 'background 0.2s', position: 'relative', cursor: 'pointer', transition: 'background 0.2s',
}} }}
> >
<span style={{ <span style={{
position: 'absolute', top: '3px', position: 'absolute', top: '3px',
left: projectOnly ? '20px' : '3px', left: isolated ? '20px' : '3px',
width: '14px', height: '14px', width: '14px', height: '14px',
borderRadius: '50%', borderRadius: '50%',
background: projectOnly ? 'white' : 'var(--text-muted)', background: isolated ? 'white' : 'var(--text-muted)',
transition: 'left 0.2s', transition: 'left 0.2s',
}} /> }} />
</button> </button>

View File

@@ -72,7 +72,7 @@ export default function ProjectView({ project, onNavigate, onSelectSession, onNe
<h1 style={{ fontSize: '22px', fontWeight: 600, color: 'var(--text-primary)' }}> <h1 style={{ fontSize: '22px', fontWeight: 600, color: 'var(--text-primary)' }}>
{project.name} {project.name}
</h1> </h1>
{project.projectOnly === 1 && ( {project.isolated === 1 && (
<span style={{ <span style={{
fontSize: '11px', fontWeight: 500, fontSize: '11px', fontWeight: 500,
padding: '2px 8px', borderRadius: '99px', padding: '2px 8px', borderRadius: '99px',

BIN
packages/files.zip Normal file

Binary file not shown.

View File

@@ -1,12 +1,12 @@
const { getDB } = require('./index'); const { getDB } = require('./index');
const { parseRow } = require('@nexusai/shared'); const { parseRow } = require('@nexusai/shared');
function createProject({ name, description, colour, icon, projectOnly }) { function createProject({ name, description, colour, icon, isolated }) {
const db = getDB(); const db = getDB();
const result = db.prepare(` const result = db.prepare(`
INSERT INTO projects (name, description, colour, icon) INSERT INTO projects (name, description, colour, icon)
VALUES (?, ?, ?, ?) VALUES (?, ?, ?, ?)
`).run(name, description ?? null, colour ?? null, icon ?? null, projectOnly ?? 0); `).run(name, description ?? null, colour ?? null, icon ?? null, isolated ?? 0);
return getProject(result.lastInsertRowid); return getProject(result.lastInsertRowid);
} }
@@ -20,12 +20,12 @@ function getProject(id) {
return parseRow(db.prepare(`SELECT * FROM projects WHERE id = ?`).get(id)); return parseRow(db.prepare(`SELECT * FROM projects WHERE id = ?`).get(id));
} }
function updateProject(id, { name, description, colour, icon, projectOnly }) { function updateProject(id, { name, description, colour, icon, isolated }) {
const db = getDB(); const db = getDB();
db.prepare(` db.prepare(`
UPDATE projects SET name = ?, description = ?, colour = ?, icon = ?, projectOnly = ? UPDATE projects SET name = ?, description = ?, colour = ?, icon = ?, isolated = ?
WHERE id = ? WHERE id = ?
`).run(name, description ?? null, colour ?? null, icon ?? null, projectOnly ?? 0, id); `).run(name, description ?? null, colour ?? null, icon ?? null, isolated ?? 0, id);
return getProject(id); return getProject(id);
} }

View File

@@ -12,10 +12,10 @@ router.get('/', async (req, res) => {
}); });
router.post('/', async (req, res) => { router.post('/', async (req, res) => {
const { name, description, colour, icon, projectOnly } = req.body; const { name, description, colour, icon, isolated } = req.body;
if (!name?.trim()) return res.status(400).json({ error: 'name is required' }); if (!name?.trim()) return res.status(400).json({ error: 'name is required' });
try { try {
res.status(201).json(await memory.createProject({ name: name.trim(), description, colour, icon, projectOnly })); res.status(201).json(await memory.createProject({ name: name.trim(), description, colour, icon, isolated }));
} catch (err) { } catch (err) {
res.status(500).json({ error: err.message }); res.status(500).json({ error: err.message });
} }