feat(websearch): settings UI overhaul and quota improvements
- Remove Priority field, auto load-balance by quota remaining - Replace QuotaRefreshInterval (daily/weekly/monthly) with SubscribedAt (subscription date, monthly lazy refresh via Redis TTL) - Add collapsible provider cards, API key show/copy, usage progress bar - Add test endpoint (POST /web-search-emulation/test) bypassing quota - Wire WebSearchManagerBuilder on startup (was never called before) - Fix nextMonthlyReset day-of-month overflow (Jan 31 → Feb 28) - Fix non-deterministic sort in selectByQuotaWeight - Map ProxyID in builder for provider-level proxy tracking - Fix frontend timezone drift in subscribed_at date picker - Fix provider deletion index shift for expandedProviders state
This commit is contained in:
@@ -497,9 +497,8 @@ export interface WebSearchProviderConfig {
|
||||
type: 'brave' | 'tavily'
|
||||
api_key: string
|
||||
api_key_configured: boolean
|
||||
priority: number
|
||||
quota_limit: number
|
||||
quota_refresh_interval: 'daily' | 'weekly' | 'monthly'
|
||||
subscribed_at: number | null
|
||||
quota_used?: number
|
||||
proxy_id: number | null
|
||||
expires_at: number | null
|
||||
@@ -510,6 +509,12 @@ export interface WebSearchEmulationConfig {
|
||||
providers: WebSearchProviderConfig[]
|
||||
}
|
||||
|
||||
export interface WebSearchTestResult {
|
||||
provider: string
|
||||
results: { url: string; title: string; snippet: string; page_age?: string }[]
|
||||
query: string
|
||||
}
|
||||
|
||||
export async function getWebSearchEmulationConfig(): Promise<WebSearchEmulationConfig> {
|
||||
const { data } = await apiClient.get<WebSearchEmulationConfig>(
|
||||
'/admin/settings/web-search-emulation'
|
||||
@@ -527,6 +532,16 @@ export async function updateWebSearchEmulationConfig(
|
||||
return data
|
||||
}
|
||||
|
||||
export async function testWebSearchEmulation(
|
||||
query: string
|
||||
): Promise<WebSearchTestResult> {
|
||||
const { data } = await apiClient.post<WebSearchTestResult>(
|
||||
'/admin/settings/web-search-emulation/test',
|
||||
{ query }
|
||||
)
|
||||
return data
|
||||
}
|
||||
|
||||
export const settingsAPI = {
|
||||
getSettings,
|
||||
updateSettings,
|
||||
@@ -544,7 +559,8 @@ export const settingsAPI = {
|
||||
getBetaPolicySettings,
|
||||
updateBetaPolicySettings,
|
||||
getWebSearchEmulationConfig,
|
||||
updateWebSearchEmulationConfig
|
||||
updateWebSearchEmulationConfig,
|
||||
testWebSearchEmulation
|
||||
}
|
||||
|
||||
export default settingsAPI
|
||||
|
||||
Reference in New Issue
Block a user