mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-05-06 04:35:50 +00:00
* refactor(ui): replace in-repo Command primitive with cmdk wrapper * feat(command-palette): add global Cmd+K palette with v1 actions * feat(command-palette): add session, file, and commit search sources * refactor: add provider names to model constants * feat(command-palette): add settings, navigation, message search, and ⌘K hints * feat(command-palette): add git fetch/pull/push and branch switch actions * refactor(command-palette): consolidate fetch source hooks behind useApiSource * refactor(command-palette): extract useCommandKey and SETTINGS_MAIN_TABS metadata * refactor(command-palette): extract groups into declarative registry * refactor(command-palette): wire openFile through PaletteOpsContext * refactor: migrate openSettings and refreshProjects from window.* to PaletteOpsContext * refactor(command-palette): inline groups and delete registry indirection * refactor(command-palette): return items array directly from source hooks * refactor(palette-ops): flatten Handle wrapper into ref-based registry * refactor: inline useCommandKey as MOD_KEY constant in two call sites * feat: introduce pages and fix bug on branch switching * fix: small labels * fix: coderabbit issues * fix: coderabbit comments * Update src/components/chat/view/subcomponents/ProviderSelectionEmptyState.tsx Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import { authenticatedFetch } from '../../../utils/api';
|
|
import type { LLMProvider, ProjectSession } from '../../../types/app';
|
|
|
|
import { useApiSource } from './useApiSource';
|
|
|
|
export type SessionResult = {
|
|
id: string;
|
|
label: string;
|
|
provider?: LLMProvider;
|
|
};
|
|
|
|
interface SessionsResponse {
|
|
sessions?: ProjectSession[];
|
|
cursorSessions?: ProjectSession[];
|
|
codexSessions?: ProjectSession[];
|
|
geminiSessions?: ProjectSession[];
|
|
}
|
|
|
|
export function useSessionsSource(projectId: string | undefined, enabled: boolean) {
|
|
return useApiSource<SessionResult, SessionsResponse>({
|
|
enabled: enabled && !!projectId,
|
|
deps: [projectId],
|
|
fetcher: (signal) => {
|
|
const params = new URLSearchParams({ limit: '50', offset: '0' });
|
|
return authenticatedFetch(
|
|
`/api/projects/${encodeURIComponent(projectId!)}/sessions?${params.toString()}`,
|
|
{ signal },
|
|
);
|
|
},
|
|
parse: (data) => {
|
|
const all: ProjectSession[] = [
|
|
...(data.sessions ?? []),
|
|
...(data.cursorSessions ?? []),
|
|
...(data.codexSessions ?? []),
|
|
...(data.geminiSessions ?? []),
|
|
];
|
|
return all.map<SessionResult>((s) => ({
|
|
id: s.id,
|
|
label: (s.title || s.summary || s.name || s.id) as string,
|
|
provider: s.__provider,
|
|
}));
|
|
},
|
|
});
|
|
}
|