Session 1:N Chat data model with backfill. Workspace switches to client-side multi-tab pane management. Right-rail file browser with float-over viewer and click-drag line selection replaces FileBrowserPane. Adds /compact streaming summarizer (respects compact markers in context builder), force-send (cancels in-flight, persists partial as 'cancelled', awaits cancellation completion via deferred Promise + 5s timeout), message queue, stop generation, chat auto-rename, session archive/unarchive with Closed Sessions section on repo landing page. CHECK constraints on sessions.status, messages.role, messages.status with KEEP IN SYNC comments tying to MESSAGE_ROLES / MESSAGE_STATUSES const arrays. Deletes dead pane routes/hook and the api.panes.* client block. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
42 lines
1.0 KiB
TypeScript
42 lines
1.0 KiB
TypeScript
import { useCallback, useEffect, useState } from 'react';
|
|
import { api } from '@/api/client';
|
|
import type { Project } from '@/api/types';
|
|
|
|
export function useProjects() {
|
|
const [projects, setProjects] = useState<Project[] | null>(null);
|
|
const [error, setError] = useState<string | null>(null);
|
|
|
|
const refresh = useCallback(async () => {
|
|
try {
|
|
const list = await api.projects.list();
|
|
setProjects(list);
|
|
setError(null);
|
|
} catch (err) {
|
|
setError(err instanceof Error ? err.message : 'failed to load projects');
|
|
}
|
|
}, []);
|
|
|
|
useEffect(() => {
|
|
void refresh();
|
|
}, [refresh]);
|
|
|
|
const add = useCallback(
|
|
async (body: { path: string; name?: string }) => {
|
|
const created = await api.projects.add(body);
|
|
await refresh();
|
|
return created;
|
|
},
|
|
[refresh]
|
|
);
|
|
|
|
const remove = useCallback(
|
|
async (id: string) => {
|
|
await api.projects.remove(id);
|
|
await refresh();
|
|
},
|
|
[refresh]
|
|
);
|
|
|
|
return { projects, error, refresh, add, remove };
|
|
}
|