@nextclaw/ui 0.12.9 → 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 +61 -0
- package/dist/assets/ChannelsList-M9FTK1Ak.js +8 -0
- package/dist/assets/DocBrowser-CH7-GxlL.js +1 -0
- package/dist/assets/{DocBrowser-6ReNjvzF.js → DocBrowser-DMfr0Oow.js} +1 -1
- package/dist/assets/{DocBrowserContext-B6SpA7Qs.js → DocBrowserContext-BXydqby-.js} +1 -1
- package/dist/assets/{LogoBadge-ByNLYg65.js → LogoBadge-hO7tY7hE.js} +1 -1
- package/dist/assets/ModelConfig-CNIgLf0e.js +1 -0
- package/dist/assets/{ProviderScopedModelInput-Da7khnBA.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-D281Rotl.js → SecretsConfig-MEt6MjuD.js} +2 -2
- package/dist/assets/SessionsConfig-DifCiXwR.js +2 -0
- package/dist/assets/{app-query-client-VnFElj4E.js → app-query-client-9jNewezV.js} +1 -1
- package/dist/assets/{book-open-BdcxxoQu.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-DK5HPmIK.js → chunk-JZWAC4HX-C5dEc8hV.js} +1 -1
- package/dist/assets/{client-_i4MU2bB.js → client-C-8fH7-c.js} +1 -1
- package/dist/assets/{config-DtIQwrHF.js → config-CBScxsdV.js} +1 -1
- package/dist/assets/config-split-page-BUout_Ak.js +1 -0
- package/dist/assets/{createLucideIcon-BSeTgkZW.js → createLucideIcon-dy5ie7Ox.js} +1 -1
- package/dist/assets/desktop-update-config-2BS6BMkW.js +1 -0
- package/dist/assets/{dist-ccBFUi-o.js → dist-BruyLa92.js} +1 -1
- package/dist/assets/{dist-6TrrnPCR.js → dist-Cy7_j6hA.js} +1 -1
- package/dist/assets/{download-BhDxnyvU.js → download-BD0ETkB-.js} +1 -1
- package/dist/assets/{external-link-BgErLCNT.js → external-link-kZSAO8nT.js} +1 -1
- package/dist/assets/{hash-Bl7dr_UG.js → hash-BHJC2Ovu.js} +1 -1
- package/dist/assets/{i18n-eDHeDY0n.js → i18n-CpTZLchQ.js} +1 -1
- package/dist/assets/index-mW8W2FUu.css +1 -0
- package/dist/assets/index-zDZfXoI4.js +6 -0
- package/dist/assets/{infiniteQueryBehavior-ZDS92Qpp.js → infiniteQueryBehavior-CyER9hv0.js} +1 -1
- package/dist/assets/loader-circle-Bc2gCU33.js +1 -0
- package/dist/assets/{logos-x89HbrZ4.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-vZnghcFy.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-DT98i__E.js → refresh-ccw-COVhNHtN.js} +1 -1
- package/dist/assets/{refresh-cw-C47QSEwg.js → refresh-cw-Bcv40SXy.js} +1 -1
- package/dist/assets/remote-access-page-CWHG-sug.js +1 -0
- package/dist/assets/{rotate-cw-JtFzpNn6.js → rotate-cw-oHMKJMC8.js} +1 -1
- package/dist/assets/{save-3S6-H3Xw.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-vbanNPFU.js → status-dot-DpPtVzQT.js} +1 -1
- package/dist/assets/{switch-BsLtHOH-.js → switch-CM29eCAR.js} +1 -1
- package/dist/assets/{tabs-custom-D3HYMt6k.js → tabs-custom-YcZUWn3o.js} +1 -1
- package/dist/assets/tag-chip-DMXdnLcj.js +1 -0
- package/dist/assets/{trash-2-G48scll7.js → trash-2-mJT6oWa2.js} +1 -1
- package/dist/assets/{use-infinite-scroll-loader-DkNhD-42.js → use-infinite-scroll-loader-DJ1L81Dz.js} +1 -1
- package/dist/assets/{useConfirmDialog-BkvTN-vd.js → useConfirmDialog-BsVuqu1x.js} +1 -1
- package/dist/assets/{useMutation-CBWjE2uj.js → useMutation-CNcz2fgt.js} +1 -1
- package/dist/assets/x-Czwxm82I.js +1 -0
- package/dist/index.html +22 -22
- 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/package.json +6 -6
- 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/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/types.ts +8 -0
- package/src/app.tsx +221 -57
- 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.tsx +11 -35
- package/src/components/chat/chat-conversation-panel.test.tsx +20 -0
- package/src/components/chat/chat-conversation-panel.tsx +83 -13
- 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 +87 -0
- package/src/components/chat/chat-session-workspace-file-preview.tsx +14 -43
- package/src/components/chat/chat-session-workspace-panel-nav.tsx +8 -2
- package/src/components/chat/chat-sidebar-project-groups.tsx +11 -36
- package/src/components/chat/ncp/__tests__/ncp-session-adapter.cancelled-tool.test.ts +77 -0
- package/src/components/chat/ncp/ncp-chat-page.tsx +2 -0
- package/src/components/chat/ncp/ncp-session-adapter.test.ts +1 -0
- package/src/components/chat/ncp/ncp-session-adapter.ts +3 -0
- package/src/components/chat/ncp/page/ncp-chat-derived-state.ts +10 -4
- package/src/components/chat/stores/chat-input.store.ts +2 -1
- package/src/components/chat/stores/chat-thread.store.ts +3 -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/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/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/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/i18n.remote.ts +1 -1
- package/src/lib/i18n.runtime-control.ts +31 -0
- package/src/lib/i18n.ts +5 -8
- 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/dist/assets/ChannelsList-Ita2Zm1_.js +0 -8
- package/dist/assets/DocBrowser-BNwbPHf4.js +0 -1
- package/dist/assets/MarketplacePage-CjX2MWww.js +0 -1
- package/dist/assets/MarketplacePage-D0sDlYX4.js +0 -49
- package/dist/assets/McpMarketplacePage-BGKJm1sJ.js +0 -40
- package/dist/assets/ModelConfig-BzZenCH-.js +0 -1
- package/dist/assets/ProvidersList-BbVzRxjY.js +0 -1
- package/dist/assets/RemoteAccessPage-BaDH_X1Q.js +0 -1
- package/dist/assets/RuntimeConfig-F_XKGgLm.js +0 -1
- package/dist/assets/SearchConfig-BGkzXQP-.js +0 -1
- package/dist/assets/SessionsConfig-ChHQ7M5c.js +0 -2
- package/dist/assets/chat-page-Doe0yTtB.js +0 -58
- package/dist/assets/chat-session-display-cw78aiI_.js +0 -1
- package/dist/assets/config-layout-CHs0mAaR.js +0 -1
- package/dist/assets/desktop-update-config-Dpcf4BKG.js +0 -1
- package/dist/assets/index-CF9xve0E.js +0 -6
- package/dist/assets/index-FgA52VBt.css +0 -1
- package/dist/assets/loader-circle-ACM1s51e.js +0 -1
- package/dist/assets/play-CFUwCA2E.js +0 -1
- package/dist/assets/plus-rYsv72JG.js +0 -1
- package/dist/assets/popover-Bg1VoTZ6.js +0 -1
- package/dist/assets/search-3kFR_zh9.js +0 -1
- package/dist/assets/security-config-BWaiARNk.js +0 -1
- package/dist/assets/select-DJ2MUjBB.js +0 -41
- package/dist/assets/skeleton-ByQepn0M.js +0 -1
- package/dist/assets/x-ByDbItbq.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/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
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
/* eslint-disable max-lines-per-function */
|
|
2
|
+
import { useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { useMutation } from "@tanstack/react-query";
|
|
4
|
+
import type {
|
|
5
|
+
MarketplaceInstalledRecord,
|
|
6
|
+
MarketplaceItemSummary,
|
|
7
|
+
MarketplaceMcpDoctorResult,
|
|
8
|
+
MarketplaceSort,
|
|
9
|
+
} from "@/api/types";
|
|
10
|
+
import {
|
|
11
|
+
fetchMcpMarketplaceContent,
|
|
12
|
+
doctorMcpMarketplaceItem,
|
|
13
|
+
} from "@/api/mcp-marketplace";
|
|
14
|
+
import { PageHeader, PageLayout } from "@/components/layout/page-layout";
|
|
15
|
+
import {
|
|
16
|
+
MarketplaceInfiniteScrollStatus,
|
|
17
|
+
MarketplaceListSkeleton,
|
|
18
|
+
} from "@/components/marketplace/marketplace-page-parts";
|
|
19
|
+
import { buildLocaleFallbacks } from "@/components/marketplace/marketplace-localization";
|
|
20
|
+
import { McpMarketplaceCard } from "@/components/marketplace/mcp/mcp-marketplace-card";
|
|
21
|
+
import {
|
|
22
|
+
buildDocDataUrl,
|
|
23
|
+
buildInstalledRecordLookup,
|
|
24
|
+
findInstalledRecordForItem,
|
|
25
|
+
readSummary,
|
|
26
|
+
} from "@/components/marketplace/mcp/mcp-marketplace-doc";
|
|
27
|
+
import {
|
|
28
|
+
DoctorDialog,
|
|
29
|
+
InstallDialog,
|
|
30
|
+
} from "@/components/marketplace/mcp/mcp-marketplace-dialogs";
|
|
31
|
+
import { Tabs } from "@/components/ui/tabs-custom";
|
|
32
|
+
import { Input } from "@/components/ui/input";
|
|
33
|
+
import { NoticeCard } from "@/components/ui/notice-card";
|
|
34
|
+
import {
|
|
35
|
+
Select,
|
|
36
|
+
SelectContent,
|
|
37
|
+
SelectItem,
|
|
38
|
+
SelectTrigger,
|
|
39
|
+
SelectValue,
|
|
40
|
+
} from "@/components/ui/select";
|
|
41
|
+
import { useConfirmDialog } from "@/hooks/useConfirmDialog";
|
|
42
|
+
import {
|
|
43
|
+
useInstallMcpMarketplaceItem,
|
|
44
|
+
useManageMcpMarketplaceItem,
|
|
45
|
+
useMcpMarketplaceInstalled,
|
|
46
|
+
useMcpMarketplaceItems,
|
|
47
|
+
} from "@/hooks/useMcpMarketplace";
|
|
48
|
+
import { useDocBrowser } from "@/components/doc-browser";
|
|
49
|
+
import { useI18n } from "@/components/providers/I18nProvider";
|
|
50
|
+
import { t } from "@/lib/i18n";
|
|
51
|
+
import { useInfiniteScrollLoader } from "@/hooks/use-infinite-scroll-loader";
|
|
52
|
+
|
|
53
|
+
type ScopeType = "catalog" | "installed";
|
|
54
|
+
|
|
55
|
+
const PAGE_SIZE = 12;
|
|
56
|
+
|
|
57
|
+
export function McpMarketplacePage() {
|
|
58
|
+
const [scope, setScope] = useState<ScopeType>("catalog");
|
|
59
|
+
const [searchText, setSearchText] = useState("");
|
|
60
|
+
const [query, setQuery] = useState("");
|
|
61
|
+
const [sort, setSort] = useState<MarketplaceSort>("relevance");
|
|
62
|
+
const [installingItem, setInstallingItem] =
|
|
63
|
+
useState<MarketplaceItemSummary | null>(null);
|
|
64
|
+
const [doctorTarget, setDoctorTarget] = useState<string | null>(null);
|
|
65
|
+
const [doctorResult, setDoctorResult] =
|
|
66
|
+
useState<MarketplaceMcpDoctorResult | null>(null);
|
|
67
|
+
const { language } = useI18n();
|
|
68
|
+
const docBrowser = useDocBrowser();
|
|
69
|
+
const { confirm, ConfirmDialog } = useConfirmDialog();
|
|
70
|
+
const localeFallbacks = useMemo(
|
|
71
|
+
() => buildLocaleFallbacks(language),
|
|
72
|
+
[language],
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
const timer = window.setTimeout(() => {
|
|
77
|
+
setQuery(searchText.trim());
|
|
78
|
+
}, 250);
|
|
79
|
+
return () => window.clearTimeout(timer);
|
|
80
|
+
}, [searchText]);
|
|
81
|
+
|
|
82
|
+
const itemsQuery = useMcpMarketplaceItems({
|
|
83
|
+
q: query || undefined,
|
|
84
|
+
sort,
|
|
85
|
+
pageSize: PAGE_SIZE,
|
|
86
|
+
});
|
|
87
|
+
const installedQuery = useMcpMarketplaceInstalled();
|
|
88
|
+
|
|
89
|
+
const infiniteScroll = useInfiniteScrollLoader({
|
|
90
|
+
disabled:
|
|
91
|
+
scope !== "catalog" ||
|
|
92
|
+
itemsQuery.isError ||
|
|
93
|
+
!itemsQuery.hasNextPage ||
|
|
94
|
+
itemsQuery.isFetchingNextPage,
|
|
95
|
+
onLoadMore: () => itemsQuery.fetchNextPage(),
|
|
96
|
+
watchValue: `${scope}:${query}:${sort}:${itemsQuery.data?.loadedItems ?? 0}:${itemsQuery.data?.loadedPages ?? 0}`,
|
|
97
|
+
});
|
|
98
|
+
const { containerRef, sentinelRef } = infiniteScroll;
|
|
99
|
+
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
const container = containerRef.current;
|
|
102
|
+
if (container && typeof container.scrollTo === "function") {
|
|
103
|
+
container.scrollTo({ top: 0 });
|
|
104
|
+
}
|
|
105
|
+
}, [containerRef, query, scope, sort]);
|
|
106
|
+
|
|
107
|
+
const installMutation = useInstallMcpMarketplaceItem();
|
|
108
|
+
const manageMutation = useManageMcpMarketplaceItem();
|
|
109
|
+
const doctorMutation = useMutation({
|
|
110
|
+
mutationFn: doctorMcpMarketplaceItem,
|
|
111
|
+
onSuccess: (result, name) => {
|
|
112
|
+
setDoctorTarget(name);
|
|
113
|
+
setDoctorResult(result);
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
const installedRecordLookup = useMemo(() => {
|
|
118
|
+
return buildInstalledRecordLookup(installedQuery.data?.records ?? []);
|
|
119
|
+
}, [installedQuery.data?.records]);
|
|
120
|
+
|
|
121
|
+
const installedRecords = useMemo(() => {
|
|
122
|
+
const entries = installedQuery.data?.records ?? [];
|
|
123
|
+
return entries.filter((record) => {
|
|
124
|
+
const text = [
|
|
125
|
+
record.id ?? "",
|
|
126
|
+
record.label ?? "",
|
|
127
|
+
record.catalogSlug ?? "",
|
|
128
|
+
record.description ?? "",
|
|
129
|
+
record.descriptionZh ?? "",
|
|
130
|
+
]
|
|
131
|
+
.join(" ")
|
|
132
|
+
.toLowerCase();
|
|
133
|
+
return query ? text.includes(query.toLowerCase()) : true;
|
|
134
|
+
});
|
|
135
|
+
}, [installedQuery.data?.records, query]);
|
|
136
|
+
|
|
137
|
+
const openDoc = async (
|
|
138
|
+
item?: MarketplaceItemSummary,
|
|
139
|
+
record?: MarketplaceInstalledRecord,
|
|
140
|
+
) => {
|
|
141
|
+
const title = item?.name ?? record?.label ?? record?.id ?? "MCP";
|
|
142
|
+
const summary = readSummary(localeFallbacks, item, record);
|
|
143
|
+
if (!item) {
|
|
144
|
+
const url = buildDocDataUrl(
|
|
145
|
+
title,
|
|
146
|
+
JSON.stringify(record ?? {}, null, 2),
|
|
147
|
+
t("marketplaceInstalledLocalSummary"),
|
|
148
|
+
record?.docsUrl,
|
|
149
|
+
summary,
|
|
150
|
+
);
|
|
151
|
+
docBrowser.open(url, { newTab: true, title, kind: "content" });
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
const content = await fetchMcpMarketplaceContent(item.slug);
|
|
156
|
+
const url = buildDocDataUrl(
|
|
157
|
+
title,
|
|
158
|
+
content.metadataRaw || JSON.stringify(item, null, 2),
|
|
159
|
+
content.bodyRaw || content.raw,
|
|
160
|
+
content.sourceUrl,
|
|
161
|
+
summary,
|
|
162
|
+
);
|
|
163
|
+
docBrowser.open(url, { newTab: true, title, kind: "content" });
|
|
164
|
+
} catch (error) {
|
|
165
|
+
const url = buildDocDataUrl(
|
|
166
|
+
title,
|
|
167
|
+
JSON.stringify(
|
|
168
|
+
{ error: error instanceof Error ? error.message : String(error) },
|
|
169
|
+
null,
|
|
170
|
+
2,
|
|
171
|
+
),
|
|
172
|
+
summary,
|
|
173
|
+
undefined,
|
|
174
|
+
summary,
|
|
175
|
+
);
|
|
176
|
+
docBrowser.open(url, { newTab: true, title, kind: "content" });
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const handleInstall = async (payload: {
|
|
181
|
+
name: string;
|
|
182
|
+
allAgents: boolean;
|
|
183
|
+
inputs: Record<string, string>;
|
|
184
|
+
}) => {
|
|
185
|
+
if (!installingItem) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
await installMutation.mutateAsync({
|
|
189
|
+
spec: installingItem.slug,
|
|
190
|
+
name: payload.name.trim(),
|
|
191
|
+
allAgents: payload.allAgents,
|
|
192
|
+
inputs: payload.inputs,
|
|
193
|
+
});
|
|
194
|
+
setInstallingItem(null);
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const handleManage = async (
|
|
198
|
+
action: "enable" | "disable" | "remove",
|
|
199
|
+
record: MarketplaceInstalledRecord,
|
|
200
|
+
) => {
|
|
201
|
+
const target = record.id || record.spec;
|
|
202
|
+
if (!target) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
if (action === "remove") {
|
|
206
|
+
const confirmed = await confirm({
|
|
207
|
+
title: `${t("marketplaceMcpRemoveTitle")} ${target}?`,
|
|
208
|
+
description: t("marketplaceMcpRemoveDescription"),
|
|
209
|
+
confirmLabel: t("marketplaceMcpRemove"),
|
|
210
|
+
variant: "destructive",
|
|
211
|
+
});
|
|
212
|
+
if (!confirmed) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
await manageMutation.mutateAsync({
|
|
217
|
+
action,
|
|
218
|
+
id: target,
|
|
219
|
+
spec: record.spec,
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
return (
|
|
224
|
+
<PageLayout className="flex h-full min-h-0 flex-col pb-0">
|
|
225
|
+
<PageHeader
|
|
226
|
+
title={t("marketplaceMcpPageTitle")}
|
|
227
|
+
description={t("marketplaceMcpPageDescription")}
|
|
228
|
+
/>
|
|
229
|
+
|
|
230
|
+
<Tabs
|
|
231
|
+
tabs={[
|
|
232
|
+
{ id: "catalog", label: t("marketplaceMcpTabCatalog") },
|
|
233
|
+
{
|
|
234
|
+
id: "installed",
|
|
235
|
+
label: t("marketplaceMcpTabInstalled"),
|
|
236
|
+
count: installedQuery.data?.total ?? 0,
|
|
237
|
+
},
|
|
238
|
+
]}
|
|
239
|
+
activeTab={scope}
|
|
240
|
+
onChange={(value) => setScope(value as ScopeType)}
|
|
241
|
+
className="mb-4"
|
|
242
|
+
/>
|
|
243
|
+
|
|
244
|
+
<div className="mb-4 flex flex-col gap-3 md:flex-row md:items-center md:justify-between">
|
|
245
|
+
<Input
|
|
246
|
+
value={searchText}
|
|
247
|
+
onChange={(event) => setSearchText(event.target.value)}
|
|
248
|
+
placeholder={t("marketplaceMcpSearchPlaceholder")}
|
|
249
|
+
className="md:max-w-sm"
|
|
250
|
+
/>
|
|
251
|
+
|
|
252
|
+
<Select
|
|
253
|
+
value={sort}
|
|
254
|
+
onValueChange={(value) => setSort(value as MarketplaceSort)}
|
|
255
|
+
>
|
|
256
|
+
<SelectTrigger className="h-9 w-[180px] rounded-lg">
|
|
257
|
+
<SelectValue />
|
|
258
|
+
</SelectTrigger>
|
|
259
|
+
<SelectContent>
|
|
260
|
+
<SelectItem value="relevance">
|
|
261
|
+
{t("marketplaceSortRelevance")}
|
|
262
|
+
</SelectItem>
|
|
263
|
+
<SelectItem value="updated">
|
|
264
|
+
{t("marketplaceSortUpdated")}
|
|
265
|
+
</SelectItem>
|
|
266
|
+
</SelectContent>
|
|
267
|
+
</Select>
|
|
268
|
+
</div>
|
|
269
|
+
|
|
270
|
+
<section className="flex min-h-0 flex-1 flex-col">
|
|
271
|
+
<div className="mb-3 flex items-center justify-between">
|
|
272
|
+
<h3 className="text-sm font-semibold text-gray-900">
|
|
273
|
+
{scope === "catalog"
|
|
274
|
+
? t("marketplaceMcpSectionCatalog")
|
|
275
|
+
: t("marketplaceMcpSectionInstalled")}
|
|
276
|
+
</h3>
|
|
277
|
+
<span className="text-xs text-gray-500">
|
|
278
|
+
{scope === "catalog"
|
|
279
|
+
? (itemsQuery.data?.total ?? 0)
|
|
280
|
+
: (installedQuery.data?.total ?? 0)}
|
|
281
|
+
</span>
|
|
282
|
+
</div>
|
|
283
|
+
|
|
284
|
+
<div
|
|
285
|
+
ref={containerRef}
|
|
286
|
+
className="min-h-0 flex-1 overflow-y-auto pr-1"
|
|
287
|
+
aria-busy={itemsQuery.isLoading || itemsQuery.isFetchingNextPage}
|
|
288
|
+
>
|
|
289
|
+
<div className="grid grid-cols-1 gap-3 lg:grid-cols-2 2xl:grid-cols-3">
|
|
290
|
+
{scope === "catalog" && itemsQuery.isLoading && (
|
|
291
|
+
<MarketplaceListSkeleton count={6} />
|
|
292
|
+
)}
|
|
293
|
+
|
|
294
|
+
{scope === "catalog" &&
|
|
295
|
+
!itemsQuery.isLoading &&
|
|
296
|
+
(itemsQuery.data?.items ?? []).map((item) => {
|
|
297
|
+
const installed = findInstalledRecordForItem(
|
|
298
|
+
item,
|
|
299
|
+
installedRecordLookup,
|
|
300
|
+
);
|
|
301
|
+
return (
|
|
302
|
+
<McpMarketplaceCard
|
|
303
|
+
key={item.id}
|
|
304
|
+
item={item}
|
|
305
|
+
record={installed}
|
|
306
|
+
localeFallbacks={localeFallbacks}
|
|
307
|
+
onOpen={() => void openDoc(item, installed)}
|
|
308
|
+
onInstall={() => setInstallingItem(item)}
|
|
309
|
+
onToggle={
|
|
310
|
+
installed
|
|
311
|
+
? () =>
|
|
312
|
+
void handleManage(
|
|
313
|
+
installed.enabled === false
|
|
314
|
+
? "enable"
|
|
315
|
+
: "disable",
|
|
316
|
+
installed,
|
|
317
|
+
)
|
|
318
|
+
: undefined
|
|
319
|
+
}
|
|
320
|
+
onDoctor={
|
|
321
|
+
installed
|
|
322
|
+
? () => {
|
|
323
|
+
setDoctorTarget(installed.id ?? null);
|
|
324
|
+
setDoctorResult(null);
|
|
325
|
+
void doctorMutation.mutateAsync(installed.id ?? "");
|
|
326
|
+
}
|
|
327
|
+
: undefined
|
|
328
|
+
}
|
|
329
|
+
onRemove={
|
|
330
|
+
installed
|
|
331
|
+
? () => void handleManage("remove", installed)
|
|
332
|
+
: undefined
|
|
333
|
+
}
|
|
334
|
+
/>
|
|
335
|
+
);
|
|
336
|
+
})}
|
|
337
|
+
{scope === "installed" &&
|
|
338
|
+
installedRecords.map((record) => (
|
|
339
|
+
<McpMarketplaceCard
|
|
340
|
+
key={record.id ?? record.spec}
|
|
341
|
+
record={record}
|
|
342
|
+
localeFallbacks={localeFallbacks}
|
|
343
|
+
onOpen={() => void openDoc(undefined, record)}
|
|
344
|
+
onToggle={() =>
|
|
345
|
+
void handleManage(
|
|
346
|
+
record.enabled === false ? "enable" : "disable",
|
|
347
|
+
record,
|
|
348
|
+
)
|
|
349
|
+
}
|
|
350
|
+
onDoctor={() => {
|
|
351
|
+
setDoctorTarget(record.id ?? null);
|
|
352
|
+
setDoctorResult(null);
|
|
353
|
+
void doctorMutation.mutateAsync(record.id ?? "");
|
|
354
|
+
}}
|
|
355
|
+
onRemove={() => void handleManage("remove", record)}
|
|
356
|
+
/>
|
|
357
|
+
))}
|
|
358
|
+
</div>
|
|
359
|
+
|
|
360
|
+
{scope === "catalog" && itemsQuery.isError && (
|
|
361
|
+
<NoticeCard
|
|
362
|
+
tone="danger"
|
|
363
|
+
title={t("marketplaceMcpSectionCatalog")}
|
|
364
|
+
description={itemsQuery.error.message}
|
|
365
|
+
/>
|
|
366
|
+
)}
|
|
367
|
+
{scope === "installed" && installedQuery.isError && (
|
|
368
|
+
<NoticeCard
|
|
369
|
+
tone="danger"
|
|
370
|
+
title={t("marketplaceMcpSectionInstalled")}
|
|
371
|
+
description={installedQuery.error.message}
|
|
372
|
+
/>
|
|
373
|
+
)}
|
|
374
|
+
{scope === "catalog" &&
|
|
375
|
+
!itemsQuery.isLoading &&
|
|
376
|
+
(itemsQuery.data?.items?.length ?? 0) === 0 && (
|
|
377
|
+
<div className="py-8 text-center text-sm text-gray-500">
|
|
378
|
+
{t("marketplaceNoMcp")}
|
|
379
|
+
</div>
|
|
380
|
+
)}
|
|
381
|
+
{scope === "installed" && installedRecords.length === 0 && (
|
|
382
|
+
<div className="py-8 text-center text-sm text-gray-500">
|
|
383
|
+
{t("marketplaceNoInstalledMcp")}
|
|
384
|
+
</div>
|
|
385
|
+
)}
|
|
386
|
+
|
|
387
|
+
{scope === "catalog" && !itemsQuery.isError && (
|
|
388
|
+
<MarketplaceInfiniteScrollStatus
|
|
389
|
+
hasMore={Boolean(itemsQuery.hasNextPage)}
|
|
390
|
+
loading={itemsQuery.isFetchingNextPage}
|
|
391
|
+
sentinelRef={sentinelRef}
|
|
392
|
+
/>
|
|
393
|
+
)}
|
|
394
|
+
</div>
|
|
395
|
+
</section>
|
|
396
|
+
|
|
397
|
+
<InstallDialog
|
|
398
|
+
item={installingItem}
|
|
399
|
+
open={Boolean(installingItem)}
|
|
400
|
+
pending={installMutation.isPending}
|
|
401
|
+
onOpenChange={(open) => !open && setInstallingItem(null)}
|
|
402
|
+
onSubmit={handleInstall}
|
|
403
|
+
/>
|
|
404
|
+
<DoctorDialog
|
|
405
|
+
open={Boolean(doctorTarget)}
|
|
406
|
+
targetName={doctorTarget}
|
|
407
|
+
result={doctorResult}
|
|
408
|
+
pending={doctorMutation.isPending}
|
|
409
|
+
onOpenChange={(open) => !open && setDoctorTarget(null)}
|
|
410
|
+
/>
|
|
411
|
+
<ConfirmDialog />
|
|
412
|
+
</PageLayout>
|
|
413
|
+
);
|
|
414
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { render, screen } from "@testing-library/react";
|
|
2
|
+
import userEvent from "@testing-library/user-event";
|
|
3
|
+
import { RemoteAccessPage } from "@/components/remote/remote-access-page";
|
|
4
|
+
import { setLanguage } from "@/lib/i18n";
|
|
5
|
+
import { useRemoteAccessStore } from "@/remote/stores/remote-access.store";
|
|
6
|
+
|
|
7
|
+
const mocks = vi.hoisted(() => ({
|
|
8
|
+
reauthorizeRemoteAccess: vi.fn(),
|
|
9
|
+
repairRemoteAccess: vi.fn(),
|
|
10
|
+
enableRemoteAccess: vi.fn(),
|
|
11
|
+
disableRemoteAccess: vi.fn(),
|
|
12
|
+
syncStatus: vi.fn(),
|
|
13
|
+
openNextClawWeb: vi.fn(),
|
|
14
|
+
statusQuery: {
|
|
15
|
+
data: undefined as unknown,
|
|
16
|
+
isLoading: false,
|
|
17
|
+
},
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
vi.mock("@/hooks/useRemoteAccess", () => ({
|
|
21
|
+
useRemoteStatus: () => mocks.statusQuery,
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
vi.mock("@/presenter/app-presenter-context", () => ({
|
|
25
|
+
useAppPresenter: () => ({
|
|
26
|
+
remoteAccessManager: {
|
|
27
|
+
reauthorizeRemoteAccess: mocks.reauthorizeRemoteAccess,
|
|
28
|
+
repairRemoteAccess: mocks.repairRemoteAccess,
|
|
29
|
+
enableRemoteAccess: mocks.enableRemoteAccess,
|
|
30
|
+
disableRemoteAccess: mocks.disableRemoteAccess,
|
|
31
|
+
syncStatus: mocks.syncStatus,
|
|
32
|
+
},
|
|
33
|
+
accountManager: {
|
|
34
|
+
openNextClawWeb: mocks.openNextClawWeb,
|
|
35
|
+
},
|
|
36
|
+
}),
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
describe("RemoteAccessPage", () => {
|
|
40
|
+
beforeEach(() => {
|
|
41
|
+
setLanguage("zh");
|
|
42
|
+
mocks.reauthorizeRemoteAccess.mockReset();
|
|
43
|
+
mocks.repairRemoteAccess.mockReset();
|
|
44
|
+
mocks.enableRemoteAccess.mockReset();
|
|
45
|
+
mocks.disableRemoteAccess.mockReset();
|
|
46
|
+
mocks.syncStatus.mockReset();
|
|
47
|
+
mocks.openNextClawWeb.mockReset();
|
|
48
|
+
useRemoteAccessStore.setState({
|
|
49
|
+
enabled: false,
|
|
50
|
+
deviceName: "",
|
|
51
|
+
platformApiBase: "",
|
|
52
|
+
draftTouched: false,
|
|
53
|
+
advancedOpen: false,
|
|
54
|
+
actionLabel: null,
|
|
55
|
+
doctor: null,
|
|
56
|
+
});
|
|
57
|
+
mocks.statusQuery = {
|
|
58
|
+
data: {
|
|
59
|
+
account: {
|
|
60
|
+
loggedIn: true,
|
|
61
|
+
email: "user@example.com",
|
|
62
|
+
apiBase: "https://ai-gateway-api.nextclaw.io/v1",
|
|
63
|
+
platformBase: "https://ai-gateway-api.nextclaw.io",
|
|
64
|
+
},
|
|
65
|
+
settings: {
|
|
66
|
+
enabled: true,
|
|
67
|
+
deviceName: "MacBook Pro",
|
|
68
|
+
platformApiBase: "https://ai-gateway-api.nextclaw.io/v1",
|
|
69
|
+
},
|
|
70
|
+
service: {
|
|
71
|
+
running: true,
|
|
72
|
+
currentProcess: false,
|
|
73
|
+
},
|
|
74
|
+
localOrigin: "http://127.0.0.1:55667",
|
|
75
|
+
configuredEnabled: true,
|
|
76
|
+
platformBase: "https://ai-gateway-api.nextclaw.io",
|
|
77
|
+
runtime: {
|
|
78
|
+
enabled: true,
|
|
79
|
+
mode: "service",
|
|
80
|
+
state: "error",
|
|
81
|
+
lastError: "Invalid or expired token.",
|
|
82
|
+
updatedAt: "2026-03-23T00:00:00.000Z",
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
isLoading: false,
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("shows a user-facing reauthorization flow instead of raw token errors", async () => {
|
|
90
|
+
const user = userEvent.setup();
|
|
91
|
+
|
|
92
|
+
render(<RemoteAccessPage />);
|
|
93
|
+
|
|
94
|
+
expect(screen.getByText("登录已过期,请重新登录 NextClaw")).toBeTruthy();
|
|
95
|
+
expect(screen.getByText("重新登录并恢复远程访问")).toBeTruthy();
|
|
96
|
+
expect(screen.queryByText("Invalid or expired token.")).toBeNull();
|
|
97
|
+
|
|
98
|
+
await user.click(
|
|
99
|
+
screen.getByRole("button", { name: "重新登录并恢复远程访问" }),
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
expect(mocks.reauthorizeRemoteAccess).toHaveBeenCalledTimes(1);
|
|
103
|
+
expect(mocks.repairRemoteAccess).not.toHaveBeenCalled();
|
|
104
|
+
});
|
|
105
|
+
});
|