Server:
- projects.status + projects.gitea_remote (additive) with CHECK ('open','archived')
- GET /api/projects?status=archived; PATCH /api/projects/:id (rename);
POST /api/projects/:id/archive | unarchive; POST /api/projects/create
- POST /api/projects ON CONFLICT (path) DO UPDATE SET status='open': re-add
of archived path restores existing row (preserves id + FKs); already-open
path returns 409. Detected-repos picker now excludes only status='open'.
- New gitea.ts (createGiteaRepo + GiteaRepoExistsError) and
project_bootstrap.ts (sanitize name, mkdir under PROJECT_ROOT_WHITELIST,
git init -b main + first commit with -c user.name/email per-command, optional
Gitea repo create + remote add + push; all via execFile, no shell).
- 3 new user-stream frames: project_archived, project_unarchived, project_updated.
- sidebar.ts now selects path + gitea_remote and filters status='open'.
- Gitea env added to config.ts (GITEA_BASE_URL, GITEA_USER, GITEA_TOKEN,
GITEA_SSH_HOST).
- docker-compose.yml /opt mount flipped to rw so create-project can mkdir.
- auto_name.ts gate relaxed from `!== 1` to `< 1` (fires on every turn while
chat name is empty, not only the first).
Web:
- ProjectSidebar: project rows use proper Radix ContextMenu; items Rename /
Archive / Open in Gitea. Inline rename, archive confirm dialog.
Removed obsolete handleRemove + DropdownMenu hack.
- Home: Add-existing + Create-new buttons; collapsible Archived Projects
section with Restore.
- New CreateProjectModal: name + live folder preview, commit msg, Private/
Public radio, create-Gitea-remote checkbox, toast on success/warnings.
- New projectUrls.ts giteaUrlFor() — uses gitea_remote when present,
falls back to convention URL.
- 3 new event types in sessionEvents.ts with idempotent useSidebar handlers.
- SidebarProject extended with path + gitea_remote so Open-in-Gitea can
resolve without a separate fetch.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import type { FastifyInstance } from 'fastify';
|
|
import type { Sql } from '../db.js';
|
|
import type {
|
|
SidebarProject,
|
|
SidebarResponse,
|
|
SidebarSession,
|
|
} from '../types/api.js';
|
|
|
|
export function registerSidebarRoutes(app: FastifyInstance, sql: Sql): void {
|
|
app.get('/api/sidebar', async (): Promise<SidebarResponse> => {
|
|
const projects = await sql<{ id: string; name: string; path: string; gitea_remote: string | null }[]>`
|
|
SELECT id, name, path, gitea_remote
|
|
FROM projects
|
|
WHERE status = 'open'
|
|
ORDER BY added_at DESC
|
|
`;
|
|
|
|
const enriched: SidebarProject[] = await Promise.all(
|
|
projects.map(async (p) => {
|
|
const [recent_sessions, countRows] = await Promise.all([
|
|
sql<SidebarSession[]>`
|
|
SELECT id, project_id, name, model, updated_at
|
|
FROM sessions
|
|
WHERE project_id = ${p.id} AND status = 'open'
|
|
ORDER BY updated_at DESC
|
|
LIMIT 6
|
|
`,
|
|
sql<{ n: number }[]>`
|
|
SELECT COUNT(*)::int AS n
|
|
FROM sessions
|
|
WHERE project_id = ${p.id} AND status = 'open'
|
|
`,
|
|
]);
|
|
return {
|
|
id: p.id,
|
|
name: p.name,
|
|
path: p.path,
|
|
gitea_remote: p.gitea_remote,
|
|
recent_sessions,
|
|
total_sessions: countRows[0]?.n ?? 0,
|
|
};
|
|
})
|
|
);
|
|
|
|
return { projects: enriched };
|
|
});
|
|
}
|