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。

revert(plugin): 撤回远程分享接收适配

liugaowei54fdbce05cfd
diff --git a/apps/desktop/src/renderer/features/plugin/RemotePluginPage.tsx b/apps/desktop/src/renderer/features/plugin/RemotePluginPage.tsx
index 1a301c9291..0ad3e2387e 100644
--- a/apps/desktop/src/renderer/features/plugin/RemotePluginPage.tsx
+++ b/apps/desktop/src/renderer/features/plugin/RemotePluginPage.tsx
@@ -1,6 +1,5 @@
import { useCallback, useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import { useSearchParams } from 'react-router-dom';
import {
REMOTE_RESOURCE_CHANGED_CHANNEL,
parseRemoteResourceChangedPayload,
@@ -83,7 +82,6 @@ export function RemotePluginPage({
onSelectCatalogTab?: (tab: 'plugins' | 'skills') => void;
}) {
const { t, i18n } = useTranslation();
- const [searchParams, setSearchParams] = useSearchParams();
const { confirm } = useConfirmDialog();
const [snapshot, setSnapshot] = useState<PluginManagementSnapshot | null>(null);
const [project, setProject] = useState<PluginManagementProject | null>(null);
@@ -411,11 +409,11 @@ export function RemotePluginPage({
projectReadStatus,
],
);
- const selectMarket = useCallback(async (pluginId: string) => {
+ const selectMarket = async (item: PluginMarketItem) => {
const revision = ++detailRevision.current;
try {
const detail = parsePluginManagementDetail(
- await invoke('market-detail', { pluginId }),
+ await invoke('market-detail', { pluginId: item.pluginId }),
);
if (writable() && revision === detailRevision.current) {
setSelected(null);
@@ -424,7 +422,7 @@ export function RemotePluginPage({
} catch {
if (writable() && revision === detailRevision.current) setStatus('readFailed');
}
- }, [invoke, writable]);
+ };
const install = async (item: PluginMarketItem) => {
if (!writable() || operation.current || preparing.current) return;
preparing.current = true;
@@ -487,16 +485,6 @@ export function RemotePluginPage({
}
};
const busy = !online || unsupported || preparingUi || !!operation.current;
- useEffect(() => {
- const pluginId = searchParams.get('market');
- if (!pluginId || !active || busy || !snapshot || !writable()) return;
- // Keep the selected computer and use its existing read/approval flow. An
- // offline target retains the query until its catalogue is available again.
- const next = new URLSearchParams(searchParams);
- next.delete('market');
- setSearchParams(next, { replace: true });
- void selectMarket(pluginId);
- }, [active, busy, snapshot, searchParams, setSearchParams, selectMarket, writable]);
const effectiveGhost = (item: InstalledGhost): InstalledGhost =>
project
? {
@@ -893,7 +881,7 @@ export function RemotePluginPage({
item={item}
busy={busy}
onSelect={() => {
- void selectMarket(item.pluginId);
+ void selectMarket(item);
}}
onInstall={
item.installState === 'conflict'
diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/RemotePluginPage.test.tsx b/apps/desktop/src/renderer/features/plugin/__tests__/RemotePluginPage.test.tsx
index f20e3b9f48..56c16a1d2a 100644
--- a/apps/desktop/src/renderer/features/plugin/__tests__/RemotePluginPage.test.tsx
+++ b/apps/desktop/src/renderer/features/plugin/__tests__/RemotePluginPage.test.tsx
@@ -1,6 +1,5 @@
// @vitest-environment jsdom
-import { act, fireEvent, render as renderUi, screen, waitFor } from '@testing-library/react';
-import { MemoryRouter, useLocation } from 'react-router-dom';
+import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { RemotePluginPage } from '../RemotePluginPage';
import { setDataOwnerGeneration } from '@/contexts/dataOwnerGeneration';
@@ -12,9 +11,6 @@ const { invoke, confirm, localGhosts, notices } = vi.hoisted(() => ({
localGhosts: vi.fn(),
}));
vi.mock('@/lib/toast', () => ({ toast: notices }));
-vi.mock('@/contexts/AuthContext', () => ({
- useAuth: () => ({ isAuthenticated: false, dataOwnerId: null, dataOwnerGeneration: 0 }),
-}));
vi.mock('@/components/new-chat/AddRemoteProjectDialog', () => ({
AddRemoteProjectDialog: ({ fixedDeviceId, onProjectAdded, onOpenChange }: {
fixedDeviceId: string;
@@ -123,17 +119,6 @@ const snapshot = (name: string) => ({
unavailableCustomSourceNames: [],
},
});
-function RouteSearch() {
- return <output data-testid="route-search">{useLocation().search}</output>;
-}
-const render = (ui: React.ReactNode, route = '/plugins') => renderUi(ui, {
- wrapper: ({ children }) => (
- <MemoryRouter initialEntries={[route]}>
- {route.includes('?') ? <RouteSearch /> : null}
- {children}
- </MemoryRouter>
- ),
-});
const configurationResource = (state = 'configured', id = 'weather') => ({
ref: { collectionId: 'plugins', kind: 'plugin', id },
revision: 'r1',
@@ -201,37 +186,6 @@ afterEach(() => {
vi.unstubAllGlobals();
});
describe('selected plugin host', () => {
- // PR #7240: a retained remote selection mounted this page, which never read
- // the public-link query. Local navigation tests cannot catch it. A query ID
- // and the real remote page must read the selected Host's existing detail action
- // once, display its result and never begin an install (unit, in-memory IPC).
- it.each([true, false])('opens a shared plugin on the selected Host (initially online: %s)', async (online) => {
- const pluginId = `c${'p'.repeat(24)}`;
- const normal = invoke.getMockImplementation()!;
- invoke.mockImplementation(async (device, channel, args) => args[0]?.actionId === 'management:market-detail'
- ? { result: {
- pluginId, ghostId: 'weather', name: 'Shared remote plugin', description: 'Public shared detail',
- author: 'Example', version: '1.0.0', publishedAt: '2026-10-27T00:00:00.000Z',
- scope: 'public', organizationId: null, defaultInstall: false, releaseId: 'shared-release',
- installState: 'not-installed', enabled: null, sourceType: 'server', sourceMarketName: null,
- icon: null, manifest: { ...snapshot(device).ghosts[0].manifest, name: 'Shared remote plugin' },
- } }
- : normal(device, channel, args));
- const ui = render(<RemotePluginPage device={{ deviceId: 'computer-a', name: 'A' }} online={online} />, `/plugins?market=${pluginId}`);
- if (!online) {
- expect(invoke).not.toHaveBeenCalled();
- expect(screen.getByTestId('route-search').textContent).toBe(`?market=${pluginId}`);
- ui.rerender(<RemotePluginPage device={{ deviceId: 'computer-a', name: 'A' }} online />);
- }
- expect(await screen.findByRole('heading', { name: 'Shared remote plugin' })).toBeTruthy();
- await waitFor(() => expect(screen.getByTestId('route-search').textContent).toBe(''));
- const reads = invoke.mock.calls.filter((call) => call[2][0]?.actionId === 'management:market-detail');
- expect(reads).toHaveLength(1);
- expect(reads[0]).toEqual(['computer-a', expect.any(String), [expect.objectContaining({ input: { pluginId } })]]);
- expect(invoke.mock.calls.some((call) => call[2][0]?.actionId === 'management:begin')).toBe(false);
- expect(localGhosts).not.toHaveBeenCalled();
- });
-
it('presents cancellation as a neutral overlay without inserting a banner', async () => {
const normal = invoke.getMockImplementation()!;
invoke.mockImplementation(async (device, channel, args) =>
diff --git a/docs/dev-rules/protocol-compatibility.md b/docs/dev-rules/protocol-compatibility.md
index 68a473edbf..ad5c7d16be 100644
--- a/docs/dev-rules/protocol-compatibility.md
+++ b/docs/dev-rules/protocol-compatibility.md
@@ -3533,9 +3533,11 @@ Share Server 以独立 PostgreSQL 库唯一保存分享关系;返回既有素
Share Server 在创建时保存已验签的分享者 `membershipId` 与身份权威。Auth 只读现有账号资料,不增加分享字段、记录、索引或 migration;公开资料接口使用 shareId,在固定 Share Server 回查有效分享与身份绑定后读取当前资料。分享服务端已独立提供该能力,客户端沿用现有认证与固定分享入口,不引入额外 Auth 写入或凭证存储。公开资料新增可选的内嵌栅格 `icon` 字段,两仓协议同步;缺失或无效时使用默认图标,旧服务与旧客户端均兼容。
-方形 SVG 为 1080×1080,Desktop PNG 为 2160×2160,接收界限 1 MiB。素材用于人工复制/保存;网页只展示与承接,不提供发送面板工具。`cindy://plugin/:pluginId` 仍只导航,拒绝 query/fragment/安装参数,沿冷启动、登录恢复、兼容包选择和原安装批准。通用市场详情入口接受服务端解析后的当前区域 ID,再与当前可见目录核对身份及发布;新旧 ID 映射仍归 Plugin Server,分享层不新增转换。插件页保留当前所选电脑,远程页面经既有 `management:market-detail` 读取该电脑的详情,离线时保留导航参数到目录恢复,不回退本机或自动安装。已有目录 ID 的请求仍严格绑定原条目,不能借规范化跳到其他插件。不扩 device-link 或 Mobile 能力,没有“我的分享”、移除已发署名、分享统计、转发链、平台 SDK 或资料快照。
+方形 SVG 为 1080×1080,Desktop PNG 为 2160×2160,接收界限 1 MiB。素材用于人工复制/保存;网页只展示与承接,不提供发送面板工具。`cindy://plugin/:pluginId` 仍只导航,拒绝 query/fragment/安装参数,沿冷启动、登录恢复、兼容包选择和原安装批准。通用市场详情入口接受服务端解析后的当前区域 ID,再与当前可见目录核对身份及发布;新旧 ID 映射仍归 Plugin Server,分享层不新增转换。已有目录 ID 的请求仍严格绑定原条目,不能借规范化跳到其他插件。不扩 device-link 或 Mobile 能力,没有“我的分享”、移除已发署名、分享统计、转发链、平台 SDK 或资料快照。
+本版分享接收限于插件页选择本机且目录正常的情况;不承接远程电脑的分享导航或断线恢复,不自动切换所选电脑。组织目录不可用时继续遵守未下发条目不读取详情的既有限制;历史或跨区域公开编号的解析也可能被该限制拒绝,本版不新增解析入口或放宽访问边界。
+
## 伙伴关联项目
`teammates` 增加 `settings:<botId>/projects` 与其项目详情资源。使用既有 list/form/toggle 原语,