Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
merge upstream/main:插件页改版与自定义市场源(#1176)合流
Chris65ff4ab4fd06
diff --cc apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsxindex 8e6ee3c905,354831c94e..c4f9413d9f--- a/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx+++ b/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx@@@ -6,29 -6,9 +6,30 @@@* [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md*/-import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';+import {+ useCallback,+ useEffect,+ useMemo,+ useRef,+ useState,+ useSyncExternalStore,+ type KeyboardEvent,+ type ReactNode,+} from 'react';import { useNavigate, useSearchParams } from 'react-router-dom';-import { ChevronDown, ChevronRight, ChevronUp, Plus, Sparkles, Store, Upload } from 'lucide-react';+import {+ ArrowUp,+ Bot,+ Check,+ ChevronDown,+ ChevronRight,+ MessageCircle,+ Plus,+ SlidersHorizontal,+ Sparkles,++ Store,+ Upload,+} from 'lucide-react';import { useTranslation } from 'react-i18next';import { WINDOW_NO_DRAG_STYLE } from '@/components/layout/windowDrag';@@@ -101,10 -72,13 +102,11 @@@ import { GhostPluginIcon } from './Ghosimport { MarketPluginDetailView } from './MarketPluginDetailView';import { PluginScopePicker, usePluginRecentWorkdirs } from './PluginScopePicker';import {- orderPluginCatalogItems,pluginPresentationOrigin,pluginUpdateForInstalledVersion,- type PluginCatalogPresentationItem,type PluginPresentationOrigin,} from './lib/pluginMarketPresentation';+ import { AddMarketplaceDialog } from './AddMarketplaceDialog';import { pluginMarketErrorKey } from './lib/pluginMarketErrorKey';import { usePluginIconRefresh } from './lib/usePluginIconRefresh';import { usePluginMarketForegroundRefresh } from './lib/usePluginMarketForegroundRefresh';@@@ -125,19 -99,10 +127,20 @@@ const RECOMMENDED_FILTERS: readonly Plu'all','public','organization',- 'local',+ 'custom',];+/** 「忽略本轮更新」的持久键(值 = updateRoundKey,版本集合变化后横幅自动回归)。 */+const IGNORED_UPDATE_ROUND_KEY = 'cindy.pluginUpdates.ignoredRound';++function readIgnoredRound(): string {+ try {+ return window.localStorage.getItem(IGNORED_UPDATE_ROUND_KEY) ?? '';+ } catch {+ return '';+ }+}+/*** Ghost-backed Plugin page.*@@@ -384,15 -356,29 +393,22 @@@ export function GhostPluginPage().includes(normalizedQuery);});}, [marketItems, query, showEnterprise]);- const originFilters = useMemo(+ const recommendedFilters = useMemo(() =>- showEnterprise- ? RECOMMENDED_FILTERS- : RECOMMENDED_FILTERS.filter((filter) => filter !== 'organization'),- [showEnterprise],- PRESENTATION_FILTERS.filter((filter) => {++ RECOMMENDED_FILTERS.filter((filter) => {+ if (filter === 'organization') return showEnterprise;- // 未添加任何自定义市场时不显示"自定义"tab(与组织 tab 的隐藏模式一致)。++ // 未添加任何自定义市场时不显示"自定义"档(与组织档的隐藏模式一致)。+ if (filter === 'custom') return customSourceNames.length > 0;+ return true;+ }),+ [customSourceNames.length, showEnterprise],);const effectiveOriginFilter =- !showEnterprise && originFilter === 'organization' ? 'all' : originFilter;+ !showEnterprise && originFilter === 'organization'+ ? 'all'+ : originFilter === 'custom' && customSourceNames.length === 0+ ? 'all'+ : originFilter;- const items = useMemo(- () =>- effectiveOriginFilter === 'all'- ? searchedInstalledItems- : searchedInstalledItems.filter((item) => item.origin === effectiveOriginFilter),- [effectiveOriginFilter, searchedInstalledItems],- );const availableMarketItems = useMemo(() =>effectiveOriginFilter === 'all'@@@ -402,12 -388,44 +418,35 @@@),[effectiveOriginFilter, searchedAvailableMarketItems],);- const catalogItems = useMemo(- () => orderPluginCatalogItems(marketItems, items, availableMarketItems),- [availableMarketItems, items, marketItems],- );- // "自定义" tab 内按来源市场分组(≥2 个源时展示小标题);组顺序沿用市场添加顺序。++ // 「自定义」档内按来源市场分组(≥2 个源时展示小标题);组顺序沿用市场添加顺序。+ const customGroups = useMemo(() => {+ if (effectiveOriginFilter !== 'custom') return null;- const groups = new Map<string, typeof catalogItems>();- for (const catalogItem of catalogItems) {- const marketName =- catalogItem.kind === 'market'- ? catalogItem.item.sourceMarketName- : (marketByGhostId.get(catalogItem.item.id)?.sourceMarketName ?? null);- const key = marketName ?? '';++ const groups = new Map<string, PluginMarketItem[]>();++ for (const item of availableMarketItems) {++ const key = item.sourceMarketName ?? '';+ const list = groups.get(key);+ if (list) {- list.push(catalogItem);++ list.push(item);+ } else {- groups.set(key, [catalogItem]);++ groups.set(key, [item]);+ }+ }+ return [...groups.entries()].sort((a, b) => {+ const aIndex = customSourceNames.indexOf(a[0]);+ const bIndex = customSourceNames.indexOf(b[0]);+ return (+ (aIndex === -1 ? Number.MAX_SAFE_INTEGER : aIndex) -+ (bIndex === -1 ? Number.MAX_SAFE_INTEGER : bIndex)+ );+ });- }, [catalogItems, customSourceNames, effectiveOriginFilter, marketByGhostId]);- const originCounts = useMemo(() => {++ }, [availableMarketItems, customSourceNames, effectiveOriginFilter]);+ const recommendedCounts = useMemo(() => {const counts: Record<PluginPresentationOrigin, number> = {public: 0,organization: 0,local: 0,+ custom: 0,};- for (const item of searchedInstalledItems) counts[item.origin] += 1;for (const item of searchedAvailableMarketItems) {counts[pluginPresentationOrigin(item)] += 1;}@@@ -622,117 -563,6 +662,118 @@@await pickAndUpdateGhost(selectedDetail.id, { t, confirm, confirmWithCheckbox });}, [confirm, confirmWithCheckbox, handleMarketUpdate, selectedDetail, selectedMarketUpdate, t]);+ const handleUpdateFromFile = useCallback(async () => {+ if (!selectedDetail) return;+ await pickAndUpdateGhost(selectedDetail.id, { t, confirm, confirmWithCheckbox });+ }, [confirm, confirmWithCheckbox, selectedDetail, t]);++ const patchUpdateRow = useCallback((pluginId: string, patch: Partial<UpdateAllRow>) => {+ updateRowsRef.current = updateRow(updateRowsRef.current, pluginId, patch);+ setUpdateRows(updateRowsRef.current);+ }, []);+ const maybeFinishBatch = useCallback(() => {+ const rows = updateRowsRef.current;+ if (rows.length === 0 || !isBatchFinished(rows) || finishToastShownRef.current) return;+ finishToastShownRef.current = true;+ const summary = batchSummary(rows);+ toast.success(+ t('settings.ghosts.updateAll.doneToast', {+ done: summary.done,+ rest: summary.skipped + summary.failed,+ }),+ );+ }, [t]);+ /** 批量更新 runner:串行走「取详情 → 权限 diff → 无扩权直接装 / 有扩权停待确认」。 */+ const runBatchQueue = useCallback(async () => {+ if (batchRunningRef.current) return;+ batchRunningRef.current = true;+ setBatchRunning(true);+ try {+ for (;;) {+ const next = updateRowsRef.current.find((row) => row.status === 'pending');+ if (!next) break;+ patchUpdateRow(next.pluginId, { status: 'installing' });+ try {+ const detail = await window.electronAPI.pluginMarket.detail(next.pluginId);+ const installedManifest = ghostsRef.current.find(+ (ghost) => ghost.manifest.id === next.ghostId,+ )?.manifest;+ const diff = diffGhostPermissionItems(+ installedManifest ?? detail.manifest,+ detail.manifest,+ );+ if (diff.added.length > 0) {+ // 扩权不自动放行:停在待确认,由用户在弹窗里逐项同意或跳过。+ patchUpdateRow(next.pluginId, {+ status: 'needs-confirm',+ releaseId: detail.releaseId,+ permissionDiff: diff,+ });+ continue;+ }+ await window.electronAPI.pluginMarket.install(next.pluginId, {+ expectedReleaseId: detail.releaseId,++ ...(detail.sourceType !== 'server' ? { expectedManifest: detail.manifest } : {}),+ });+ patchUpdateRow(next.pluginId, { status: 'done' });+ } catch (error) {+ patchUpdateRow(next.pluginId, {+ status: 'failed',+ errorText: t(pluginMarketErrorKey(error)),+ });+ }+ }+ } finally {+ batchRunningRef.current = false;+ setBatchRunning(false);+ await refreshMarket();+ maybeFinishBatch();+ }+ }, [maybeFinishBatch, patchUpdateRow, refreshMarket, t]);+ const handleUpdateAll = useCallback(() => {+ if (batchRunningRef.current) {+ setUpdateDialogOpen(true);+ return;+ }+ const installedVersionById = new Map(+ ghostsRef.current.map((ghost) => [ghost.manifest.id, ghost.manifest.version]),+ );+ updateRowsRef.current = buildUpdateAllRows(+ updatableInstalledItems.flatMap((item) => (item.marketUpdate ? [item.marketUpdate] : [])),+ installedVersionById,+ );+ finishToastShownRef.current = false;+ setUpdateRows(updateRowsRef.current);+ setUpdateDialogOpen(true);+ void runBatchQueue();+ }, [runBatchQueue, updatableInstalledItems]);+ const handleApproveExpansion = useCallback(+ async (pluginId: string) => {+ const row = updateRowsRef.current.find((candidate) => candidate.pluginId === pluginId);+ if (!row?.releaseId) return;+ patchUpdateRow(pluginId, { status: 'installing' });+ try {+ await window.electronAPI.pluginMarket.install(pluginId, {+ expectedReleaseId: row.releaseId,+ allowPermissionExpansion: true,+ });+ patchUpdateRow(pluginId, { status: 'done' });+ } catch (error) {+ patchUpdateRow(pluginId, { status: 'failed', errorText: t(pluginMarketErrorKey(error)) });+ }+ await refreshMarket();+ maybeFinishBatch();+ },+ [maybeFinishBatch, patchUpdateRow, refreshMarket, t],+ );+ const handleSkipExpansion = useCallback(+ (pluginId: string) => {+ patchUpdateRow(pluginId, { status: 'skipped' });+ maybeFinishBatch();+ },+ [maybeFinishBatch, patchUpdateRow],+ );+const handleInstall = useCallback(async () => {const picked = await window.electronAPI.ghosts.pickFile().catch(() => null);if (!picked || 'canceled' in picked) return;@@@ -1312,102 -1159,13 +1350,138 @@@</div>) : null}</section>- </PluginManagementPage>- </main>++ {availableMarketItems.length > 0 ||+ searchedAvailableMarketItems.length > 0 ||+ marketSnapshot?.unavailableReason ? (+ <section className="plugin-motion-page-section mt-10 min-w-0">+ <div className={PLUGIN_CATALOG_TOOLBAR_CLASS}>+ {/* 推荐区标题不带数字(设计定稿):数量感由卡片自身传达。 */}+ <h2 className="shrink-0 whitespace-nowrap text-20 font-medium text-[var(--text-primary)]">+ {t('settings.ghosts.page.recommendedSection')}+ </h2>+ <div+ className="plugin-catalog-filters flex min-w-0 max-w-full items-center gap-1 overflow-x-auto"+ role="group"+ aria-label={t('settings.ghosts.page.filtersAria')}+ style={WINDOW_NO_DRAG_STYLE}+ >+ {recommendedFilters.map((filter) => {+ const selected = effectiveOriginFilter === filter;+ const count =+ filter === 'all'+ ? searchedAvailableMarketItems.length+ : recommendedCounts[filter];+ return (+ <button+ key={filter}+ type="button"+ aria-pressed={selected}+ onClick={() => setOriginFilter(filter)}+ className={cn(+ 'shrink-0 select-none rounded-full px-3.5 py-2 text-12 transition-colors duration-150',+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',+ selected+ ? 'bg-[var(--surface-chip)] text-[var(--text-primary)]'+ : 'text-[var(--text-secondary)] hover:bg-[var(--surface-hover-soft)] hover:text-[var(--text-primary)]',+ )}+ >+ {filter === 'all'+ ? t('settings.ghosts.page.filterAll')+ : t(`settings.ghosts.page.origin.${filter}`)}+ <span className="ml-1.5 tabular-nums text-[var(--text-tertiary)]">+ {count}+ </span>+ </button>+ );+ })}+ </div>+ </div>++ {marketSnapshot?.unavailableReason ? (+ <p className="mb-4 rounded-xl border border-[var(--border-default)] bg-[var(--surface-chip)] px-4 py-3 text-12 text-[var(--text-secondary)]">+ {t(+ marketSnapshot.unavailableReason === 'authentication-required'+ ? 'settings.ghosts.market.authenticationRequired'+ : marketSnapshot.unavailableReason === 'not-configured'+ ? 'settings.ghosts.market.notConfigured'+ : 'settings.ghosts.market.unavailable',+ )}+ </p>+ ) : null}++ {availableMarketItems.length > 0 ? (- <div className={cn('plugin-motion-stagger', PLUGIN_MANAGEMENT_CARD_GRID_CLASS)}>- {availableMarketItems.map((item) => (- <MarketPluginCard- key={item.pluginId}- item={item}- busy={marketBusyId !== null}- onSelect={() => void handleSelectMarket(item.pluginId)}- onInstall={() => void handleInstallMarketItem(item.pluginId)}- onIconLoadError={handleMarketIconLoadError}- />- ))}- </div>++ customGroups && customGroups.length > 1 ? (++ <div className="flex flex-col gap-6">++ {customGroups.map(([marketName, groupItems]) => (++ <section key={marketName || 'unknown-source'}>++ <header className="mb-3 flex items-baseline gap-2">++ <h3 className="text-14 font-medium text-[var(--text-primary)]">++ {marketName || t('settings.ghosts.page.origin.custom')}++ </h3>++ <span className="text-12 tabular-nums text-[var(--text-tertiary)]">++ {groupItems.length}++ </span>++ </header>++ <div++ className={cn('plugin-motion-stagger', PLUGIN_MANAGEMENT_CARD_GRID_CLASS)}++ >++ {groupItems.map((item) => (++ <MarketPluginCard++ key={item.pluginId}++ item={item}++ busy={marketBusyId !== null}++ onSelect={() => void handleSelectMarket(item.pluginId)}++ onInstall={() => void handleInstallMarketItem(item.pluginId)}++ onIconLoadError={handleMarketIconLoadError}++ />++ ))}++ </div>++ </section>++ ))}++ </div>++ ) : (++ <div className={cn('plugin-motion-stagger', PLUGIN_MANAGEMENT_CARD_GRID_CLASS)}>++ {availableMarketItems.map((item) => (++ <MarketPluginCard++ key={item.pluginId}++ item={item}++ busy={marketBusyId !== null}++ onSelect={() => void handleSelectMarket(item.pluginId)}++ onInstall={() => void handleInstallMarketItem(item.pluginId)}++ onIconLoadError={handleMarketIconLoadError}++ />++ ))}++ </div>++ )+ ) : marketSnapshot?.unavailableReason ? null : (+ <div className="rounded-xl border-[0.5px] border-[var(--border-default)] px-5 py-10 text-center">+ <p className="text-13 text-[var(--text-secondary)]">+ {t('settings.ghosts.page.emptyFiltered')}+ </p>+ </div>+ )}+ </section>+ ) : null}+ </PluginManagementPage>+ </main>+ {panelAside}+ </div>+ <AddMarketplaceDialog+ open={addMarketplaceOpen}+ onOpenChange={setAddMarketplaceOpen}+ onSourcesChanged={() => void refreshMarket()}+ />+ {updateRows ? (+ <UpdateAllDialog+ open={updateDialogOpen}+ rows={updateRows}+ iconByGhostId={new Map(ghosts.map((ghost) => [ghost.manifest.id, ghost.iconDataUrl]))}+ onApprove={(pluginId) => void handleApproveExpansion(pluginId)}+ onSkip={handleSkipExpansion}+ onClose={() => setUpdateDialogOpen(false)}+ />+ ) : null}</PluginManagementLayout>);}diff --cc apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsxindex dd38e0be5b,e4bac6e86a..98b4d05c71--- a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsx+++ b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsx@@@ -63,41 -54,114 +63,43 @@@ const marketPlugin: PluginMarketItem =icon: null,installState: 'not-installed',enabled: null,+ sourceType: 'server',+ sourceMarketName: null,};-function InstalledQueueHarness({ items }: { items: readonly GhostPluginListItem[] }) {- const [expanded, setExpanded] = useState(false);- return (- <InstalledGhostQueue- items={items}- expanded={expanded}- onExpandedChange={setExpanded}- onSelect={vi.fn()}- />- );-}-describe('GhostPluginCard', () => {- it('shows the installed shortcut name through the shared Tooltip', () => {- const onSelect = vi.fn();- const { container } = render(- <InstalledGhostShortcut item={installedPlugin} onSelect={onSelect} />,- );-- const button = screen.getByRole('button', { name: 'Filo Google' });- expect(container.querySelector('[data-tooltip="Filo Google"]')).toBeTruthy();- expect(button.getAttribute('title')).toBeNull();- fireEvent.click(button);- expect(onSelect).toHaveBeenCalledWith('filo-google');+ it('fires the primary action from the whole card for a command plugin', () => {+ const onPrimary = vi.fn();+ const onManage = vi.fn();+ render(<GhostPluginCard item={commandPlugin} onPrimary={onPrimary} onManage={onManage} />);++ fireEvent.click(screen.getByRole('button', { name: 'Filo Google' }));+ expect(onPrimary).toHaveBeenCalledTimes(1);+ expect(onManage).not.toHaveBeenCalled();+ // 指令型主按钮 = 「对话」。+ expect(screen.getByRole('button', { name: 'settings.ghosts.page.chatAria' })).toBeTruthy();});- it('puts the collapse control after every installed plugin in the expanded queue', () => {- const plugins = Array.from({ length: 7 }, (_, index) => ({- ...installedPlugin,- id: `plugin-${index + 1}`,- name: `Plugin ${index + 1}`,- }));- const { container } = render(<InstalledQueueHarness items={plugins} />);-- expect(screen.getByRole('button', { name: 'Plugin 5' })).toBeTruthy();- expect(screen.queryByRole('button', { name: 'Plugin 6' })).toBeNull();-- const expand = screen.getByRole('button', {- name: 'settings.ghosts.page.installedExpand',- });- expand.focus();- fireEvent.click(expand);-- const queue = container.querySelector('[data-testid="installed-plugin-queue"]');- const collapse = screen.getByRole('button', {- name: 'settings.ghosts.page.installedCollapse',- });- expect(screen.getByRole('button', { name: 'Plugin 7' })).toBeTruthy();- expect(queue?.lastElementChild).toBe(collapse);- expect(within(collapse).queryByText('+2')).toBeNull();- expect(collapse.querySelector('.lucide-chevron-up')).toBeTruthy();- expect(document.activeElement).toBe(collapse);-- fireEvent.click(collapse);- expect(document.activeElement).toBe(- screen.getByRole('button', { name: 'settings.ghosts.page.installedExpand' }),- );- });-- it('opens the plugin detail from the card body without firing the action', () => {- const onSelect = vi.fn();- const onAction = vi.fn();- render(<GhostPluginCard item={installedPlugin} onSelect={onSelect} onAction={onAction} />);-- const detailButton = screen.getByRole('button', { name: 'Filo Google' });- fireEvent.click(detailButton);+ it('labels the primary button 使用 for a tab-panel plugin', () => {+ const onPrimary = vi.fn();+ render(<GhostPluginCard item={panelPlugin} onPrimary={onPrimary} onManage={vi.fn()} />);- expect(onSelect).toHaveBeenCalledTimes(1);- expect(onAction).not.toHaveBeenCalled();+ fireEvent.click(screen.getByRole('button', { name: 'settings.ghosts.page.useAria' }));+ expect(onPrimary).toHaveBeenCalledTimes(1);});- it('routes projected icon failures from installed cards and shortcuts to market recovery', () => {- const onIconLoadError = vi.fn();- const projected = {- ...installedPlugin,- iconDataUrl: 'https://plugins.example.invalid/icon.png?signature=current',- };- const { container, rerender } = render(- <GhostPluginCard- item={projected}- onSelect={vi.fn()}- onAction={vi.fn()}- onIconLoadError={onIconLoadError}- />,- );-- fireEvent.error(container.querySelector('img') as HTMLImageElement);- expect(onIconLoadError).toHaveBeenCalledTimes(1);+ it('routes the manage icon to detail without firing the primary action', () => {+ const onPrimary = vi.fn();+ const onManage = vi.fn();+ render(<GhostPluginCard item={commandPlugin} onPrimary={onPrimary} onManage={onManage} />);- rerender(- <InstalledGhostQueue- items={[projected]}- expanded={false}- onExpandedChange={vi.fn()}- onSelect={vi.fn()}- onIconLoadError={onIconLoadError}- />,- );- fireEvent.error(container.querySelector('img') as HTMLImageElement);- expect(onIconLoadError).toHaveBeenCalledTimes(2);+ fireEvent.click(screen.getByRole('button', { name: 'settings.ghosts.page.manageAria' }));+ expect(onManage).toHaveBeenCalledTimes(1);+ expect(onPrimary).not.toHaveBeenCalled();});- it('surfaces the market update state with a badge and a direct update action', () => {- const onAction = vi.fn();+ it('shows the update pill and keeps it from triggering the card action', () => {+ const onPrimary = vi.fn();const onUpdate = vi.fn();render(<GhostPluginCarddiff --cc apps/desktop/src/renderer/features/plugin/__tests__/updateAllModel.test.tsindex 988724f2df,0000000000..295dd584fdmode 100644,000000..100644--- a/apps/desktop/src/renderer/features/plugin/__tests__/updateAllModel.test.ts+++ b/apps/desktop/src/renderer/features/plugin/__tests__/updateAllModel.test.ts@@@ -1,108 -1,0 +1,110 @@@+/**+ * Unit coverage for the update-all batch model: row extraction, transitions,+ * settlement predicates, and the ignore-round identity key.+ * [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md+ */++import { describe, expect, it } from 'vitest';++import type { PluginMarketItem } from '../../../../shared/pluginMarket';+import {+ batchSummary,+ buildUpdateAllRows,+ isBatchFinished,+ isBatchSettled,+ updateRoundKey,+ updateRow,+} from '../lib/updateAllModel';++function marketItem(overrides: Partial<PluginMarketItem>): PluginMarketItem {+ return {+ pluginId: 'release-a',+ ghostId: 'ghost-a',+ name: 'Ghost A',+ description: '',+ author: null,+ scope: 'public',+ organizationId: null,+ defaultInstall: false,+ releaseId: 'release-1',+ version: '1.1.0',+ publishedAt: '2026-08-01T00:00:00.000Z',+ icon: null,+ installState: 'update-available',+ enabled: true,++ sourceType: 'server',++ sourceMarketName: null,+ ...overrides,+ };+}++describe('buildUpdateAllRows', () => {+ it('extracts only update-available items and keeps snapshot order', () => {+ const rows = buildUpdateAllRows(+ [+ marketItem({ pluginId: 'p1', ghostId: 'g1', version: '2.0.0' }),+ marketItem({ pluginId: 'p2', ghostId: 'g2', installState: 'installed' }),+ marketItem({ pluginId: 'p3', ghostId: 'g3', installState: 'not-installed' }),+ marketItem({ pluginId: 'p4', ghostId: 'g4', version: '0.2.0' }),+ ],+ new Map([+ ['g1', '1.0.0'],+ ['g4', '0.1.0'],+ ]),+ );++ expect(rows.map((row) => row.pluginId)).toEqual(['p1', 'p4']);+ expect(rows[0]).toMatchObject({+ ghostId: 'g1',+ fromVersion: '1.0.0',+ toVersion: '2.0.0',+ status: 'pending',+ });+ });+});++describe('batch transitions', () => {+ const rows = buildUpdateAllRows(+ [+ marketItem({ pluginId: 'p1', ghostId: 'g1' }),+ marketItem({ pluginId: 'p2', ghostId: 'g2' }),+ ],+ new Map(),+ );++ it('updates a single row immutably', () => {+ const next = updateRow(rows, 'p1', { status: 'done' });+ expect(next[0].status).toBe('done');+ expect(rows[0].status).toBe('pending');+ expect(next[1].status).toBe('pending');+ });++ it('settles when nothing auto-advances, finishes only after confirms resolve', () => {+ let next = updateRow(rows, 'p1', { status: 'done' });+ next = updateRow(next, 'p2', { status: 'needs-confirm' });+ // needs-confirm 不再自动推进,但用户还没处理 → settled 而未 finished。+ expect(isBatchSettled(next)).toBe(true);+ expect(isBatchFinished(next)).toBe(false);++ next = updateRow(next, 'p2', { status: 'skipped' });+ expect(isBatchFinished(next)).toBe(true);+ expect(batchSummary(next)).toEqual({ done: 1, skipped: 1, failed: 0 });+ });+});++describe('updateRoundKey', () => {+ it('is stable across ordering and changes when any target version changes', () => {+ const a = [+ marketItem({ pluginId: 'p1', ghostId: 'g1', version: '1.1.0' }),+ marketItem({ pluginId: 'p2', ghostId: 'g2', version: '2.0.0' }),+ ];+ const b = [a[1], a[0]];+ expect(updateRoundKey(a)).toBe(updateRoundKey(b));+ const c = [a[0], marketItem({ pluginId: 'p2', ghostId: 'g2', version: '2.0.1' })];+ expect(updateRoundKey(c)).not.toBe(updateRoundKey(a));+ // 非可更新项不参与身份键。+ expect(+ updateRoundKey([...a, marketItem({ ghostId: 'g9', installState: 'installed' })]),+ ).toBe(updateRoundKey(a));+ });+});diff --cc apps/desktop/src/renderer/i18n/locales/en/common.jsonindex 11efb2f6ff,afcdf5123b..0b0193b380--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@@ -2887,18 -3106,12 +3109,19 @@@"origin": {"public": "Public","organization": "Team shared",- "local": "Local"+ "local": "Local",+ "custom": "Custom"},"emptyFiltered": "No matching plugins",- "useAction": "Use",- "useAria": "Use {{name}}"+ "useAria": "Use {{name}}",+ "usePanelAction": "Use",+ "chatAction": "Chat",+ "chatAria": "Chat with {{name}}",+ "manageAction": "Manage",+ "manageAria": "Manage {{name}}",+ "agentInvoked": "Invoked by Agent",+ "upToDate": "Up to date",+ "installAria": "Install {{name}}"},"market": {"scopeAria": "Filter plugin sources",diff --cc apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex 4dec965f17,8f04ecf29b..56ca174682--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@@ -2886,18 -3105,12 +3108,19 @@@"origin": {"public": "公開","organization": "チーム共有",- "local": "ローカル"+ "local": "ローカル",+ "custom": "カスタム"},"emptyFiltered": "一致するプラグインがありません",- "useAction": "使用",- "useAria": "{{name}} を使用"+ "useAria": "{{name}} を使用",+ "usePanelAction": "使う",+ "chatAction": "会話",+ "chatAria": "{{name}} と会話",+ "manageAction": "管理",+ "manageAria": "{{name}} を管理",+ "agentInvoked": "Agent が自動で呼び出し",+ "upToDate": "最新です",+ "installAria": "{{name}} をインストール"},"market": {"scopeAria": "プラグインの提供元を絞り込む",diff --cc apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex 9828eef3e3,626c038d6a..652d49b1ae--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@@ -2886,18 -3105,12 +3108,19 @@@"origin": {"public": "공개","organization": "팀 공유",- "local": "로컬"+ "local": "로컬",+ "custom": "사용자 지정"},"emptyFiltered": "일치하는 플러그인이 없습니다",- "useAction": "사용",- "useAria": "{{name}} 사용"+ "useAria": "{{name}} 사용",+ "usePanelAction": "사용",+ "chatAction": "대화",+ "chatAria": "{{name}}과(와) 대화",+ "manageAction": "관리",+ "manageAria": "{{name}} 관리",+ "agentInvoked": "Agent가 자동 호출",+ "upToDate": "최신 상태",+ "installAria": "{{name}} 설치"},"market": {"scopeAria": "플러그인 출처 필터",diff --cc apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex 5897069da3,3656a75d3d..b070a1c3f0--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@@ -2886,18 -3105,12 +3108,19 @@@"origin": {"public": "公开","organization": "团队共享",- "local": "本地"+ "local": "本地",+ "custom": "自定义"},"emptyFiltered": "没有找到匹配的插件",- "useAction": "使用",- "useAria": "使用 {{name}}"+ "useAria": "使用 {{name}}",+ "usePanelAction": "使用",+ "chatAction": "对话",+ "chatAria": "与 {{name}} 对话",+ "manageAction": "管理",+ "manageAria": "管理 {{name}}",+ "agentInvoked": "Agent 自动调用",+ "upToDate": "已是最新",+ "installAria": "安装 {{name}}"},"market": {"scopeAria": "筛选插件来源",