mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
fix(sandbox): guard enable path and harden UI rendering performance (#341)
* fix(sandbox): guard enable path and harden UI rendering performance * chore(deps): allow esbuild postinstall in pnpm onlyBuiltDependencies * fix(sandbox): align availability reporting and address PR review feedback * fix(sandbox): block planning without process attestation
This commit is contained in:
1 parent
ba8e8f4b29
commit
d63198ec8a
19 files changed
+501
-82
No files matched your search
@@ -13,6 +13,7 @@ import { invalidateRepoGitCachesDebounced } from '@/lib/queryInvalidation'
|
||||
|
||||
type PermissionsBySession = Record<string, PermissionRequest[]>
|
||||
type QuestionsBySession = Record<string, QuestionRequest[]>
|
||||
type SSEHealthState = Pick<EventStreamHealthState, 'isConnected' | 'isHealthy' | 'isStalled'>
|
||||
|
||||
type SessionScopedItem = { id: string; sessionID: string }
|
||||
|
||||
@@ -163,7 +164,7 @@ interface EventContextValue {
|
||||
navigateToCurrent: () => void
|
||||
syncForSession: (directory: string, sessionID: string) => Promise<void>
|
||||
}
|
||||
sseHealth: EventStreamHealthState
|
||||
sseHealth: SSEHealthState
|
||||
getRepoIdForSession: (sessionID: string) => number | null
|
||||
getClient: (sessionID: string) => OpenCodeClient | null
|
||||
}
|
||||
@@ -175,7 +176,10 @@ export function EventProvider({ children }: { children: React.ReactNode }) {
|
||||
const navigate = useNavigate()
|
||||
|
||||
const [sshHostKeyRequest, setSSHHostKeyRequest] = useState<SSHHostKeyRequest | null>(null)
|
||||
const [sseHealth, setSseHealth] = useState<EventStreamHealthState>(() => openCodeEventStream.getHealth())
|
||||
const [sseHealth, setSseHealth] = useState<SSEHealthState>(() => {
|
||||
const { isConnected, isHealthy, isStalled } = openCodeEventStream.getHealth()
|
||||
return { isConnected, isHealthy, isStalled }
|
||||
})
|
||||
|
||||
const respondToSSHHostKey = useCallback(async (requestId: string, approved: boolean) => {
|
||||
try {
|
||||
@@ -187,6 +191,15 @@ export function EventProvider({ children }: { children: React.ReactNode }) {
|
||||
}
|
||||
}, [])
|
||||
|
||||
const handleHealthChange = useCallback((next: EventStreamHealthState) => {
|
||||
setSseHealth((prev) => {
|
||||
if (prev.isConnected === next.isConnected && prev.isHealthy === next.isHealthy && prev.isStalled === next.isStalled) {
|
||||
return prev
|
||||
}
|
||||
return { isConnected: next.isConnected, isHealthy: next.isHealthy, isStalled: next.isStalled }
|
||||
})
|
||||
}, [])
|
||||
|
||||
const [permissionsBySession, setPermissionsBySession] = useState<PermissionsBySession>({})
|
||||
const [questionsBySession, setQuestionsBySession] = useState<QuestionsBySession>({})
|
||||
const [showPermissionDialog, setShowPermissionDialog] = useState(true)
|
||||
@@ -552,7 +565,7 @@ export function EventProvider({ children }: { children: React.ReactNode }) {
|
||||
directories: initialDirectories,
|
||||
onEvent: handleSSEMessage,
|
||||
onStatusChange: handleStatusChange,
|
||||
onHealthChange: setSseHealth,
|
||||
onHealthChange: handleHealthChange,
|
||||
})
|
||||
subscriptionRef.current = subscription
|
||||
|
||||
@@ -560,7 +573,7 @@ export function EventProvider({ children }: { children: React.ReactNode }) {
|
||||
subscription.dispose()
|
||||
subscriptionRef.current = null
|
||||
}
|
||||
}, [addPermission, removePermission, addQuestion, removeQuestion, rememberSessionDirectory, fetchInitialPendingData, queryClient, setSseHealth])
|
||||
}, [addPermission, removePermission, addQuestion, removeQuestion, rememberSessionDirectory, fetchInitialPendingData, queryClient, handleHealthChange])
|
||||
|
||||
useEffect(() => {
|
||||
reposRef.current = repos
|
||||
@@ -658,6 +671,6 @@ export function useQuestions() {
|
||||
return questions
|
||||
}
|
||||
|
||||
export function useSSEHealth(): EventStreamHealthState {
|
||||
export function useSSEHealth(): SSEHealthState {
|
||||
return useEventContext().sseHealth
|
||||
}
|
||||
Reference in new issue
Block a user