Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(plugins): 收敛发布入口并完善提交反馈

liugaoweif609fd488f11
diff --git a/apps/desktop/resources/system-skills/cindy-plugin-creator/references/plugin-packaging.md b/apps/desktop/resources/system-skills/cindy-plugin-creator/references/plugin-packaging.md
index ba7382df58..fec14ce6bf 100644
--- a/apps/desktop/resources/system-skills/cindy-plugin-creator/references/plugin-packaging.md
+++ b/apps/desktop/resources/system-skills/cindy-plugin-creator/references/plugin-packaging.md
@@ -109,6 +109,13 @@
不要求额外的最后人工点击。Host 在提交前再次检查已安装内容,变更后必须刷新摘要,不能悄悄替换包。
用户已明确委托发布时,不再另问一次是否发布。预检有 blockers 时先说明具体原因;需要改包则回到
现有作者源码,用原 Forge 工具修改、安装更新后重新预检,不直接改 Host 管理的安装目录。
+
+预检或提交返回 `PLUGIN_GHOST_ID_CONFLICT` 时,冲突指 `ghost.json.id`,不是显示名称;按错误码判断,不依赖服务端文案。先停止继续提交:
+
+- 发布另一款新插件:说明标识已被使用,获得用户同意后才修改作者源码中的 `ghost.json.id`,沿原 Forge 流程重新打包、安装后预检,不直接改 Host 管理的安装目录。
+- 更新已有插件:保留 ID,核对当前登录账号及 `ghost_my_plugins` 返回的当前提交权限;没有权限则说明并停止,不自动切换账号,不改 ID 或换发布入口绕过。
+- 无法判断是新插件还是已有插件更新:先询问用户,不能自行选择改 ID,也不重复提交相同请求。
+
权限拒绝按原任务权限处理,返回原因并停止,不切换权限或借其它入口重试。
当前个人账号与组织成员的普通任务均可向公开市场投稿,插件归提交者本人管理,不赋予组织管理员其他成员投稿的管理权。组织内部发布仍使用原 Forge 流程。共享访客及插件托管任务不能借用房主账号。
diff --git a/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx b/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx
index 35549bbc55..ffd4e713cb 100644
--- a/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx
+++ b/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx
@@ -113,8 +113,8 @@ interface GhostPluginDetailViewProps {
onUninstall: () => void;
/** 导出 .cindy;当前详情非已装插件(纯市场视图)时缺省,菜单项不渲染。 */
onExport?: () => void;
+ /** Opens publishing; package preparation and submission belong to the dialog. */
onContribute?: () => void;
- contributionUpdate?: boolean;
contributionBusy?: boolean;
contributionSummary?: string;
publishingPreview?: PreparedPluginContribution;
@@ -159,7 +159,6 @@ export function GhostPluginDetailView({
onUninstall,
onExport,
onContribute,
- contributionUpdate = false,
contributionBusy = false,
contributionSummary,
publishingPreview,
@@ -296,7 +295,7 @@ export function GhostPluginDetailView({
aria-describedby={contributionNoticeId}
title={contributionUnavailableReason}
>
- {publishingPreview ? t('settings.ghosts.contribution.submitVersion', { version: publishingPreview.version }) : t(`settings.ghosts.contribution.${contributionUpdate ? 'submitUpdate' : 'publish'}`)}
+ {t('settings.ghosts.contribution.publishPlugin')}
</Button>
) : null}
{/* 启用开关带明确文字(设计定稿):状态一目了然,点文字同样可切换。 */}
diff --git a/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx b/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
index 28e512b1d8..d0ba453118 100644
--- a/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
+++ b/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
@@ -1,4 +1,3 @@
-import { useContributionPreview } from './lib/useContributionPreview';
import { CatalogDeviceScope, type CatalogDeviceControl } from './useCatalogDevice';
import { RemotePluginPage } from './RemotePluginPage';
import { PluginVersionFacts } from './PluginVersionFacts';
@@ -6,7 +5,7 @@ import { useSignInToCindy } from '@/hooks/useSignInToCindy';
import { rememberContributionIntent, consumeContributionIntent, matchesContributionIntent } from './lib/contributionIntent';
import { MyPluginsPage, contributionErrorKey, type MyPluginsPageCache, type PluginSubmitOptions } from './MyPluginsPage';
import { localPublishingUnavailableKey } from './lib/ghostPluginDetailModel';
-import type { MyPluginView } from '../../../shared/pluginContributions';
+import { PluginPublishDialog, type PluginPublishDialogRequest } from './PluginPublishDialog';
import { featureRetirementById, type FeatureRetirement } from '../../../shared/featureRetirements';
import { RetiredFeatureDetail } from './RetiredFeatureDetail';
import { Button } from '@/components/ui/button';
@@ -16,7 +15,7 @@ import { Button } from '@/components/ui/button';
* Inputs: installed Ghost snapshots and user actions. `embedded` mounts the same
* catalog inside Settings; `onSelectCatalogTab` keeps Plugins / Skills in-panel.
* Outputs: the Plugin list/detail UI, recommendation-aware return navigation, and Plugin action flows.
- * Personal submissions remain in the original detail until the server confirms the result.
+ * Publishing preparation starts in the shared dialog; submission stays in-place until confirmed.
* [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md
*/
@@ -478,8 +477,8 @@ function LocalGhostPluginPage({
const [contributionBusy, setContributionBusy] = useState(false);
const [submissionRevision, setSubmissionRevision] = useState(0);
const contributing = useRef<string | null>(null);
- const [publicationRefresh, setPublicationRefresh] = useState(0);
- const [localContribution, setLocalContribution] = useState<{ key: string; plugin: MyPluginView | null; versionUsed: boolean; error: string | null } | null>(null);
+ const [publicationDialog, setPublicationDialog] = useState<PluginPublishDialogRequest | null>(null);
+ const publicationDialogSequence = useRef(0);
const [recommendationNonce] = useState(() => searchParams.get('recommendation'));
const pendingRecommendation = useSyncExternalStore(
subscribePendingPluginSuggestion,
@@ -1690,77 +1689,12 @@ function LocalGhostPluginPage({
const next = new URLSearchParams(searchParams); next.delete('contributionChild'); next.delete('contributionTransfer');
setSearchParams(next, { replace: true });
}, [searchParams, setSearchParams]);
- const localContributionKey = JSON.stringify([contributionOwner, selectedDetail?.id, selectedGhost?.dir, selectedGhost?.manifest.version, ghostInstallApprovalToken(selectedGhost?.approval), selectedGhost?.publishingSource, publicationRefresh]);
- const localContributionResult = localContribution?.key === localContributionKey ? localContribution : null;
const contributionUnavailableKey = localPublishingUnavailableKey(selectedGhost, selectedMarketInstall);
- // Ordinary downloads have use/configuration details only. Unknown provenance
- // also cannot become a first publication merely because no market card exists.
- const showLocalPublishing = selectedGhost?.publishingSource?.kind === 'local';
- const localPublishBlocker = localContributionResult?.plugin
- ? !localContributionResult.plugin.actions.submitUpdate ? 'PERMISSION_DENIED'
- : localContributionResult.plugin.latestSubmission?.reviewStatus === 'pending' && localContributionResult.plugin.latestSubmission.revisionState === 'current' ? 'PLUGIN_PENDING_RELEASE_EXISTS'
- : localContributionResult.versionUsed ? 'VERSION_ALREADY_SUBMITTED'
- : null
- : null;
- useEffect(() => {
- let disposed = false;
- setLocalContribution(null);
- if (!contributor || !selectedGhost || !selectedGhost.publishingSource || selectedGhost.publishingSource.kind !== 'local' || selectedGhost.namespace !== null || selectedGhost.namespaceState !== 'confirmed' || selectedGhost.approval.state !== 'approved' || showMyPlugins) return;
- const owner = contributionOwner;
- const instanceId = installedGhostStoragePart(selectedGhost);
- const read = async () => {
- let cursor: string | undefined;
- const listCursors = new Set<string>();
- do {
- const page = await window.electronAPI.pluginContributions.list({ query: selectedGhost.manifest.id, filter: 'all', cursor });
- if (disposed || contributionOwnerRef.current !== owner) return;
- const plugin = page.plugins.find((item) => item.localInstanceId === instanceId);
- if (plugin) {
- // Cancelled/rejected versions stay occupied, including versions older
- // than latestSubmission. Do not enable an update until this read ends.
- const version = selectedGhost.manifest.version;
- let versionUsed = plugin.market.version === version || plugin.latestSubmission?.version === version;
- const pending = plugin.latestSubmission?.reviewStatus === 'pending' && plugin.latestSubmission.revisionState === 'current';
- if (plugin.actions.submitUpdate && !pending && !versionUsed) {
- let releaseCursor: string | undefined;
- const releaseCursors = new Set<string>();
- do {
- const releases = await window.electronAPI.pluginContributions.releases(plugin.pluginId, releaseCursor);
- if (disposed || contributionOwnerRef.current !== owner) return;
- versionUsed = releases.releases.some(release => release.version === version);
- if (versionUsed) break;
- releaseCursor = releases.nextCursor ?? undefined;
- if (releaseCursor && releaseCursors.has(releaseCursor)) throw new Error('Repeated release cursor');
- if (releaseCursor) releaseCursors.add(releaseCursor);
- } while (releaseCursor);
- }
- setLocalContribution({ key: localContributionKey, plugin, versionUsed, error: null });
- return;
- }
- cursor = page.nextCursor ?? undefined;
- if (cursor && listCursors.has(cursor)) throw new Error('Repeated contribution cursor');
- if (cursor) listCursors.add(cursor);
- } while (cursor);
- setLocalContribution({ key: localContributionKey, plugin: null, versionUsed: false, error: null });
- };
- void read().catch((error) => {
- if (!disposed && contributionOwnerRef.current === owner) setLocalContribution({ key: localContributionKey, plugin: null, versionUsed: false, error: contributionErrorKey(error) });
- });
- return () => { disposed = true; };
- }, [contributor, localContributionKey, showMyPlugins]);
- const canPreparePublication = contributor && selectedGhost?.publishingSource?.kind === 'local' &&
- !contributionUnavailableKey && !showMyPlugins && localContributionResult &&
- !localContributionResult.error && !localPublishBlocker;
- const currentPublicationDraft = useContributionPreview(localContributionKey,
- canPreparePublication && selectedGhost ? installedGhostStoragePart(selectedGhost) : undefined,
- selectedGhost?.manifest.version,
- instanceId => window.electronAPI.pluginContributions.prepare(instanceId, selectedGhost ? {
- directory: selectedGhost.dir, approvalToken: ghostInstallApprovalToken(selectedGhost.approval),
- } : undefined),
- preparedId => window.electronAPI.pluginContributions.discard(preparedId));
+ const showLocalPublishing = selectedGhost?.publishingSource?.kind === 'local' && !contributionUnavailableKey;
useEffect(() => {
if (showMyPlugins) { setSelectedId(null); setMarketDetail(null); }
}, [showMyPlugins]);
+ useEffect(() => { setPublicationDialog(null); }, [contributionOwner, selectedDetail?.id, showMyPlugins]);
useEffect(() => { contributing.current = null; setContributionBusy(false); }, [contributionOwner]);
const openMyPlugins = (pluginId?: string) => {
@@ -1806,7 +1740,7 @@ function LocalGhostPluginPage({
if (!clicked) throw new Error('Original installed plugin is unavailable');
if (clicked.publishingSource?.kind !== 'local' || localPublishingUnavailableKey(clicked, marketItemForInstalledGhost(marketItems, clicked)))
throw new Error('Current publishing source or permission is unavailable');
- const prepared = options?.prepared ?? (currentPublicationDraft?.prepared?.instanceId === instanceId ? currentPublicationDraft.prepared : undefined) ?? await preparePublication(instanceId);
+ const prepared = options?.prepared ?? await preparePublication(instanceId);
if (prepared.instanceId !== instanceId) throw new Error('Original installed plugin changed');
preparedId = prepared.preparedId;
if (contributionOwnerRef.current !== owner) return false;
@@ -1822,14 +1756,9 @@ function LocalGhostPluginPage({
}
if (!contributionMounted.current || contributionOwnerRef.current !== owner) return false;
if (result.operation?.status !== 'succeeded' || !result.operation.receipt) {
- const message = result.operation?.failure?.message;
- toast.error(message && ![
- '投稿处理暂不可用,请查看原操作后重试',
- '发布处理暂不可用,请查看原操作后重试',
- ].includes(message) ? message : t(`settings.ghosts.contribution.errors.${result.errorCode ?? 'INTERNAL'}`, {
+ toast.error(t(`settings.ghosts.contribution.errors.${result.operation?.failure?.code ?? result.errorCode ?? 'INTERNAL'}`, {
defaultValue: t('settings.ghosts.contribution.submitFailed'),
}));
- if (result.stage === 'complete' && stillHere()) setPublicationRefresh(value => value + 1);
return false;
}
contributionCache.current.page = null; contributionCache.current.detail = null;
@@ -1838,7 +1767,7 @@ function LocalGhostPluginPage({
openMyPlugins(result.operation.receipt.pluginId);
return true;
} catch (error) {
- if (contributionOwnerRef.current === owner) { toast.error(t(contributionErrorKey(error), { defaultValue: t('settings.ghosts.contribution.loadFailed') })); setPublicationRefresh(value => value + 1); }
+ if (contributionOwnerRef.current === owner) { toast.error(t(contributionErrorKey(error), { defaultValue: t('settings.ghosts.contribution.loadFailed') })); }
return false;
} finally {
if (preparedId && contributionOwnerRef.current === owner) void window.electronAPI.pluginContributions.discard(preparedId).catch(() => undefined);
@@ -1864,6 +1793,27 @@ function LocalGhostPluginPage({
else toast.error(t('settings.ghosts.contribution.installForAccount'));
}, [searchParams, contributor, contributionOwner, ghosts]);
+ const publishingInstalledRevision = JSON.stringify([installedGhostMarketKey, installedGhostLocationsKey,
+ ghosts.map(ghost => [installedGhostStoragePart(ghost), ghostInstallApprovalToken(ghost.approval), ghost.publishingSource])]);
+ const publicationDialogView = publicationDialog && publicationDialog.owner === contributionOwner && publicationDialog.instanceId === selectedDetail?.id ? (
+ <PluginPublishDialog
+ key={publicationDialog.id}
+ open={publicationDialog.open}
+ ownerKey={contributionOwner}
+ initialInstanceId={publicationDialog.instanceId}
+ reader={window.electronAPI.pluginContributions}
+ localPlugins={publishableInstalledItems}
+ installedPluginCount={allInstalledItems.length}
+ onPrepare={preparePublication}
+ onSubmitUpdate={contribute}
+ submitBusy={contributionBusy}
+ installedRevision={publishingInstalledRevision}
+ submissionRevision={submissionRevision}
+ onOpenChange={open => setPublicationDialog(current => current?.id === publicationDialog.id ? { ...current, open } : current)}
+ onClosed={() => setPublicationDialog(current => current?.id === publicationDialog.id && !current.open ? null : current)}
+ />
+ ) : null;
+
// 面板收束:aside 只挂在插件页语境里(列表/详情/市场详情共用),
// 路由离开本页组件整体卸载 → webview 一并回收,绝不残留到别的界面。
const panelAside = openPanelGhost ? (
@@ -1915,11 +1865,16 @@ function LocalGhostPluginPage({
? () => void handleExport()
: undefined
}
- onContribute={!showLocalPublishing || contributionUnavailableKey || localPublishBlocker ? undefined : () => void contribute(selectedDetail.id)}
- contributionUnavailableReason={contributionUnavailableKey === 'officialGithubRequired' || (contributionUnavailableKey === 'reservedId' && selectedGhost?.publishingSource?.kind === 'public-market') ? t(`settings.ghosts.contribution.unavailable.${contributionUnavailableKey}`) : !showLocalPublishing ? undefined : contributionUnavailableKey ? t(`settings.ghosts.contribution.unavailable.${contributionUnavailableKey}`) : localContributionResult?.error ? t(localContributionResult.error) : localPublishBlocker ? t(`settings.ghosts.contribution.errors.${localPublishBlocker}`) : currentPublicationDraft?.error ? t(currentPublicationDraft.error, { defaultValue: t('settings.ghosts.contribution.loadFailed') }) : currentPublicationDraft?.prepared?.preflight?.blockers[0] ? currentPublicationDraft.prepared.preflight.blockers[0].message : contributor && !currentPublicationDraft?.prepared ? t('settings.ghosts.contribution.preparing') : undefined}
- publishingPreview={currentPublicationDraft?.prepared}
- onRefreshPublishing={() => setPublicationRefresh(value => value + 1)}
- contributionUpdate={Boolean(localContributionResult?.plugin || (selectedGhost?.manifest.id && marketItems.some((item) => marketItemMatchesInstalledGhost(item, selectedGhost))))}
+ onContribute={!showLocalPublishing ? undefined : () => {
+ if (!contributor) { void contribute(selectedDetail.id); return; }
+ setPublicationDialog({
+ id: ++publicationDialogSequence.current, owner: contributionOwner, open: true, instanceId: selectedDetail.id,
+ });
+ }}
+ contributionUnavailableReason={contributionUnavailableKey === 'officialGithubRequired' || (contributionUnavailableKey === 'reservedId' && selectedGhost?.publishingSource?.kind === 'public-market')
+ ? t(`settings.ghosts.contribution.unavailable.${contributionUnavailableKey}`)
+ : selectedGhost?.publishingSource?.kind === 'local' && contributionUnavailableKey
+ ? t(`settings.ghosts.contribution.unavailable.${contributionUnavailableKey}`) : undefined}
contributionBusy={contributionBusy}
toggleDisabled={scopeDir !== null && selectedGhost !== null && !selectedGhost.enabled}
onIconLoadError={handleMarketIconLoadError}
@@ -1927,6 +1882,7 @@ function LocalGhostPluginPage({
</div>
</div>
{panelAside}
+ {publicationDialogView}
</div>
) : null;
@@ -1937,8 +1893,7 @@ function LocalGhostPluginPage({
localPlugins={publishableInstalledItems}
installedPluginCount={allInstalledItems.length}
onPrepare={preparePublication}
- installedRevision={JSON.stringify([installedGhostMarketKey, installedGhostLocationsKey,
- ghosts.map(ghost => [installedGhostStoragePart(ghost), ghostInstallApprovalToken(ghost.approval), ghost.publishingSource])])}
+ installedRevision={publishingInstalledRevision}
renderVersionFacts={(plugin) => <PluginVersionFacts plugin={plugin} />}
onReadPublished={window.electronAPI.pluginMarket.detail}
submitBusy={contributionBusy}
diff --git a/apps/desktop/src/renderer/features/plugin/MyPluginsPage.tsx b/apps/desktop/src/renderer/features/plugin/MyPluginsPage.tsx
index b6a2b943e5..4bb9ff3b7c 100644
--- a/apps/desktop/src/renderer/features/plugin/MyPluginsPage.tsx
+++ b/apps/desktop/src/renderer/features/plugin/MyPluginsPage.tsx
@@ -1,15 +1,14 @@
import { useConfirmDialog } from '@/components/ui/confirm-dialog-provider';
import { PluginPublisherBadge } from './PluginPublisherBadge';
import { PluginSharedUsage } from './PluginSharedUsage';
-import * as Dialog from '@radix-ui/react-dialog';
-import { Check, ChevronRight, Plus, RotateCw } from 'lucide-react';
+import { ChevronRight, Plus, RotateCw } from 'lucide-react';
import { Select } from '@/components/ui/select';
import { Tip } from '@/components/ui/tooltip';
import type { GhostPluginListItem } from './lib/ghostPluginViewModel';
import type { PluginMarketDetail } from '../../../shared/pluginMarket';
import { AccountSwitcherDialog } from '@/components/sidebar/AccountSwitcherDialog';
import { useSignInToCindy } from '@/hooks/useSignInToCindy';
-import { useCallback, useEffect, useId, useLayoutEffect, useRef, useState, type ReactNode } from 'react';
+import { useCallback, useEffect, useLayoutEffect, useRef, useState, type ReactNode } from 'react';
import { useLocation, useNavigate, useSearchParams } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { Button } from '@/components/ui/button';
@@ -33,6 +32,8 @@ import type {
import { PluginDetailTopBar, usePluginDetailScrolled } from './PluginDetailTopBar';
import { PLUGIN_MANAGEMENT_FRAME_CLASS, PluginManagementPage } from './PluginManagementLayout';
import { GhostPluginIcon } from './GhostPluginIcon';
+import { PluginPublishDialog, type PluginPublishDialogRequest, type PluginSubmitOptions } from './PluginPublishDialog';
+export type { PluginSubmitOptions } from './PluginPublishDialog';
import { usePluginMarketForegroundRefresh } from './lib/usePluginMarketForegroundRefresh';
const copy = 'settings.ghosts.contribution';
@@ -51,12 +52,6 @@ export interface MyPluginsPageCache {
selectedRelease?: { pluginId: string; key: string };
}
-export interface PluginSubmitOptions {
- prepared?: PreparedPluginContribution;
- /** Closing/reopening the picker must not let an old completion navigate. */
- isCurrent?: () => boolean;
-}
-
/** Kept independent of transport DTOs; the Host supplies an owner-fenced read projection. */
export function MyPluginsPage({
reader,
@@ -93,13 +88,8 @@ export function MyPluginsPage({
const navigate = useNavigate();
const location = useLocation();
const signIn = useSignInToCindy(`${location.pathname}${location.search}`);
- const [pickerOwner, setPickerOwner] = useState<string | null>(null);
- const pickerStatusId = useId();
- const [pickerSelection, setPickerSelection] = useState<string | null>(null);
- const [pickerRefresh, setPickerRefresh] = useState(0);
- const [pickerPlugins, setPickerPlugins] = useState<{
- key: string; plugins: MyPluginView[]; failure?: string;
- } | null>(null);
+ const [picker, setPicker] = useState<PluginPublishDialogRequest | null>(null);
+ const pickerSequence = useRef(0);
const [updateRefresh, setUpdateRefresh] = useState(0);
const preparePreview = onPrepare ?? reader.prepare;
const [accountSwitcherOpen, setAccountSwitcherOpen] = useState(false);
@@ -174,59 +164,11 @@ export function MyPluginsPage({
const scrollFrame = useRef<HTMLElement>(null);
const { scrolled, onScroll } = usePluginDetailScrolled();
const contributor = mode === 'cloud' && (user?.membershipKind === 'personal' || user?.membershipKind === 'org');
- const pickerOpen = contributor && ownerMatches && pickerOwner === ownerKey && !selectedId;
- const pickerReadKey = JSON.stringify([ownerKey, installedRevision, submissionRevision]);
- const pickerRead = pickerPlugins?.key === pickerReadKey ? pickerPlugins : null;
- const pickerReady = Boolean(pickerRead && !pickerRead.failure);
- const pickerItem = localPlugins.find(item => item.id === pickerSelection);
- const pickerVersion = pickerItem?.version;
- const pickerKey = JSON.stringify([ownerKey, location.key, pickerOpen, pickerSelection,
- pickerVersion, installedRevision, pickerRefresh]);
- const pickerContext = useRef({ key: pickerKey, token: {} });
- if (pickerContext.current.key !== pickerKey) pickerContext.current = { key: pickerKey, token: {} };
- const currentPickerDraft = useContributionPreview(pickerKey,
- pickerOpen && pickerVersion !== undefined ? pickerSelection ?? undefined : undefined,
- pickerVersion, preparePreview, reader.discard);
- const pickerBlocker = currentPickerDraft?.prepared?.preflight?.blockers[0];
- const pickerUnavailable = (local: GhostPluginListItem) => {
- const plugin = pickerRead?.plugins.find(item => item.localInstanceId === local.id);
- if (!plugin) return null;
- if (plugin.publisherKind === 'official') return `${copy}.unavailable.officialGithubRequired`;
- if (!plugin.actions.submitUpdate) return `${copy}.permissionDenied`;
- if (plugin.latestSubmission?.reviewStatus === 'pending' && plugin.latestSubmission.revisionState === 'current')
- return `${copy}.errors.PLUGIN_PENDING_RELEASE_EXISTS`;
- if (plugin.market.version === local.version || plugin.latestSubmission?.version === local.version)
- return `${copy}.errors.VERSION_ALREADY_SUBMITTED`;
- return null;
+ const openPicker = () => {
+ setPicker({ id: ++pickerSequence.current, owner: ownerKey, open: true });
};
- const selectedPickerUnavailable = pickerItem ? pickerUnavailable(pickerItem) : null;
-
- useEffect(() => {
- let disposed = false;
- setPickerPlugins(null);
- if (!pickerOpen || !localPlugins.length) return;
- // Read version facts once for this dialog, independently of the list's search
- // and pagination. Do not prepare packages just to render the choices.
- void (async () => {
- const plugins: MyPluginView[] = [];
- const cursors = new Set<string>();
- let cursor: string | undefined;
- do {
- const page = await reader.list({ query: '', filter: 'all', cursor });
- if (disposed) return;
- plugins.push(...page.plugins);
- cursor = page.nextCursor ?? undefined;
- if (cursor && cursors.has(cursor)) throw new Error('Repeated contribution cursor');
- if (cursor) cursors.add(cursor);
- } while (cursor);
- setPickerPlugins({ key: pickerReadKey, plugins });
- })().catch(error => {
- if (!disposed) setPickerPlugins({ key: pickerReadKey, plugins: [], failure: contributionErrorKey(error) });
- });
- return () => { disposed = true; };
- }, [pickerOpen, pickerReadKey, reader, localPlugins.length]);
- useEffect(() => { setPickerOwner(null); }, [selectedId]);
+ useEffect(() => { setPicker(null); }, [selectedId]);
useEffect(() => {
mounted.current = true;
@@ -245,7 +187,7 @@ export function MyPluginsPage({
setDetail(null);
setInstallationRead(null);
setFailure(null);
- setPickerOwner(null);
+ setPicker(null);
setPublishedContent(null);
setHistoryOpenKey(null);
setSnapshots({});
@@ -449,8 +391,8 @@ export function MyPluginsPage({
return () => { window.removeEventListener('online', online); window.removeEventListener('offline', offline); };
}, [refreshAll]);
useLayoutEffect(() => {
- if (!selectedId && scrollFrame.current)
- scrollFrame.current.scrollTop = listScroll.current;
+ if (scrollFrame.current)
+ scrollFrame.current.scrollTop = selectedId ? 0 : listScroll.current;
}, [selectedId, page]);
const loadSnapshot = useCallback(
@@ -887,9 +829,11 @@ export function MyPluginsPage({
{canPrepareUpdate ? currentUpdateDraft?.prepared ? <>
<p className="text-13 font-medium leading-5 text-[var(--text-primary)]">{currentUpdateDraft.prepared.name} · {currentUpdateDraft.prepared.version}</p>
<p className="select-text whitespace-pre-wrap break-words text-14 leading-6 text-[var(--text-secondary)]">{currentUpdateDraft.prepared.description}</p>
- <h3 className="text-13 font-medium leading-5 text-[var(--text-secondary)]">{t(`${copy}.releaseNotes`)}</h3>
- <p className="select-text whitespace-pre-wrap break-words text-14 leading-6 text-[var(--text-primary)]">{currentUpdateDraft.prepared.releaseNotes?.trim() || t(`${copy}.notesMissing`)}</p>
- {updateBlocker ? <p role="status" className="text-13 leading-5 text-[var(--text-secondary)]">{updateBlocker.message}</p> : null}
+ {currentUpdateDraft.prepared.releaseNotes?.trim() ? <>
+ <h3 className="text-13 font-medium leading-5 text-[var(--text-secondary)]">{t(`${copy}.releaseNotes`)}</h3>
+ <p className="select-text whitespace-pre-wrap break-words text-14 leading-6 text-[var(--text-primary)]">{currentUpdateDraft.prepared.releaseNotes}</p>
+ </> : null}
+ {updateBlocker ? <p role="status" className="text-13 leading-5 text-[var(--text-secondary)]">{t(`${copy}.errors.${updateBlocker.code}`, { defaultValue: t(`${copy}.errors.PRECONDITION_FAILED`) })}</p> : null}
</> : <p role={currentUpdateDraft?.error ? 'alert' : 'status'} className="text-13 leading-5 text-[var(--text-secondary)]">{t(currentUpdateDraft?.error ?? `${copy}.preparing`)}</p> : null}
</section>
<section aria-label={t(`${copy}.listedVersion`)} className="space-y-3 border-t border-[var(--border-default)] pt-5">
@@ -899,8 +843,10 @@ export function MyPluginsPage({
{plugin.market.state !== 'available' ? <p className="text-14 leading-6 text-[var(--text-secondary)]">{t(`${copy}.market.${plugin.market.state}`)}</p>
: published?.value ? <>
<p className="select-text whitespace-pre-wrap break-words text-14 leading-6 text-[var(--text-primary)]">{published.value.description || published.value.manifest.description}</p>
- <h3 className="text-13 font-medium leading-5 text-[var(--text-secondary)]">{t(`${copy}.releaseNotes`)}</h3>
- <p className="select-text whitespace-pre-wrap break-words text-14 leading-6 text-[var(--text-primary)]">{published.value.manifest.releaseNotes?.trim() || t(`${copy}.notesMissing`)}</p>
+ {published.value.manifest.releaseNotes?.trim() ? <>
+ <h3 className="text-13 font-medium leading-5 text-[var(--text-secondary)]">{t(`${copy}.releaseNotes`)}</h3>
+ <p className="select-text whitespace-pre-wrap break-words text-14 leading-6 text-[var(--text-primary)]">{published.value.manifest.releaseNotes}</p>
+ </> : null}
</> : <p role="status" className="text-14 leading-6 text-[var(--text-secondary)]">{t(`${copy}.${published?.loading ? 'loading' : 'publishedContentUnavailable'}`)}</p>}
{plugin.market.reason ? <p className="select-text whitespace-pre-wrap break-words text-14 leading-6 text-[var(--text-secondary)]">{plugin.market.reason}</p> : null}
</section>
@@ -919,10 +865,14 @@ export function MyPluginsPage({
<p role="status" className="text-13 leading-5 text-[var(--text-secondary)]">{t(`${copy}.${cancelResult.cancelled ? 'cancelReviewCompleted' : 'cancelReviewAlreadyFinal'}`)}</p>
) : null}
{currentSubmission.reason ? <p className="select-text whitespace-pre-wrap break-words text-14 leading-6 text-[var(--text-primary)]">{currentSubmission.reason}</p> : null}
- <h3 className="text-13 font-medium leading-5 text-[var(--text-secondary)]">{t(`${copy}.releaseNotes`)}</h3>
+ <h3 className="text-13 font-medium leading-5 text-[var(--text-secondary)]">{t('settings.ghosts.detail.infoDescription')}</h3>
<p className="select-text whitespace-pre-wrap break-words text-14 leading-6 text-[var(--text-primary)]">
- {typeof currentNotes === 'string' && currentNotes.trim() ? currentNotes : t(`${copy}.${currentSubmission.content ? 'notesMissing' : 'snapshotUnavailable'}`)}
+ {currentSubmission.content ? currentSubmission.content.description : t(`${copy}.snapshotUnavailable`)}
</p>
+ {typeof currentNotes === 'string' && currentNotes.trim() ? <>
+ <h3 className="text-13 font-medium leading-5 text-[var(--text-secondary)]">{t(`${copy}.releaseNotes`)}</h3>
+ <p className="select-text whitespace-pre-wrap break-words text-14 leading-6 text-[var(--text-primary)]">{currentNotes}</p>
+ </> : null}
<details className="group/current">
<summary className="flex cursor-pointer list-none items-center gap-2 text-13 font-medium leading-5 text-[var(--text-secondary)] [&::-webkit-details-marker]:hidden">
<ChevronRight size={14} aria-hidden="true" className="shrink-0 group-open/current:rotate-90" />{t(`${copy}.submittedContent`)}
@@ -1011,16 +961,16 @@ export function MyPluginsPage({
<section className="space-y-3 pt-2">
<div className="space-y-1">
<h3 className="text-14 font-medium leading-5 text-[var(--text-primary)]">
- {t(`${copy}.releaseNotes`)}
+ {t('settings.ghosts.detail.infoDescription')}
</h3>
</div>
<p className="select-text whitespace-pre-wrap break-words text-14 leading-6 text-[var(--text-primary)]">
- {typeof notes === 'string' && notes.trim()
- ? notes
- : t(
- `${copy}.${shownRelease.content ? 'notesMissing' : 'snapshotUnavailable'}`,
- )}
+ {shownRelease.content ? shownRelease.content.description : t(`${copy}.snapshotUnavailable`)}
</p>
+ {typeof notes === 'string' && notes.trim() ? <>
+ <h3 className="text-14 font-medium leading-5 text-[var(--text-primary)]">{t(`${copy}.releaseNotes`)}</h3>
+ <p className="select-text whitespace-pre-wrap break-words text-14 leading-6 text-[var(--text-primary)]">{notes}</p>
+ </> : null}
</section>
<details className="group/version border-t border-[var(--border-default)] pt-4">
<summary className="flex cursor-pointer list-none items-center gap-2 text-13 font-medium leading-5 text-[var(--text-secondary)] [&::-webkit-details-marker]:hidden">
@@ -1067,15 +1017,17 @@ export function MyPluginsPage({
) : null}
{event.submissionId ? (
<div>
- <Button
- variant="secondary"
- size="sm"
- compact
- loading={snapshotLoading === event.submissionId}
- onClick={() => void loadSnapshot(event.submissionId!)}
- >
- {t(`${copy}.submittedContent`)}
- </Button>
+ {!snapshots[event.submissionId] ? (
+ <Button
+ variant="secondary"
+ size="sm"
+ compact
+ loading={snapshotLoading === event.submissionId}
+ onClick={() => void loadSnapshot(event.submissionId!)}
+ >
+ {t(`${copy}.submittedContent`)}
+ </Button>
+ ) : null}
{snapshots[event.submissionId] ? (
<div className="mt-3">
{releaseContent(snapshots[event.submissionId])}
@@ -1113,7 +1065,6 @@ export function MyPluginsPage({
</div>
) : null;
const publishing = <section aria-label={t(`${copy}.versionManagement`)}>
- {currentSubmission?.content?.description ? <p className="mb-6 select-text whitespace-pre-wrap break-words text-14 leading-6 text-[var(--text-secondary)]">{currentSubmission.content.description}</p> : null}
{versions ? <div className="mb-6">{versions}</div> : null}
{publishingContent}
</section>;
@@ -1176,7 +1127,7 @@ export function MyPluginsPage({
<Button
variant="cta"
disabled={!contributor || !ownerMatches}
- onClick={() => { setPickerPlugins(null); setPickerSelection(null); setPickerOwner(ownerKey); }}
+ onClick={openPicker}
>
<Plus size={16} />
{t(`${copy}.publishPlugin`)}
@@ -1258,8 +1209,8 @@ export function MyPluginsPage({
<div className="flex min-h-72 flex-col items-center justify-center gap-4 py-8 text-center text-14 leading-6 text-[var(--text-tertiary)]">
<p>{t(`${copy}.${query || filter !== 'all' ? 'noMatches' : 'empty'}`)}</p>
{!query && filter === 'all' ? (
- <Button variant="secondary" onClick={onViewLocal}>
- {t(`${copy}.viewLocal`)}
+ <Button variant="secondary" onClick={openPicker} disabled={!ownerMatches}>
+ {t(`${copy}.goPublish`)}
</Button>
) : null}
</div>
@@ -1352,9 +1303,7 @@ export function MyPluginsPage({
<span>
{timestamp
? t(`${copy}.lastRefreshed`, { time: formatDate(timestamp) })
- : loading
- ? t(`${copy}.loading`)
- : ''}
+ : ''}
</span>
{!isDetail && listEmpty && !query && filter === 'all' ? refreshButton : null}
</footer>
@@ -1362,113 +1311,23 @@ export function MyPluginsPage({
)}
</PluginManagementPage>
</main>
- <Dialog.Root
- open={pickerOpen}
- onOpenChange={(open) => {
- if (!open) setPickerOwner(null);
- }}
- >
- <Dialog.Portal>
- <Dialog.Overlay className="modal-scrim fixed inset-0 z-[10000]" />
- <Dialog.Content onInteractOutside={event => event.preventDefault()} className="modal-panel fixed left-1/2 top-1/2 z-[10000] flex max-h-[85vh] w-[calc(100vw-32px)] max-w-[460px] -translate-x-1/2 -translate-y-1/2 flex-col p-4">
- <Dialog.Title className="text-18 font-medium text-[var(--text-primary)]">
- {t(`${copy}.publishPlugin`)}
- </Dialog.Title>
- <Dialog.Description className="mt-2 text-13 leading-5 text-[var(--text-secondary)]">
- {t(`${copy}.chooseLocal`)}
- </Dialog.Description>
- <div className="my-4 min-h-0 overflow-y-auto p-1">
- {pickerOwner === ownerKey && ownerMatches
- ? localPlugins.map((local) => {
- const unavailable = pickerUnavailable(local);
- return (
- <button
- type="button"
- key={local.id}
- className={`flex w-full min-w-0 items-center gap-3 rounded-lg border px-2 py-3 text-left enabled:hover:bg-[var(--surface-hover)] disabled:cursor-default focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--focus-ring)] ${submitBusy || !pickerReady ? 'opacity-60' : ''} ${pickerSelection === local.id ? 'border-[var(--border-default)] bg-[var(--surface-hover)]' : 'border-transparent'}`}
- aria-label={`${local.name} · ${local.version} · ${local.id}`}
- aria-describedby={unavailable ? `${pickerStatusId}-${local.id}` : undefined}
- aria-pressed={pickerSelection === local.id}
- disabled={submitBusy || !pickerReady || Boolean(unavailable)}
- onClick={() => setPickerSelection(local.id)}
- >
- <GhostPluginIcon
- iconDataUrl={local.iconDataUrl}
- iconId={local.id}
- iconName={local.name}
- />
- <span className="min-w-0 flex-1 [overflow-wrap:anywhere]">
- <span className={`block text-14 font-medium leading-5 ${unavailable ? 'text-[var(--text-secondary)]' : 'text-[var(--text-primary)]'}`}>
- {local.name}
- </span>
- <span className="mt-1 block text-12 leading-4 text-[var(--text-tertiary)]">
- {local.version}
- </span>
- <span className="mt-1 block text-12 leading-4 text-[var(--text-tertiary)]">
- {local.id}
- </span>
- {unavailable ? <span id={`${pickerStatusId}-${local.id}`} className="mt-1 block text-13 leading-5 text-[var(--text-secondary)]">
- {t(unavailable)}
- </span> : null}
- </span>
- {pickerSelection === local.id ? <Check size={16} aria-hidden="true" className="shrink-0 text-[var(--text-primary)]" /> : null}
- </button>
- );
- })
- : null}
- {localPlugins.length === 0 ? (
- <p className="text-14 leading-6 text-[var(--text-secondary)]">
- {t(
- `${copy}.${installedPluginCount === 0 ? 'noLocalPlugins' : 'noPublishablePlugins'}`,
- )}
- </p>
- ) : null}
- </div>
- {pickerSelection && pickerItem ? (
- <section aria-label={t(`${copy}.publishingVersion`, { version: pickerItem.version })}
- className="mb-4 max-h-52 space-y-2 overflow-y-auto border-t border-[var(--border-default)] pt-3 text-13 leading-5 text-[var(--text-secondary)]">
- <p className="font-medium text-[var(--text-primary)]">{pickerItem.name} · {pickerItem.version}</p>
- {currentPickerDraft?.prepared ? <>
- <p className="whitespace-pre-wrap break-words">{currentPickerDraft.prepared.description}</p>
- {currentPickerDraft.prepared.releaseNotes?.trim() ? <>
- <h3 className="font-medium">{t(`${copy}.releaseNotes`)}</h3>
- <p className="whitespace-pre-wrap break-words">{currentPickerDraft.prepared.releaseNotes}</p>
- </> : null}
- <p>{t(`${copy}.confirmPublic`)}</p>
- </> : !currentPickerDraft?.error ? <p role="status">{t(`${copy}.preparing`)}</p> : null}
- </section>
- ) : null}
- {localPlugins.length > 0 && !pickerRead ? <p role="status" className="mb-3 shrink-0 text-13 leading-5 text-[var(--text-secondary)]">{t(`${copy}.loading`)}</p> : null}
- {pickerRead?.failure || currentPickerDraft?.error ? (
- <p role="alert" className="mb-3 shrink-0 text-13 leading-5 text-[var(--text-secondary)]">
- {t((pickerRead?.failure ?? currentPickerDraft?.error)!, { defaultValue: t(`${copy}.loadFailed`) })}
- </p>
- ) : pickerBlocker || selectedPickerUnavailable ? (
- <p role="status" className="mb-3 shrink-0 text-13 leading-5 text-[var(--text-primary)]">
- {selectedPickerUnavailable ? t(selectedPickerUnavailable) : pickerBlocker?.message}
- </p>
- ) : null}
- <div className="flex shrink-0 flex-wrap justify-end gap-2">
- <Dialog.Close asChild>
- <Button variant="secondary">{t('settings.ghosts.detail.closeDialog')}</Button>
- </Dialog.Close>
- {pickerReady && !selectedPickerUnavailable && pickerItem && currentPickerDraft?.prepared?.preflight?.actions.canSubmit ? (
- <Button variant="cta" loading={submitBusy} disabled={submitBusy || !navigator.onLine}
- onClick={() => {
- const prepared = currentPickerDraft.prepared!;
- const token = pickerContext.current.token;
- const isCurrent = () => mounted.current && pickerContext.current.token === token;
- void onSubmitUpdate(pickerItem.id, { prepared, isCurrent }).then(submitted => {
- if (!isCurrent()) return;
- if (submitted) setPickerOwner(null);
- else setPickerRefresh(value => value + 1);
- });
- }}>{t(`${copy}.submitVersion`, { version: currentPickerDraft.prepared.version })}</Button>
- ) : null}
- </div>
- </Dialog.Content>
- </Dialog.Portal>
- </Dialog.Root>
+ {picker && contributor && ownerMatches && picker.owner === ownerKey && !selectedId ? (
+ <PluginPublishDialog
+ key={picker.id}
+ open={picker.open}
+ ownerKey={ownerKey}
+ reader={reader}
+ localPlugins={localPlugins}
+ installedPluginCount={installedPluginCount}
+ onPrepare={onPrepare}
+ onSubmitUpdate={onSubmitUpdate}
+ submitBusy={submitBusy}
+ installedRevision={installedRevision}
+ submissionRevision={submissionRevision}
+ onOpenChange={open => setPicker(current => current?.id === picker.id ? { ...current, open } : current)}
+ onClosed={() => setPicker(current => current?.id === picker.id && !current.open ? null : current)}
+ />
+ ) : null}
</div>
);
}
diff --git a/apps/desktop/src/renderer/features/plugin/PluginPublishDialog.tsx b/apps/desktop/src/renderer/features/plugin/PluginPublishDialog.tsx
new file mode 100644
index 0000000000..e8e1ddbd1c
--- /dev/null
+++ b/apps/desktop/src/renderer/features/plugin/PluginPublishDialog.tsx
@@ -0,0 +1,237 @@
+import * as Dialog from '@radix-ui/react-dialog';
+import { Check } from 'lucide-react';
+import { useEffect, useId, useRef, useState } from 'react';
+import { useLocation } from 'react-router-dom';
+import { useTranslation } from 'react-i18next';
+import { Button } from '@/components/ui/button';
+import type {
+ MyPluginView,
+ PluginContributionsApi,
+ PreparedPluginContribution,
+} from '../../../shared/pluginContributions';
+import type { GhostPluginListItem } from './lib/ghostPluginViewModel';
+import { contributionErrorKey, useContributionPreview } from './lib/useContributionPreview';
+import { GhostPluginIcon } from './GhostPluginIcon';
+
+const copy = 'settings.ghosts.contribution';
+
+export interface PluginSubmitOptions {
+ prepared?: PreparedPluginContribution;
+ /** Closing/reopening the dialog must not let an old completion navigate. */
+ isCurrent?: () => boolean;
+}
+
+export interface PluginPublishDialogRequest {
+ id: number;
+ owner: string;
+ open: boolean;
+ instanceId?: string;
+}
+
+/** Mounted for one owner-bound opening; retained through Radix's exit animation. */
+export function PluginPublishDialog({
+ open, ownerKey, initialInstanceId, onOpenChange, onClosed,
+ reader, localPlugins, installedPluginCount, onPrepare, onSubmitUpdate,
+ submitBusy = false, installedRevision, submissionRevision = 0,
+}: {
+ open: boolean;
+ ownerKey: string;
+ initialInstanceId?: string;
+ onOpenChange: (open: boolean) => void;
+ onClosed: () => void;
+ reader: PluginContributionsApi;
+ localPlugins: readonly GhostPluginListItem[];
+ installedPluginCount: number;
+ onPrepare?: PluginContributionsApi['prepare'];
+ onSubmitUpdate: (instanceId: string, options?: PluginSubmitOptions) => Promise<boolean>;
+ submitBusy?: boolean;
+ installedRevision?: string;
+ submissionRevision?: number;
+}) {
+ const { t } = useTranslation();
+ const location = useLocation();
+ const pickerStatusId = useId();
+ const [pickerSelection, setPickerSelection] = useState<string | null>(initialInstanceId ?? null);
+ const [pickerRefresh, setPickerRefresh] = useState(0);
+ const [pickerPlugins, setPickerPlugins] = useState<{
+ key: string; plugins: MyPluginView[]; failure?: string;
+ } | null>(null);
+ const [versionRead, setVersionRead] = useState<{
+ key: string; used: boolean; failure?: string;
+ } | null>(null);
+ const mounted = useRef(true);
+ useEffect(() => {
+ mounted.current = true;
+ return () => { mounted.current = false; };
+ }, []);
+ const pickerReadKey = JSON.stringify([ownerKey, installedRevision, submissionRevision]);
+ const pickerRead = pickerPlugins?.key === pickerReadKey ? pickerPlugins : null;
+ const pickerReady = Boolean(pickerRead && !pickerRead.failure);
+ const pickerItem = localPlugins.find(item => item.id === pickerSelection);
+ const pickerUnavailable = (local: GhostPluginListItem) => {
+ const plugin = pickerRead?.plugins.find(item => item.localInstanceId === local.id);
+ if (!plugin) return null;
+ if (plugin.publisherKind === 'official') return `${copy}.unavailable.officialGithubRequired`;
+ if (!plugin.actions.submitUpdate) return `${copy}.permissionDenied`;
+ if (plugin.latestSubmission?.reviewStatus === 'pending' && plugin.latestSubmission.revisionState === 'current')
+ return `${copy}.errors.PLUGIN_PENDING_RELEASE_EXISTS`;
+ if (plugin.market.version === local.version || plugin.latestSubmission?.version === local.version)
+ return `${copy}.errors.VERSION_ALREADY_SUBMITTED`;
+ return null;
+ };
+ const selectedPlugin = pickerRead?.plugins.find(item => item.localInstanceId === pickerItem?.id);
+ const initialUnavailable = pickerItem ? pickerUnavailable(pickerItem) : null;
+ const versionReadKey = JSON.stringify([pickerReadKey, pickerItem?.id, pickerItem?.version, selectedPlugin?.pluginId]);
+ const selectedVersionRead = versionRead?.key === versionReadKey ? versionRead : null;
+ const selectedPickerUnavailable = initialUnavailable ?? (selectedVersionRead?.used ? `${copy}.errors.VERSION_ALREADY_SUBMITTED` : null);
+ const versionReady = !selectedPlugin || Boolean(selectedVersionRead && !selectedVersionRead.used && !selectedVersionRead.failure);
+ const pickerKey = JSON.stringify([pickerReadKey, location.key, pickerSelection, pickerItem?.version, pickerRefresh]);
+ const pickerContextKey = JSON.stringify([pickerKey, open]);
+ const pickerContext = useRef({ key: pickerContextKey, token: {}, open });
+ if (pickerContext.current.key !== pickerContextKey)
+ pickerContext.current = { key: pickerContextKey, token: {}, open };
+ const currentPickerDraft = useContributionPreview(pickerKey,
+ pickerReady && versionReady && !selectedPickerUnavailable ? pickerItem?.id : undefined,
+ pickerItem?.version, onPrepare ?? reader.prepare, reader.discard);
+ const pickerBlocker = currentPickerDraft?.prepared?.preflight?.blockers[0];
+
+ useEffect(() => {
+ let disposed = false;
+ if (!open || !localPlugins.length) return;
+ setPickerPlugins(null);
+ void (async () => {
+ const plugins: MyPluginView[] = [];
+ const cursors = new Set<string>();
+ let cursor: string | undefined;
+ do {
+ const page = await reader.list({ query: '', filter: 'all', cursor });
+ if (disposed) return;
+ plugins.push(...page.plugins);
+ cursor = page.nextCursor ?? undefined;
+ if (cursor && cursors.has(cursor)) throw new Error('Repeated contribution cursor');
+ if (cursor) cursors.add(cursor);
+ } while (cursor);
+ setPickerPlugins({ key: pickerReadKey, plugins });
+ })().catch(error => {
+ if (!disposed) setPickerPlugins({ key: pickerReadKey, plugins: [], failure: contributionErrorKey(error) });
+ });
+ return () => { disposed = true; };
+ }, [open, pickerReadKey, reader, localPlugins.length]);
+
+ useEffect(() => {
+ if (!open || !pickerReady || !pickerItem || !selectedPlugin || initialUnavailable) return;
+ let disposed = false;
+ setVersionRead(null);
+ const pluginId = selectedPlugin.pluginId, version = pickerItem.version;
+ void (async () => {
+ const cursors = new Set<string>();
+ let cursor: string | undefined;
+ do {
+ const page = await reader.releases(pluginId, cursor);
+ if (disposed) return;
+ if (page.releases.some(release => release.version === version)) {
+ setVersionRead({ key: versionReadKey, used: true });
+ return;
+ }
+ cursor = page.nextCursor ?? undefined;
+ if (cursor && cursors.has(cursor)) throw new Error('Repeated release cursor');
+ if (cursor) cursors.add(cursor);
+ } while (cursor);
+ setVersionRead({ key: versionReadKey, used: false });
+ })().catch(error => {
+ if (!disposed) setVersionRead({ key: versionReadKey, used: false, failure: contributionErrorKey(error) });
+ });
+ return () => { disposed = true; };
+ }, [open, pickerReady, versionReadKey, reader, pickerItem, selectedPlugin, initialUnavailable]);
+
+ return (
+ <Dialog.Root open={open} onOpenChange={onOpenChange}>
+ <Dialog.Portal>
+ <Dialog.Overlay className="modal-scrim fixed inset-0 z-[10000]" />
+ <Dialog.Content
+ onCloseAutoFocus={() => {
+ if (!pickerContext.current.open) onClosed();
+ }}
+ onInteractOutside={event => event.preventDefault()}
+ className="modal-panel fixed left-1/2 top-1/2 z-[10000] flex max-h-[85vh] w-[calc(100vw-32px)] max-w-[460px] -translate-x-1/2 -translate-y-1/2 flex-col p-4">
+ <Dialog.Title className="text-18 font-medium text-[var(--text-primary)]">
+ {t(`${copy}.publishPlugin`)}
+ </Dialog.Title>
+ <Dialog.Description className="mt-2 text-13 leading-5 text-[var(--text-secondary)]">
+ {t(`${copy}.chooseLocal`)}
+ </Dialog.Description>
+ <div className="my-4 min-h-0 overflow-y-auto p-1">
+ {localPlugins.map(local => {
+ const unavailable = pickerUnavailable(local);
+ return (
+ <button type="button" key={local.id}
+ className={`flex w-full min-w-0 items-center gap-3 rounded-lg border px-2 py-3 text-left enabled:hover:bg-[var(--surface-hover)] disabled:cursor-default focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--focus-ring)] ${submitBusy || !pickerReady ? 'opacity-60' : ''} ${pickerSelection === local.id ? 'border-[var(--border-default)] bg-[var(--surface-hover)]' : 'border-transparent'}`}
+ aria-label={`${local.name} · ${local.version} · ${local.id}`}
+ aria-describedby={unavailable ? `${pickerStatusId}-${local.id}` : undefined}
+ aria-pressed={pickerSelection === local.id}
+ disabled={!open || submitBusy || !pickerReady || Boolean(unavailable)}
+ onClick={() => setPickerSelection(local.id)}>
+ <GhostPluginIcon iconDataUrl={local.iconDataUrl} iconId={local.id} iconName={local.name} />
+ <span className="min-w-0 flex-1 [overflow-wrap:anywhere]">
+ <span className={`block text-14 font-medium leading-5 ${unavailable ? 'text-[var(--text-secondary)]' : 'text-[var(--text-primary)]'}`}>{local.name}</span>
+ <span className="mt-1 block text-12 leading-4 text-[var(--text-tertiary)]">{local.version}</span>
+ <span className="mt-1 block text-12 leading-4 text-[var(--text-tertiary)]">{local.id}</span>
+ {unavailable ? <span id={`${pickerStatusId}-${local.id}`} className="mt-1 block text-13 leading-5 text-[var(--text-secondary)]">{t(unavailable)}</span> : null}
+ </span>
+ {pickerSelection === local.id ? <Check size={16} aria-hidden="true" className="shrink-0 text-[var(--text-primary)]" /> : null}
+ </button>
+ );
+ })}
+ {!localPlugins.length ? (
+ <p className="text-14 leading-6 text-[var(--text-secondary)]">
+ {t(`${copy}.${installedPluginCount === 0 ? 'noLocalPlugins' : 'noPublishablePlugins'}`)}
+ </p>
+ ) : null}
+ </div>
+ {pickerItem ? (
+ <section aria-label={t(`${copy}.publishingVersion`, { version: pickerItem.version })}
+ className="mb-4 max-h-52 space-y-2 overflow-y-auto border-t border-[var(--border-default)] pt-3 text-13 leading-5 text-[var(--text-secondary)]">
+ <p className="font-medium text-[var(--text-primary)]">{pickerItem.name} · {pickerItem.version}</p>
+ <p className="whitespace-pre-wrap break-words">{currentPickerDraft?.prepared?.description ?? pickerItem.description}</p>
+ {currentPickerDraft?.prepared ? <>
+ {currentPickerDraft.prepared.releaseNotes?.trim() ? <>
+ <h3 className="font-medium">{t(`${copy}.releaseNotes`)}</h3>
+ <p className="whitespace-pre-wrap break-words">{currentPickerDraft.prepared.releaseNotes}</p>
+ </> : null}
+ <p>{t(`${copy}.confirmPublic`)}</p>
+ </> : pickerReady && !selectedPickerUnavailable && !currentPickerDraft?.error && !selectedVersionRead?.failure ? <p role="status">{t(`${copy}.${versionReady ? 'preparing' : 'loading'}`)}</p> : null}
+ </section>
+ ) : null}
+ {localPlugins.length > 0 && !pickerRead ? <p role="status" className="mb-3 shrink-0 text-13 leading-5 text-[var(--text-secondary)]">{t(`${copy}.loading`)}</p> : null}
+ {pickerRead?.failure || selectedVersionRead?.failure || currentPickerDraft?.error ? (
+ <p role="alert" className="mb-3 shrink-0 text-13 leading-5 text-[var(--text-secondary)]">
+ {t((pickerRead?.failure ?? selectedVersionRead?.failure ?? currentPickerDraft?.error)!, { defaultValue: t(`${copy}.loadFailed`) })}
+ </p>
+ ) : pickerBlocker || selectedPickerUnavailable ? (
+ <p role="status" className="mb-3 shrink-0 text-13 leading-5 text-[var(--text-primary)]">
+ {selectedPickerUnavailable ? t(selectedPickerUnavailable) : t(`${copy}.errors.${pickerBlocker?.code}`, { defaultValue: t(`${copy}.errors.PRECONDITION_FAILED`) })}
+ </p>
+ ) : null}
+ <div className="flex shrink-0 flex-wrap justify-end gap-2">
+ <Dialog.Close asChild>
+ <Button variant="secondary">{t('settings.ghosts.detail.closeDialog')}</Button>
+ </Dialog.Close>
+ {pickerReady && !selectedPickerUnavailable && !pickerBlocker && pickerItem && currentPickerDraft?.prepared?.preflight?.actions.canSubmit ? (
+ <Button variant="cta" loading={submitBusy} disabled={!open || submitBusy || !navigator.onLine}
+ onClick={() => {
+ const prepared = currentPickerDraft.prepared!;
+ const token = pickerContext.current.token;
+ const isCurrent = () => mounted.current && pickerContext.current.token === token;
+ void onSubmitUpdate(pickerItem.id, { prepared, isCurrent }).then(submitted => {
+ if (!isCurrent()) return;
+ if (submitted) onOpenChange(false);
+ else setPickerRefresh(value => value + 1);
+ });
+ }}>{t(`${copy}.submitVersion`, { version: currentPickerDraft.prepared.version })}</Button>
+ ) : null}
+ </div>
+ </Dialog.Content>
+ </Dialog.Portal>
+ </Dialog.Root>
+ );
+}
diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsx b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsx
index 6c4024c397..c237bbd087 100644
--- a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsx
+++ b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsx
@@ -297,7 +297,7 @@ describe('Ghost plugin detail sections', () => {
expect(updates.open).toBe(false);
expect(screen.getByRole('heading', { name: 'settings.ghosts.contribution.version · 1.0.0' }).closest('details')).toBe(updates);
fireEvent.click(screen.getByText('settings.ghosts.contribution.versionUpdates'));
- expect(screen.queryByRole('button', { name: 'settings.ghosts.contribution.submitVersion' })).toBeNull();
+ expect(screen.queryByRole('button', { name: 'settings.ghosts.contribution.publishPlugin' })).toBeNull();
expect(screen.getByRole('status').textContent).toBe(`1.0.0 · ${status}`);
expect(screen.getByText('Change the version before publishing again')).toBeTruthy();
expect(screen.getByRole('heading', { name: 'settings.ghosts.contribution.version · 1.0.0' })).toBeTruthy();
@@ -308,7 +308,7 @@ describe('Ghost plugin detail sections', () => {
expect(publish).not.toHaveBeenCalled();
// A previous cancelled/rejected/approved result does not hide a new eligible version.
rerender(view({ ...preview, version: '1.1.0', preflight: { ...preview.preflight!, target: { ...preview.preflight!.target, version: '1.1.0' }, pendingRelease: null, blockers: [], actions: { canSubmit: true } } }));
- const submit = screen.getByRole('button', { name: 'settings.ghosts.contribution.submitVersion' });
+ const submit = screen.getByRole('button', { name: 'settings.ghosts.contribution.publishPlugin' });
expect(submit).toHaveProperty('disabled', false);
expect(screen.getByRole('heading', { name: 'settings.ghosts.contribution.publishingVersion' })).toBeTruthy();
fireEvent.click(submit);
@@ -316,7 +316,7 @@ describe('Ghost plugin detail sections', () => {
},
);
- it('keeps the local quick submission in the use header and release information secondary', () => {
+ it('keeps the local publishing entry in the use header and release information secondary', () => {
vi.stubGlobal('ResizeObserver', class { observe() {} disconnect() {} });
const publish = vi.fn();
render(<GhostPluginDetailView ghost={null} detail={detail} panelStatus={null}
@@ -326,13 +326,13 @@ describe('Ghost plugin detail sections', () => {
const summary = screen.getByText('settings.ghosts.contribution.versionUpdates');
const updates = summary.closest('details')!;
expect(updates.open).toBe(false);
- expect(screen.getByRole('button', { name: 'settings.ghosts.contribution.publish' }).closest('header')).toBeTruthy();
+ expect(screen.getByRole('button', { name: 'settings.ghosts.contribution.publishPlugin' }).closest('header')).toBeTruthy();
expect(within(updates).getByRole('status').textContent).toBe('2.0.0 · Pending Review');
const chat = screen.getByRole('button', { name: 'settings.ghosts.detail.chatAction' });
expect(within(chat.closest('.plugin-detail-actions') as HTMLElement).getByRole('switch')).toBeTruthy();
expect(screen.getByText('Example plugin').compareDocumentPosition(updates) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
fireEvent.click(summary);
- const action = screen.getByRole('button', { name: 'settings.ghosts.contribution.publish' });
+ const action = screen.getByRole('button', { name: 'settings.ghosts.contribution.publishPlugin' });
expect(within(updates).getByRole('status').textContent).toBe('2.0.0 · Pending Review');
fireEvent.click(action);
expect(publish).toHaveBeenCalledOnce();
diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginPage.navigation.test.tsx b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginPage.navigation.test.tsx
index cf4d83a30c..bed1292df0 100644
--- a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginPage.navigation.test.tsx
+++ b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginPage.navigation.test.tsx
@@ -391,7 +391,7 @@ describe('plugin page return navigation', () => {
render(page('/plugins'));
fireEvent.click(await screen.findByText('Installed Plugin'));
fireEvent.click(screen.getByText('settings.ghosts.contribution.versionUpdates'));
- expect(screen.queryByRole('button', { name: 'settings.ghosts.contribution.publish' })).toBeNull();
+ expect(screen.queryByRole('button', { name: 'settings.ghosts.contribution.publishPlugin' })).toBeNull();
expect(screen.getByText('settings.ghosts.contribution.unavailable.' + reason)).toBeTruthy();
});
@@ -432,7 +432,7 @@ describe('plugin page return navigation', () => {
expect(screen.queryByRole('heading', { name: 'Local Author Plugin' })).toBeNull();
});
- it.each(['VERSION_ALREADY_SUBMITTED', 'PLUGIN_PENDING_RELEASE_EXISTS', 'RELEASE_NOTES_REQUIRED'])(
+ it.each(['VERSION_ALREADY_SUBMITTED', 'PLUGIN_PENDING_RELEASE_EXISTS', 'RELEASE_NOTES_REQUIRED', 'PLUGIN_GHOST_ID_CONFLICT'])(
'hides the unavailable submit action after reading the real preflight projection (%s)', async code => {
auth.mode = 'cloud';
const installed: InstalledGhost = {
@@ -449,10 +449,13 @@ describe('plugin page return navigation', () => {
Object.assign(window.electronAPI, { pluginContributions: api });
render(page('/plugins'));
fireEvent.click(await screen.findByText('Local Author Plugin'));
- await screen.findAllByText('Publication blocked');
- expect(screen.queryByRole('button', { name: 'settings.ghosts.contribution.submitVersion' })).toBeNull();
- fireEvent.click(screen.getByText('settings.ghosts.contribution.versionUpdates'));
- expect(screen.getByRole('button', { name: 'settings.ghosts.contribution.refreshSummary' })).toBeTruthy();
+ expect(api.prepare).not.toHaveBeenCalled();
+ fireEvent.click(screen.getByRole('button', { name: 'settings.ghosts.contribution.publishPlugin' }));
+ const picker = screen.getByRole('dialog');
+ await within(picker).findAllByText(`settings.ghosts.contribution.errors.${code}`);
+ expect(within(picker).queryByText('Publication blocked')).toBeNull();
+ expect(within(picker).queryByRole('button', { name: 'settings.ghosts.contribution.submitVersion' })).toBeNull();
+ expect(within(picker).getByRole('button', { name: 'settings.ghosts.detail.closeDialog' })).toHaveProperty('disabled', false);
expect(api.submit).not.toHaveBeenCalled();
},
);
@@ -867,6 +870,10 @@ describe('organization catalog access notice', () => {
describe('plugin use details and independent author management', () => {
const prefix = 'settings.ghosts.contribution';
+ async function openLocalPublishing() {
+ fireEvent.click(await screen.findByRole('button', { name: `${prefix}.publishPlugin` }));
+ return screen.getByRole('dialog');
+ }
function authorApi(localInstanceId: string | null = '_root__navigation-plugin') {
const own: MyPluginDetailView = {
plugin: { pluginId: detail.pluginId, name: 'Published snapshot name', iconUrl: null,
@@ -931,8 +938,9 @@ describe('plugin use details and independent author management', () => {
Object.assign(window.electronAPI, { pluginContributions: { ...api, status, discard: vi.fn().mockResolvedValue(undefined) } });
render(page(`/plugins?ghost=${installed.instanceKey}`));
await screen.findByRole('heading', { name: 'Local Author Plugin' });
- fireEvent.click(screen.getByText(`${prefix}.versionUpdates`));
- const submit = await screen.findByRole('button', { name: `${prefix}.submitVersion` });
+ expect(api.prepare).not.toHaveBeenCalled();
+ const picker = await openLocalPublishing();
+ const submit = await within(picker).findByRole('button', { name: `${prefix}.submitVersion` });
fireEvent.click(submit);
fireEvent.click(submit);
await waitFor(() => expect(api.submit).toHaveBeenCalledExactlyOnceWith(prepared.preparedId));
@@ -949,8 +957,9 @@ describe('plugin use details and independent author management', () => {
fireEvent.click(screen.getByRole('button', { name: 'settings.ghosts.title' }));
await screen.findByRole('heading', { level: 1, name: 'settings.ghosts.title' });
} else {
- await waitFor(() => expect(error).toHaveBeenCalledWith(message ?? `${prefix}.errors.INTERNAL`));
- expect(screen.getByRole('heading', { name: 'Local Author Plugin' })).toBeTruthy();
+ await waitFor(() => expect(error).toHaveBeenCalledWith(`${prefix}.errors.${message ? 'PLUGIN_PACKAGE_INVALID' : 'INTERNAL'}`));
+ if (message) expect(error).not.toHaveBeenCalledWith(message);
+ expect(screen.getByText('Local Author Plugin', { selector: 'h1' })).toBeTruthy();
}
expect(screen.queryByText(`${prefix}.resume`)).toBeNull();
expect(screen.queryByText(`${prefix}.retryPublish`)).toBeNull();
@@ -970,9 +979,9 @@ describe('plugin use details and independent author management', () => {
Object.assign(window.electronAPI, { pluginContributions: api });
render(page(`/plugins?ghost=${installed.instanceKey}`));
await screen.findByRole('heading', { name: 'Local Author Plugin' });
- fireEvent.click(screen.getByText(`${prefix}.versionUpdates`));
- await screen.findByText(`${prefix}.errors.${reviewStatus === 'pending' ? 'PLUGIN_PENDING_RELEASE_EXISTS' : 'VERSION_ALREADY_SUBMITTED'}`);
- expect(screen.queryByRole('button', { name: `${prefix}.submitUpdate` })).toBeNull();
+ const picker = await openLocalPublishing();
+ await within(picker).findAllByText(`${prefix}.errors.${reviewStatus === 'pending' ? 'PLUGIN_PENDING_RELEASE_EXISTS' : 'VERSION_ALREADY_SUBMITTED'}`);
+ expect(within(picker).queryByRole('button', { name: `${prefix}.submitVersion` })).toBeNull();
expect(api.prepare).not.toHaveBeenCalled();
expect(api.submit).not.toHaveBeenCalled();
},
@@ -991,15 +1000,15 @@ describe('plugin use details and independent author management', () => {
Object.assign(window.electronAPI, { pluginContributions: api });
render(page(`/plugins?ghost=${installed.instanceKey}`));
await screen.findByRole('heading', { name: 'Local Author Plugin' });
- fireEvent.click(screen.getByText(`${prefix}.versionUpdates`));
- await screen.findByText(`${prefix}.errors.VERSION_ALREADY_SUBMITTED`);
+ const picker = await openLocalPublishing();
+ await within(picker).findAllByText(`${prefix}.errors.VERSION_ALREADY_SUBMITTED`);
expect(api.releases).toHaveBeenCalledWith(detail.pluginId, 'older');
- expect(screen.queryByRole('button', { name: `${prefix}.submitUpdate` })).toBeNull();
+ expect(within(picker).queryByRole('button', { name: `${prefix}.submitVersion` })).toBeNull();
expect(api.prepare).not.toHaveBeenCalled();
expect(api.submit).not.toHaveBeenCalled();
});
- it('keeps submission disabled while version eligibility is loading or failed', async () => {
+ it('keeps the entry usable and offers no submission while dialog eligibility is loading or failed', async () => {
auth.mode = 'cloud';
const installed = localAuthorInstallation('2.0.0');
window.electronAPI.ghosts.listSync = () => ({ ghosts: [installed] });
@@ -1009,12 +1018,15 @@ describe('plugin use details and independent author management', () => {
api.releases.mockImplementation(() => new Promise((_, reject) => { fail = reject; }));
Object.assign(window.electronAPI, { pluginContributions: api });
render(page(`/plugins?ghost=${installed.instanceKey}`));
+ const action = await screen.findByRole('button', { name: `${prefix}.publishPlugin` });
+ expect(action).toHaveProperty('disabled', false);
+ expect(api.releases).not.toHaveBeenCalled();
+ const picker = await openLocalPublishing();
await waitFor(() => expect(api.releases).toHaveBeenCalled());
- const action = screen.getByRole('button', { name: /settings\.ghosts\.contribution\.(publish|submitUpdate)$/ });
- expect(action).toHaveProperty('disabled', true);
- fireEvent.click(action);
+ expect(within(picker).queryByRole('button', { name: `${prefix}.submitVersion` })).toBeNull();
await act(async () => { fail(new Error('Offline')); });
- expect(screen.getByRole('button', { name: /settings\.ghosts\.contribution\.(publish|submitUpdate)$/ })).toHaveProperty('disabled', true);
+ expect(await within(picker).findByRole('alert')).toHaveProperty('textContent', `${prefix}.loadFailed`);
+ expect(within(picker).queryByRole('button', { name: `${prefix}.submitVersion` })).toBeNull();
expect(api.prepare).not.toHaveBeenCalled();
expect(api.submit).not.toHaveBeenCalled();
});
@@ -1041,14 +1053,15 @@ describe('plugin use details and independent author management', () => {
api.prepare.mockImplementation(() => new Promise<ContributionTransferView['prepared']>(resolve => { finishPreview = resolve; }));
Object.assign(window.electronAPI, { pluginContributions: { ...api, discard: vi.fn().mockResolvedValue(undefined) } });
render(page(`/plugins?ghost=${installed.instanceKey}`));
+ expect(api.prepare).not.toHaveBeenCalled();
+ const picker = await openLocalPublishing();
await waitFor(() => expect(api.prepare).toHaveBeenCalledTimes(1));
- expect(screen.getByRole('button', { name: `${prefix}.submitUpdate` })).toHaveProperty('disabled', true);
+ expect(within(picker).queryByRole('button', { name: `${prefix}.submitVersion` })).toBeNull();
expect(api.submit).not.toHaveBeenCalled();
await act(async () => { finishPreview(prepared); });
if (allowed) {
expect(await screen.findByRole('button', { name: `${prefix}.submitVersion` })).toHaveProperty('disabled', false);
- fireEvent.click(screen.getByText(`${prefix}.versionUpdates`));
- expect(screen.getByText('Checked update notes')).toBeTruthy();
+ expect(within(picker).getByText('Checked update notes')).toBeTruthy();
} else {
expect(await screen.findByText('Missing release notes')).toBeTruthy();
expect(screen.queryByRole('button', { name: `${prefix}.submitUpdate` })).toBeNull();
@@ -1074,7 +1087,7 @@ describe('plugin use details and independent author management', () => {
await screen.findByRole('heading', { name: 'Downloaded Plugin' });
await act(async () => { await Promise.resolve(); });
expect(screen.queryByRole('heading', { name: `${prefix}.publishing` })).toBeNull();
- expect(screen.queryByRole('button', { name: `${prefix}.publish` })).toBeNull();
+ expect(screen.queryByRole('button', { name: `${prefix}.publishPlugin` })).toBeNull();
expect(api.prepare).not.toHaveBeenCalled();
expect(api.submit).not.toHaveBeenCalled();
// 普通下载详情无需扫描本人投稿权限,公开安装也不能开启 UI 提审。
@@ -1147,7 +1160,9 @@ describe('plugin use details and independent author management', () => {
const api = authorApi(null); api.list.mockRejectedValue(new Error('Offline'));
Object.assign(window.electronAPI, { pluginContributions: api });
render(page(`/plugins?ghost=${installed.instanceKey}`));
- await screen.findAllByText(`${prefix}.loadFailed`);
+ expect(api.list).not.toHaveBeenCalled();
+ const picker = await openLocalPublishing();
+ await within(picker).findAllByText(`${prefix}.loadFailed`);
expect(api.prepare).not.toHaveBeenCalled();
expect(api.submit).not.toHaveBeenCalled();
});
diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/MyPluginsPage.test.tsx b/apps/desktop/src/renderer/features/plugin/__tests__/MyPluginsPage.test.tsx
index af188a0f0a..6060334d94 100644
--- a/apps/desktop/src/renderer/features/plugin/__tests__/MyPluginsPage.test.tsx
+++ b/apps/desktop/src/renderer/features/plugin/__tests__/MyPluginsPage.test.tsx
@@ -158,7 +158,7 @@ beforeEach(() => {
auth.generation = 1;
auth.membershipKind = 'personal';
});
-afterEach(() => { cleanup(); vi.restoreAllMocks(); });
+afterEach(() => { cleanup(); vi.restoreAllMocks(); vi.unstubAllGlobals(); });
describe('My Plugins facts', () => {
it.each(['personal', 'org'])('shows the actual new package notes to a %s member before submitting the same prepared package', async membershipKind => {
@@ -183,7 +183,8 @@ describe('My Plugins facts', () => {
blockers: [{ code: 'VERSION_ALREADY_SUBMITTED', message: 'This exact new package version is already submitted.' }], actions: { canSubmit: false } } });
view(api);
const local = await screen.findByRole('region', { name: `${prefix}.localVersion` });
- await within(local).findByText('This exact new package version is already submitted.');
+ await within(local).findByText(`${prefix}.errors.VERSION_ALREADY_SUBMITTED`);
+ expect(within(local).queryByText('This exact new package version is already submitted.')).toBeNull();
expect(within(local).queryByRole('button', { name: `${prefix}.submitVersion 1.2.0` })).toBeNull();
expect(api.submit).not.toHaveBeenCalled();
});
@@ -291,7 +292,8 @@ describe('My Plugins facts', () => {
view(api, false, {}, installations, submit);
await screen.findByText(`${prefix}.empty`);
expect(screen.queryByRole('textbox', { name: `${prefix}.search` })).toBeNull();
- fireEvent.click(screen.getByRole('button', { name: `${prefix}.publishPlugin` }));
+ expect(screen.queryByRole('button', { name: `${prefix}.viewLocal` })).toBeNull();
+ fireEvent.click(screen.getByRole('button', { name: `${prefix}.goPublish` }));
const picker = screen.getByRole('dialog');
expect(submit).not.toHaveBeenCalled();
expect(api.prepare).not.toHaveBeenCalled();
@@ -306,6 +308,43 @@ describe('My Plugins facts', () => {
expect(screen.getByRole('dialog')).toBe(picker);
});
+ // Unit: closing used to clear the real picker while Radix kept it mounted for
+ // its exit animation, flashing Loading. Existing close/reopen cases unmounted
+ // immediately in jsdom and missed this interval. One loaded choice is enough.
+ it('retains the publishing choices and preview throughout the close animation', async () => {
+ // jsdom lacks CSS.escape; the simulated animation names are plain identifiers.
+ vi.stubGlobal('CSS', { escape: (value: string) => value });
+ const computedStyle = window.getComputedStyle.bind(window);
+ vi.spyOn(window, 'getComputedStyle').mockImplementation(element => {
+ const style = computedStyle(element);
+ if (element.getAttribute('role') === 'dialog') {
+ Object.defineProperty(style, 'animationName', {
+ get: () => element.getAttribute('data-state') === 'closed' ? 'modal-fade-out' : 'modal-panel-in',
+ });
+ }
+ return style;
+ });
+ const api = reader();
+ view(api, false);
+ fireEvent.click(screen.getByRole('button', { name: `${prefix}.publishPlugin` }));
+ await selectPublishingPlugin('Local Plugin · 1.2.0 · exact-instance');
+ const picker = screen.getByRole('dialog');
+ await within(picker).findByText('Actual selected package');
+
+ fireEvent.click(within(picker).getByRole('button', { name: 'settings.ghosts.detail.closeDialog' }));
+ expect(picker.isConnected).toBe(true);
+ expect(within(picker).getByText('Local Plugin')).toBeTruthy();
+ expect(within(picker).getByText('Actual selected package')).toBeTruthy();
+ expect(within(picker).queryByText(`${prefix}.loading`)).toBeNull();
+ expect(within(picker).queryByText(`${prefix}.preparing`)).toBeNull();
+
+ const end = new Event('animationend', { bubbles: true });
+ Object.defineProperty(end, 'animationName', { value: 'modal-fade-out' });
+ fireEvent(picker, end);
+ await waitFor(() => expect(picker.isConnected).toBe(false));
+ await waitFor(() => expect(api.discard).toHaveBeenCalledWith('chosen-snapshot'));
+ });
+
it('explains official GitHub publishing in management and the picker despite a submission grant', async () => {
const api = reader();
const official = { ...detail.plugin, publisherKind: 'official' as const };
@@ -374,7 +413,8 @@ describe('My Plugins facts', () => {
fireEvent.click(screen.getByRole('button', { name: `${prefix}.publishPlugin` }));
await selectPublishingPlugin('Local Plugin · 0.9.0 · exact-instance');
const picker = screen.getByRole('dialog');
- const reason = await within(picker).findByText('This earlier version was already submitted');
+ const reason = await within(picker).findByText(`${prefix}.errors.VERSION_ALREADY_SUBMITTED`);
+ expect(within(picker).queryByText('This earlier version was already submitted')).toBeNull();
const summary = within(picker).getByRole('region', { name: `${prefix}.publishingVersion 0.9.0` });
expect(summary.contains(reason)).toBe(false);
expect(reason.getAttribute('role')).toBe('status');
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index c244a93b22..3c97d05899 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -7296,9 +7296,9 @@
"published": "Published"
},
"loading": "Loading…",
- "empty": "No plugins submitted yet. Choose Publish Plugin to start with a plugin you developed and use.",
+ "empty": "No plugins submitted yet. Choose a plugin you developed and use, then submit it for review.",
"noMatches": "No plugins match this search or filter.",
- "viewLocal": "View Installed Plugins",
+ "goPublish": "Publish Plugin",
"currentMarket": "Currently Published Version",
"inUseVersion": "In Use",
"localVersion": "Local version",
@@ -7377,7 +7377,7 @@
"CONTRIBUTION_NOT_AUTHORIZED": "You do not have permission to publish this public plugin. Contact its maintainer; installation does not grant publishing rights.",
"CONTRIBUTION_REVISION_STALE": "The target version changed. Refresh and review it, then prepare again explicitly.",
"RELEASE_VERSION_CONFLICT": "This version cannot replace its existing runtime content. Update the plugin version before submitting.",
- "PLUGIN_GHOST_ID_CONFLICT": "This public plugin ID already exists. It cannot be claimed by uploading a package.",
+ "PLUGIN_GHOST_ID_CONFLICT": "This plugin identifier is already in use. Choose a different identifier for a new plugin, or sign in with the original publishing account to update the existing plugin.",
"CONTRIBUTION_OPERATION_NOT_FOUND": "This account cannot view this submission.",
"PRECONDITION_FAILED": "This plugin cannot currently be submitted for review.",
"PERSONAL_CONTEXT_REQUIRED": "Sign in to manage plugins you submit to the public marketplace.",
@@ -7439,7 +7439,6 @@
"releaseNotes": "Release notes",
"versionUpdates": "Versions & Updates",
"versionManagement": "Manage Versions",
- "notesMissing": "No release notes were provided for this version",
"versionContent": "Version content",
"loadMoreVersions": "Load more versions",
"notSubmitted": "Not submitted for review",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index aac5add925..5409238d57 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -7265,9 +7265,9 @@
"published": "公開中"
},
"loading": "読み込み中…",
- "empty": "提出したプラグインはまだありません。「プラグインを公開」から、自分で開発して使用しているプラグインを選んでください。",
+ "empty": "提出したプラグインはまだありません。自分で開発して使用しているプラグインを選び、審査に提出してください。",
"noMatches": "検索条件に一致するプラグインはありません。",
- "viewLocal": "インストール済みプラグインを見る",
+ "goPublish": "プラグインを公開",
"currentMarket": "現在公開中のバージョン",
"inUseVersion": "使用中",
"localVersion": "ローカル版",
@@ -7346,7 +7346,7 @@
"CONTRIBUTION_NOT_AUTHORIZED": "この公開プラグインを審査に提出する権限がありません。管理者に連絡してください。インストールしても公開する権限は付与されません。",
"CONTRIBUTION_REVISION_STALE": "対象のバージョンが変わりました。更新して確認後に再準備してください。",
"RELEASE_VERSION_CONFLICT": "このバージョンの実行内容は上書きできません。バージョンを更新してください。",
- "PLUGIN_GHOST_ID_CONFLICT": "この公開プラグイン ID は使用済みです。アップロードで所有権は取得できません。",
+ "PLUGIN_GHOST_ID_CONFLICT": "このプラグインの識別子は使用済みです。新しいプラグインは識別子を変更し、既存プラグインの更新は公開時のアカウントで行ってください。",
"CONTRIBUTION_OPERATION_NOT_FOUND": "このアカウントでは、この提出を確認できません。",
"PRECONDITION_FAILED": "現在、このプラグインは審査に提出できません。",
"PERSONAL_CONTEXT_REQUIRED": "ログインすると、公開マーケットに提出したプラグインを管理できます。",
@@ -7408,7 +7408,6 @@
"releaseNotes": "更新内容",
"versionUpdates": "バージョンと更新",
"versionManagement": "バージョン管理",
- "notesMissing": "このバージョンの更新内容は記載されていません",
"versionContent": "バージョンの内容",
"loadMoreVersions": "さらにバージョンを読み込む",
"notSubmitted": "審査未提出",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 1a63179262..5796671fc5 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -7265,9 +7265,9 @@
"published": "게시됨"
},
"loading": "불러오는 중…",
- "empty": "아직 제출한 플러그인이 없습니다. 플러그인 게시를 눌러 직접 개발하고 사용하는 플러그인을 선택하세요.",
+ "empty": "아직 제출한 플러그인이 없습니다. 직접 개발하고 사용하는 플러그인을 선택해 심사를 요청하세요.",
"noMatches": "검색 또는 필터 조건과 일치하는 플러그인이 없습니다.",
- "viewLocal": "설치된 플러그인 보기",
+ "goPublish": "플러그인 게시",
"currentMarket": "현재 게시된 버전",
"inUseVersion": "사용 중",
"localVersion": "로컬 버전",
@@ -7346,7 +7346,7 @@
"CONTRIBUTION_NOT_AUTHORIZED": "이 공개 플러그인을 심사에 제출할 권한이 없습니다. 관리자에게 문의하세요. 설치만으로 게시 권한이 부여되지는 않습니다.",
"CONTRIBUTION_REVISION_STALE": "대상 버전이 변경되었습니다. 새로고침해 확인한 후 다시 준비하세요.",
"RELEASE_VERSION_CONFLICT": "이 버전의 기존 실행 내용을 덮어쓸 수 없습니다. 버전을 올린 후 제출하세요.",
- "PLUGIN_GHOST_ID_CONFLICT": "이 공개 플러그인 ID는 이미 존재합니다. 업로드로 소유권을 얻을 수 없습니다.",
+ "PLUGIN_GHOST_ID_CONFLICT": "이 플러그인 식별자는 이미 사용 중입니다. 새 플러그인은 식별자를 변경하고, 기존 플러그인을 업데이트하려면 처음 게시한 계정으로 로그인하세요.",
"CONTRIBUTION_OPERATION_NOT_FOUND": "현재 계정으로 이 제출 내역을 볼 수 없습니다.",
"PRECONDITION_FAILED": "현재 이 플러그인을 검토에 제출할 수 없습니다.",
"PERSONAL_CONTEXT_REQUIRED": "로그인하면 공개 마켓에 제출한 플러그인을 관리할 수 있습니다.",
@@ -7408,7 +7408,6 @@
"releaseNotes": "업데이트 내용",
"versionUpdates": "버전 및 업데이트",
"versionManagement": "버전 관리",
- "notesMissing": "이 버전에는 업데이트 내용이 제공되지 않았습니다",
"versionContent": "버전 내용",
"loadMoreVersions": "버전 더 불러오기",
"notSubmitted": "심사에 제출되지 않음",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index c384201f99..4f28241831 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -7265,9 +7265,9 @@
"published": "已上架"
},
"loading": "正在加载…",
- "empty": "还没有提交过插件。点击“发布插件”,选择自己开发并使用的插件。",
+ "empty": "还没有提交过插件。选择自己开发并使用的插件,提交审核。",
"noMatches": "没有符合搜索或筛选条件的插件。",
- "viewLocal": "查看已安装插件",
+ "goPublish": "去发布",
"currentMarket": "当前上架版本",
"inUseVersion": "使用中",
"localVersion": "本地版本",
@@ -7346,7 +7346,7 @@
"CONTRIBUTION_NOT_AUTHORIZED": "没有此公开插件的提交权限,请联系维护者。安装插件不授予发布权。",
"CONTRIBUTION_REVISION_STALE": "目标版本已变化,请刷新并核对内容后重新准备。",
"RELEASE_VERSION_CONFLICT": "此版本不能覆盖已有运行内容,请修改插件版本后再提交。",
- "PLUGIN_GHOST_ID_CONFLICT": "此公开插件 ID 已存在,不能通过上传插件包认领。",
+ "PLUGIN_GHOST_ID_CONFLICT": "这个插件标识已被使用。发布新插件请更换标识;更新已有插件请使用原发布账号。",
"CONTRIBUTION_OPERATION_NOT_FOUND": "当前账号无法查看这次提交。",
"PRECONDITION_FAILED": "当前插件无法提交审核。",
"PERSONAL_CONTEXT_REQUIRED": "登录后即可管理你向公开市场提交的插件。",
@@ -7408,7 +7408,6 @@
"releaseNotes": "更新说明",
"versionUpdates": "版本与更新",
"versionManagement": "版本管理",
- "notesMissing": "此版本未提供更新说明",
"versionContent": "版本内容",
"loadMoreVersions": "加载更多版本",
"notSubmitted": "尚未提审",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
index f037c5f1f7..856efe766f 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -7265,9 +7265,9 @@
"published": "已上架"
},
"loading": "正在載入…",
- "empty": "還沒有提交過插件。點擊「發佈插件」,選擇自己開發並使用的插件。",
+ "empty": "還沒有提交過插件。選擇自己開發並使用的插件,提交審核。",
"noMatches": "沒有符合搜尋或篩選條件的插件。",
- "viewLocal": "查看已安裝插件",
+ "goPublish": "去發佈",
"currentMarket": "目前上架版本",
"inUseVersion": "使用中",
"localVersion": "本機版本",
@@ -7346,7 +7346,7 @@
"CONTRIBUTION_NOT_AUTHORIZED": "沒有此公開插件的提交權限,請聯絡維護者。安裝插件不授予發佈權。",
"CONTRIBUTION_REVISION_STALE": "目標版本已變更,請重新整理並核對內容後重新準備。",
"RELEASE_VERSION_CONFLICT": "此版本不能覆寫既有執行內容,請修改插件版本後再提交。",
- "PLUGIN_GHOST_ID_CONFLICT": "此公開插件 ID 已存在,無法透過上傳套件認領。",
+ "PLUGIN_GHOST_ID_CONFLICT": "這個插件識別碼已被使用。發佈新插件請更換識別碼;更新既有插件請使用原發佈帳號。",
"CONTRIBUTION_OPERATION_NOT_FOUND": "目前帳號無法查看這次提交。",
"PRECONDITION_FAILED": "目前插件無法提交審核。",
"PERSONAL_CONTEXT_REQUIRED": "登入後即可管理你向公開市場提交的插件。",
@@ -7408,7 +7408,6 @@
"releaseNotes": "更新說明",
"versionUpdates": "版本與更新",
"versionManagement": "版本管理",
- "notesMissing": "此版本未提供更新說明",
"versionContent": "版本內容",
"loadMoreVersions": "載入更多版本",
"notSubmitted": "尚未送審",
diff --git a/docs/plugin-community-contribution.md b/docs/plugin-community-contribution.md
index abb318ffca..5d33232597 100644
--- a/docs/plugin-community-contribution.md
+++ b/docs/plugin-community-contribution.md
@@ -5,16 +5,16 @@
插件列表以当前最新主线为基线,原卡片、来源文案、署名布局、统计、推荐分类、筛选与排序保持一致,仅新增“发布插件”按钮。来源继续使用主线的“公开 / 团队共享 / 本地 / 自定义”,不新增“本地开发 / 本地导入”等分类,不用来源推断作者身份或发布状态。个人投稿的展示署名暂由服务端统一返回为空,作者绑定和提审昵称仍完整记录;客户端保留原有展示,不回退包内个人信息。
-作者在独立源码目录开发、安装并使用插件后,可在本地插件使用详情选择“提交审核”;后续版本在“发布插件”的独立管理页选择“提交 {{version}} 审核”,提交完成后留在本页刷新版本和审核状态。
-本地使用详情准备当前包的只读发布摘要,在“版本与更新”中查看;按钮显示“提交 {{version}} 审核”时,点击就是公开发布意图:Host 固定并再核对当前安装内容,
-不弹保存或选文件框,没有资料表单、独立介绍、翻译或第二个确认步骤。只有提交结果已确认后才进入该插件管理详情;提交失败留在原处显示实际原因,用户已离开时不抢回页面。作者继续开发时仍回到源码目录,不直接编辑 Host 的安装目录。
-本地使用详情顶部操作区排列提审按钮、使用动作与启用开关;发布说明、适用的限制原因、
-当前准备阶段和提审限制在版本与更新中查看。普通列表始终进入使用详情,不自动跳入作者管理;发布结果和版本历史集中在“发布插件”独立页面。保留原三列详情头部:
+作者在独立源码目录开发、安装并使用插件后,满足本地基础条件的使用详情提供“发布插件”入口;来源、保留标识、组织范围、安装身份或批准条件不满足时隐藏入口。
+打开普通使用详情不读取提审记录或准备发布包。点击“发布插件”复用发布页的同一个弹窗,并自动选中当前精确安装实例;弹窗内读取版本和提审状态、准备实际包,展示功能说明与存在的更新说明,允许提交后才显示“提交 {{version}} 审核”。后续版本也可沿独立管理页的本地版本区域提交。
+Host 固定并再核对当前安装内容,不弹保存或选文件框,不另加确认弹窗。只有提交结果已确认后才进入该插件管理详情;提交失败留在原处显示实际原因,用户已离开时不抢回页面。作者继续开发时仍回到源码目录,不直接编辑 Host 的安装目录。
+本地使用详情顶部操作区排列发布入口、使用动作与启用开关;发布检查、包准备与不能提交的原因在发布弹窗中展示。
+普通列表始终进入使用详情,不自动跳入作者管理;发布结果和版本历史集中在“发布插件”独立页面。保留原三列详情头部:
宽窗图标与标题在左、操作在右,发布按钮紧随使用动作;详情内容区不足 680px 时整组转到标题下方换行。
右侧按钮较多时允许组内换行,并为标题至少保留 160px;管理页的长名称自然换行,不提供匿名发布开关。
未能查询时显示错误,不以本地版本推断线上结果。
-“发布插件”是插件页常驻入口,页头(含空列表)提供“发布插件”。该按钮只打开当前账号的已安装插件选择,
+“发布插件”是插件页常驻入口,管理页页头提供“发布插件”,空列表提供“去发布”。两个按钮都只打开当前账号的已安装插件选择,
选择框与原详情复用同一份本地条件判断,只列出可信本地精确实例;保留标识、组织/私域、
安装身份未确认或权限未批准的实例不进入选择框。没有可选项时区分未安装与没有可发布实例,
引导安装、使用自己的插件并核对详情。选择后留在当前弹窗,展示所选精确本地安装的实际名称、版本、用途、更新说明与只读预检结果,不创建上传或占用版本;点击“提交 {{version}} 审核”才开始上传。关闭弹窗保留管理列表位置,不提交。
@@ -27,7 +27,7 @@
自动代替原目标。列表支持服务端搜索、筛选与分页,每行以插件为主体,分别列出本地版本、当前上架版本和最近提审;
列表只展示服务端已收到的插件提交,不把未完成上传当作插件记录。上传与提交过程留在原提交按钮中,失败原因也在该次提交时显示。
管理详情默认显示本地、已上架、待审核三份当前事实,以及本地动作、已上架内容和当前提审。
-本地版本可提交时先只读准备该安装的名称、版本、用途、更新说明和预检,显示在本地版本区域;同一个提交按钮只提交这份已展示的固定包,不借用上一提审的说明,也不增加确认弹窗。三处现有摘要共用相同的准备与释放逻辑;普通对话结束不取消已经获准的本次提交,账号、任务实例、权限与安装变化仍会阻止后续写入。
+本地版本可提交时先只读准备该安装的名称、版本、用途、更新说明和预检,显示在本地版本区域;同一个提交按钮只提交这份已展示的固定包,不借用上一提审的说明,也不增加确认弹窗。发布弹窗与管理详情共用相同的准备与释放逻辑;普通对话结束不取消已经获准的本次提交,账号、任务实例、权限与安装变化仍会阻止后续写入。
已上架介绍与更新说明只读取匹配当前市场 releaseId/version 的真实公开版本,不借最新待审内容补齐。
发布记录默认收起,内部版本选择仅切换历史快照;版本号与状态分开显示,共用应用 Select,
单个历史版本不显示无用下拉框。完整退回原因保留,历史选择不改变本地版本、当前提审或提交目标。
diff --git a/packages/cindy-tools/src/ghost/mcpServer.ts b/packages/cindy-tools/src/ghost/mcpServer.ts
index 88aac5c330..56d6176f38 100644
--- a/packages/cindy-tools/src/ghost/mcpServer.ts
+++ b/packages/cindy-tools/src/ghost/mcpServer.ts
@@ -1527,7 +1527,7 @@ export function createCindyGhostsMcpServer(
};
const contributionId = z.string().min(1).max(256);
server.registerTool('ghost_contribution_prepare', {
- description: '为用户自己开发、已安装并使用的确切插件固定临时快照并进行发布预检。此工具只读取原插件,不修改 ghost.json、插件源码或用户文件,不上传、不提审,也不自动补写更新说明。返回 preparedId、包摘要、包内 ghost.json.releaseNotes 和 blockers。首次上架不要求更新说明,插件用途写在 description;曾上架后再提审须用顶层纯文本 releaseNotes 完整覆盖相对上一已上架版本的变化(v2/v3 均支持)。仅更新缺失时按已有 Forge 开发流程修改作者源码,再用 ghost_forge_install 安装更新后重新预检,不改 Host 管理的安装目录。成功受理后的版本号永久占用,预检或未受理的上传失败不占号;同一插件只能有一个待审版本。用户已明确委托公开发布且 blockers 为空时,直接接 ghost_contribution_submit,不要求用户重新授权或手动完成最后一步。首次发布只接受 Host 可核实的本地包或 Forge 开发安装,属于人工审核申请,不代表作者认证。市场下载与可读历史不授予提交权;公共市场更新须有当前服务端精确提交授权和 Host 来源关联,Git/本地自定义市场、私域或来源不明不能转作首发。不能认领同名插件。官方 public 插件不允许经客户端或本工具提审;须通过 GitHub 仓库提交修改,保证仓库源码完整并便于后续维护。',
+ description: '为用户自己开发、已安装并使用的确切插件固定临时快照并进行发布预检。此工具只读取原插件,不修改 ghost.json、插件源码或用户文件,不上传、不提审,也不自动补写更新说明。返回 preparedId、包摘要、包内 ghost.json.releaseNotes 和 blockers。首次上架不要求更新说明,插件用途写在 description;曾上架后再提审须用顶层纯文本 releaseNotes 完整覆盖相对上一已上架版本的变化(v2/v3 均支持)。仅更新缺失时按已有 Forge 开发流程修改作者源码,再用 ghost_forge_install 安装更新后重新预检,不改 Host 管理的安装目录。成功受理后的版本号永久占用,预检或未受理的上传失败不占号;同一插件只能有一个待审版本。用户已明确委托公开发布且 blockers 为空时,直接接 ghost_contribution_submit,不要求用户重新授权或手动完成最后一步。首次发布只接受 Host 可核实的本地包或 Forge 开发安装,属于人工审核申请,不代表作者认证。市场下载与可读历史不授予提交权;公共市场更新须有当前服务端精确提交授权和 Host 来源关联,Git/本地自定义市场、私域或来源不明不能转作首发。冲突按 ghost.json.id 判断,不是显示名称。预检或提交返回 PLUGIN_GHOST_ID_CONFLICT 时停止继续提交:新插件经用户同意才可修改作者源码中的 ID,沿原 Forge 流程重新打包、安装后预检;已有插件更新保留 ID,核对发布账号及 ghost_my_plugins 返回的当前提交权限,无权限就说明并停止,不自动切换账号或换发布入口绕过;无法判断先询问用户,不重复提交相同请求。完整规则见手册 §7.3。官方 public 插件不允许经客户端或本工具提审;须通过 GitHub 仓库提交修改,保证仓库源码完整并便于后续维护。',
inputSchema: z.object({ ghost_id: contributionId, namespace: ghostNamespaceInput }).strict() },
async ({ ghost_id, namespace }) => contribute({ action: 'prepare', ghostId: ghost_id, namespace }));
server.registerTool('ghost_contribution_submit', {