Files
opencode-manager/frontend/src/lib/schedules/schedule-target.ts
T
Chris Scott 6a4e8734f9 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
2026-06-28 14:49:00 -04:00

41 lines
1.1 KiB
TypeScript

import type { Repo } from '@/api/types'
import type { AssistantModeStatus } from '@opencode-manager/shared/types'
import { ASSISTANT_REPO_ID, ASSISTANT_REPO_NAME } from '@opencode-manager/shared/utils'
import { getRepoDisplayName } from '@/lib/utils'
import { getAssistantPath } from '@/lib/navigation'
export interface ScheduleTarget {
repoId: number
kind: 'assistant' | 'repo'
name: string
subtitle: string
fullPath: string
backHref: string
}
export function isAssistantRepoId(repoId: number | undefined): boolean {
return repoId === ASSISTANT_REPO_ID
}
export function scheduleTargetFromRepo(repo: Repo): ScheduleTarget {
return {
repoId: repo.id,
kind: 'repo',
name: getRepoDisplayName(repo),
subtitle: repo.localPath,
fullPath: repo.fullPath,
backHref: `/repos/${repo.id}`,
}
}
export function scheduleTargetFromAssistant(status: AssistantModeStatus): ScheduleTarget {
return {
repoId: ASSISTANT_REPO_ID,
kind: 'assistant',
name: ASSISTANT_REPO_NAME,
subtitle: 'Built-in assistant',
fullPath: status.directory,
backHref: getAssistantPath(),
}
}