feat: independent project creation + canvas filtering#11
Conversation
- Schema: project.directory_key nullable, add user_created column - Migration 0006: rename-recreate for SQLite - POST /api/project: create project with name + optional directory - POST /api/session: accept optional projectId for assignment - Store: extract rebuildGraph helper (replaces 9 duplicate buildGraph calls), filter sessions by activeProjectKey, setActiveProjectKey triggers rebuild, add createProject action - HomeScreen: + New Project input/button, improved empty state CTA - Canvas: pass activeProjectKey as projectId on session creation
There was a problem hiding this comment.
Code Review
This pull request enables manual project creation and session association by updating the database schema, adding a creation UI to the Home Screen, and implementing the necessary backend routes. Feedback suggests improving the user experience by providing UI feedback for failed project creations and handling database unique constraint violations on the server to prevent internal errors.
| } catch (err) { | ||
| console.error('[HomeScreen] create project failed', err) | ||
| } finally { |
There was a problem hiding this comment.
The error handling for project creation only logs to the console. If the API call fails (e.g., due to a network issue or a duplicate directory key on the server), the user will see the button stop loading but won't know why the project wasn't created. Consider adding a simple error state or a toast notification to inform the user.
| if (typeof body.name !== 'string' || !body.name.trim()) { | ||
| return c.json({ error: 'name is required' }, 400) | ||
| } | ||
| const proj = createProject(body.name.trim(), body.directory?.trim() || null) |
There was a problem hiding this comment.
The createProject call can throw a SqliteError if the provided directory key already exists in the database (due to the UNIQUE constraint). This would result in a 500 Internal Server Error. It's better to check for existence first or catch the error and return a 409 Conflict or 400 Bad Request with a descriptive message.
Closes #10
What
project.directory_keynullable,user_createdcolumn (0=auto, 1=user)POST /api/projectfor explicit creation,POST /api/sessionacceptsprojectIdrebuildGraphhelper (replaces 9 duplicatebuildGraphcalls), filter byactiveProjectKey,setActiveProjectKeytriggers rebuild,createProjectactionactiveProjectKeyasprojectIdon session creationWhy
Fresh installs show an empty HomeScreen with no way to create projects — projects were auto-derived from sessions. Now projects are first-class entities (Figma-like). Auto-grouping kept as fallback for CLI-originated sessions.
Test plan
pnpm testpasses (72 tests)pnpm exec tsc --noEmitpassespnpm exec tsc --noEmit -p tsconfig.client.jsonpasses