mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
Critical and high: - repos: unlinking a local repo removes only the Manager reference and alias, never the repository files; confirm button reads "Unlink" - auth: rate-limit by the socket address; trust proxy headers only when AUTH_TRUSTED_PROXY_HEADERS is set (documented and forwarded in compose) - composer: per-session in-memory drafts (text, bash mode, attachments); Escape no longer clears the prompt - url params: compose same-tick updates so schedule dialogs stay closed after create/delete; delete dialog names the job Medium: - tool rows show failures (non-zero shell exit, failed exploration members) - voice conversation shows the specific error and a starting state - settings: Escape in dropdowns and the shortcut recorder no longer closes the dialog; mobile deep links open the requested section; one content tree per platform - closing pushed sheets, settings, tool panels and schedule dialogs goes back in history - login returns to the requested page; signed-out pages make no authenticated requests - action terminals keep their output (Manager-side output capture and replay) - unpushed-commit detection, commit message kept on failure - binary files with unknown extensions are detected and not editable - tool panel resizes when docked and floats as a dismissible sheet when the page is too narrow - Docker image runs tini as PID 1 Low: not-found states, add-repo and branch validation errors (4xx), search-aware empty states, mobile repo sort/filter/select cues, sidebar resize affordance and collapse shortcut, mobile unread badge, preview port filtering, terminal close handling, walkthrough empty state and helper session filtering, placeholder contrast, permission labels and focus, TTS task-list sanitizing, git identity email validation, quieter git logging, hermetic worktree tests, and accessible names for icon-only controls.
116 lines
4.0 KiB
TypeScript
116 lines
4.0 KiB
TypeScript
import { useMemo } from 'react'
|
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
|
import type { QueryClient } from '@tanstack/react-query'
|
|
import {
|
|
cancelChangeWalkthrough,
|
|
generateChangeWalkthrough,
|
|
getChangeWalkthrough,
|
|
getWalkthroughHelperSessionIds,
|
|
refineChangeWalkthrough,
|
|
} from '@/api/changeWalkthroughs'
|
|
import { walkthroughSourceKey } from '@opencode-manager/shared/schemas'
|
|
import type {
|
|
ChangeWalkthroughState,
|
|
GenerateChangeWalkthroughRequest,
|
|
WalkthroughSource,
|
|
} from '@opencode-manager/shared/schemas'
|
|
|
|
const GENERATING_POLL_INTERVAL_MS = 2_000
|
|
|
|
type ChangeWalkthroughMutationResult = {
|
|
sessionId: string
|
|
sourceKey: string
|
|
state: ChangeWalkthroughState
|
|
}
|
|
|
|
function writeChangeWalkthroughToCache(
|
|
queryClient: QueryClient,
|
|
{ sessionId, sourceKey, state }: ChangeWalkthroughMutationResult,
|
|
) {
|
|
queryClient.setQueryData(changeWalkthroughQueryKey(sessionId, sourceKey), state)
|
|
}
|
|
|
|
export function changeWalkthroughQueryKey(sessionId: string, sourceKey?: string) {
|
|
return sourceKey === undefined
|
|
? (['change-walkthrough', sessionId] as const)
|
|
: (['change-walkthrough', sessionId, sourceKey] as const)
|
|
}
|
|
|
|
export function useWalkthroughHelperSessionIds(): ReadonlySet<string> {
|
|
const { data } = useQuery({
|
|
queryKey: ['change-walkthrough-helper-sessions'],
|
|
queryFn: getWalkthroughHelperSessionIds,
|
|
staleTime: 5 * 60_000,
|
|
retry: false,
|
|
})
|
|
return useMemo(() => new Set(data ?? []), [data])
|
|
}
|
|
|
|
export function useChangeWalkthrough(
|
|
sessionId: string | undefined,
|
|
enabled: boolean,
|
|
source: WalkthroughSource,
|
|
) {
|
|
const sourceKey = walkthroughSourceKey(source)
|
|
const queryKey = changeWalkthroughQueryKey(sessionId ?? '', sourceKey)
|
|
return useQuery({
|
|
queryKey,
|
|
queryFn: () => getChangeWalkthrough(sessionId!, source),
|
|
enabled: enabled && !!sessionId,
|
|
staleTime: 30_000,
|
|
refetchInterval: (query) =>
|
|
query.state.data?.generating || query.state.data?.running ? GENERATING_POLL_INTERVAL_MS : false,
|
|
})
|
|
}
|
|
|
|
export function useGenerateChangeWalkthrough(sessionId: string | undefined, source: WalkthroughSource) {
|
|
const queryClient = useQueryClient()
|
|
const sourceKey = walkthroughSourceKey(source)
|
|
|
|
return useMutation({
|
|
mutationFn: async (request: GenerateChangeWalkthroughRequest) => {
|
|
const targetSessionId = sessionId!
|
|
const state = await generateChangeWalkthrough(targetSessionId, { ...request, source })
|
|
return { sessionId: targetSessionId, sourceKey, state }
|
|
},
|
|
onSuccess: (result) => {
|
|
writeChangeWalkthroughToCache(queryClient, result)
|
|
void queryClient.invalidateQueries({ queryKey: ['change-walkthrough-helper-sessions'] })
|
|
},
|
|
})
|
|
}
|
|
|
|
export function useRefineChangeWalkthrough(sessionId: string | undefined, source: WalkthroughSource) {
|
|
const queryClient = useQueryClient()
|
|
const sourceKey = walkthroughSourceKey(source)
|
|
|
|
return useMutation({
|
|
mutationFn: async (text: string) => {
|
|
const targetSessionId = sessionId!
|
|
const state = await refineChangeWalkthrough(targetSessionId, { source, text })
|
|
return { sessionId: targetSessionId, sourceKey, state }
|
|
},
|
|
onSuccess: (result) => writeChangeWalkthroughToCache(queryClient, result),
|
|
})
|
|
}
|
|
|
|
export function useCancelChangeWalkthrough(sessionId: string | undefined, source: WalkthroughSource) {
|
|
const queryClient = useQueryClient()
|
|
const sourceKey = walkthroughSourceKey(source)
|
|
|
|
return useMutation({
|
|
mutationFn: async () => {
|
|
const targetSessionId = sessionId!
|
|
await cancelChangeWalkthrough(targetSessionId, source)
|
|
return { sessionId: targetSessionId, sourceKey }
|
|
},
|
|
onSuccess: ({ sessionId: targetSessionId, sourceKey: targetSourceKey }) => {
|
|
const queryKey = changeWalkthroughQueryKey(targetSessionId, targetSourceKey)
|
|
queryClient.setQueryData<ChangeWalkthroughState>(queryKey, (cached) =>
|
|
cached ? { ...cached, generating: false, running: false, error: null } : cached,
|
|
)
|
|
queryClient.invalidateQueries({ queryKey })
|
|
},
|
|
})
|
|
}
|