Refactor global schedules with mobile-responsive UI and backend optimizations (#167)

* ralph: ralph-global-schedules-dashboard completed after 2 iterations

* Refactor global schedules with mobile-responsive UI and backend optimizations
This commit is contained in:
Chris Scott authored and GitHub committed 2026-03-22 18:23:36 -04:00
1 parent ba15fb31e4
commit f18bcbbf3e
10 files changed
+721 -1

No files matched your search

+37
View File
@@ -373,3 +373,40 @@ export function listScheduleRunsByJob(db: Database, repoId: number, jobId: numbe
const rows = stmt.all(repoId, jobId, limit) as ScheduleRunRow[]
return rows.map(rowToScheduleRun)
}
export interface ScheduleJobWithRepo extends ScheduleJob {
repoName: string
repoPath: string
repoUrl: string
}
interface ScheduleJobWithRepoRow extends ScheduleJobRow {
repo_url: string
repo_path: string
}
function repoNameFromPath(repoPath: string): string {
if (!repoPath || repoPath === '/') return 'Unknown'
return repoPath.split(/[\\/]/).pop() ?? repoPath
}
function rowToScheduleJobWithRepo(row: ScheduleJobWithRepoRow): ScheduleJobWithRepo {
const job = rowToScheduleJob(row)
return {
...job,
repoName: repoNameFromPath(row.repo_path),
repoPath: row.repo_path,
repoUrl: row.repo_url,
}
}
export function listAllScheduleJobsWithRepos(db: Database): ScheduleJobWithRepo[] {
const stmt = db.prepare(`
SELECT sj.*, r.repo_url, r.local_path as repo_path
FROM schedule_jobs sj
JOIN repos r ON sj.repo_id = r.id
ORDER BY r.local_path, sj.name
`)
const rows = stmt.all() as ScheduleJobWithRepoRow[]
return rows.map(rowToScheduleJobWithRepo)
}
+2
View File
@@ -15,6 +15,7 @@ import { createHealthRoutes } from './routes/health'
import { createTTSRoutes, cleanupExpiredCache } from './routes/tts';
import { createSTTRoutes } from './routes/stt'
import { createFileRoutes } from './routes/files'
import { createScheduleRoutes } from './routes/schedules'
async function getAppVersion(): Promise<string> {
try {
@@ -370,6 +371,7 @@ protectedApi.route('/ssh', createSSHRoutes(gitAuthService))
protectedApi.route('/notifications', createNotificationRoutes(notificationService))
protectedApi.route('/memory', createMemoryRoutes(db))
protectedApi.route('/prompt-templates', createPromptTemplateRoutes(db))
protectedApi.route('/schedules', createScheduleRoutes(scheduleService))
app.route('/api', protectedApi)
+9
View File
@@ -35,6 +35,15 @@ function parseRunListLimit(value: string | undefined): number {
export function createScheduleRoutes(scheduleService: ScheduleService) {
const app = new Hono()
app.get('/all', (c) => {
try {
const jobs = scheduleService.listAllJobsWithRepos()
return c.json({ jobs })
} catch (error) {
return handleScheduleError(c, error, 'Failed to list all schedules')
}
})
app.get('/', (c) => {
try {
const repoId = parseId(c.req.param('id'), 'repo id')
+6
View File
@@ -8,6 +8,7 @@ import {
type UpdateScheduleJobRequest,
} from '@opencode-manager/shared/types'
import { getRepoById } from '../db/queries'
import type { ScheduleJobWithRepo } from '../db/schedules'
import {
createScheduleJob,
createScheduleRun,
@@ -15,6 +16,7 @@ import {
getScheduleJobById,
getRunningScheduleRunByJob,
getScheduleRunById,
listAllScheduleJobsWithRepos,
listEnabledScheduleJobs,
listScheduleJobsByRepo,
listRunningScheduleRuns,
@@ -359,6 +361,10 @@ export class ScheduleService {
return listEnabledScheduleJobs(this.db)
}
listAllJobsWithRepos(): ScheduleJobWithRepo[] {
return listAllScheduleJobsWithRepos(this.db)
}
async recoverRunningRuns(): Promise<void> {
const runningRuns = listRunningScheduleRuns(this.db)