Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(plugins): 修复提审生命周期与版本署名展示
liugaoweid40daa65a626
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/mobilePageService.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/mobilePageService.test.tsindex 2972ebe1ec..c18d677e33 100644--- a/apps/desktop/src/main/cindy-brain/__tests__/mobilePageService.test.ts+++ b/apps/desktop/src/main/cindy-brain/__tests__/mobilePageService.test.ts@@ -556,4 +556,9 @@ it('projects the same installed Details as PC, with factual unsigned trust and nexpect(JSON.stringify(signed)).not.toContain('not-a-display-field');h.ghost.manifest.panel = {html: 'panel.html', position: 'tab'};expect((await read()).find(fact => fact.key === 'panel')?.value).toBe('Panel');+ h.ghost.publishingSource = { kind: 'public-market', pluginId: 'public-practice' };+ expect(toGhostPluginDetail(h.ghost).author).toBeNull();+ expect((await read()).some(fact => fact.key === 'author')).toBe(false);+ h.ghost.publishingSource = { kind: 'local', source: 'manual' };+ expect((await read()).find(fact => fact.key === 'author')?.value).toBe('Cindy');});diff --git a/apps/desktop/src/main/cindy-brain/mobilePageService.ts b/apps/desktop/src/main/cindy-brain/mobilePageService.tsindex 4e359bb964..2045effc8f 100644--- a/apps/desktop/src/main/cindy-brain/mobilePageService.ts+++ b/apps/desktop/src/main/cindy-brain/mobilePageService.ts@@ -16,7 +16,7 @@ import {type RemoteCollectionItem,type PluginConfigurationSummary,} from '@cindy/device-link';-import { ghostContentKeys, ghostInstallApprovalToken, ghostPermissionItems, ghostTrustLabelKey, type GhostSetupAssessment, type InstalledGhost } from '../../shared/ghost.js';+import { ghostContentKeys, ghostFallbackDisplayAuthor, ghostInstallApprovalToken, ghostPermissionItems, ghostTrustLabelKey, type GhostSetupAssessment, type InstalledGhost } from '../../shared/ghost.js';import { getRemoteOauthContext, notifyOauthCardClosed } from '../plugin-oauth/context.js';import type { OauthCardBinding } from '../plugin-oauth/transactions.js';import { installedGhostStoragePart } from '../../shared/pluginIdentity.js';@@ -664,18 +664,19 @@ export class MobilePluginPages {.filter(Boolean).join('\n\n'),}));+ const author = ghostFallbackDisplayAuthor(ghost);const detailFacts = [{key: 'version',title: t('settings.ghosts.detail.infoVersion', locale),value: 'v' + ghost.manifest.version,},- ...(ghost.manifest.author+ ...(author? [{key: 'author',title: t('settings.ghosts.detail.infoAuthor', locale),- value: ghost.manifest.author,+ value: author,},]: []),diff --git a/apps/desktop/src/main/maker-host/index.ts b/apps/desktop/src/main/maker-host/index.tsindex d605c7649b..95e9ce9151 100644--- a/apps/desktop/src/main/maker-host/index.ts+++ b/apps/desktop/src/main/maker-host/index.ts@@ -1102,14 +1102,21 @@ export function getMaker(): Maker {const session = _maker?.getSession(sessionId);if (!session || session.instanceId !== sessionInstanceId) return null;const snapshot = resolveGhostFsSessionSnapshot((id) => _maker?.getSession(id), sessionId, sessionInstanceId);+ const acceptedInput = getSessionInputProvenance(sessionId);+ const accountInput = isActiveInputAccountScoped(sessionId);return {- contributionAccountAllowed: async () => {- if (!isActiveInputAccountScoped(sessionId) || isAppSessionBoundaryPending()) return false;+ contributionAccountAllowed: async (acceptedOperation = false) => {+ const current = () => !isAppSessionBoundaryPending() && _maker?.getSession(sessionId) === session+ && (acceptedOperation ? accountInput : isActiveInputAccountScoped(sessionId));+ if (!current()) return false;const db = getCurrentDbClientSnapshot();if (!db) return false;- const surface = await resolveHelperSurface(db.client, sessionId, getSessionInputProvenance);+ // An authorized upload outlives the input that started it. Keep that+ // input's identity; recheck task, owner, helper surface and permissions.+ const surface = await resolveHelperSurface(db.client, sessionId,+ acceptedOperation ? () => acceptedInput : getSessionInputProvenance);return surface !== 'restricted' && db === getCurrentDbClientSnapshot()- && !isAppSessionBoundaryPending() && isActiveInputAccountScoped(sessionId);+ && current();},permissionMode: session.stablePermissionModeState?.mode ?? null,remoteHostId: session.remoteHostId,diff --git a/apps/desktop/src/main/mcp-integrations/__tests__/ghostWorkdirGate.test.ts b/apps/desktop/src/main/mcp-integrations/__tests__/ghostWorkdirGate.test.tsindex ee45b5005a..f07d1e291b 100644--- a/apps/desktop/src/main/mcp-integrations/__tests__/ghostWorkdirGate.test.ts+++ b/apps/desktop/src/main/mcp-integrations/__tests__/ghostWorkdirGate.test.ts@@ -3463,6 +3463,22 @@ describe('personal contribution account surface', () => {expect(permission).not.toHaveBeenCalled();});+ it('keeps accepted background submission alive after normal input completion but rechecks its scope', async () => {+ let active = true, writable = true, allowed = true;+ liveGrantStateMock.mockReturnValue({ permissionMode: 'bypassPermissions', remoteHostId: null,+ isCurrent: () => writable, contributionAccountAllowed: async (accepted = false) => allowed && (active || accepted) });+ const deps = makeDeps('pi', 'author', 'author-instance');+ await expect(deps.communityContribution!({ action: 'submit', id: 'prepared-1' })).resolves.toMatchObject({ ok: true });+ const check = communitySubmitMock.mock.calls[0][1] as () => Promise<void>;+ active = false;+ await expect(check()).resolves.toBeUndefined();+ await expect(deps.communityContribution!({ action: 'list' })).resolves.toMatchObject({ ok: false, errorCode: 'PERMISSION_DENIED' });+ writable = false;+ await expect(check()).rejects.toThrow('PERMISSION_DENIED');+ writable = true; allowed = false;+ await expect(check()).rejects.toThrow('PERMISSION_DENIED');+ });+it.each(['allow', 'block'] as const)('honors Auto %s for the exact public bytes', async (verdict) => {const permission = vi.fn();const reviewAction = vi.fn<(action: { description: string }) => Promise<{ verdict: typeof verdict; reason: string }>>()diff --git a/apps/desktop/src/main/mcp-integrations/ghost.ts b/apps/desktop/src/main/mcp-integrations/ghost.tsindex b945d663ef..0c547dd4ec 100644--- a/apps/desktop/src/main/mcp-integrations/ghost.ts+++ b/apps/desktop/src/main/mcp-integrations/ghost.ts@@ -463,7 +463,7 @@ async function packForgeSource(export interface GhostGrantLiveSessionState {/** Rechecks accepted account input and the existing plugin-managed helper surface. */- contributionAccountAllowed?: () => Promise<boolean>;+ contributionAccountAllowed?: (acceptedOperation?: boolean) => Promise<boolean>;permissionMode: PermissionMode | null;remoteHostId: string | null;/** Includes the captured permission/Plan generations and forbids active or unknown Plan. */@@ -1772,15 +1772,15 @@ export function getCindyGhostsMcpDeps(const owner = contributionOwnerKey();const live = context?.sessionId && context.sessionInstanceId? hostDeps.getLiveSessionGrantState?.(context.sessionId, context.sessionInstanceId) : null;- const assert = async () => {+ const assert = async (acceptedOperation = false) => {assertContributionOwner(owner);- if (!live || await live.contributionAccountAllowed?.() !== true || (write && (live.isCurrent?.() !== true || !live.permissionMode || workdirWriteVerdict(live.permissionMode, false) === 'deny'))) {+ if (!live || await live.contributionAccountAllowed?.(acceptedOperation) !== true || (write && (live.isCurrent?.() !== true || !live.permissionMode || workdirWriteVerdict(live.permissionMode, false) === 'deny'))) {throwIpcError('PERMISSION_DENIED', 'Community contributions require a current account task; shared-task guests cannot borrow the Host account');}assertContributionOwner(owner);};await assert();- return { context: context!, assert };+ return { context: context!, assert: () => assert(), assertAccepted: () => assert(true) };};return {...(marketTools ? {@@ -1840,7 +1840,7 @@ export function getCindyGhostsMcpDeps(}await authority.assert();if (!allowed) return { ok: false, errorCode: 'MUTATION_CANCELLED' };- result = input.action === 'cancel-review' ? await community.cancelPluginReview(input.pluginId, input.release, authority.assert) : input.action === 'submit' ? await community.submitContribution(input.id, authority.assert) : await community.resumeContribution(input.id, authority.assert);+ result = input.action === 'cancel-review' ? await community.cancelPluginReview(input.pluginId, input.release, authority.assert) : input.action === 'submit' ? await community.submitContribution(input.id, authority.assertAccepted) : await community.resumeContribution(input.id, authority.assertAccepted);} else if (input.action === 'status') result = await community.contributionTransferStatus(input.id);else if (input.action === 'cancel') result = community.cancelContribution(input.id);else if (input.action === 'list') result = await community.listMyPlugins({ query: input.query ?? '', filter: input.filter ?? 'all', cursor: input.cursor });diff --git a/apps/desktop/src/main/plugin-contributions/__tests__/prepared.test.ts b/apps/desktop/src/main/plugin-contributions/__tests__/prepared.test.tsindex 1cef6e3a18..7da7195048 100644--- a/apps/desktop/src/main/plugin-contributions/__tests__/prepared.test.ts+++ b/apps/desktop/src/main/plugin-contributions/__tests__/prepared.test.ts@@ -163,3 +163,19 @@ it('gives concurrent preview callers independent ownership', async () => {await prepared.releasePreparedContribution(first.preparedId);expect(prepared.getPreparedContribution(second.preparedId).summary).toEqual(second);});++it('keeps operation-owned packages without consuming the eight preview slots', async () => {+ const ids: string[] = [];+ try {+ for (let i = 0; i < 8; i++) {+ const summary = await prepared.prepareInstalledContribution('hello');+ ids.push(summary.preparedId);+ prepared.getPreparedContribution(summary.preparedId).pinned = true;+ }+ for (let i = 0; i < 8; i++) ids.push((await prepared.prepareInstalledContribution('hello')).preparedId);+ await expect(prepared.prepareInstalledContribution('hello')).rejects.toThrow('Too many prepared contributions');+ await expect(fsp.access(prepared.getPreparedContribution(ids[0]).filePath)).resolves.toBeUndefined();+ } finally {+ await Promise.all(ids.map(id => prepared.releasePreparedContribution(id)));+ }+});diff --git a/apps/desktop/src/main/plugin-contributions/prepared.ts b/apps/desktop/src/main/plugin-contributions/prepared.tsindex 66191e4608..90353ebd4c 100644--- a/apps/desktop/src/main/plugin-contributions/prepared.ts+++ b/apps/desktop/src/main/plugin-contributions/prepared.ts@@ -115,7 +115,7 @@ async function prepare(): Promise<PreparedPluginContribution> {await prune();assertContributionOwner(owner);- if ([...entries.values()].filter((entry) => entry.owner === owner).length >= 8)+ if ([...entries.values()].filter((entry) => entry.owner === owner && !entry.pinned).length >= 8)throwIpcError('PRECONDITION_FAILED', 'Too many prepared contributions');const manager = getGhostManager();const { ghost, source } = readContributionInstallation(instanceId, expected);diff --git a/apps/desktop/src/main/plugin-market/__tests__/service.test.ts b/apps/desktop/src/main/plugin-market/__tests__/service.test.tsindex 48cb8e472c..5905f7f465 100644--- a/apps/desktop/src/main/plugin-market/__tests__/service.test.ts+++ b/apps/desktop/src/main/plugin-market/__tests__/service.test.ts@@ -602,10 +602,16 @@ describe('workflow display author projection', () => {if (state === 'missing') runtime.approvedInstallEvidence.mockReturnValue(null);if (state === 'mismatch') h.evidence.packageSha256 = 'c'.repeat(64);h.item.displayAuthor = 'Current name';+ const installedRelease = h.item.currentRelease;h.item.currentRelease = { ...h.item.currentRelease, id: 'release-2', version: '2.0.0', sha256: 'b'.repeat(64) };const item = (await h.service.snapshot({ discoveryOnly: true })).items[0];expect(item.installState).toBe('update-available');- expect(item.installedAuthor).toBe(state === 'verified' ? 'Current name' : undefined);+ expect(item.author).toBe('Current name');+ expect(item.installedAuthor).toBe(state === 'verified' ? null : undefined);+ if (state === 'verified') {+ h.item.currentRelease = installedRelease;+ expect((await h.service.snapshot({ discoveryOnly: true })).items[0].installedAuthor).toBe('Current name');+ }});it.each([{ displayAuthor: '名'.repeat(100), expected: '名'.repeat(100) },diff --git a/apps/desktop/src/main/plugin-market/service.ts b/apps/desktop/src/main/plugin-market/service.tsindex ed413339d5..139d3cc6fe 100644--- a/apps/desktop/src/main/plugin-market/service.ts+++ b/apps/desktop/src/main/plugin-market/service.ts@@ -2656,7 +2656,8 @@ export class PluginMarketService {author,...(plugin.scope === 'public' && plugin.publisherKind !== undefined ? { publisherKind: plugin.publisherKind } : {}),...(evidence?.packageSha256 && evidence.packageSha256 === record?.sha256- ? { installedAuthor: author }+ ? { installedAuthor: record.releaseId === plugin.currentRelease.id+ && record.sha256 === plugin.currentRelease.sha256 ? author : null }: {}),scope: plugin.scope,organizationId: plugin.organizationId,diff --git a/apps/desktop/src/renderer/features/plugin/MyPluginsPage.tsx b/apps/desktop/src/renderer/features/plugin/MyPluginsPage.tsxindex a9a1d86493..d8ce633ad3 100644--- a/apps/desktop/src/renderer/features/plugin/MyPluginsPage.tsx+++ b/apps/desktop/src/renderer/features/plugin/MyPluginsPage.tsx@@ -116,6 +116,10 @@ export function MyPluginsPage({const [pickerDraft, setPickerDraft] = useState<{key: string; prepared?: PreparedPluginContribution; error?: string;} | null>(null);+ const [updateDraft, setUpdateDraft] = useState<{+ token: object; prepared?: PreparedPluginContribution; error?: string;+ } | null>(null);+ const [updateRefresh, setUpdateRefresh] = useState(0);const preparePicker = useRef(onPrepare ?? reader.prepare);preparePicker.current = onPrepare ?? reader.prepare;const [accountSwitcherOpen, setAccountSwitcherOpen] = useState(false);@@ -907,9 +911,45 @@ export function MyPluginsPage({? 'PLUGIN_PENDING_RELEASE_EXISTS': releases.some(release => release.version === installedLocal.version) ? 'VERSION_ALREADY_SUBMITTED' : null);- const localCanSubmit = installedLocal && localPlugins.some(item => item.id === installedLocal.instanceId);+ const localCanSubmit = installedLocal && localPlugins.some(item => item.id === installedLocal.instanceId && item.version === installedLocal.version);const updateUnavailable = plugin?.publisherKind === 'official' ? t(`${copy}.unavailable.officialGithubRequired`): knownPublishBlocker ? t(`${copy}.errors.${knownPublishBlocker}`) : undefined;+ const canPrepareUpdate = Boolean(installedLocal && localCanSubmit && plugin?.actions.submitUpdate && writeReady && !updateUnavailable);+ const updateInstanceId = installedLocal?.instanceId;+ const updateVersion = installedLocal?.version;+ const updateKey = JSON.stringify([ownerKey, location.key, selectedId, installedRevision, submissionRevision,+ installedLocal?.instanceId, installedLocal?.version, canPrepareUpdate, updateRefresh]);+ const updateContext = useRef({ key: updateKey, token: {} });+ if (updateContext.current.key !== updateKey) updateContext.current = { key: updateKey, token: {} };+ const currentUpdateDraft = updateDraft?.token === updateContext.current.token ? updateDraft : null;+ const updateBlocker = currentUpdateDraft?.prepared?.preflight?.blockers[0];+ useEffect(() => {+ if (!canPrepareUpdate || !updateInstanceId || !updateVersion) return;+ let disposed = false;+ let held: string | undefined;+ const token = updateContext.current.token;+ const instanceId = updateInstanceId, version = updateVersion;+ void Promise.resolve().then(() => preparePicker.current(instanceId)).then(prepared => {+ held = prepared.preparedId;+ if (disposed || updateContext.current.token !== token) {+ void reader.discard(prepared.preparedId).catch(() => undefined);+ return;+ }+ if (prepared.instanceId !== instanceId || prepared.version !== version) {+ void reader.discard(prepared.preparedId).catch(() => undefined);+ held = undefined;+ setUpdateDraft({ token, error: `${copy}.errors.CONTRIBUTION_PACKAGE_CHANGED` });+ } else setUpdateDraft({ token, prepared });+ }).catch(error => {+ if (!disposed && updateContext.current.token === token)+ setUpdateDraft({ token, error: contributionErrorKey(error) });+ });+ return () => {+ disposed = true;+ if (held) void reader.discard(held).catch(() => undefined);+ };+ // The key captures the exact installation and permission generation, not the response object.+ }, [updateKey, canPrepareUpdate, updateInstanceId, updateVersion, reader]);const published = publishedContent?.key === publishedKey ? publishedContent : null;const listedDetail = plugin?.market.state === 'available' ? published?.value : null;const currentNotes = currentSubmission?.content?.manifestView.releaseNotes;@@ -925,9 +965,19 @@ export function MyPluginsPage({</p></div><div className="flex flex-wrap items-center gap-2">- {installedLocal && localCanSubmit && plugin.actions.submitUpdate && writeReady && !updateUnavailable ? (+ {installedLocal && canPrepareUpdate && currentUpdateDraft?.prepared?.preflight?.actions.canSubmit && !updateBlocker ? (<Button variant="cta" size="sm" loading={submitBusy} disabled={submitBusy}- onClick={() => void onSubmitUpdate(installedLocal.instanceId)}>{t(`${copy}.submitVersion`, { version: installedLocal.version })}</Button>+ onClick={() => {+ const token = updateContext.current.token;+ void onSubmitUpdate(installedLocal.instanceId, {+ prepared: currentUpdateDraft.prepared,+ isCurrent: () => mounted.current && updateContext.current.token === token,+ }).catch(error => {+ if (mounted.current && updateContext.current.token === token) setFailure(contributionErrorKey(error));+ }).finally(() => {+ if (mounted.current && updateContext.current.token === token) setUpdateRefresh(value => value + 1);+ });+ }}>{t(`${copy}.submitVersion`, { version: installedLocal.version })}</Button>) : null}{localInstallation?.state === 'missing' && plugin.market.state === 'available' && onInstallPublished && writeReady ? (<Button variant="secondary" size="sm" loading={installBusy} disabled={installBusy}@@ -946,6 +996,13 @@ export function MyPluginsPage({</div></div>{updateUnavailable && (installedLocal || plugin.publisherKind === 'official') ? <p role="status" className="text-12 leading-5 text-[var(--text-tertiary)]">{updateUnavailable}</p> : null}+ {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}+ </> : <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"><h2 className="text-16 font-medium leading-6 text-[var(--text-primary)]">diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/MyPluginsPage.test.tsx b/apps/desktop/src/renderer/features/plugin/__tests__/MyPluginsPage.test.tsxindex 436380a11f..6758c412b7 100644--- a/apps/desktop/src/renderer/features/plugin/__tests__/MyPluginsPage.test.tsx+++ b/apps/desktop/src/renderer/features/plugin/__tests__/MyPluginsPage.test.tsx@@ -100,7 +100,7 @@ function reader(transfers: ContributionTransferView[] = []): PluginContributionsreturn {reviewUpdates: vi.fn().mockResolvedValue([]),markReviewRead: vi.fn(),- prepare: vi.fn(),+ prepare: vi.fn(async (instanceId: string) => packagePreview(instanceId, '1.2.0')),submit: vi.fn(),resume: vi.fn(),cancel: vi.fn(),@@ -160,22 +160,49 @@ beforeEach(() => {auth.owner = 'A';auth.generation = 1;});-afterEach(cleanup);+afterEach(() => { cleanup(); vi.restoreAllMocks(); });describe('My Plugins facts', () => {+ it('shows the actual new package notes before submitting the same prepared package', async () => {+ const api = reader();+ const preview = { ...packagePreview('exact-instance', '1.2.0'), releaseNotes: 'Not yet submitted: new package changes' };+ vi.mocked(api.prepare).mockResolvedValue(preview);+ const submit = vi.fn().mockResolvedValue(false);+ view(api, true, {}, [{ id: 'exact-instance', name: 'Local Plugin', version: '1.2.0' } as GhostPluginListItem], submit);+ const local = await screen.findByRole('region', { name: `${prefix}.localVersion` });+ await within(local).findByText(preview.releaseNotes);+ expect(within(local).queryByText('New version changes')).toBeNull();+ expect(api.submit).not.toHaveBeenCalled();+ fireEvent.click(await within(local).findByRole('button', { name: `${prefix}.submitVersion 1.2.0` }));+ expect(submit).toHaveBeenCalledExactlyOnceWith('exact-instance', { prepared: preview, isCurrent: expect.any(Function) });+ });++ it('shows the new package preflight blocker without a submission button', async () => {+ const api = reader();+ const preview = packagePreview('exact-instance', '1.2.0');+ vi.mocked(api.prepare).mockResolvedValue({ ...preview, preflight: { ...preview.preflight!,+ 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.');+ expect(within(local).queryByRole('button', { name: `${prefix}.submitVersion 1.2.0` })).toBeNull();+ expect(api.submit).not.toHaveBeenCalled();+ });+it('opens an independent management page with immediately visible versions and publishing controls', async () => {const api = reader();view(api);await waitForManagement();expect(screen.getByLabelText(`${prefix}.versionFacts`).closest('details')).toBeNull();- expect(screen.getByRole('button', { name: `${prefix}.submitVersion 1.2.0` })).toBeTruthy();+ expect(await screen.findByRole('button', { name: `${prefix}.submitVersion 1.2.0` })).toBeTruthy();expect(screen.getByText('New version changes')).toBeTruthy();expect(screen.queryByText(`${prefix}.versionUpdates`)).toBeNull();expect(screen.queryByRole('switch', { name: 'settings.ghosts.enableAria' })).toBeNull();- expect(api.prepare).not.toHaveBeenCalled();+ expect(api.prepare).toHaveBeenCalledWith('exact-instance');+ expect(api.submit).not.toHaveBeenCalled();});- it('shows the running version in the developer list and opens management without preparing a package', async () => {+ it('shows the running version in the developer list and opens management with a read-only package preview', async () => {const api = reader();view(api, false);const row = await screen.findByRole('button', { name: /My Plugin/ });@@ -184,8 +211,8 @@ describe('My Plugins facts', () => {fireEvent.click(row);await waitForManagement();expect(within(screen.getByLabelText(`${prefix}.versionFacts`)).getByText('1.2.0')).toBeTruthy();- expect(screen.getByRole('button', { name: `${prefix}.submitVersion 1.2.0` })).toBeTruthy();- expect(api.prepare).not.toHaveBeenCalled();+ expect(await screen.findByRole('button', { name: `${prefix}.submitVersion 1.2.0` })).toBeTruthy();+ expect(api.prepare).toHaveBeenCalledWith('exact-instance');expect(api.submit).not.toHaveBeenCalled();fireEvent.click(screen.getByRole('button', { name: `${prefix}.myPlugins` }));expect(await screen.findByRole('button', { name: /My Plugin/ })).toBeTruthy();@@ -501,7 +528,7 @@ describe('My Plugins facts', () => {expect(screen.getByText('Full reason, line one Full reason, line two')).toBeTruthy();expect(screen.queryByRole('button', { name: `${prefix}.viewMarket` })).toBeNull();expect(screen.queryByRole('button', { name: `${prefix}.openLocal` })).toBeNull();- expect(screen.getByRole('button', { name: `${prefix}.submitVersion 1.2.0` })).toBeTruthy();+ expect(await screen.findByRole('button', { name: `${prefix}.submitVersion 1.2.0` })).toBeTruthy();const history = screen.getByText(`${prefix}.history`).closest('details')!;expect(history.open).toBe(false);await openHistory();@@ -522,6 +549,7 @@ describe('My Plugins facts', () => {let finish!: (value: MyPluginDetailView) => void;vi.mocked(api.detail).mockReturnValue(new Promise(resolve => { finish = resolve; }));const reads = vi.mocked(api.detail).mock.calls.length;+ vi.mocked(api.prepare).mockClear();rendered.rerender(element('replacement-package'));expect(screen.queryByRole('button', { name: `${prefix}.submitVersion 1.2.0` })?.hasAttribute('disabled') ?? true).toBe(true);await waitFor(() => expect(vi.mocked(api.detail).mock.calls.length).toBeGreaterThan(reads));@@ -982,7 +1010,6 @@ describe('review result indicators in My Plugins', () => {const count = reviews.markRead.mock.calls.length;await act(async () => {});expect(reviews.markRead.mock.calls.length).toBe(count);- vi.restoreAllMocks();});it('does not clear an older unread decision when viewing a newer pending version; opens its exact paginated version', async () => {vi.spyOn(document, 'visibilityState', 'get').mockReturnValue('visible');@@ -1007,7 +1034,6 @@ describe('review result indicators in My Plugins', () => {expect(within(facts).getByText('1.2.0')).toBeTruthy();expect(within(facts).getByText('2.0.0')).toBeTruthy(); // Still the real pending version after opening old approval.expect(within(facts).getByText('1.0.0')).toBeTruthy();- vi.restoreAllMocks();});});diff --git a/apps/desktop/src/renderer/features/plugin/lib/__tests__/ghostPluginViewModel.author.test.ts b/apps/desktop/src/renderer/features/plugin/lib/__tests__/ghostPluginViewModel.author.test.tsindex d70cbe1c8e..9f9ec57569 100644--- a/apps/desktop/src/renderer/features/plugin/lib/__tests__/ghostPluginViewModel.author.test.ts+++ b/apps/desktop/src/renderer/features/plugin/lib/__tests__/ghostPluginViewModel.author.test.ts@@ -25,8 +25,12 @@ describe('workflow-owned author presentation', () => {expect(toGhostPluginDetail(organization).author).toBe('Package claim');expect(toGhostPluginDetail({ ...organization, manifest: { ...installed.manifest, author: undefined } }).author).toBeNull();});- it('does not display a local package author when verified market attribution is absent', () => {- expect(toGhostPluginDetail(installed).author).toBeNull();+ it('does not display a public package author when verified market attribution is absent', () => {+ expect(toGhostPluginDetail({ ...installed, publishingSource: { kind: 'public-market', pluginId: 'public-1' } }).author).toBeNull();+ });+ it('preserves package attribution for local and legacy installations', () => {+ expect(toGhostPluginDetail(installed).author).toBe('Package claim');+ expect(toGhostPluginDetail({ ...installed, publishingSource: { kind: 'local', source: 'manual' } }).author).toBe('Package claim');});it('uses the market attribution and does not fall back when it is explicitly missing', () => {const presentation = { name: 'Example', description: '', iconDataUrl: undefined, author: 'Verified account' };diff --git a/apps/desktop/src/renderer/features/plugin/lib/ghostPluginViewModel.ts b/apps/desktop/src/renderer/features/plugin/lib/ghostPluginViewModel.tsindex 397b04e6e3..21889d4767 100644--- a/apps/desktop/src/renderer/features/plugin/lib/ghostPluginViewModel.ts+++ b/apps/desktop/src/renderer/features/plugin/lib/ghostPluginViewModel.ts@@ -8,6 +8,7 @@import {ghostContentKeys,+ ghostFallbackDisplayAuthor,ghostPermissionItems,type GhostInstallApproval,type GhostPermissionItem,@@ -325,8 +326,7 @@ export function toGhostPluginDetail(...listItem,trust: listItem.trust!,releaseNotes: manifest.releaseNotes,- author: presentation ? presentation.author- : typeof ghost.namespace === 'string' ? manifest.author ?? null : null,+ author: presentation ? presentation.author : ghostFallbackDisplayAuthor(ghost),contents: ghostContentKeys(manifest),permissions: ghostPermissionItems(manifest),tools: manifest.tools ?? [],diff --git a/apps/desktop/src/shared/ghost.ts b/apps/desktop/src/shared/ghost.tsindex 8edf8fc7ca..09accf2a4b 100644--- a/apps/desktop/src/shared/ghost.ts+++ b/apps/desktop/src/shared/ghost.ts@@ -1642,6 +1642,11 @@ export function isGhostInstallApprovalToken(value: unknown): value is string {);}+/** Public attribution requires a server projection; other installs retain their package attribution. */+export function ghostFallbackDisplayAuthor(ghost: Pick<InstalledGhost, 'manifest' | 'publishingSource'>): string | null {+ return ghost.publishingSource?.kind === 'public-market' ? null : ghost.manifest.author ?? null;+}+/** 已装入主机的插件(批准清单 + 安装位置 + 启用态)。 */export interface InstalledGhost {/** Read-only Host provenance, not authorship or publication permission. Missing is unknown. */diff --git a/docs/plugin-community-contribution.md b/docs/plugin-community-contribution.mdindex 0fd604dd2f..954b7cb002 100644--- a/docs/plugin-community-contribution.md+++ b/docs/plugin-community-contribution.md@@ -26,6 +26,7 @@自动代替原目标。列表支持服务端搜索、筛选与分页,每行以插件为主体,分别列出本地版本、当前上架版本和最近提审;列表只展示服务端已收到的插件提交,不把未完成上传当作插件记录。上传与提交过程留在原提交按钮中,失败原因也在该次提交时显示。管理详情默认显示本地、已上架、待审核三份当前事实,以及本地动作、已上架内容和当前提审。+本地版本可提交时先只读准备该安装的名称、版本、用途、更新说明和预检,显示在本地版本区域;同一个提交按钮只提交这份已展示的固定包,不借用上一提审的说明,也不增加确认弹窗。受管预览与后台操作持有的包分开计算名额;普通对话结束不取消已经获准的后台提交,账号、任务实例、权限与安装变化仍会阻止后续写入。已上架介绍与更新说明只读取匹配当前市场 releaseId/version 的真实公开版本,不借最新待审内容补齐。发布记录默认收起,内部版本选择仅切换历史快照;版本号与状态分开显示,共用应用 Select,单个历史版本不显示无用下拉框。完整退回原因保留,历史选择不改变本地版本、当前提审或提交目标。@@ -83,6 +84,7 @@本地版本、已上架版本、当前提审是独立事实。提审、审核通过和页面读取都不改变安装来源,不自动安装或替换包。同一账号仍按现有 namespace + id 去重,不支持同身份的本地版与公开版并装;名称相同而 ID 不同的插件不合并。发布权限与匿名修改权限继续由服务端分别判定,不能从本地安装推断。+已安装旧版本无法取得可信的提审昵称时隐藏署名,不用当前市场新版昵称补齐;本地、组织和旧安装仍按原包内署名规则展示。桌面与远程详情共用公开来源的署名回退限制。## 基础数据