summaryrefslogtreecommitdiff
path: root/makima/frontend/src/lib
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-01-15 03:37:44 +0000
committerGitHub <noreply@github.com>2026-01-15 03:37:44 +0000
commit764bd28d08ceaef03cd4050f9568a62d77bbcfca (patch)
treedbd83ea7d213902f2b8021acc98798b6f3545946 /makima/frontend/src/lib
parenteeafe072bc6bb81459f7d087b48fc921afe9cc11 (diff)
downloadsoryu-764bd28d08ceaef03cd4050f9568a62d77bbcfca.tar.gz
soryu-764bd28d08ceaef03cd4050f9568a62d77bbcfca.zip
Add repository history feature to store and suggest previously used repositories (#18)
- Add repository_history table migration with repo_type, repo_path, use_count, last_used_at - Add RepositoryHistoryEntry model and CRUD database functions - Create API endpoints: GET/POST/DELETE /api/v1/repository-history, GET /api/v1/repository-history/suggestions - Update add_remote_repository and add_local_repository handlers to automatically track history - Update frontend API with repository history types and functions - Add Repository History section to Settings page with list of entries and delete functionality - Add suggestions dropdown to RepositoryPanel when entering new repository URL/path - Suggestions filter by repo type (remote vs local) and match on user input Test plan: - Add a remote repository to a contract - verify it appears in Settings history - Add a local repository to a contract - verify it appears in Settings history - Add same repository again - verify use_count increments, not duplicate - When adding new repository, verify suggestions appear based on history - Delete a history entry from Settings - verify it's removed - Verify suggestions only show matching type (remote for remote, local for local) Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Diffstat (limited to 'makima/frontend/src/lib')
-rw-r--r--makima/frontend/src/lib/api.ts74
1 files changed, 74 insertions, 0 deletions
diff --git a/makima/frontend/src/lib/api.ts b/makima/frontend/src/lib/api.ts
index 2ea1128..100a85a 100644
--- a/makima/frontend/src/lib/api.ts
+++ b/makima/frontend/src/lib/api.ts
@@ -1973,3 +1973,77 @@ export async function answerQuestion(
}
return res.json();
}
+
+// =============================================================================
+// Repository History Types and API
+// =============================================================================
+
+export interface RepositoryHistoryEntry {
+ id: string;
+ ownerId: string;
+ name: string;
+ repositoryUrl: string | null;
+ localPath: string | null;
+ sourceType: "remote" | "local";
+ useCount: number;
+ lastUsedAt: string;
+ createdAt: string;
+}
+
+export interface RepositoryHistoryListResponse {
+ entries: RepositoryHistoryEntry[];
+ total: number;
+}
+
+/**
+ * List all repository history entries.
+ * Returns entries ordered by use_count DESC, last_used_at DESC.
+ */
+export async function listRepositoryHistory(): Promise<RepositoryHistoryListResponse> {
+ const res = await authFetch(`${API_BASE}/api/v1/settings/repository-history`);
+ if (!res.ok) {
+ throw new Error(`Failed to list repository history: ${res.statusText}`);
+ }
+ return res.json();
+}
+
+/**
+ * Get repository suggestions based on history.
+ * Optionally filter by source type and search query.
+ */
+export async function getRepositorySuggestions(
+ sourceType?: "remote" | "local",
+ query?: string,
+ limit?: number
+): Promise<RepositoryHistoryListResponse> {
+ const params = new URLSearchParams();
+ if (sourceType) params.append("source_type", sourceType);
+ if (query) params.append("query", query);
+ if (limit) params.append("limit", limit.toString());
+
+ const queryString = params.toString();
+ const url = `${API_BASE}/api/v1/settings/repository-history/suggestions${
+ queryString ? `?${queryString}` : ""
+ }`;
+
+ const res = await authFetch(url);
+ if (!res.ok) {
+ throw new Error(`Failed to get repository suggestions: ${res.statusText}`);
+ }
+ return res.json();
+}
+
+/**
+ * Delete a repository history entry.
+ */
+export async function deleteRepositoryHistory(id: string): Promise<void> {
+ const res = await authFetch(
+ `${API_BASE}/api/v1/settings/repository-history/${id}`,
+ {
+ method: "DELETE",
+ }
+ );
+ if (!res.ok) {
+ throw new Error(`Failed to delete repository history: ${res.statusText}`);
+ }
+}