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>
140 lines
2.9 KiB
TypeScript
140 lines
2.9 KiB
TypeScript
// Tiny in-app event bus for session metadata changes that need to propagate
|
|
// across hooks (e.g. AI rename arriving via WS in the session view needs to
|
|
// also refresh the sidebar's session list).
|
|
|
|
import type { Chat, Project, Session } from '@/api/types';
|
|
import type { Attachment } from '@/lib/attachments';
|
|
|
|
export interface SessionRenamedEvent {
|
|
type: 'session_renamed';
|
|
session_id: string;
|
|
name: string;
|
|
}
|
|
|
|
export interface ProjectCreatedEvent {
|
|
type: 'project_created';
|
|
project: Project;
|
|
}
|
|
|
|
export interface ProjectDeletedEvent {
|
|
type: 'project_deleted';
|
|
project_id: string;
|
|
}
|
|
|
|
export interface SessionCreatedEvent {
|
|
type: 'session_created';
|
|
session: Session;
|
|
project_id: string;
|
|
}
|
|
|
|
export interface SessionDeletedEvent {
|
|
type: 'session_deleted';
|
|
session_id: string;
|
|
project_id: string;
|
|
}
|
|
|
|
export interface SessionUpdatedEvent {
|
|
type: 'session_updated';
|
|
session_id: string;
|
|
project_id: string;
|
|
name: string;
|
|
updated_at: string;
|
|
}
|
|
|
|
export interface SessionLoadedEvent {
|
|
type: 'session_loaded';
|
|
session_id: string;
|
|
project_id: string;
|
|
}
|
|
|
|
export interface OpenFileInBrowserEvent {
|
|
type: 'open_file_in_browser';
|
|
path: string; // project-relative
|
|
}
|
|
|
|
export interface AttachChatFileEvent {
|
|
type: 'attach_chat_file';
|
|
attachment: Omit<Attachment, 'id'>;
|
|
}
|
|
|
|
export interface SessionArchivedEvent {
|
|
type: 'session_archived';
|
|
session_id: string;
|
|
project_id: string;
|
|
}
|
|
|
|
export interface ChatCreatedEvent {
|
|
type: 'chat_created';
|
|
chat: Chat;
|
|
session_id: string;
|
|
}
|
|
|
|
export interface ChatUpdatedEvent {
|
|
type: 'chat_updated';
|
|
chat_id: string;
|
|
session_id: string;
|
|
name: string | null;
|
|
updated_at: string;
|
|
}
|
|
|
|
export interface ChatClosedEvent {
|
|
type: 'chat_closed';
|
|
chat_id: string;
|
|
session_id: string;
|
|
}
|
|
|
|
export interface ProjectArchivedEvent {
|
|
type: 'project_archived';
|
|
project_id: string;
|
|
}
|
|
|
|
export interface ProjectUnarchivedEvent {
|
|
type: 'project_unarchived';
|
|
project: Project;
|
|
}
|
|
|
|
export interface ProjectUpdatedEvent {
|
|
type: 'project_updated';
|
|
project_id: string;
|
|
name: string;
|
|
}
|
|
|
|
export type SessionEvent =
|
|
| SessionRenamedEvent
|
|
| ProjectCreatedEvent
|
|
| ProjectDeletedEvent
|
|
| SessionCreatedEvent
|
|
| SessionDeletedEvent
|
|
| SessionUpdatedEvent
|
|
| SessionLoadedEvent
|
|
| OpenFileInBrowserEvent
|
|
| AttachChatFileEvent
|
|
| SessionArchivedEvent
|
|
| ChatCreatedEvent
|
|
| ChatUpdatedEvent
|
|
| ChatClosedEvent
|
|
| ProjectArchivedEvent
|
|
| ProjectUnarchivedEvent
|
|
| ProjectUpdatedEvent;
|
|
type Listener = (event: SessionEvent) => void;
|
|
|
|
const listeners = new Set<Listener>();
|
|
|
|
export const sessionEvents = {
|
|
emit(event: SessionEvent) {
|
|
for (const listener of listeners) {
|
|
try {
|
|
listener(event);
|
|
} catch {
|
|
// swallow — one bad listener shouldn't break others
|
|
}
|
|
}
|
|
},
|
|
subscribe(listener: Listener): () => void {
|
|
listeners.add(listener);
|
|
return () => {
|
|
listeners.delete(listener);
|
|
};
|
|
},
|
|
};
|