refactor(websearch): rename search domain
This commit is contained in:
parent
97aa6713b5
commit
c86f4e9b9b
51 changed files with 478 additions and 462 deletions
|
|
@ -65,11 +65,11 @@ export function DialogIntegration(
|
|||
.map((integration) => {
|
||||
const methods = connectMethods(integration)
|
||||
const connected = integration.connections.length > 0
|
||||
const search = integration.search
|
||||
const selected = data.location.search.provider() === integration.id
|
||||
const websearch = integration.websearch
|
||||
const selected = data.location.websearch.provider() === integration.id
|
||||
const credentials = credentialConnections(integration)
|
||||
const description = search?.connection === "optional" ? "API key optional" : undefined
|
||||
const category = search ? "Web search" : undefined
|
||||
const description = websearch?.connection === "optional" ? "API key optional" : undefined
|
||||
const category = websearch ? "Web search" : undefined
|
||||
return {
|
||||
title: integration.name,
|
||||
value: integration.id,
|
||||
|
|
@ -79,7 +79,7 @@ export function DialogIntegration(
|
|||
.filter((value) => value !== undefined && value.length > 0)
|
||||
.join(" · ") || undefined,
|
||||
category: category ?? (integration.id in INTEGRATION_PRIORITY ? "Popular" : "Services"),
|
||||
disabled: methods.length === 0 && !search,
|
||||
disabled: methods.length === 0 && !websearch,
|
||||
gutter: connected ? () => <text fg={theme.success}>✓</text> : undefined,
|
||||
onSelect: () => {
|
||||
if (props.connectionOnly) {
|
||||
|
|
@ -87,7 +87,7 @@ export function DialogIntegration(
|
|||
? manageConnections(integration, methods, dialog, props.onConnected)
|
||||
: selectMethod(integration, methods, dialog, props.onConnected)
|
||||
}
|
||||
if (search) return manageIntegration(integration, methods, search, dialog)
|
||||
if (websearch) return manageIntegration(integration, methods, websearch, dialog)
|
||||
return credentials.length
|
||||
? manageConnections(integration, methods, dialog, props.onConnected)
|
||||
: selectMethod(integration, methods, dialog, props.onConnected)
|
||||
|
|
@ -112,7 +112,7 @@ export function DialogIntegration(
|
|||
function manageIntegration(
|
||||
integration: IntegrationInfo,
|
||||
methods: ConnectMethod[],
|
||||
search: NonNullable<IntegrationInfo["search"]>,
|
||||
websearch: NonNullable<IntegrationInfo["websearch"]>,
|
||||
dialog: ReturnType<typeof useDialog>,
|
||||
) {
|
||||
const connected = integration.connections.length > 0
|
||||
|
|
@ -121,15 +121,15 @@ function manageIntegration(
|
|||
const sdk = useSDK()
|
||||
const toast = useToast()
|
||||
const credentials = credentialConnections(integration)
|
||||
const selected = createMemo(() => data.location.search.provider() === integration.id)
|
||||
const selectSearch = () => {
|
||||
void sdk.api.search.provider
|
||||
const selected = createMemo(() => data.location.websearch.provider() === integration.id)
|
||||
const selectWebSearch = () => {
|
||||
void sdk.api.websearch.provider
|
||||
.select({
|
||||
providerID: integration.id,
|
||||
location: location(data),
|
||||
})
|
||||
.then(async () => {
|
||||
await Promise.all([data.location.integration.refresh(), data.location.search.refresh()])
|
||||
await Promise.all([data.location.integration.refresh(), data.location.websearch.refresh()])
|
||||
toast.show({ variant: "success", message: `${integration.name} is now the web search default` })
|
||||
dialog.clear()
|
||||
})
|
||||
|
|
@ -142,12 +142,12 @@ function manageIntegration(
|
|||
options={[
|
||||
{
|
||||
title: selected() ? "Web search default" : "Use for web search",
|
||||
value: "search",
|
||||
value: "websearch",
|
||||
disabled: selected(),
|
||||
onSelect:
|
||||
search.connection === "required" && !connected
|
||||
? () => selectMethod(integration, methods, dialog, selectSearch)
|
||||
: selectSearch,
|
||||
websearch.connection === "required" && !connected
|
||||
? () => selectMethod(integration, methods, dialog, selectWebSearch)
|
||||
: selectWebSearch,
|
||||
},
|
||||
...(methods.length
|
||||
? [
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ type LocationData = {
|
|||
model?: ModelInfo[]
|
||||
provider?: ProviderV2Info[]
|
||||
reference?: ReferenceInfo[]
|
||||
searchProvider?: string | null
|
||||
websearchProvider?: string | null
|
||||
// Currently running shell commands for this location, keyed by shell id. Entries are removed
|
||||
// once the command exits or is deleted, so this only ever holds in-flight shells.
|
||||
shell?: Record<string, Shell>
|
||||
|
|
@ -803,7 +803,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
|
|||
])
|
||||
break
|
||||
case "config.updated":
|
||||
void result.location.search.refresh(event.location)
|
||||
void result.location.websearch.refresh(event.location)
|
||||
break
|
||||
// Authenticating an MCP integration reconnects its server, which emits mcp.status.changed,
|
||||
// so the mcp list refreshes here rather than off integration.updated.
|
||||
|
|
@ -1049,14 +1049,14 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
|
|||
setStore("location", key, { ...store.location[key], reference: mutable(result.data) })
|
||||
},
|
||||
},
|
||||
search: {
|
||||
websearch: {
|
||||
provider(location?: LocationRef) {
|
||||
return store.location[locationKey(location ?? defaultLocation())]?.searchProvider ?? undefined
|
||||
return store.location[locationKey(location ?? defaultLocation())]?.websearchProvider ?? undefined
|
||||
},
|
||||
async refresh(ref?: LocationRef) {
|
||||
const result = await sdk.api.search.provider.get({ location: locationQuery(ref ?? defaultLocation()) })
|
||||
const result = await sdk.api.websearch.provider.get({ location: locationQuery(ref ?? defaultLocation()) })
|
||||
const key = locationKey(result.location)
|
||||
setStore("location", key, { ...store.location[key], searchProvider: result.data ?? null })
|
||||
setStore("location", key, { ...store.location[key], websearchProvider: result.data ?? null })
|
||||
},
|
||||
},
|
||||
skill: {
|
||||
|
|
@ -1119,7 +1119,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
|
|||
result.location.model.refresh(),
|
||||
result.location.provider.refresh(),
|
||||
result.location.reference.refresh(),
|
||||
result.location.search.refresh(),
|
||||
result.location.websearch.refresh(),
|
||||
result.location.command.refresh(),
|
||||
result.location.skill.refresh(),
|
||||
result.shell.refresh(),
|
||||
|
|
|
|||
|
|
@ -2382,10 +2382,12 @@ function WebFetch(props: ToolProps) {
|
|||
|
||||
function WebSearch(props: ToolProps) {
|
||||
const data = useData()
|
||||
const [provider, setProvider] = createSignal(data.location.search.provider() ?? stringValue(props.metadata.provider))
|
||||
const [provider, setProvider] = createSignal(
|
||||
data.location.websearch.provider() ?? stringValue(props.metadata.provider),
|
||||
)
|
||||
createEffect(() => {
|
||||
if (provider()) return
|
||||
const next = data.location.search.provider()
|
||||
const next = data.location.websearch.provider()
|
||||
if (next) setProvider(next)
|
||||
})
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ export function createFetch(override?: FetchHandler, events?: ReturnType<typeof
|
|||
})
|
||||
if (url.pathname === "/api/reference")
|
||||
return json({ location: { directory, project: { id: "proj_test", directory } }, data: [] })
|
||||
if (url.pathname === "/api/search/provider") {
|
||||
if (url.pathname === "/api/websearch/provider") {
|
||||
if (request.method === "POST") return new Response(null, { status: 204 })
|
||||
return json({ location: { directory, project: { id: "proj_test", directory } }, data: null })
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue