@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,596 @@
|
|
|
1
|
+
/* eslint-disable max-lines-per-function */
|
|
2
|
+
import type {
|
|
3
|
+
MarketplaceInstalledRecord,
|
|
4
|
+
MarketplaceItemSummary,
|
|
5
|
+
MarketplaceManageAction,
|
|
6
|
+
MarketplacePluginContentView,
|
|
7
|
+
MarketplaceSkillContentView,
|
|
8
|
+
MarketplaceSort,
|
|
9
|
+
MarketplaceItemType,
|
|
10
|
+
} from "@/api/types";
|
|
11
|
+
import {
|
|
12
|
+
fetchMarketplacePluginContent,
|
|
13
|
+
fetchMarketplaceSkillContent,
|
|
14
|
+
} from "@/api/marketplace";
|
|
15
|
+
import { NoticeCard } from "@/components/ui/notice-card";
|
|
16
|
+
import { Tabs } from "@/components/ui/tabs-custom";
|
|
17
|
+
import { useDocBrowser } from "@/components/doc-browser";
|
|
18
|
+
import { useI18n } from "@/components/providers/I18nProvider";
|
|
19
|
+
import { useConfirmDialog } from "@/hooks/useConfirmDialog";
|
|
20
|
+
import {
|
|
21
|
+
useInstallMarketplaceItem,
|
|
22
|
+
useManageMarketplaceItem,
|
|
23
|
+
useMarketplaceInstalled,
|
|
24
|
+
useMarketplaceItems,
|
|
25
|
+
} from "@/hooks/useMarketplace";
|
|
26
|
+
import {
|
|
27
|
+
FilterPanel,
|
|
28
|
+
MarketplaceListSkeleton,
|
|
29
|
+
MarketplaceInfiniteScrollStatus,
|
|
30
|
+
} from "@/components/marketplace/marketplace-page-parts";
|
|
31
|
+
import {
|
|
32
|
+
buildLocaleFallbacks,
|
|
33
|
+
pickLocalizedText,
|
|
34
|
+
} from "@/components/marketplace/marketplace-localization";
|
|
35
|
+
import {
|
|
36
|
+
buildCatalogLookup,
|
|
37
|
+
buildInstalledRecordLookup,
|
|
38
|
+
findCatalogItemForRecord,
|
|
39
|
+
findInstalledRecordForItem,
|
|
40
|
+
matchInstalledSearch,
|
|
41
|
+
type InstalledRenderEntry,
|
|
42
|
+
} from "@/components/marketplace/marketplace-page-data";
|
|
43
|
+
import { buildGenericDetailDataUrl } from "@/components/marketplace/marketplace-detail-doc";
|
|
44
|
+
import {
|
|
45
|
+
MarketplaceListCard,
|
|
46
|
+
type InstallState,
|
|
47
|
+
type ManageState,
|
|
48
|
+
} from "@/components/marketplace/marketplace-list-card";
|
|
49
|
+
import { t } from "@/lib/i18n";
|
|
50
|
+
import { PageLayout, PageHeader } from "@/components/layout/page-layout";
|
|
51
|
+
import { useEffect, useMemo, useState } from "react";
|
|
52
|
+
import { useNavigate, useParams } from "react-router-dom";
|
|
53
|
+
import { useInfiniteScrollLoader } from "@/hooks/use-infinite-scroll-loader";
|
|
54
|
+
|
|
55
|
+
const PAGE_SIZE = 12;
|
|
56
|
+
const SKELETON_CARD_COUNT = PAGE_SIZE;
|
|
57
|
+
|
|
58
|
+
type ScopeType = "all" | "installed";
|
|
59
|
+
|
|
60
|
+
type MarketplaceRouteType = "plugins" | "skills";
|
|
61
|
+
type MarketplacePageProps = {
|
|
62
|
+
forcedType?: MarketplaceRouteType;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export function MarketplacePage(props: MarketplacePageProps = {}) {
|
|
66
|
+
const { forcedType } = props;
|
|
67
|
+
const navigate = useNavigate();
|
|
68
|
+
const params = useParams<{ type?: string }>();
|
|
69
|
+
const { language } = useI18n();
|
|
70
|
+
const docBrowser = useDocBrowser();
|
|
71
|
+
|
|
72
|
+
const routeType: MarketplaceRouteType | null = useMemo(() => {
|
|
73
|
+
if (forcedType === "plugins" || forcedType === "skills") {
|
|
74
|
+
return forcedType;
|
|
75
|
+
}
|
|
76
|
+
if (params.type === "plugins" || params.type === "skills") {
|
|
77
|
+
return params.type;
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}, [forcedType, params.type]);
|
|
81
|
+
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
if (forcedType) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (!routeType) {
|
|
87
|
+
navigate("/marketplace/plugins", { replace: true });
|
|
88
|
+
}
|
|
89
|
+
}, [forcedType, routeType, navigate]);
|
|
90
|
+
|
|
91
|
+
const typeFilter: MarketplaceItemType =
|
|
92
|
+
routeType === "skills" ? "skill" : "plugin";
|
|
93
|
+
const localeFallbacks = useMemo(
|
|
94
|
+
() => buildLocaleFallbacks(language),
|
|
95
|
+
[language],
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
const isPluginModule = typeFilter === "plugin";
|
|
99
|
+
const copyKeys = isPluginModule
|
|
100
|
+
? {
|
|
101
|
+
pageTitle: "marketplacePluginsPageTitle",
|
|
102
|
+
pageDescription: "marketplacePluginsPageDescription",
|
|
103
|
+
tabMarketplace: "marketplaceTabMarketplacePlugins",
|
|
104
|
+
tabInstalled: "marketplaceTabInstalledPlugins",
|
|
105
|
+
searchPlaceholder: "marketplaceSearchPlaceholderPlugins",
|
|
106
|
+
sectionCatalog: "marketplaceSectionPlugins",
|
|
107
|
+
sectionInstalled: "marketplaceSectionInstalledPlugins",
|
|
108
|
+
errorLoadData: "marketplaceErrorLoadingPluginsData",
|
|
109
|
+
errorLoadInstalled: "marketplaceErrorLoadingInstalledPlugins",
|
|
110
|
+
emptyData: "marketplaceNoPlugins",
|
|
111
|
+
emptyInstalled: "marketplaceNoInstalledPlugins",
|
|
112
|
+
installedCountSuffix: "marketplaceInstalledPluginsCountSuffix",
|
|
113
|
+
}
|
|
114
|
+
: {
|
|
115
|
+
pageTitle: "marketplaceSkillsPageTitle",
|
|
116
|
+
pageDescription: "marketplaceSkillsPageDescription",
|
|
117
|
+
tabMarketplace: "marketplaceTabMarketplaceSkills",
|
|
118
|
+
tabInstalled: "marketplaceTabInstalledSkills",
|
|
119
|
+
searchPlaceholder: "marketplaceSearchPlaceholderSkills",
|
|
120
|
+
sectionCatalog: "marketplaceSectionSkills",
|
|
121
|
+
sectionInstalled: "marketplaceSectionInstalledSkills",
|
|
122
|
+
errorLoadData: "marketplaceErrorLoadingSkillsData",
|
|
123
|
+
errorLoadInstalled: "marketplaceErrorLoadingInstalledSkills",
|
|
124
|
+
emptyData: "marketplaceNoSkills",
|
|
125
|
+
emptyInstalled: "marketplaceNoInstalledSkills",
|
|
126
|
+
installedCountSuffix: "marketplaceInstalledSkillsCountSuffix",
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const [searchText, setSearchText] = useState("");
|
|
130
|
+
const [query, setQuery] = useState("");
|
|
131
|
+
const [scope, setScope] = useState<ScopeType>("all");
|
|
132
|
+
const [sort, setSort] = useState<MarketplaceSort>("relevance");
|
|
133
|
+
const [installingSpecs, setInstallingSpecs] = useState<ReadonlySet<string>>(
|
|
134
|
+
new Set(),
|
|
135
|
+
);
|
|
136
|
+
const [managingTargets, setManagingTargets] = useState<
|
|
137
|
+
ReadonlyMap<string, MarketplaceManageAction>
|
|
138
|
+
>(new Map());
|
|
139
|
+
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
const timer = setTimeout(() => {
|
|
142
|
+
setQuery(searchText.trim());
|
|
143
|
+
}, 250);
|
|
144
|
+
return () => clearTimeout(timer);
|
|
145
|
+
}, [searchText]);
|
|
146
|
+
|
|
147
|
+
const installedQuery = useMarketplaceInstalled(typeFilter);
|
|
148
|
+
|
|
149
|
+
const itemsQuery = useMarketplaceItems({
|
|
150
|
+
q: query || undefined,
|
|
151
|
+
type: typeFilter,
|
|
152
|
+
sort,
|
|
153
|
+
pageSize: PAGE_SIZE,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
const infiniteScroll = useInfiniteScrollLoader({
|
|
157
|
+
disabled:
|
|
158
|
+
scope !== "all" ||
|
|
159
|
+
itemsQuery.isError ||
|
|
160
|
+
!itemsQuery.hasNextPage ||
|
|
161
|
+
itemsQuery.isFetchingNextPage,
|
|
162
|
+
onLoadMore: () => itemsQuery.fetchNextPage(),
|
|
163
|
+
watchValue: `${typeFilter}:${scope}:${query}:${sort}:${itemsQuery.data?.loadedItems ?? 0}:${itemsQuery.data?.loadedPages ?? 0}`,
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
useEffect(() => {
|
|
167
|
+
const container = infiniteScroll.containerRef.current;
|
|
168
|
+
if (container && typeof container.scrollTo === "function") {
|
|
169
|
+
container.scrollTo({ top: 0 });
|
|
170
|
+
}
|
|
171
|
+
}, [infiniteScroll.containerRef, query, scope, sort, typeFilter]);
|
|
172
|
+
|
|
173
|
+
const installMutation = useInstallMarketplaceItem();
|
|
174
|
+
const manageMutation = useManageMarketplaceItem();
|
|
175
|
+
const { confirm, ConfirmDialog } = useConfirmDialog();
|
|
176
|
+
|
|
177
|
+
const installedRecords = useMemo(
|
|
178
|
+
() => installedQuery.data?.records ?? [],
|
|
179
|
+
[installedQuery.data?.records],
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
const allItems = useMemo(
|
|
183
|
+
() => itemsQuery.data?.items ?? [],
|
|
184
|
+
[itemsQuery.data?.items],
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
const catalogLookup = useMemo(() => buildCatalogLookup(allItems), [allItems]);
|
|
188
|
+
|
|
189
|
+
const installedRecordLookup = useMemo(
|
|
190
|
+
() => buildInstalledRecordLookup(installedRecords),
|
|
191
|
+
[installedRecords],
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
const installedEntries = useMemo<InstalledRenderEntry[]>(() => {
|
|
195
|
+
const entries = installedRecords
|
|
196
|
+
.filter((record) => record.type === typeFilter)
|
|
197
|
+
.map((record) => ({
|
|
198
|
+
key: `${record.type}:${record.spec}:${record.id ?? ""}`,
|
|
199
|
+
record,
|
|
200
|
+
item: findCatalogItemForRecord(record, catalogLookup),
|
|
201
|
+
}))
|
|
202
|
+
.filter((entry) =>
|
|
203
|
+
matchInstalledSearch(entry.record, entry.item, query, localeFallbacks),
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
entries.sort((left, right) => {
|
|
207
|
+
const leftTs = left.record.installedAt
|
|
208
|
+
? Date.parse(left.record.installedAt)
|
|
209
|
+
: Number.NaN;
|
|
210
|
+
const rightTs = right.record.installedAt
|
|
211
|
+
? Date.parse(right.record.installedAt)
|
|
212
|
+
: Number.NaN;
|
|
213
|
+
const leftValid = !Number.isNaN(leftTs);
|
|
214
|
+
const rightValid = !Number.isNaN(rightTs);
|
|
215
|
+
|
|
216
|
+
if (leftValid && rightValid && leftTs !== rightTs) {
|
|
217
|
+
return rightTs - leftTs;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return left.record.spec.localeCompare(right.record.spec);
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
return entries;
|
|
224
|
+
}, [installedRecords, typeFilter, catalogLookup, query, localeFallbacks]);
|
|
225
|
+
|
|
226
|
+
const total =
|
|
227
|
+
scope === "installed"
|
|
228
|
+
? installedEntries.length
|
|
229
|
+
: (itemsQuery.data?.total ?? 0);
|
|
230
|
+
const showCatalogSkeleton =
|
|
231
|
+
scope === "all" && itemsQuery.isLoading && !itemsQuery.data;
|
|
232
|
+
const showInstalledSkeleton =
|
|
233
|
+
scope === "installed" && installedQuery.isLoading && !installedQuery.data;
|
|
234
|
+
const showListSkeleton = showCatalogSkeleton || showInstalledSkeleton;
|
|
235
|
+
|
|
236
|
+
const listSummary = useMemo(() => {
|
|
237
|
+
if (scope === "installed") {
|
|
238
|
+
if (installedQuery.isLoading && !installedQuery.data) {
|
|
239
|
+
return t("loading");
|
|
240
|
+
}
|
|
241
|
+
return `${installedEntries.length} ${t(copyKeys.installedCountSuffix)}`;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (!itemsQuery.data) {
|
|
245
|
+
return t("loading");
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return `${allItems.length} / ${total}`;
|
|
249
|
+
}, [
|
|
250
|
+
scope,
|
|
251
|
+
installedQuery.data,
|
|
252
|
+
installedQuery.isLoading,
|
|
253
|
+
installedEntries.length,
|
|
254
|
+
itemsQuery.data,
|
|
255
|
+
allItems.length,
|
|
256
|
+
total,
|
|
257
|
+
copyKeys.installedCountSuffix,
|
|
258
|
+
]);
|
|
259
|
+
|
|
260
|
+
const installState: InstallState = { installingSpecs };
|
|
261
|
+
|
|
262
|
+
const manageState: ManageState = {
|
|
263
|
+
actionsByTarget: managingTargets,
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
const scopeTabs = [
|
|
267
|
+
{ id: "all", label: t(copyKeys.tabMarketplace) },
|
|
268
|
+
{
|
|
269
|
+
id: "installed",
|
|
270
|
+
label: t(copyKeys.tabInstalled),
|
|
271
|
+
count: installedQuery.data?.total ?? 0,
|
|
272
|
+
},
|
|
273
|
+
];
|
|
274
|
+
|
|
275
|
+
const handleInstall = async (item: MarketplaceItemSummary) => {
|
|
276
|
+
const installSpec = item.install.spec;
|
|
277
|
+
if (installingSpecs.has(installSpec)) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
setInstallingSpecs((prev) => {
|
|
282
|
+
const next = new Set(prev);
|
|
283
|
+
next.add(installSpec);
|
|
284
|
+
return next;
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
try {
|
|
288
|
+
await installMutation.mutateAsync({
|
|
289
|
+
type: item.type,
|
|
290
|
+
spec: installSpec,
|
|
291
|
+
kind: item.install.kind,
|
|
292
|
+
...(item.type === "skill"
|
|
293
|
+
? {
|
|
294
|
+
skill: item.slug,
|
|
295
|
+
installPath: `skills/${item.slug}`,
|
|
296
|
+
}
|
|
297
|
+
: {}),
|
|
298
|
+
});
|
|
299
|
+
} catch {
|
|
300
|
+
// handled in mutation onError
|
|
301
|
+
} finally {
|
|
302
|
+
setInstallingSpecs((prev) => {
|
|
303
|
+
if (!prev.has(installSpec)) {
|
|
304
|
+
return prev;
|
|
305
|
+
}
|
|
306
|
+
const next = new Set(prev);
|
|
307
|
+
next.delete(installSpec);
|
|
308
|
+
return next;
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
const handleManage = async (
|
|
314
|
+
action: MarketplaceManageAction,
|
|
315
|
+
record: MarketplaceInstalledRecord,
|
|
316
|
+
) => {
|
|
317
|
+
const targetId = record.id || record.spec;
|
|
318
|
+
if (!targetId) {
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
if (managingTargets.has(targetId)) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
if (action === "uninstall") {
|
|
326
|
+
const confirmed = await confirm({
|
|
327
|
+
title: `${t("marketplaceUninstallTitle")} ${targetId}?`,
|
|
328
|
+
description: t("marketplaceUninstallDescription"),
|
|
329
|
+
confirmLabel: t("marketplaceUninstall"),
|
|
330
|
+
variant: "destructive",
|
|
331
|
+
});
|
|
332
|
+
if (!confirmed) {
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
setManagingTargets((previous) => {
|
|
338
|
+
const next = new Map(previous);
|
|
339
|
+
next.set(targetId, action);
|
|
340
|
+
return next;
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
try {
|
|
344
|
+
await manageMutation.mutateAsync({
|
|
345
|
+
type: record.type,
|
|
346
|
+
action,
|
|
347
|
+
id: targetId,
|
|
348
|
+
spec: record.spec,
|
|
349
|
+
});
|
|
350
|
+
} finally {
|
|
351
|
+
setManagingTargets((previous) => {
|
|
352
|
+
if (!previous.has(targetId)) {
|
|
353
|
+
return previous;
|
|
354
|
+
}
|
|
355
|
+
const next = new Map(previous);
|
|
356
|
+
next.delete(targetId);
|
|
357
|
+
return next;
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
const openItemDetail = async (
|
|
363
|
+
item?: MarketplaceItemSummary,
|
|
364
|
+
record?: MarketplaceInstalledRecord,
|
|
365
|
+
) => {
|
|
366
|
+
const title =
|
|
367
|
+
item?.name ??
|
|
368
|
+
record?.label ??
|
|
369
|
+
record?.id ??
|
|
370
|
+
record?.spec ??
|
|
371
|
+
t("marketplaceUnknownItem");
|
|
372
|
+
|
|
373
|
+
if (!item) {
|
|
374
|
+
const url = buildGenericDetailDataUrl({
|
|
375
|
+
title,
|
|
376
|
+
typeLabel:
|
|
377
|
+
record?.type === "plugin"
|
|
378
|
+
? t("marketplaceTypePlugin")
|
|
379
|
+
: t("marketplaceTypeSkill"),
|
|
380
|
+
spec: record?.spec ?? "-",
|
|
381
|
+
summary: t("marketplaceInstalledLocalSummary"),
|
|
382
|
+
metadataRaw: JSON.stringify(record ?? {}, null, 2),
|
|
383
|
+
contentRaw: "-",
|
|
384
|
+
});
|
|
385
|
+
docBrowser.open(url, { newTab: true, title, kind: "content" });
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
const summary = pickLocalizedText(
|
|
390
|
+
item.summaryI18n,
|
|
391
|
+
item.summary,
|
|
392
|
+
localeFallbacks,
|
|
393
|
+
);
|
|
394
|
+
|
|
395
|
+
if (item.type === "skill") {
|
|
396
|
+
try {
|
|
397
|
+
const content: MarketplaceSkillContentView =
|
|
398
|
+
await fetchMarketplaceSkillContent(item.slug);
|
|
399
|
+
const url = buildGenericDetailDataUrl({
|
|
400
|
+
title,
|
|
401
|
+
typeLabel: t("marketplaceTypeSkill"),
|
|
402
|
+
spec: item.install.spec,
|
|
403
|
+
summary,
|
|
404
|
+
metadataRaw: content.metadataRaw,
|
|
405
|
+
contentRaw: content.bodyRaw || content.raw,
|
|
406
|
+
sourceUrl: content.sourceUrl,
|
|
407
|
+
sourceLabel: `Source (${content.source})`,
|
|
408
|
+
tags: item.tags,
|
|
409
|
+
author: item.author,
|
|
410
|
+
});
|
|
411
|
+
docBrowser.open(url, { newTab: true, title, kind: "content" });
|
|
412
|
+
} catch (error) {
|
|
413
|
+
const url = buildGenericDetailDataUrl({
|
|
414
|
+
title,
|
|
415
|
+
typeLabel: t("marketplaceTypeSkill"),
|
|
416
|
+
spec: item.install.spec,
|
|
417
|
+
summary,
|
|
418
|
+
metadataRaw: JSON.stringify(
|
|
419
|
+
{ error: error instanceof Error ? error.message : String(error) },
|
|
420
|
+
null,
|
|
421
|
+
2,
|
|
422
|
+
),
|
|
423
|
+
contentRaw: t("marketplaceOperationFailed"),
|
|
424
|
+
});
|
|
425
|
+
docBrowser.open(url, { newTab: true, title, kind: "content" });
|
|
426
|
+
}
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
try {
|
|
431
|
+
const content: MarketplacePluginContentView =
|
|
432
|
+
await fetchMarketplacePluginContent(item.slug);
|
|
433
|
+
const url = buildGenericDetailDataUrl({
|
|
434
|
+
title,
|
|
435
|
+
typeLabel: t("marketplaceTypePlugin"),
|
|
436
|
+
spec: item.install.spec,
|
|
437
|
+
summary,
|
|
438
|
+
metadataRaw: content.metadataRaw,
|
|
439
|
+
contentRaw: content.bodyRaw || content.raw || item.summary,
|
|
440
|
+
sourceUrl: content.sourceUrl,
|
|
441
|
+
sourceLabel: `Source (${content.source})`,
|
|
442
|
+
tags: item.tags,
|
|
443
|
+
author: item.author,
|
|
444
|
+
});
|
|
445
|
+
docBrowser.open(url, { newTab: true, title, kind: "content" });
|
|
446
|
+
} catch (error) {
|
|
447
|
+
const url = buildGenericDetailDataUrl({
|
|
448
|
+
title,
|
|
449
|
+
typeLabel: t("marketplaceTypePlugin"),
|
|
450
|
+
spec: item.install.spec,
|
|
451
|
+
summary,
|
|
452
|
+
metadataRaw: JSON.stringify(
|
|
453
|
+
{ error: error instanceof Error ? error.message : String(error) },
|
|
454
|
+
null,
|
|
455
|
+
2,
|
|
456
|
+
),
|
|
457
|
+
contentRaw: "-",
|
|
458
|
+
});
|
|
459
|
+
docBrowser.open(url, { newTab: true, title, kind: "content" });
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
return (
|
|
464
|
+
<PageLayout className="flex h-full min-h-0 flex-col pb-0">
|
|
465
|
+
<PageHeader
|
|
466
|
+
title={t(copyKeys.pageTitle)}
|
|
467
|
+
description={t(copyKeys.pageDescription)}
|
|
468
|
+
/>
|
|
469
|
+
|
|
470
|
+
<Tabs
|
|
471
|
+
tabs={scopeTabs}
|
|
472
|
+
activeTab={scope}
|
|
473
|
+
onChange={(value) => setScope(value as ScopeType)}
|
|
474
|
+
className="mb-4"
|
|
475
|
+
/>
|
|
476
|
+
|
|
477
|
+
<FilterPanel
|
|
478
|
+
scope={scope}
|
|
479
|
+
searchText={searchText}
|
|
480
|
+
searchPlaceholder={t(copyKeys.searchPlaceholder)}
|
|
481
|
+
sort={sort}
|
|
482
|
+
onSearchTextChange={setSearchText}
|
|
483
|
+
onSortChange={setSort}
|
|
484
|
+
/>
|
|
485
|
+
|
|
486
|
+
<section className="flex min-h-0 flex-1 flex-col">
|
|
487
|
+
<div className="flex items-center justify-between mb-3">
|
|
488
|
+
<h3 className="text-[14px] font-semibold text-gray-900">
|
|
489
|
+
{scope === "installed"
|
|
490
|
+
? t(copyKeys.sectionInstalled)
|
|
491
|
+
: t(copyKeys.sectionCatalog)}
|
|
492
|
+
</h3>
|
|
493
|
+
<span className="text-[12px] text-gray-500">{listSummary}</span>
|
|
494
|
+
</div>
|
|
495
|
+
|
|
496
|
+
{scope === "all" && itemsQuery.isError && (
|
|
497
|
+
<NoticeCard
|
|
498
|
+
tone="danger"
|
|
499
|
+
title={t(copyKeys.errorLoadData)}
|
|
500
|
+
description={itemsQuery.error.message}
|
|
501
|
+
/>
|
|
502
|
+
)}
|
|
503
|
+
{scope === "installed" && installedQuery.isError && (
|
|
504
|
+
<NoticeCard
|
|
505
|
+
tone="danger"
|
|
506
|
+
title={t(copyKeys.errorLoadInstalled)}
|
|
507
|
+
description={installedQuery.error.message}
|
|
508
|
+
/>
|
|
509
|
+
)}
|
|
510
|
+
|
|
511
|
+
<div
|
|
512
|
+
ref={infiniteScroll.containerRef}
|
|
513
|
+
className="min-h-0 flex-1 overflow-y-auto custom-scrollbar pr-1"
|
|
514
|
+
aria-busy={showListSkeleton || itemsQuery.isFetchingNextPage}
|
|
515
|
+
>
|
|
516
|
+
<div
|
|
517
|
+
data-testid={
|
|
518
|
+
showListSkeleton ? "marketplace-list-skeleton" : undefined
|
|
519
|
+
}
|
|
520
|
+
className="grid grid-cols-1 gap-3 lg:grid-cols-2 2xl:grid-cols-3"
|
|
521
|
+
>
|
|
522
|
+
{showListSkeleton && (
|
|
523
|
+
<MarketplaceListSkeleton count={SKELETON_CARD_COUNT} />
|
|
524
|
+
)}
|
|
525
|
+
|
|
526
|
+
{!showListSkeleton &&
|
|
527
|
+
scope === "all" &&
|
|
528
|
+
allItems.map((item) => (
|
|
529
|
+
<MarketplaceListCard
|
|
530
|
+
key={item.id}
|
|
531
|
+
item={item}
|
|
532
|
+
record={findInstalledRecordForItem(
|
|
533
|
+
item,
|
|
534
|
+
installedRecordLookup,
|
|
535
|
+
)}
|
|
536
|
+
language={language}
|
|
537
|
+
installState={installState}
|
|
538
|
+
manageState={manageState}
|
|
539
|
+
onOpen={() =>
|
|
540
|
+
void openItemDetail(
|
|
541
|
+
item,
|
|
542
|
+
findInstalledRecordForItem(item, installedRecordLookup),
|
|
543
|
+
)
|
|
544
|
+
}
|
|
545
|
+
onInstall={handleInstall}
|
|
546
|
+
onManage={handleManage}
|
|
547
|
+
/>
|
|
548
|
+
))}
|
|
549
|
+
|
|
550
|
+
{!showListSkeleton &&
|
|
551
|
+
scope === "installed" &&
|
|
552
|
+
installedEntries.map((entry) => (
|
|
553
|
+
<MarketplaceListCard
|
|
554
|
+
key={entry.key}
|
|
555
|
+
item={entry.item}
|
|
556
|
+
record={entry.record}
|
|
557
|
+
language={language}
|
|
558
|
+
installState={installState}
|
|
559
|
+
manageState={manageState}
|
|
560
|
+
onOpen={() => void openItemDetail(entry.item, entry.record)}
|
|
561
|
+
onInstall={handleInstall}
|
|
562
|
+
onManage={handleManage}
|
|
563
|
+
/>
|
|
564
|
+
))}
|
|
565
|
+
</div>
|
|
566
|
+
|
|
567
|
+
{scope === "all" &&
|
|
568
|
+
!showListSkeleton &&
|
|
569
|
+
!itemsQuery.isError &&
|
|
570
|
+
allItems.length === 0 && (
|
|
571
|
+
<div className="text-[13px] text-gray-500 py-8 text-center">
|
|
572
|
+
{t(copyKeys.emptyData)}
|
|
573
|
+
</div>
|
|
574
|
+
)}
|
|
575
|
+
{scope === "installed" &&
|
|
576
|
+
!showListSkeleton &&
|
|
577
|
+
!installedQuery.isError &&
|
|
578
|
+
installedEntries.length === 0 && (
|
|
579
|
+
<div className="text-[13px] text-gray-500 py-8 text-center">
|
|
580
|
+
{t(copyKeys.emptyInstalled)}
|
|
581
|
+
</div>
|
|
582
|
+
)}
|
|
583
|
+
|
|
584
|
+
{scope === "all" && !showCatalogSkeleton && !itemsQuery.isError && (
|
|
585
|
+
<MarketplaceInfiniteScrollStatus
|
|
586
|
+
hasMore={Boolean(itemsQuery.hasNextPage)}
|
|
587
|
+
loading={itemsQuery.isFetchingNextPage}
|
|
588
|
+
sentinelRef={infiniteScroll.sentinelRef}
|
|
589
|
+
/>
|
|
590
|
+
)}
|
|
591
|
+
</div>
|
|
592
|
+
</section>
|
|
593
|
+
<ConfirmDialog />
|
|
594
|
+
</PageLayout>
|
|
595
|
+
);
|
|
596
|
+
}
|