feat: add repo rename capability with custom name field (#294)

* feat: add repo rename capability with custom name field

Add a custom name field to repos, allowing users to set a display name
independent of the repo URL or path. Includes a migration, PATCH endpoint,
rename dialog, and display name consolidation.

- DB migration 014 adds name column to repos table
- PATCH /api/repos/:id endpoint with Zod validation
- RenameRepoDialog component with clear/reset support
- RepoRowActions gains Rename action in both dropdown and inline modes
- getRepoDisplayName() consolidated to accept a repo object and prefer name
- All repo name display call sites updated to use the new API

* fix: add DialogTitle to RenameRepoDialog for a11y compliance

* refactor: extract getRepoDisplayName to shared utils, fix schedule cache invalidation on rename
This commit is contained in:
Chris Scott authored and GitHub committed 2026-06-28 14:49:00 -04:00
1 parent 01e50a7019
commit 6a4e8734f9
33 files changed
+535 -84

No files matched your search

+5
View File
@@ -4,6 +4,7 @@ export const RepoStatusSchema = z.enum(['cloning', 'ready', 'error'])
export const RepoSchema = z.object({
id: z.number(),
name: z.string().optional(),
repoUrl: z.string().url().optional(),
localPath: z.string(),
fullPath: z.string(),
@@ -45,6 +46,10 @@ export const DiscoverReposRequestSchema = z.object({
maxDepth: z.number().int().min(0).max(8).optional(),
})
export const UpdateRepoRequestSchema = z.object({
name: z.string().trim().max(100).nullable(),
})
export const DiscoverReposResponseSchema = z.object({
repos: z.array(RepoSchema),
discoveredCount: z.number().int().nonnegative(),
+2
View File
@@ -17,6 +17,7 @@ import {
CreateRepoRequestSchema,
DiscoverReposRequestSchema,
DiscoverReposResponseSchema,
UpdateRepoRequestSchema,
RepoStatusSchema,
AssistantModeStatusSchema,
AssistantModeInitRequestSchema,
@@ -65,6 +66,7 @@ export type CreateRepoRequest = z.infer<typeof CreateRepoRequestSchema>
export type DiscoverReposRequest = z.infer<typeof DiscoverReposRequestSchema>
export type DiscoverReposResponse = z.infer<typeof DiscoverReposResponseSchema>
export type RepoStatus = z.infer<typeof RepoStatusSchema>
export type UpdateRepoRequest = z.infer<typeof UpdateRepoRequestSchema>
export type AssistantModeStatus = z.infer<typeof AssistantModeStatusSchema>
export type AssistantModeInitRequest = z.infer<typeof AssistantModeInitRequestSchema>
+17
View File
@@ -79,6 +79,23 @@ export function getRepoNameFromUrl(url: string): string {
return parts[parts.length - 1] || ''
}
function getPathBaseName(filePath: string): string {
return filePath.split(/[\\/]/).pop() || filePath
}
export function getRepoDisplayName(repo: {
name?: string | null
repoUrl?: string | null
localPath?: string | null
sourcePath?: string | null
}): string {
if (repo.name && repo.name.trim()) return repo.name.trim()
const fromLocalPath = repo.localPath ? getPathBaseName(repo.localPath) : ''
if (repo.repoUrl) return getRepoNameFromUrl(repo.repoUrl) || fromLocalPath || 'Repository'
if (repo.sourcePath) return getPathBaseName(repo.sourcePath) || fromLocalPath || 'Repository'
return fromLocalPath || 'Repository'
}
export function normalizeRepoUrlForCompare(url: string): string {
let normalized = trimTrailingChar(url.trim().replace(/\.git$/, ''), '/')
const shorthandMatch = normalized.match(/^([^/]+)\/([^/]+)$/)