@nextclaw/ui 0.12.8 → 0.12.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +96 -0
- package/dist/assets/ChannelsList-M9FTK1Ak.js +8 -0
- package/dist/assets/DocBrowser-CH7-GxlL.js +1 -0
- package/dist/assets/{DocBrowser-BMxf9CIK.js → DocBrowser-DMfr0Oow.js} +1 -1
- package/dist/assets/{DocBrowserContext-Ce28gRXt.js → DocBrowserContext-BXydqby-.js} +1 -1
- package/dist/assets/{LogoBadge-o92MOA2L.js → LogoBadge-hO7tY7hE.js} +1 -1
- package/dist/assets/ModelConfig-CNIgLf0e.js +1 -0
- package/dist/assets/{ProviderScopedModelInput-CmTIzgI7.js → ProviderScopedModelInput-B3HWP4oz.js} +1 -1
- package/dist/assets/ProvidersList-CHjMnRhX.js +1 -0
- package/dist/assets/RuntimeConfig-psp8nMSG.js +1 -0
- package/dist/assets/SearchConfig-CSoKip1f.js +1 -0
- package/dist/assets/{SecretsConfig-Ba1RPJaG.js → SecretsConfig-MEt6MjuD.js} +2 -2
- package/dist/assets/SessionsConfig-DifCiXwR.js +2 -0
- package/dist/assets/{app-query-client-DniXoIN5.js → app-query-client-9jNewezV.js} +1 -1
- package/dist/assets/{book-open-DocgeQtR.js → book-open-DzdUViDm.js} +1 -1
- package/dist/assets/chat-page-CLp0UV0Y.js +58 -0
- package/dist/assets/chat-session-display-DsYHx0RZ.js +1 -0
- package/dist/assets/{chunk-JZWAC4HX-BvKvh1R8.js → chunk-JZWAC4HX-C5dEc8hV.js} +1 -1
- package/dist/assets/{client-CVqPF5ie.js → client-C-8fH7-c.js} +1 -1
- package/dist/assets/{config-Bop2oB18.js → config-CBScxsdV.js} +1 -1
- package/dist/assets/config-split-page-BUout_Ak.js +1 -0
- package/dist/assets/{createLucideIcon-DVv8taGY.js → createLucideIcon-dy5ie7Ox.js} +1 -1
- package/dist/assets/desktop-update-config-2BS6BMkW.js +1 -0
- package/dist/assets/{dist-DmAlInRu.js → dist-BruyLa92.js} +1 -1
- package/dist/assets/{dist-Da5Gm_pO.js → dist-Cy7_j6hA.js} +1 -1
- package/dist/assets/download-BD0ETkB-.js +1 -0
- package/dist/assets/{external-link-DFjw3x1B.js → external-link-kZSAO8nT.js} +1 -1
- package/dist/assets/{hash-DJtaCejM.js → hash-BHJC2Ovu.js} +1 -1
- package/dist/assets/i18n-CpTZLchQ.js +1 -0
- package/dist/assets/index-mW8W2FUu.css +1 -0
- package/dist/assets/index-zDZfXoI4.js +6 -0
- package/dist/assets/{infiniteQueryBehavior-DHSEQ3OH.js → infiniteQueryBehavior-CyER9hv0.js} +1 -1
- package/dist/assets/loader-circle-Bc2gCU33.js +1 -0
- package/dist/assets/{logos-DEFUIR12.js → logos-B7gRObP8.js} +1 -1
- package/dist/assets/marketplace-page-3qVMnF3d.js +1 -0
- package/dist/assets/marketplace-page-BhFIeQzI.js +49 -0
- package/dist/assets/mcp-marketplace-page-DYfteJ1D.js +40 -0
- package/dist/assets/{page-layout-Da3i3r6G.js → page-layout-0UcO9H9Z.js} +1 -1
- package/dist/assets/play-CKDjSQFL.js +1 -0
- package/dist/assets/plus-CG0QrVY_.js +1 -0
- package/dist/assets/{refresh-ccw-D6HkNtfz.js → refresh-ccw-COVhNHtN.js} +1 -1
- package/dist/assets/{refresh-cw-DRcvRrnc.js → refresh-cw-Bcv40SXy.js} +1 -1
- package/dist/assets/remote-access-page-CWHG-sug.js +1 -0
- package/dist/assets/{rotate-cw-BmDKfXtH.js → rotate-cw-oHMKJMC8.js} +1 -1
- package/dist/assets/{save-DHGmi2e9.js → save-EqJPOF0G.js} +1 -1
- package/dist/assets/search-BCAlB8nz.js +1 -0
- package/dist/assets/security-config-Slh0Mayz.js +1 -0
- package/dist/assets/select-CVz0t7MF.js +41 -0
- package/dist/assets/setting-row-CbVHAuQt.js +1 -0
- package/dist/assets/skeleton-D5rdKvzy.js +1 -0
- package/dist/assets/{status-dot-DurKKSwA.js → status-dot-DpPtVzQT.js} +1 -1
- package/dist/assets/{switch-0rmPBRKI.js → switch-CM29eCAR.js} +1 -1
- package/dist/assets/{tabs-custom-5JLVL6v8.js → tabs-custom-YcZUWn3o.js} +1 -1
- package/dist/assets/tag-chip-DMXdnLcj.js +1 -0
- package/dist/assets/{trash-2-C6caKPoz.js → trash-2-mJT6oWa2.js} +1 -1
- package/dist/assets/{use-infinite-scroll-loader-dwnaa_qi.js → use-infinite-scroll-loader-DJ1L81Dz.js} +1 -1
- package/dist/assets/{useConfirmDialog-mMeWD_yo.js → useConfirmDialog-BsVuqu1x.js} +1 -1
- package/dist/assets/{useMutation-BmxxvCNf.js → useMutation-CNcz2fgt.js} +1 -1
- package/dist/assets/x-Czwxm82I.js +1 -0
- package/dist/index.html +95 -21
- package/dist/manifest.webmanifest +30 -0
- package/dist/offline.html +102 -0
- package/dist/pwa-192.png +0 -0
- package/dist/pwa-512.png +0 -0
- package/dist/runtime-icons/claude.ico +0 -0
- package/dist/runtime-icons/codex-openai.svg +6 -0
- package/dist/runtime-icons/hermes-agent.png +0 -0
- package/dist/sw.js +80 -0
- package/index.html +73 -1
- package/package.json +5 -5
- package/public/manifest.webmanifest +30 -0
- package/public/offline.html +102 -0
- package/public/pwa-192.png +0 -0
- package/public/pwa-512.png +0 -0
- package/public/runtime-icons/claude.ico +0 -0
- package/public/runtime-icons/codex-openai.svg +6 -0
- package/public/runtime-icons/hermes-agent.png +0 -0
- package/public/sw.js +80 -0
- package/src/account/components/account-panel.tsx +217 -97
- package/src/account/managers/account.manager.ts +3 -2
- package/src/api/chat-session-type.types.ts +7 -0
- package/src/api/runtime-control.types.ts +8 -0
- package/src/api/server-path.ts +27 -4
- package/src/api/types.ts +25 -10
- package/src/app.tsx +227 -54
- package/src/components/agents/agent-dialogs.tsx +499 -0
- package/src/components/agents/agents-page.test.tsx +238 -0
- package/src/components/agents/agents-page.tsx +435 -0
- package/src/components/chat/ChatSidebar.test.tsx +43 -1
- package/src/components/chat/ChatSidebar.tsx +35 -35
- package/src/components/chat/adapters/chat-message.summary-truncation.test.ts +66 -0
- package/src/components/chat/adapters/file-operation/card.ts +9 -0
- package/src/components/chat/adapters/file-operation/diff.ts +14 -0
- package/src/components/chat/{ChatConversationPanel.test.tsx → chat-conversation-panel.test.tsx} +127 -206
- package/src/components/chat/chat-conversation-panel.tsx +482 -0
- package/src/components/chat/chat-page-shell.tsx +19 -13
- package/src/components/chat/chat-session-type-option-item.test.tsx +46 -0
- package/src/components/chat/chat-session-type-option-item.tsx +68 -0
- package/src/components/chat/chat-session-workspace-file-preview.test.tsx +178 -0
- package/src/components/chat/chat-session-workspace-file-preview.tsx +278 -0
- package/src/components/chat/chat-session-workspace-panel-nav.tsx +203 -0
- package/src/components/chat/chat-session-workspace-panel.tsx +318 -0
- package/src/components/chat/chat-sidebar-project-groups.tsx +11 -36
- package/src/components/chat/chat-sidebar-session-item.tsx +32 -2
- package/src/components/chat/containers/chat-message-list.container.test.tsx +49 -0
- package/src/components/chat/containers/chat-message-list.container.tsx +4 -0
- package/src/components/chat/managers/chat-session-list.manager.test.ts +12 -0
- package/src/components/chat/managers/chat-session-list.manager.ts +7 -0
- package/src/components/chat/ncp/__tests__/ncp-session-adapter.cancelled-tool.test.ts +77 -0
- package/src/components/chat/ncp/ncp-chat-page.tsx +9 -7
- package/src/components/chat/ncp/ncp-chat-thread.manager.ts +179 -41
- package/src/components/chat/ncp/ncp-session-adapter.test.ts +36 -1
- package/src/components/chat/ncp/ncp-session-adapter.ts +20 -0
- package/src/components/chat/ncp/page/ncp-chat-derived-state.ts +62 -13
- package/src/components/chat/ncp/tests/ncp-chat-thread.manager.test.ts +189 -0
- package/src/components/chat/presenter/chat-presenter-context.tsx +13 -2
- package/src/components/chat/session-header/chat-session-header-actions.test.tsx +26 -0
- package/src/components/chat/session-header/chat-session-header-actions.tsx +19 -1
- package/src/components/chat/stores/chat-input.store.ts +2 -1
- package/src/components/chat/stores/chat-thread.store.ts +27 -1
- package/src/components/chat/useChatSessionTypeState.ts +10 -1
- package/src/components/chat/workspace/chat-session-workspace-file-breadcrumbs.tsx +86 -0
- package/src/components/common/BrandHeader.tsx +3 -1
- package/src/components/common/session-context-icon.tsx +15 -2
- package/src/components/common/{TagInput.tsx → tag-input.tsx} +25 -17
- package/src/components/config/ChannelForm.test.tsx +89 -3
- package/src/components/config/ChannelForm.tsx +157 -188
- package/src/components/config/ChannelsList.test.tsx +163 -119
- package/src/components/config/ChannelsList.tsx +90 -101
- package/src/components/config/ProviderForm.tsx +108 -146
- package/src/components/config/ProvidersList.tsx +100 -123
- package/src/components/config/RuntimeConfig.tsx +141 -2
- package/src/components/config/SearchConfig.tsx +423 -393
- package/src/components/config/channel-form-fields-section.tsx +70 -37
- package/src/components/config/config-split-page.tsx +109 -0
- package/src/components/config/provider-enabled-field.tsx +17 -10
- package/src/components/config/runtime-control-card.test.tsx +56 -0
- package/src/components/config/runtime-control-card.tsx +25 -0
- package/src/components/config/runtime-presence-card.tsx +93 -79
- package/src/components/layout/AppLayout.tsx +25 -37
- package/src/components/layout/app-layout.test.tsx +46 -14
- package/src/components/layout/runtime-status-entry.test.tsx +157 -0
- package/src/components/layout/runtime-status-entry.tsx +143 -0
- package/src/components/marketplace/marketplace-detail-doc.ts +93 -0
- package/src/components/marketplace/marketplace-list-card.tsx +288 -0
- package/src/components/marketplace/marketplace-page-data.ts +129 -0
- package/src/components/marketplace/marketplace-page.test.tsx +339 -0
- package/src/components/marketplace/marketplace-page.tsx +596 -0
- package/src/components/marketplace/mcp/mcp-marketplace-card.tsx +128 -0
- package/src/components/marketplace/mcp/mcp-marketplace-dialogs.tsx +191 -0
- package/src/components/marketplace/mcp/mcp-marketplace-doc.ts +152 -0
- package/src/components/marketplace/mcp/mcp-marketplace-page.test.tsx +223 -0
- package/src/components/marketplace/mcp/mcp-marketplace-page.tsx +414 -0
- package/src/components/providers/ThemeProvider.tsx +5 -0
- package/src/components/remote/remote-access-page.test.tsx +105 -0
- package/src/components/remote/remote-access-page.tsx +248 -0
- package/src/components/ui/notice-card.tsx +129 -0
- package/src/components/ui/setting-row.tsx +51 -0
- package/src/components/ui/tag-chip.tsx +39 -0
- package/src/components/ui/textarea.tsx +19 -0
- package/src/hooks/server-path/use-server-path-read.ts +20 -0
- package/src/hooks/useConfig.ts +2 -1
- package/src/index.css +24 -0
- package/src/lib/app-resource-uri.test.ts +20 -0
- package/src/lib/app-resource-uri.ts +29 -0
- package/src/lib/chat-message.ts +14 -3
- package/src/lib/i18n.chat.ts +12 -1
- package/src/lib/i18n.pwa.ts +62 -0
- package/src/lib/i18n.remote.ts +1 -1
- package/src/lib/i18n.runtime-control.ts +31 -0
- package/src/lib/i18n.ts +7 -10
- package/src/lib/session-context.utils.test.ts +71 -0
- package/src/lib/session-context.utils.ts +28 -3
- package/src/lib/session-project/workspace-file-breadcrumb.test.ts +83 -0
- package/src/lib/session-project/workspace-file-breadcrumb.ts +188 -0
- package/src/pwa/components/pwa-install-entry.test.tsx +110 -0
- package/src/pwa/components/pwa-install-entry.tsx +205 -0
- package/src/pwa/managers/pwa-install.manager.test.ts +160 -0
- package/src/pwa/managers/pwa-install.manager.ts +232 -0
- package/src/pwa/managers/pwa-runtime.manager.ts +196 -0
- package/src/pwa/managers/pwa-shell-theme.manager.test.ts +30 -0
- package/src/pwa/managers/pwa-shell-theme.manager.ts +46 -0
- package/src/pwa/pwa-install-banner.storage.ts +55 -0
- package/src/pwa/pwa.types.ts +22 -0
- package/src/pwa/register-pwa.ts +14 -0
- package/src/pwa/stores/pwa.store.ts +17 -0
- package/src/vite-env.d.ts +9 -0
- package/dist/assets/ChannelsList-KIQIxluX.js +0 -8
- package/dist/assets/DocBrowser-CyDgAtO9.js +0 -1
- package/dist/assets/MarketplacePage-BySqkYDh.js +0 -49
- package/dist/assets/MarketplacePage-C0olZaek.js +0 -1
- package/dist/assets/McpMarketplacePage-DqKaiXO9.js +0 -40
- package/dist/assets/ModelConfig-IrmzoslW.js +0 -1
- package/dist/assets/ProvidersList-8_Kalfwl.js +0 -1
- package/dist/assets/RemoteAccessPage-CyQlSjPf.js +0 -1
- package/dist/assets/RuntimeConfig-Bk0uYBhf.js +0 -1
- package/dist/assets/SearchConfig-DNBR-UbE.js +0 -1
- package/dist/assets/SessionsConfig-Doqp5ghH.js +0 -2
- package/dist/assets/chat-page-Bph8M5zo.js +0 -58
- package/dist/assets/chat-session-display-CoN3Wmn-.js +0 -1
- package/dist/assets/config-layout-DmlGaay2.js +0 -1
- package/dist/assets/desktop-update-config-1KBrqLBC.js +0 -1
- package/dist/assets/i18n-CwHZ-9vt.js +0 -1
- package/dist/assets/index-DafCdM4F.css +0 -1
- package/dist/assets/index-DdksE6U3.js +0 -6
- package/dist/assets/loader-circle-PsSP0H9n.js +0 -1
- package/dist/assets/play-DBQbBxTA.js +0 -1
- package/dist/assets/plus-DUOVbsyQ.js +0 -1
- package/dist/assets/popover-C_mWOFzI.js +0 -1
- package/dist/assets/search-MChQRYR1.js +0 -1
- package/dist/assets/security-config-CbXfPZzr.js +0 -1
- package/dist/assets/select-Caud8QvU.js +0 -41
- package/dist/assets/skeleton-B-4vRq_Z.js +0 -1
- package/dist/assets/x-DuMhMATD.js +0 -1
- package/src/components/agents/AgentDialogs.tsx +0 -400
- package/src/components/agents/AgentsPage.test.tsx +0 -217
- package/src/components/agents/AgentsPage.tsx +0 -352
- package/src/components/chat/ChatConversationPanel.tsx +0 -256
- package/src/components/chat/chat-child-session-panel.tsx +0 -270
- package/src/components/config/config-layout.ts +0 -10
- package/src/components/marketplace/MarketplacePage.test.tsx +0 -322
- package/src/components/marketplace/MarketplacePage.tsx +0 -827
- package/src/components/marketplace/mcp/McpMarketplacePage.test.tsx +0 -208
- package/src/components/marketplace/mcp/McpMarketplacePage.tsx +0 -580
- package/src/components/remote/RemoteAccessPage.test.tsx +0 -103
- package/src/components/remote/RemoteAccessPage.tsx +0 -144
- /package/dist/assets/{config-hints-BZoDjXye.js → config-hints-BhTmc9P1.js} +0 -0
|
@@ -1,229 +1,203 @@
|
|
|
1
|
-
import { useEffect, useMemo, useState } from
|
|
2
|
-
import { ExternalLink, KeyRound, Search as SearchIcon } from
|
|
3
|
-
import { PageHeader, PageLayout } from
|
|
4
|
-
import { Button } from
|
|
5
|
-
import { Input } from
|
|
6
|
-
import { Label } from
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { ExternalLink, KeyRound, Search as SearchIcon } from "lucide-react";
|
|
3
|
+
import { PageHeader, PageLayout } from "@/components/layout/page-layout";
|
|
4
|
+
import { Button } from "@/components/ui/button";
|
|
5
|
+
import { Input } from "@/components/ui/input";
|
|
6
|
+
import { Label } from "@/components/ui/label";
|
|
7
|
+
import {
|
|
8
|
+
Select,
|
|
9
|
+
SelectContent,
|
|
10
|
+
SelectItem,
|
|
11
|
+
SelectTrigger,
|
|
12
|
+
SelectValue,
|
|
13
|
+
} from "@/components/ui/select";
|
|
14
|
+
import { useConfig, useConfigMeta, useUpdateSearch } from "@/hooks/useConfig";
|
|
15
|
+
import { t } from "@/lib/i18n";
|
|
16
|
+
import type {
|
|
17
|
+
SearchConfigUpdate,
|
|
18
|
+
SearchProviderName,
|
|
19
|
+
TavilySearchDepthValue,
|
|
20
|
+
} from "@/api/types";
|
|
21
|
+
import {
|
|
22
|
+
ConfigSelectionCard,
|
|
23
|
+
ConfigSplitDetailPane,
|
|
24
|
+
ConfigSplitEmptyPane,
|
|
25
|
+
ConfigSplitPage,
|
|
26
|
+
ConfigSplitPaneBody,
|
|
27
|
+
ConfigSplitPaneFooter,
|
|
28
|
+
ConfigSplitPaneHeader,
|
|
29
|
+
ConfigSplitSidebar,
|
|
30
|
+
} from "./config-split-page";
|
|
13
31
|
|
|
14
32
|
const FRESHNESS_OPTIONS = [
|
|
15
|
-
{ value:
|
|
16
|
-
{ value:
|
|
17
|
-
{ value:
|
|
18
|
-
{ value:
|
|
19
|
-
{ value:
|
|
33
|
+
{ value: "noLimit", label: "searchFreshnessNoLimit" },
|
|
34
|
+
{ value: "oneDay", label: "searchFreshnessOneDay" },
|
|
35
|
+
{ value: "oneWeek", label: "searchFreshnessOneWeek" },
|
|
36
|
+
{ value: "oneMonth", label: "searchFreshnessOneMonth" },
|
|
37
|
+
{ value: "oneYear", label: "searchFreshnessOneYear" },
|
|
20
38
|
] as const;
|
|
21
39
|
|
|
22
40
|
const SEARCH_DEPTH_OPTIONS = [
|
|
23
|
-
{ value:
|
|
24
|
-
{ value:
|
|
41
|
+
{ value: "basic", label: "searchDepthBasic" },
|
|
42
|
+
{ value: "advanced", label: "searchDepthAdvanced" },
|
|
25
43
|
] as const;
|
|
26
44
|
|
|
27
45
|
const SEARCH_PROVIDER_DESCRIPTION_KEYS: Record<SearchProviderName, string> = {
|
|
28
|
-
bocha:
|
|
29
|
-
tavily:
|
|
30
|
-
brave:
|
|
46
|
+
bocha: "searchProviderBochaDescription",
|
|
47
|
+
tavily: "searchProviderTavilyDescription",
|
|
48
|
+
brave: "searchProviderBraveDescription",
|
|
31
49
|
};
|
|
32
50
|
|
|
33
|
-
type
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
51
|
+
type SearchDraft = {
|
|
52
|
+
activeProvider: SearchProviderName;
|
|
53
|
+
enabledProviders: SearchProviderName[];
|
|
54
|
+
maxResults: string;
|
|
55
|
+
providers: {
|
|
56
|
+
bocha: {
|
|
57
|
+
apiKey: string;
|
|
58
|
+
baseUrl: string;
|
|
59
|
+
summary: boolean;
|
|
60
|
+
freshness: string;
|
|
61
|
+
};
|
|
62
|
+
tavily: {
|
|
63
|
+
apiKey: string;
|
|
64
|
+
baseUrl: string;
|
|
65
|
+
searchDepth: TavilySearchDepthValue;
|
|
66
|
+
includeAnswer: boolean;
|
|
67
|
+
};
|
|
68
|
+
brave: {
|
|
69
|
+
apiKey: string;
|
|
70
|
+
baseUrl: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
44
73
|
};
|
|
45
74
|
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
75
|
+
function buildSearchDraft(
|
|
76
|
+
search: NonNullable<ReturnType<typeof useConfig>["data"]>["search"],
|
|
77
|
+
): SearchDraft {
|
|
78
|
+
return {
|
|
79
|
+
activeProvider: search.provider,
|
|
80
|
+
enabledProviders: search.enabledProviders,
|
|
81
|
+
maxResults: String(search.defaults.maxResults),
|
|
82
|
+
providers: {
|
|
83
|
+
bocha: {
|
|
84
|
+
apiKey: "",
|
|
85
|
+
baseUrl: search.providers.bocha.baseUrl,
|
|
86
|
+
summary: Boolean(search.providers.bocha.summary),
|
|
87
|
+
freshness: search.providers.bocha.freshness ?? "noLimit",
|
|
88
|
+
},
|
|
89
|
+
tavily: {
|
|
90
|
+
apiKey: "",
|
|
91
|
+
baseUrl: search.providers.tavily.baseUrl,
|
|
92
|
+
searchDepth: search.providers.tavily.searchDepth ?? "basic",
|
|
93
|
+
includeAnswer: Boolean(search.providers.tavily.includeAnswer),
|
|
94
|
+
},
|
|
95
|
+
brave: {
|
|
96
|
+
apiKey: "",
|
|
97
|
+
baseUrl: search.providers.brave.baseUrl,
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function buildSearchPayload(draft: SearchDraft): SearchConfigUpdate {
|
|
104
|
+
return {
|
|
105
|
+
provider: draft.activeProvider,
|
|
106
|
+
enabledProviders: draft.enabledProviders,
|
|
107
|
+
defaults: { maxResults: Number(draft.maxResults) || 10 },
|
|
108
|
+
providers: {
|
|
109
|
+
bocha: {
|
|
110
|
+
apiKey: draft.providers.bocha.apiKey || undefined,
|
|
111
|
+
baseUrl: draft.providers.bocha.baseUrl,
|
|
112
|
+
summary: draft.providers.bocha.summary,
|
|
113
|
+
freshness: draft.providers.bocha.freshness,
|
|
114
|
+
},
|
|
115
|
+
tavily: {
|
|
116
|
+
apiKey: draft.providers.tavily.apiKey || undefined,
|
|
117
|
+
baseUrl: draft.providers.tavily.baseUrl,
|
|
118
|
+
searchDepth: draft.providers.tavily.searchDepth,
|
|
119
|
+
includeAnswer: draft.providers.tavily.includeAnswer,
|
|
120
|
+
},
|
|
121
|
+
brave: {
|
|
122
|
+
apiKey: draft.providers.brave.apiKey || undefined,
|
|
123
|
+
baseUrl: draft.providers.brave.baseUrl,
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function SearchTextField({
|
|
130
|
+
label,
|
|
131
|
+
value,
|
|
132
|
+
onChange,
|
|
133
|
+
placeholder,
|
|
134
|
+
type = "text",
|
|
135
|
+
inputMode,
|
|
136
|
+
}: {
|
|
137
|
+
label: string;
|
|
138
|
+
value: string;
|
|
139
|
+
onChange: (value: string) => void;
|
|
140
|
+
placeholder?: string;
|
|
141
|
+
type?: string;
|
|
142
|
+
inputMode?: "numeric";
|
|
143
|
+
}) {
|
|
58
144
|
return (
|
|
59
|
-
<div className="space-y-
|
|
60
|
-
<
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
</div>
|
|
70
|
-
<div className="space-y-2">
|
|
71
|
-
<Label>{t('searchProviderBaseUrl')}</Label>
|
|
72
|
-
<Input value={baseUrl} onChange={(event) => onBaseUrlChange(event.target.value)} className="rounded-xl" />
|
|
73
|
-
</div>
|
|
74
|
-
<div className="grid gap-4 md:grid-cols-2">
|
|
75
|
-
<div className="space-y-2">
|
|
76
|
-
<Label>{t('searchProviderSummary')}</Label>
|
|
77
|
-
<Select value={summary ? 'true' : 'false'} onValueChange={(value) => onSummaryChange(value === 'true')}>
|
|
78
|
-
<SelectTrigger className="rounded-xl">
|
|
79
|
-
<SelectValue />
|
|
80
|
-
</SelectTrigger>
|
|
81
|
-
<SelectContent>
|
|
82
|
-
<SelectItem value="true">{t('enabled')}</SelectItem>
|
|
83
|
-
<SelectItem value="false">{t('disabled')}</SelectItem>
|
|
84
|
-
</SelectContent>
|
|
85
|
-
</Select>
|
|
86
|
-
</div>
|
|
87
|
-
<div className="space-y-2">
|
|
88
|
-
<Label>{t('searchProviderFreshness')}</Label>
|
|
89
|
-
<Select value={freshness} onValueChange={onFreshnessChange}>
|
|
90
|
-
<SelectTrigger className="rounded-xl">
|
|
91
|
-
<SelectValue />
|
|
92
|
-
</SelectTrigger>
|
|
93
|
-
<SelectContent>
|
|
94
|
-
{FRESHNESS_OPTIONS.map((option) => (
|
|
95
|
-
<SelectItem key={option.value} value={option.value}>{t(option.label)}</SelectItem>
|
|
96
|
-
))}
|
|
97
|
-
</SelectContent>
|
|
98
|
-
</Select>
|
|
99
|
-
</div>
|
|
100
|
-
</div>
|
|
101
|
-
<div className="space-y-2">
|
|
102
|
-
<a href={docsUrl ?? 'https://open.bocha.cn'} target="_blank" rel="noreferrer">
|
|
103
|
-
<Button type="button" variant="outline" className="rounded-xl">
|
|
104
|
-
<ExternalLink className="mr-2 h-4 w-4" />
|
|
105
|
-
{t('searchProviderOpenDocs')}
|
|
106
|
-
</Button>
|
|
107
|
-
</a>
|
|
108
|
-
</div>
|
|
145
|
+
<div className="space-y-2">
|
|
146
|
+
<Label>{label}</Label>
|
|
147
|
+
<Input
|
|
148
|
+
type={type}
|
|
149
|
+
value={value}
|
|
150
|
+
onChange={(event) => onChange(event.target.value)}
|
|
151
|
+
placeholder={placeholder}
|
|
152
|
+
inputMode={inputMode}
|
|
153
|
+
className="rounded-xl"
|
|
154
|
+
/>
|
|
109
155
|
</div>
|
|
110
156
|
);
|
|
111
157
|
}
|
|
112
158
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
function TavilyProviderFields({
|
|
127
|
-
apiKey,
|
|
128
|
-
apiKeyMasked,
|
|
129
|
-
baseUrl,
|
|
130
|
-
searchDepth,
|
|
131
|
-
includeAnswer,
|
|
132
|
-
docsUrl,
|
|
133
|
-
onApiKeyChange,
|
|
134
|
-
onBaseUrlChange,
|
|
135
|
-
onSearchDepthChange,
|
|
136
|
-
onIncludeAnswerChange
|
|
137
|
-
}: TavilyProviderFieldsProps) {
|
|
159
|
+
function SearchSelectField({
|
|
160
|
+
label,
|
|
161
|
+
value,
|
|
162
|
+
options,
|
|
163
|
+
onChange,
|
|
164
|
+
}: {
|
|
165
|
+
label: string;
|
|
166
|
+
value: string;
|
|
167
|
+
options: ReadonlyArray<{ value: string; label: string }>;
|
|
168
|
+
onChange: (value: string) => void;
|
|
169
|
+
}) {
|
|
138
170
|
return (
|
|
139
|
-
<div className="space-y-
|
|
140
|
-
<
|
|
141
|
-
|
|
142
|
-
<
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
</div>
|
|
154
|
-
<div className="grid gap-4 md:grid-cols-2">
|
|
155
|
-
<div className="space-y-2">
|
|
156
|
-
<Label>{t('searchProviderSearchDepth')}</Label>
|
|
157
|
-
<Select value={searchDepth} onValueChange={(value) => onSearchDepthChange(value as TavilySearchDepthValue)}>
|
|
158
|
-
<SelectTrigger className="rounded-xl">
|
|
159
|
-
<SelectValue />
|
|
160
|
-
</SelectTrigger>
|
|
161
|
-
<SelectContent>
|
|
162
|
-
{SEARCH_DEPTH_OPTIONS.map((option) => (
|
|
163
|
-
<SelectItem key={option.value} value={option.value}>{t(option.label)}</SelectItem>
|
|
164
|
-
))}
|
|
165
|
-
</SelectContent>
|
|
166
|
-
</Select>
|
|
167
|
-
</div>
|
|
168
|
-
<div className="space-y-2">
|
|
169
|
-
<Label>{t('searchProviderIncludeAnswer')}</Label>
|
|
170
|
-
<Select value={includeAnswer ? 'true' : 'false'} onValueChange={(value) => onIncludeAnswerChange(value === 'true')}>
|
|
171
|
-
<SelectTrigger className="rounded-xl">
|
|
172
|
-
<SelectValue />
|
|
173
|
-
</SelectTrigger>
|
|
174
|
-
<SelectContent>
|
|
175
|
-
<SelectItem value="true">{t('enabled')}</SelectItem>
|
|
176
|
-
<SelectItem value="false">{t('disabled')}</SelectItem>
|
|
177
|
-
</SelectContent>
|
|
178
|
-
</Select>
|
|
179
|
-
</div>
|
|
180
|
-
</div>
|
|
181
|
-
{docsUrl ? (
|
|
182
|
-
<div className="space-y-2">
|
|
183
|
-
<a href={docsUrl} target="_blank" rel="noreferrer">
|
|
184
|
-
<Button type="button" variant="outline" className="rounded-xl">
|
|
185
|
-
<ExternalLink className="mr-2 h-4 w-4" />
|
|
186
|
-
{t('searchProviderOpenDocs')}
|
|
187
|
-
</Button>
|
|
188
|
-
</a>
|
|
189
|
-
</div>
|
|
190
|
-
) : null}
|
|
171
|
+
<div className="space-y-2">
|
|
172
|
+
<Label>{label}</Label>
|
|
173
|
+
<Select value={value} onValueChange={onChange}>
|
|
174
|
+
<SelectTrigger className="rounded-xl">
|
|
175
|
+
<SelectValue />
|
|
176
|
+
</SelectTrigger>
|
|
177
|
+
<SelectContent>
|
|
178
|
+
{options.map((option) => (
|
|
179
|
+
<SelectItem key={option.value} value={option.value}>
|
|
180
|
+
{t(option.label)}
|
|
181
|
+
</SelectItem>
|
|
182
|
+
))}
|
|
183
|
+
</SelectContent>
|
|
184
|
+
</Select>
|
|
191
185
|
</div>
|
|
192
186
|
);
|
|
193
187
|
}
|
|
194
188
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
onApiKeyChange: (value: string) => void;
|
|
200
|
-
onBaseUrlChange: (value: string) => void;
|
|
201
|
-
};
|
|
189
|
+
function SearchDocsButton({ docsUrl }: { docsUrl?: string }) {
|
|
190
|
+
if (!docsUrl) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
202
193
|
|
|
203
|
-
function BraveProviderFields({
|
|
204
|
-
apiKey,
|
|
205
|
-
apiKeyMasked,
|
|
206
|
-
baseUrl,
|
|
207
|
-
onApiKeyChange,
|
|
208
|
-
onBaseUrlChange
|
|
209
|
-
}: BraveProviderFieldsProps) {
|
|
210
194
|
return (
|
|
211
|
-
<
|
|
212
|
-
<
|
|
213
|
-
<
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
onChange={(event) => onApiKeyChange(event.target.value)}
|
|
218
|
-
placeholder={apiKeyMasked || t('enterApiKey')}
|
|
219
|
-
className="rounded-xl"
|
|
220
|
-
/>
|
|
221
|
-
</div>
|
|
222
|
-
<div className="space-y-2">
|
|
223
|
-
<Label>{t('searchProviderBaseUrl')}</Label>
|
|
224
|
-
<Input value={baseUrl} onChange={(event) => onBaseUrlChange(event.target.value)} className="rounded-xl" />
|
|
225
|
-
</div>
|
|
226
|
-
</div>
|
|
195
|
+
<a href={docsUrl} target="_blank" rel="noreferrer">
|
|
196
|
+
<Button type="button" variant="outline" className="rounded-xl">
|
|
197
|
+
<ExternalLink className="mr-2 h-4 w-4" />
|
|
198
|
+
{t("searchProviderOpenDocs")}
|
|
199
|
+
</Button>
|
|
200
|
+
</a>
|
|
227
201
|
);
|
|
228
202
|
}
|
|
229
203
|
|
|
@@ -233,251 +207,307 @@ export function SearchConfig() {
|
|
|
233
207
|
const updateSearch = useUpdateSearch();
|
|
234
208
|
const providers = useMemo(() => meta?.search ?? [], [meta]);
|
|
235
209
|
const search = config?.search;
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
const [
|
|
239
|
-
const [enabledProviders, setEnabledProviders] = useState<SearchProviderName[]>(['bocha']);
|
|
240
|
-
const [maxResults, setMaxResults] = useState('10');
|
|
241
|
-
const [bochaApiKey, setBochaApiKey] = useState('');
|
|
242
|
-
const [bochaBaseUrl, setBochaBaseUrl] = useState('https://api.bocha.cn/v1/web-search');
|
|
243
|
-
const [bochaSummary, setBochaSummary] = useState(true);
|
|
244
|
-
const [bochaFreshness, setBochaFreshness] = useState('noLimit');
|
|
245
|
-
const [tavilyApiKey, setTavilyApiKey] = useState('');
|
|
246
|
-
const [tavilyBaseUrl, setTavilyBaseUrl] = useState('https://api.tavily.com/search');
|
|
247
|
-
const [tavilySearchDepth, setTavilySearchDepth] = useState<TavilySearchDepthValue>('basic');
|
|
248
|
-
const [tavilyIncludeAnswer, setTavilyIncludeAnswer] = useState(false);
|
|
249
|
-
const [braveApiKey, setBraveApiKey] = useState('');
|
|
250
|
-
const [braveBaseUrl, setBraveBaseUrl] = useState('https://api.search.brave.com/res/v1/web/search');
|
|
210
|
+
const [selectedProvider, setSelectedProvider] =
|
|
211
|
+
useState<SearchProviderName>("bocha");
|
|
212
|
+
const [draft, setDraft] = useState<SearchDraft | null>(null);
|
|
251
213
|
|
|
252
214
|
useEffect(() => {
|
|
253
215
|
if (!search) {
|
|
254
216
|
return;
|
|
255
217
|
}
|
|
256
218
|
setSelectedProvider(search.provider);
|
|
257
|
-
|
|
258
|
-
setEnabledProviders(search.enabledProviders);
|
|
259
|
-
setMaxResults(String(search.defaults.maxResults));
|
|
260
|
-
setBochaBaseUrl(search.providers.bocha.baseUrl);
|
|
261
|
-
setBochaSummary(Boolean(search.providers.bocha.summary));
|
|
262
|
-
setBochaFreshness(search.providers.bocha.freshness ?? 'noLimit');
|
|
263
|
-
setTavilyBaseUrl(search.providers.tavily.baseUrl);
|
|
264
|
-
setTavilySearchDepth(search.providers.tavily.searchDepth ?? 'basic');
|
|
265
|
-
setTavilyIncludeAnswer(Boolean(search.providers.tavily.includeAnswer));
|
|
266
|
-
setBraveBaseUrl(search.providers.brave.baseUrl);
|
|
219
|
+
setDraft(buildSearchDraft(search));
|
|
267
220
|
}, [search]);
|
|
268
221
|
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
[providers
|
|
272
|
-
)
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
222
|
+
const updateProviderDraft = <T extends SearchProviderName>(
|
|
223
|
+
provider: T,
|
|
224
|
+
patch: Partial<SearchDraft["providers"][T]>,
|
|
225
|
+
) => {
|
|
226
|
+
setDraft((prev) =>
|
|
227
|
+
prev
|
|
228
|
+
? {
|
|
229
|
+
...prev,
|
|
230
|
+
providers: {
|
|
231
|
+
...prev.providers,
|
|
232
|
+
[provider]: {
|
|
233
|
+
...prev.providers[provider],
|
|
234
|
+
...patch,
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
}
|
|
238
|
+
: prev,
|
|
239
|
+
);
|
|
240
|
+
};
|
|
279
241
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
},
|
|
289
|
-
providers: {
|
|
290
|
-
bocha: {
|
|
291
|
-
apiKey: bochaApiKey || undefined,
|
|
292
|
-
baseUrl: bochaBaseUrl,
|
|
293
|
-
summary: bochaSummary,
|
|
294
|
-
freshness: bochaFreshness
|
|
295
|
-
},
|
|
296
|
-
tavily: {
|
|
297
|
-
apiKey: tavilyApiKey || undefined,
|
|
298
|
-
baseUrl: tavilyBaseUrl,
|
|
299
|
-
searchDepth: tavilySearchDepth,
|
|
300
|
-
includeAnswer: tavilyIncludeAnswer
|
|
301
|
-
},
|
|
302
|
-
brave: {
|
|
303
|
-
apiKey: braveApiKey || undefined,
|
|
304
|
-
baseUrl: braveBaseUrl
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
});
|
|
242
|
+
if (!search || providers.length === 0 || !draft) {
|
|
243
|
+
return <div className="p-8">{t("loading")}</div>;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const selectedMeta = providers.find((provider) => provider.name === selectedProvider);
|
|
247
|
+
const selectedView = search.providers[selectedProvider];
|
|
248
|
+
const selectedEnabled = draft.enabledProviders.includes(selectedProvider);
|
|
249
|
+
const selectedDocsUrl = selectedView?.docsUrl ?? selectedMeta?.docsUrl;
|
|
308
250
|
|
|
309
251
|
const handleToggleEnabled = () => {
|
|
310
|
-
const
|
|
311
|
-
? enabledProviders.filter((provider) => provider !== selectedProvider)
|
|
312
|
-
: [...enabledProviders, selectedProvider];
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
});
|
|
252
|
+
const enabledProviders = selectedEnabled
|
|
253
|
+
? draft.enabledProviders.filter((provider) => provider !== selectedProvider)
|
|
254
|
+
: [...draft.enabledProviders, selectedProvider];
|
|
255
|
+
const nextDraft = { ...draft, enabledProviders };
|
|
256
|
+
setDraft(nextDraft);
|
|
257
|
+
updateSearch.mutate({ data: buildSearchPayload(nextDraft) });
|
|
317
258
|
};
|
|
318
259
|
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
|
|
260
|
+
const renderProviderFields = () => {
|
|
261
|
+
if (selectedProvider === "bocha") {
|
|
262
|
+
const bocha = draft.providers.bocha;
|
|
263
|
+
return (
|
|
264
|
+
<>
|
|
265
|
+
<SearchTextField
|
|
266
|
+
label={t("apiKey")}
|
|
267
|
+
value={bocha.apiKey}
|
|
268
|
+
onChange={(apiKey) => updateProviderDraft("bocha", { apiKey })}
|
|
269
|
+
placeholder={search.providers.bocha.apiKeyMasked || t("enterApiKey")}
|
|
270
|
+
type="password"
|
|
271
|
+
/>
|
|
272
|
+
<SearchTextField
|
|
273
|
+
label={t("searchProviderBaseUrl")}
|
|
274
|
+
value={bocha.baseUrl}
|
|
275
|
+
onChange={(baseUrl) => updateProviderDraft("bocha", { baseUrl })}
|
|
276
|
+
/>
|
|
277
|
+
<div className="grid gap-4 md:grid-cols-2">
|
|
278
|
+
<SearchSelectField
|
|
279
|
+
label={t("searchProviderSummary")}
|
|
280
|
+
value={bocha.summary ? "true" : "false"}
|
|
281
|
+
options={[
|
|
282
|
+
{ value: "true", label: "enabled" },
|
|
283
|
+
{ value: "false", label: "disabled" },
|
|
284
|
+
]}
|
|
285
|
+
onChange={(value) =>
|
|
286
|
+
updateProviderDraft("bocha", { summary: value === "true" })
|
|
287
|
+
}
|
|
288
|
+
/>
|
|
289
|
+
<SearchSelectField
|
|
290
|
+
label={t("searchProviderFreshness")}
|
|
291
|
+
value={bocha.freshness}
|
|
292
|
+
options={FRESHNESS_OPTIONS}
|
|
293
|
+
onChange={(freshness) =>
|
|
294
|
+
updateProviderDraft("bocha", { freshness })
|
|
295
|
+
}
|
|
296
|
+
/>
|
|
297
|
+
</div>
|
|
298
|
+
<SearchDocsButton docsUrl={selectedDocsUrl ?? "https://open.bocha.cn"} />
|
|
299
|
+
</>
|
|
300
|
+
);
|
|
301
|
+
}
|
|
322
302
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
303
|
+
if (selectedProvider === "tavily") {
|
|
304
|
+
const tavily = draft.providers.tavily;
|
|
305
|
+
return (
|
|
306
|
+
<>
|
|
307
|
+
<SearchTextField
|
|
308
|
+
label={t("apiKey")}
|
|
309
|
+
value={tavily.apiKey}
|
|
310
|
+
onChange={(apiKey) => updateProviderDraft("tavily", { apiKey })}
|
|
311
|
+
placeholder={search.providers.tavily.apiKeyMasked || t("enterApiKey")}
|
|
312
|
+
type="password"
|
|
313
|
+
/>
|
|
314
|
+
<SearchTextField
|
|
315
|
+
label={t("searchProviderBaseUrl")}
|
|
316
|
+
value={tavily.baseUrl}
|
|
317
|
+
onChange={(baseUrl) => updateProviderDraft("tavily", { baseUrl })}
|
|
318
|
+
/>
|
|
319
|
+
<div className="grid gap-4 md:grid-cols-2">
|
|
320
|
+
<SearchSelectField
|
|
321
|
+
label={t("searchProviderSearchDepth")}
|
|
322
|
+
value={tavily.searchDepth}
|
|
323
|
+
options={SEARCH_DEPTH_OPTIONS}
|
|
324
|
+
onChange={(searchDepth) =>
|
|
325
|
+
updateProviderDraft("tavily", {
|
|
326
|
+
searchDepth: searchDepth as TavilySearchDepthValue,
|
|
327
|
+
})
|
|
328
|
+
}
|
|
329
|
+
/>
|
|
330
|
+
<SearchSelectField
|
|
331
|
+
label={t("searchProviderIncludeAnswer")}
|
|
332
|
+
value={tavily.includeAnswer ? "true" : "false"}
|
|
333
|
+
options={[
|
|
334
|
+
{ value: "true", label: "enabled" },
|
|
335
|
+
{ value: "false", label: "disabled" },
|
|
336
|
+
]}
|
|
337
|
+
onChange={(value) =>
|
|
338
|
+
updateProviderDraft("tavily", {
|
|
339
|
+
includeAnswer: value === "true",
|
|
340
|
+
})
|
|
341
|
+
}
|
|
342
|
+
/>
|
|
343
|
+
</div>
|
|
344
|
+
<SearchDocsButton docsUrl={selectedDocsUrl} />
|
|
345
|
+
</>
|
|
346
|
+
);
|
|
347
|
+
}
|
|
329
348
|
|
|
330
|
-
|
|
331
|
-
return
|
|
332
|
-
|
|
349
|
+
const brave = draft.providers.brave;
|
|
350
|
+
return (
|
|
351
|
+
<>
|
|
352
|
+
<SearchTextField
|
|
353
|
+
label={t("apiKey")}
|
|
354
|
+
value={brave.apiKey}
|
|
355
|
+
onChange={(apiKey) => updateProviderDraft("brave", { apiKey })}
|
|
356
|
+
placeholder={search.providers.brave.apiKeyMasked || t("enterApiKey")}
|
|
357
|
+
type="password"
|
|
358
|
+
/>
|
|
359
|
+
<SearchTextField
|
|
360
|
+
label={t("searchProviderBaseUrl")}
|
|
361
|
+
value={brave.baseUrl}
|
|
362
|
+
onChange={(baseUrl) => updateProviderDraft("brave", { baseUrl })}
|
|
363
|
+
/>
|
|
364
|
+
</>
|
|
365
|
+
);
|
|
366
|
+
};
|
|
333
367
|
|
|
334
368
|
return (
|
|
335
|
-
<PageLayout>
|
|
336
|
-
<PageHeader
|
|
369
|
+
<PageLayout className="pb-0 xl:flex xl:h-full xl:min-h-0 xl:flex-col">
|
|
370
|
+
<PageHeader
|
|
371
|
+
title={t("searchPageTitle")}
|
|
372
|
+
description={t("searchPageDescription")}
|
|
373
|
+
/>
|
|
337
374
|
|
|
338
|
-
<
|
|
339
|
-
<
|
|
340
|
-
<
|
|
341
|
-
<p className="text-xs font-semibold uppercase tracking-[0.16em] text-gray-500">
|
|
342
|
-
|
|
343
|
-
|
|
375
|
+
<ConfigSplitPage className="xl:min-h-0">
|
|
376
|
+
<ConfigSplitSidebar>
|
|
377
|
+
<ConfigSplitPaneHeader className="px-4 py-4">
|
|
378
|
+
<p className="text-xs font-semibold uppercase tracking-[0.16em] text-gray-500">
|
|
379
|
+
{t("searchChannels")}
|
|
380
|
+
</p>
|
|
381
|
+
</ConfigSplitPaneHeader>
|
|
382
|
+
<ConfigSplitPaneBody className="space-y-2 p-3">
|
|
344
383
|
{providers.map((provider) => {
|
|
345
384
|
const providerView = search.providers[provider.name];
|
|
346
|
-
const isEnabled = enabledProviders.includes(provider.name);
|
|
347
|
-
const isSelected = selectedProvider === provider.name;
|
|
385
|
+
const isEnabled = draft.enabledProviders.includes(provider.name);
|
|
348
386
|
return (
|
|
349
|
-
<
|
|
387
|
+
<ConfigSelectionCard
|
|
350
388
|
key={provider.name}
|
|
351
|
-
type="button"
|
|
352
389
|
onClick={() => setSelectedProvider(provider.name)}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
isSelected
|
|
356
|
-
? 'border-primary/30 bg-primary-50/40 shadow-sm'
|
|
357
|
-
: 'border-gray-200/70 bg-white hover:border-gray-300 hover:bg-gray-50/70'
|
|
358
|
-
)}
|
|
390
|
+
active={selectedProvider === provider.name}
|
|
391
|
+
className="p-3"
|
|
359
392
|
>
|
|
360
393
|
<div className="flex items-start justify-between gap-3">
|
|
361
394
|
<div className="min-w-0">
|
|
362
|
-
<p className="truncate text-sm font-semibold text-gray-900">
|
|
395
|
+
<p className="truncate text-sm font-semibold text-gray-900">
|
|
396
|
+
{provider.displayName}
|
|
397
|
+
</p>
|
|
363
398
|
<p className="line-clamp-2 text-[11px] text-gray-500">
|
|
364
399
|
{t(SEARCH_PROVIDER_DESCRIPTION_KEYS[provider.name])}
|
|
365
400
|
</p>
|
|
366
401
|
</div>
|
|
367
402
|
<div className="flex flex-col items-end gap-1">
|
|
368
403
|
<span className="rounded-full bg-gray-100 px-2 py-0.5 text-[11px] font-medium text-gray-600">
|
|
369
|
-
{providerView.apiKeySet
|
|
404
|
+
{providerView.apiKeySet
|
|
405
|
+
? t("searchStatusConfigured")
|
|
406
|
+
: t("searchStatusNeedsSetup")}
|
|
370
407
|
</span>
|
|
371
408
|
{isEnabled ? (
|
|
372
409
|
<span className="rounded-full bg-emerald-50 px-2 py-0.5 text-[11px] font-medium text-emerald-700">
|
|
373
|
-
{t(
|
|
410
|
+
{t("searchProviderActivated")}
|
|
374
411
|
</span>
|
|
375
412
|
) : null}
|
|
376
413
|
</div>
|
|
377
414
|
</div>
|
|
378
|
-
</
|
|
415
|
+
</ConfigSelectionCard>
|
|
379
416
|
);
|
|
380
417
|
})}
|
|
381
|
-
</
|
|
382
|
-
</
|
|
418
|
+
</ConfigSplitPaneBody>
|
|
419
|
+
</ConfigSplitSidebar>
|
|
383
420
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
<
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
421
|
+
{!selectedMeta ? (
|
|
422
|
+
<ConfigSplitEmptyPane>
|
|
423
|
+
<p className="text-sm text-gray-500">
|
|
424
|
+
{t("searchNoProviderSelected")}
|
|
425
|
+
</p>
|
|
426
|
+
</ConfigSplitEmptyPane>
|
|
427
|
+
) : (
|
|
428
|
+
<ConfigSplitDetailPane>
|
|
429
|
+
<form
|
|
430
|
+
onSubmit={(event) => {
|
|
431
|
+
event.preventDefault();
|
|
432
|
+
updateSearch.mutate({ data: buildSearchPayload(draft) });
|
|
433
|
+
}}
|
|
434
|
+
className="flex min-h-0 flex-1 flex-col"
|
|
435
|
+
>
|
|
436
|
+
<ConfigSplitPaneHeader className="px-6 py-5">
|
|
437
|
+
<div className="flex items-start justify-between gap-4">
|
|
438
|
+
<div className="flex items-center gap-3">
|
|
439
|
+
<div className="flex h-10 w-10 items-center justify-center rounded-xl bg-primary text-white">
|
|
440
|
+
<SearchIcon className="h-5 w-5" />
|
|
441
|
+
</div>
|
|
442
|
+
<div>
|
|
443
|
+
<h3 className="text-lg font-semibold text-gray-900">
|
|
444
|
+
{selectedMeta.displayName}
|
|
445
|
+
</h3>
|
|
446
|
+
<p className="text-sm text-gray-500">
|
|
447
|
+
{selectedMeta.description}
|
|
448
|
+
</p>
|
|
449
|
+
</div>
|
|
397
450
|
</div>
|
|
451
|
+
<Button
|
|
452
|
+
type="button"
|
|
453
|
+
variant={selectedEnabled ? "secondary" : "outline"}
|
|
454
|
+
className="rounded-xl"
|
|
455
|
+
onClick={handleToggleEnabled}
|
|
456
|
+
>
|
|
457
|
+
{selectedEnabled
|
|
458
|
+
? t("searchProviderDeactivate")
|
|
459
|
+
: t("searchProviderActivate")}
|
|
460
|
+
</Button>
|
|
398
461
|
</div>
|
|
399
|
-
|
|
400
|
-
type="button"
|
|
401
|
-
variant={selectedEnabled ? 'secondary' : 'outline'}
|
|
402
|
-
className="rounded-xl"
|
|
403
|
-
onClick={handleToggleEnabled}
|
|
404
|
-
>
|
|
405
|
-
{activationButtonLabel}
|
|
406
|
-
</Button>
|
|
407
|
-
</div>
|
|
462
|
+
</ConfigSplitPaneHeader>
|
|
408
463
|
|
|
409
|
-
<
|
|
410
|
-
<div className="
|
|
411
|
-
<
|
|
412
|
-
|
|
413
|
-
<
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
464
|
+
<ConfigSplitPaneBody className="space-y-6 px-6 py-5">
|
|
465
|
+
<div className="grid gap-4 md:grid-cols-2">
|
|
466
|
+
<div className="space-y-2">
|
|
467
|
+
<Label>{t("searchActiveProvider")}</Label>
|
|
468
|
+
<Select
|
|
469
|
+
value={draft.activeProvider}
|
|
470
|
+
onValueChange={(activeProvider) =>
|
|
471
|
+
setDraft({
|
|
472
|
+
...draft,
|
|
473
|
+
activeProvider: activeProvider as SearchProviderName,
|
|
474
|
+
})
|
|
475
|
+
}
|
|
476
|
+
>
|
|
477
|
+
<SelectTrigger className="rounded-xl">
|
|
478
|
+
<SelectValue />
|
|
479
|
+
</SelectTrigger>
|
|
480
|
+
<SelectContent>
|
|
481
|
+
{providers.map((provider) => (
|
|
482
|
+
<SelectItem key={provider.name} value={provider.name}>
|
|
483
|
+
{provider.displayName}
|
|
484
|
+
</SelectItem>
|
|
485
|
+
))}
|
|
486
|
+
</SelectContent>
|
|
487
|
+
</Select>
|
|
488
|
+
</div>
|
|
423
489
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
onChange={(event) => setMaxResults(event.target.value)}
|
|
490
|
+
<SearchTextField
|
|
491
|
+
label={t("searchDefaultMaxResults")}
|
|
492
|
+
value={draft.maxResults}
|
|
493
|
+
onChange={(maxResults) => setDraft({ ...draft, maxResults })}
|
|
429
494
|
inputMode="numeric"
|
|
430
|
-
className="rounded-xl"
|
|
431
495
|
/>
|
|
432
496
|
</div>
|
|
433
|
-
</div>
|
|
434
497
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
apiKey={bochaApiKey}
|
|
438
|
-
apiKeyMasked={search.providers.bocha.apiKeyMasked}
|
|
439
|
-
baseUrl={bochaBaseUrl}
|
|
440
|
-
summary={bochaSummary}
|
|
441
|
-
freshness={bochaFreshness}
|
|
442
|
-
docsUrl={selectedDocsUrl}
|
|
443
|
-
onApiKeyChange={setBochaApiKey}
|
|
444
|
-
onBaseUrlChange={setBochaBaseUrl}
|
|
445
|
-
onSummaryChange={setBochaSummary}
|
|
446
|
-
onFreshnessChange={setBochaFreshness}
|
|
447
|
-
/>
|
|
448
|
-
) : selectedProvider === 'tavily' ? (
|
|
449
|
-
<TavilyProviderFields
|
|
450
|
-
apiKey={tavilyApiKey}
|
|
451
|
-
apiKeyMasked={search.providers.tavily.apiKeyMasked}
|
|
452
|
-
baseUrl={tavilyBaseUrl}
|
|
453
|
-
searchDepth={tavilySearchDepth}
|
|
454
|
-
includeAnswer={tavilyIncludeAnswer}
|
|
455
|
-
docsUrl={selectedDocsUrl}
|
|
456
|
-
onApiKeyChange={setTavilyApiKey}
|
|
457
|
-
onBaseUrlChange={setTavilyBaseUrl}
|
|
458
|
-
onSearchDepthChange={setTavilySearchDepth}
|
|
459
|
-
onIncludeAnswerChange={setTavilyIncludeAnswer}
|
|
460
|
-
/>
|
|
461
|
-
) : (
|
|
462
|
-
<BraveProviderFields
|
|
463
|
-
apiKey={braveApiKey}
|
|
464
|
-
apiKeyMasked={search.providers.brave.apiKeyMasked}
|
|
465
|
-
baseUrl={braveBaseUrl}
|
|
466
|
-
onApiKeyChange={setBraveApiKey}
|
|
467
|
-
onBaseUrlChange={setBraveBaseUrl}
|
|
468
|
-
/>
|
|
469
|
-
)}
|
|
498
|
+
{renderProviderFields()}
|
|
499
|
+
</ConfigSplitPaneBody>
|
|
470
500
|
|
|
471
|
-
<
|
|
501
|
+
<ConfigSplitPaneFooter className="flex justify-end px-6 py-4">
|
|
472
502
|
<Button type="submit" disabled={updateSearch.isPending}>
|
|
473
503
|
<KeyRound className="mr-2 h-4 w-4" />
|
|
474
|
-
{updateSearch.isPending ? t(
|
|
504
|
+
{updateSearch.isPending ? t("saving") : t("saveChanges")}
|
|
475
505
|
</Button>
|
|
476
|
-
</
|
|
477
|
-
</
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
</
|
|
506
|
+
</ConfigSplitPaneFooter>
|
|
507
|
+
</form>
|
|
508
|
+
</ConfigSplitDetailPane>
|
|
509
|
+
)}
|
|
510
|
+
</ConfigSplitPage>
|
|
481
511
|
</PageLayout>
|
|
482
512
|
);
|
|
483
513
|
}
|