mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
feat: add assistant mode, SSE streaming, and OpenCode server integration (#214)
This commit is contained in:
1 parent
3cc24288a6
commit
c3d6549f01
133 files changed
+7284
-6293
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import { getOpenCodeServerAuth, updateOpenCodeServerAuth } from '@/api/settings'
|
||||
import type { OpenCodeServerAuthStatus as OpenCodeServerAuthStatusType } from '@/api/settings'
|
||||
|
||||
export function useOpenCodeServerAuth() {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
const query = useQuery({
|
||||
queryKey: ['settings', 'opencode-server-auth'],
|
||||
queryFn: getOpenCodeServerAuth,
|
||||
})
|
||||
|
||||
const setPassword = useMutation({
|
||||
mutationFn: (password: string) => updateOpenCodeServerAuth(password),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['settings', 'opencode-server-auth'] })
|
||||
},
|
||||
})
|
||||
|
||||
const clearPassword = useMutation({
|
||||
mutationFn: () => updateOpenCodeServerAuth(null),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['settings', 'opencode-server-auth'] })
|
||||
},
|
||||
})
|
||||
|
||||
return {
|
||||
status: query.data as OpenCodeServerAuthStatusType | undefined,
|
||||
isLoading: query.isLoading,
|
||||
setPassword,
|
||||
clearPassword,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user