feat(EMBEDDINGS-0001): enable local embedder by default and overhaul settings page

- Wire local embedding provider as the default on startup when no profile is configured
- Refactor embedding settings into dedicated service, DTOs, mappers and models
- Rebuild settings page with profile management UI and live test feedback
- Expose index summary (indexed versions + embedding count) on repo endpoints
- Harden indexing pipeline and context search with additional test coverage

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Giancarmine Salucci
2026-03-28 09:28:01 +01:00
parent d1381f7fc0
commit 781d224adc
30 changed files with 1419 additions and 313 deletions

View File

@@ -39,6 +39,11 @@ export interface RepositoryStats {
lastIndexedAt: Date | null;
}
export interface RepositoryIndexSummary {
embeddingCount: number;
indexedVersions: string[];
}
export class RepositoryService {
constructor(private readonly db: Database.Database) {}
@@ -266,6 +271,49 @@ export class RepositoryService {
return rows.map((r) => r.tag);
}
getIndexSummary(repositoryId: string): RepositoryIndexSummary {
const repository = this.get(repositoryId);
if (!repository) throw new NotFoundError(`Repository ${repositoryId} not found`);
const embeddingRow = this.db
.prepare(
`SELECT COUNT(*) AS count
FROM snippet_embeddings se
INNER JOIN snippets s ON s.id = se.snippet_id
WHERE s.repository_id = ?`
)
.get(repositoryId) as { count: number };
const versionRows = this.db
.prepare(
`SELECT tag FROM repository_versions
WHERE repository_id = ? AND state = 'indexed'
ORDER BY created_at DESC`
)
.all(repositoryId) as { tag: string }[];
const hasDefaultBranchIndex = Boolean(
this.db
.prepare(
`SELECT 1 AS found
FROM documents
WHERE repository_id = ? AND version_id IS NULL
LIMIT 1`
)
.get(repositoryId)
);
const indexedVersions = [
...(hasDefaultBranchIndex ? [repository.branch ?? 'default branch'] : []),
...versionRows.map((row) => row.tag)
];
return {
embeddingCount: embeddingRow.count,
indexedVersions: Array.from(new Set(indexedVersions))
};
}
/**
* Create an indexing job for a repository.
* If a job is already running, returns the existing job.