refactor(web): replace query option tunneling with queryOptions factories

Extract sandboxFilesTreeOptions and buildTreeFromFlatList from
useSandboxFilesTree so callers that need custom TanStack Query behavior
(e.g. refetchInterval) can compose at the call site instead of tunneling
options through the hook. Remove the thin useGetSandboxProviderList
wrapper in favor of inline oRPC queryOptions in the component.

Also remove redundant .input(type<unknown>()) from three no-input GET
contracts—oc already defaults TInputSchema to Schema<unknown, unknown>.
This commit is contained in:
yyh
2026-02-27 11:58:16 +08:00
parent 60b02e6d2b
commit 0bdd21bc17
9 changed files with 44 additions and 74 deletions

View File

@ -1,11 +1,12 @@
'use client'
import type { SandboxProvider } from '@/types/sandbox-provider'
import { useQuery } from '@tanstack/react-query'
import { memo, useState } from 'react'
import { useTranslation } from 'react-i18next'
import Loading from '@/app/components/base/loading'
import { useAppContext } from '@/context/app-context'
import { useGetSandboxProviderList } from '@/service/use-sandbox-provider'
import { consoleQuery } from '@/service/client'
import ConfigModal from './config-modal'
import ProviderCard from './provider-card'
import SwitchModal from './switch-modal'
@ -13,7 +14,7 @@ import SwitchModal from './switch-modal'
const SandboxProviderPage = () => {
const { t } = useTranslation()
const { isCurrentWorkspaceManager, isLoadingCurrentWorkspace } = useAppContext()
const { data: providers, isLoading } = useGetSandboxProviderList()
const { data: providers, isLoading } = useQuery(consoleQuery.sandboxProvider.getSandboxProviderList.queryOptions())
const [configModalProvider, setConfigModalProvider] = useState<SandboxProvider | null>(null)
const [switchModalProvider, setSwitchModalProvider] = useState<SandboxProvider | null>(null)