mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
feat(schedules): support scheduling jobs for the Assistant workspace (#254)
* feat(schedules): support scheduling jobs for the Assistant workspace * refactor(schedules): extract assistant repo constants, rename workspace to schedule-target * feat(navigation): add schedules link to session drawer menu * fix(schedules): document Assistant repoId=0 in generated schedule-management skill
This commit is contained in:
1 parent
9479e1f662
commit
70cb62b77b
18 files changed
+402
-115
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { getRepo } from '@/api/repos'
|
||||
import { useAssistantMode } from '@/hooks/useAssistantMode'
|
||||
import { isAssistantRepoId, scheduleTargetFromAssistant, scheduleTargetFromRepo } from '@/lib/schedules/schedule-target'
|
||||
import type { ScheduleTarget } from '@/lib/schedules/schedule-target'
|
||||
|
||||
export function useScheduleTarget(repoId: number | undefined): {
|
||||
scheduleTarget: ScheduleTarget | undefined
|
||||
isLoading: boolean
|
||||
isError: boolean
|
||||
} {
|
||||
const assistantQuery = useAssistantMode(repoId)
|
||||
|
||||
const repoQuery = useQuery({
|
||||
queryKey: ['repo', repoId],
|
||||
queryFn: () => getRepo(repoId!),
|
||||
enabled: repoId !== undefined && repoId > 0,
|
||||
})
|
||||
|
||||
if (isAssistantRepoId(repoId)) {
|
||||
return {
|
||||
scheduleTarget: assistantQuery.status ? scheduleTargetFromAssistant(assistantQuery.status) : undefined,
|
||||
isLoading: assistantQuery.isLoading,
|
||||
isError: assistantQuery.isError,
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
scheduleTarget: repoQuery.data ? scheduleTargetFromRepo(repoQuery.data) : undefined,
|
||||
isLoading: repoQuery.isLoading,
|
||||
isError: repoQuery.isError,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user