Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(provider-share): show approval disclosure from management
Lizi03dc757c8f86
diff --git a/apps/desktop/src/renderer/components/layout/MainLayout.tsx b/apps/desktop/src/renderer/components/layout/MainLayout.tsxindex 673cd318b1..5777a0cfc1 100644--- a/apps/desktop/src/renderer/components/layout/MainLayout.tsx+++ b/apps/desktop/src/renderer/components/layout/MainLayout.tsx@@ -1697,8 +1697,8 @@ export function MainLayout() {)}{/* FeiShu Bot conflict dialog -- subscribes to main process push and surfaces a global modal */}<FeishuConflictDialogHost />- {/* 供应商分享:分享者的审批弹窗与受邀者的申请弹窗。只挂在主窗口,副窗不重复弹。 */}- {!isSecondaryWindow() && <ProviderShareGlobalHost />}+ {/* 副窗支持管理页手动审批;自动提醒与受邀申请仍只由主窗口处理。 */}+ <ProviderShareGlobalHost manualOnly={isSecondaryWindow()} />{!isSecondaryWindow() && <ChatInviteHost />}{sharedTaskInvitation && <JoinSharedTaskDialog key={sharedTaskInvitation.id} open initialInvitation={sharedTaskInvitation.link}onOpenChange={(open) => { if (!open) setSharedTaskInvitation(null); }} />}diff --git a/apps/desktop/src/renderer/features/provider-share/ProviderShareGlobalHost.tsx b/apps/desktop/src/renderer/features/provider-share/ProviderShareGlobalHost.tsxindex 9243124c7a..d3499f8c14 100644--- a/apps/desktop/src/renderer/features/provider-share/ProviderShareGlobalHost.tsx+++ b/apps/desktop/src/renderer/features/provider-share/ProviderShareGlobalHost.tsx@@ -1,5 +1,5 @@/**- * 供应商分享的全局宿主(只在主窗口 MainLayout 挂一次):+ * 供应商分享的窗口宿主:主窗口处理自动提醒,副窗口只展示管理页手动打开的审批。** - 分享者:启动时读一次 `owned`,把本次运行还没弹过的待审批申请排队;之后靠 REQUESTED 推送。* 逐条弹审批弹窗,Esc / × = 稍后处理(申请留在管理页)。系统通知点击 → 打开对应管理页。@@ -29,22 +29,24 @@ import {getProviderSharePendingRequests,getProviderSharePendingReshares,refreshProviderShareOwnerPending,+ useProviderShareApprovalSelection,useProviderSharePendingRequests,} from './providerShareStore';import { subscribeProviderShareJoin } from './joinIntent';const SETTLED_TOAST_MS = 6000;-export function ProviderShareGlobalHost() {+export function ProviderShareGlobalHost({ manualOnly = false }: { manualOnly?: boolean }) {const { t } = useTranslation();const { dataOwnerId, dataOwnerGeneration } = useAuth();useEffect(() => {+ if (manualOnly) return;refreshProviderShareFavoriteMembership();- }, [dataOwnerId, dataOwnerGeneration]);+ }, [dataOwnerId, dataOwnerGeneration, manualOnly]);const favoriteCleanupFailed = useProviderShareFavoriteCleanupFailed();useEffect(() => {- if (favoriteCleanupFailed) toast.error(t('newChat.modelSelector.unified.favoritesCleanupFailed'));- }, [favoriteCleanupFailed, t]);+ if (!manualOnly && favoriteCleanupFailed) toast.error(t('newChat.modelSelector.unified.favoritesCleanupFailed'));+ }, [favoriteCleanupFailed, manualOnly, t]);const navigate = useNavigate();const location = useLocation();const navigateRef = useRef(navigate);@@ -55,6 +57,7 @@ export function ProviderShareGlobalHost() {tRef.current = t;const pending = useProviderSharePendingRequests();+ const selection = useProviderShareApprovalSelection();// 本次运行已排过队的申请:main 重连后会重新推送全部待审批申请,不重复弹。const queuedRef = useRef(new Set<string>());const [queue, setQueue] = useState<readonly string[]>([]);@@ -76,6 +79,7 @@ export function ProviderShareGlobalHost() {}, []);useEffect(() => {+ if (manualOnly) return;const api = (window as Partial<Window>).electronAPI?.providerShare;if (!api) return;let disposed = false;@@ -142,19 +146,32 @@ export function ProviderShareGlobalHost() {offSettled();offJoinIntent();};- }, [enqueue, openJoin]);+ }, [enqueue, openJoin, manualOnly]);++ const selectedId = selection?.item.request.requestId;+ useEffect(() => {+ if (!selectedId) return;+ // 手动打开也算本次运行已弹过:启动读取与重连推送不能再把它排入自动队列。+ queuedRef.current.add(selectedId);+ setQueue((items) => items.filter((id) => id !== selectedId));+ }, [selectedId]);const currentId = queue[0] ?? null;- const current = currentId ? pending.find((item) => item.request.requestId === currentId) ?? null : null;+ const queued = currentId ? pending.find((item) => item.request.requestId === currentId) ?? null : null;+ const current = selection?.item ?? queued;// 队首的申请已不在待审批里(在管理页处理了、被撤回或过期):跳过。useEffect(() => {- if (currentId && !current) setQueue((items) => items.filter((id) => id !== currentId));- }, [current, currentId]);+ if (currentId && !queued) setQueue((items) => items.filter((id) => id !== currentId));+ }, [queued, currentId]);const closeApproval = useCallback(() => {+ if (selection) {+ selection.onClose();+ return;+ }setQueue((items) => (items.length > 0 ? items.slice(1) : items));- }, []);+ }, [selection]);const openNewTask = useCallback(() => {navigateRef.current('/cc-agent/new', { state: makeGenericNewMakerRouteState(pathnameRef.current) });diff --git a/apps/desktop/src/renderer/features/provider-share/ProviderShareManagePage.tsx b/apps/desktop/src/renderer/features/provider-share/ProviderShareManagePage.tsxindex 049fe2d54a..e554d8ddbf 100644--- a/apps/desktop/src/renderer/features/provider-share/ProviderShareManagePage.tsx+++ b/apps/desktop/src/renderer/features/provider-share/ProviderShareManagePage.tsx@@ -40,7 +40,7 @@ import type {import { ProviderShareLinkDialog } from './ProviderShareLinkDialog';import { pendingResharesFromOwned, sharesClaudeLoginEmail, type ProviderShareGate, type ProviderSharePendingRequest } from './providerShareFormat';import { ProviderUsageSection } from './ProviderUsageSection';-import { publishProviderShareOwnerState, removeProviderSharePendingRequest } from './providerShareStore';+import { presentProviderShareApproval, publishProviderShareOwnerState, removeProviderSharePendingRequest } from './providerShareStore';import { ShareAvatar } from './ShareAvatar';import { useShareTimeFormat } from './useShareTimeFormat';@@ -83,6 +83,7 @@ export function ProviderShareManagePage({const [own, setOwn] = useState<ProviderOwnUsageView | null>(null);const [ownFailed, setOwnFailed] = useState(false);const [linkOpen, setLinkOpen] = useState(false);+ const [approvalRequestId, setApprovalRequestId] = useState<string | null>(null);const [busy, setBusy] = useState<ReadonlySet<string>>(() => new Set());const loadSeq = useRef(0);const remoteLoadRange = useRef<ProviderShareUsageRange | null>(null);@@ -147,6 +148,7 @@ export function ProviderShareManagePage({pending.push({request,share: { shareId: share.shareId, providerId: share.providerId, providerLabel: share.providerLabel },+ ...(deviceId ? { hostDeviceId: deviceId } : {}),});}}@@ -157,7 +159,20 @@ export function ProviderShareManagePage({// 转分享请求(provider-sharing.md §4.3):成员想经自己的供应商组把这里分享的供应商转给别人用。reshares: pendingResharesFromOwned(shares),};- }, [providerId, state]);+ }, [providerId, deviceId, state]);++ const approvalItem = requests.find((item) => item.request.requestId === approvalRequestId);+ const closeApproval = useCallback(() => {+ setApprovalRequestId(null);+ void load();+ }, [load]);+ useEffect(() => {+ if (!approvalItem) {+ setApprovalRequestId(null);+ return;+ }+ return presentProviderShareApproval(approvalItem, closeApproval);+ }, [approvalItem, closeApproval]);const withBusy = useCallback(async (key: string, run: () => Promise<void>) => {setBusy((current) => new Set(current).add(key));@@ -172,24 +187,20 @@ export function ProviderShareManagePage({}}, []);- const decide = useCallback(- (item: ProviderSharePendingRequest, action: 'approve' | 'reject') =>+ const reject = useCallback(+ (item: ProviderSharePendingRequest) =>withBusy(item.request.requestId, async () => {try {- await providerShareManagementCommand({ action, requestId: item.request.requestId }, deviceId);+ await providerShareManagementCommand({ action: 'reject', requestId: item.request.requestId }, deviceId);// 远程管理时,本机生成链接带来的申请也在待审批里(由本机弹窗),一并移除。removeProviderSharePendingRequest(item.request.requestId);- toast.success(- action === 'approve'- ? t('providerShare.toast.approved', { name: item.request.displayName, provider: providerName })- : t('providerShare.toast.rejected', { name: item.request.displayName }),- );+ toast.success(t('providerShare.toast.rejected', { name: item.request.displayName }));} catch (error) {toast.error(t(providerManagementErrorKey(error, Boolean(deviceId))));}void load();}),- [load, providerName, deviceId, t, withBusy],+ [load, deviceId, t, withBusy],);const setMember = useCallback(@@ -359,7 +370,7 @@ export function ProviderShareManagePage({size="sm"compactdisabled={loadFailed || busy.has(item.request.requestId)}- onClick={() => void decide(item, 'reject')}+ onClick={() => void reject(item)}>{t('providerShare.approve.reject')}</Button>@@ -368,7 +379,7 @@ export function ProviderShareManagePage({size="sm"compactdisabled={loadFailed || !providerClassificationReady || busy.has(item.request.requestId)}- onClick={() => void decide(item, 'approve')}+ onClick={() => setApprovalRequestId(item.request.requestId)}>{t('providerShare.approve.approve')}</Button>diff --git a/apps/desktop/src/renderer/features/provider-share/__tests__/ProviderShareManagePage.test.tsx b/apps/desktop/src/renderer/features/provider-share/__tests__/ProviderShareManagePage.test.tsxindex 53aa82966e..f1c5d9a360 100644--- a/apps/desktop/src/renderer/features/provider-share/__tests__/ProviderShareManagePage.test.tsx+++ b/apps/desktop/src/renderer/features/provider-share/__tests__/ProviderShareManagePage.test.tsx@@ -1,12 +1,14 @@// @vitest-environment jsdom-import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';+import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';+import { MemoryRouter } from 'react-router-dom';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import type { ProviderView } from '@cindy/model-providers';import type { ProviderGroupConfig } from '../../../../shared/providerGroup';-import type { ProviderOwnUsageView, ProviderShareOwnerState } from '../../../../shared/providerShare';+import type { ProviderOwnUsageView, ProviderShareOwnerState, ProviderShareRequestedEvent } from '../../../../shared/providerShare';import { __testing as localGroupsTesting } from '../../provider-group/useLocalProviderGroups';import { ProviderShareManagePage } from '../ProviderShareManagePage';+import { ProviderShareGlobalHost } from '../ProviderShareGlobalHost';import {getProviderSharePendingRequests,getProviderSharePendingReshares,@@ -32,7 +34,7 @@ const localCatalog = vi.hoisted(() => ({providers: [] as Array<{ id: string; source: string; auth: { method: string; native?: string } }>,}));const remoteCatalog = vi.hoisted(() => ({- providers: [] as Array<{ id: string; source: string; auth: { method: string; native?: string } }>,+ providers: [] as Array<{ id: string; source: string; auth: { method: string; native?: string }; group?: unknown }>,loading: false,error: null as string | null,}));@@ -40,6 +42,7 @@ vi.mock('@/hooks/useProviders', () => ({ useProviders: () => localCatalog }));vi.mock('@/hooks/useDeviceProviders', () => ({ useDeviceProviders: () => remoteCatalog }));vi.mock('@/contexts/AuthContext', async (importOriginal) => ({...(await importOriginal<typeof import('@/contexts/AuthContext')>()),+ useAuth: () => ({ dataOwnerId: null, dataOwnerGeneration: 0 }),useOptionalAuthUser: () => ({ name: 'Magi', avatar: null }),}));const confirmSpy = vi.hoisted(() => vi.fn(async () => true));@@ -136,11 +139,17 @@ const xdGroup: ProviderGroupConfig = {let localGroups: Record<string, ProviderGroupConfig> = {};const command = vi.fn();+let currentOwned: ProviderShareOwnerState;+const ownedListeners = new Set<() => void>();+const requestedListeners = new Set<(event: ProviderShareRequestedEvent) => void>();beforeEach(() => {resetProviderShareStoreForTests();localGroupsTesting.reset();localGroups = {};+ currentOwned = owned();+ ownedListeners.clear();+ requestedListeners.clear();localCatalog.providers = [{ id: 'xd', source: 'builtin', auth: { method: 'apiKey' } }];remoteCatalog.providers = [];remoteCatalog.loading = false;@@ -148,15 +157,30 @@ beforeEach(() => {confirmSpy.mockClear();command.mockReset();command.mockImplementation(async (cmd: { action: string }) => {- if (cmd.action === 'owned') return owned();+ if (cmd.action === 'owned') return currentOwned;if (cmd.action === 'own-usage') return ownUsage();if (cmd.action === 'received') return [];- if (cmd.action === 'set-member' || cmd.action === 'approve' || cmd.action === 'reject') return { ok: true };+ if (cmd.action === 'received-snapshot') return { ownerStamp: { dataOwnerId: null, ownerGeneration: 0 }, received: [], confirmedRegions: [] };+ if (cmd.action === 'set-member') return { ok: true };+ if (cmd.action === 'approve' || cmd.action === 'reject') {+ currentOwned = { ...currentOwned, shares: currentOwned.shares.map((share) => ({ ...share, requests: [] })) };+ return { ok: true };+ }throw new Error(`unexpected ${cmd.action}`);});Object.assign(window, {electronAPI: {- providerShare: { command, onOwnedChanged: () => () => undefined, onReceivedChanged: () => () => undefined },+ providerShare: {+ command,+ onOwnedChanged: (listener: () => void) => { ownedListeners.add(listener); return () => ownedListeners.delete(listener); },+ onRequested: (listener: (event: ProviderShareRequestedEvent) => void) => {+ requestedListeners.add(listener); return () => requestedListeners.delete(listener);+ },+ onReceivedChanged: () => () => undefined,+ onSettled: () => () => undefined,+ onOpenJoin: () => () => undefined,+ onOpenManage: () => () => undefined,+ },// 页面上方的供应商组一块(由 ProviderGroupSection 自己的测试覆盖):这里只给一个空组。providerGroup: {command: async (cmd: {@@ -167,9 +191,12 @@ beforeEach(() => {if (cmd.action === 'list') return localGroups;if (cmd.action === 'remote-manage') {const action = cmd.request?.command?.action;- if (action === 'owned') return owned();+ if (action === 'owned') return currentOwned;if (action === 'own-usage') return ownUsage();- if (action === 'approve' || action === 'reject') return { ok: true };+ if (action === 'approve' || action === 'reject') {+ currentOwned = { ...currentOwned, shares: currentOwned.shares.map((share) => ({ ...share, requests: [] })) };+ return { ok: true };+ }}return { providerId: cmd.providerId, config: null, members: [] };},@@ -183,24 +210,133 @@ afterEach(() => cleanup());function renderPage(gate: 'on' | 'remote-off' | 'invocation-off' = 'on',- options: { deviceId?: string; remoteProvider?: ProviderView } = {},+ options: { deviceId?: string; remoteProvider?: ProviderView; globalHost?: boolean; manualOnly?: boolean } = {},) {const onBack = vi.fn();const view = render(- <ProviderShareManagePage- providerId="xd"- providerName="Cindy AI"- providerIcon={null}- gate={gate}- deviceId={options.deviceId}- remoteProvider={options.remoteProvider}- onBack={onBack}- />,+ <MemoryRouter>+ {options.globalHost && <ProviderShareGlobalHost manualOnly={options.manualOnly} />}+ <ProviderShareManagePage+ providerId="xd"+ providerName="Cindy AI"+ providerIcon={null}+ gate={gate}+ deviceId={options.deviceId}+ remoteProvider={options.remoteProvider}+ onBack={onBack}+ />+ </MemoryRouter>,);return { onBack, ...view };}describe('ProviderShareManagePage', () => {+ it('supports manual approval in secondary windows without automatic share subscriptions', async () => {+ renderPage('on', { globalHost: true, manualOnly: true });+ const row = await screen.findByTestId('provider-share-pending-row');+ expect(screen.queryByTestId('provider-share-approve-dialog')).toBeNull();+ expect(requestedListeners.size).toBe(0);+ // The management page reads owned once; a secondary host must not seed its own automatic queue.+ expect(command.mock.calls.filter(([cmd]) => cmd.action === 'owned')).toHaveLength(1);+ fireEvent.click(within(row).getByRole('button', { name: 'providerShare.approve.approve' }));+ const dialog = await screen.findByTestId('provider-share-approve-dialog');+ expect(dialog.textContent).toContain('providerShare.approve.callout');+ fireEvent.click(within(dialog).getByRole('button', { name: 'providerShare.approve.approve' }));+ await waitFor(() => expect(screen.queryByTestId('provider-share-pending-row')).toBeNull());+ expect(command).toHaveBeenCalledWith({ action: 'approve', requestId: 'req-1' });+ });++ // §4.1/§7.2: management approval must show the same disclosure and route as automatic approval.+ // Existing host tests do not click this entry; keep the host real to catch duplicate modal ownership.+ it.each([undefined, 'studio'])('shows approval disclosure before submitting on the provider’s computer (%s)', async (deviceId) => {+ currentOwned.quietRequestIds = ['req-1'];+ localGroups = deviceId ? {} : { xd: xdGroup };+ remoteCatalog.providers = [{ id: 'xd', source: 'builtin', auth: { method: 'apiKey' }, group: xdGroup }];+ const remoteCommand = vi.spyOn(window.electronAPI.providerGroup, 'command');+ renderPage('on', { deviceId, globalHost: true });+ const row = await screen.findByTestId('provider-share-pending-row');+ fireEvent.click(within(row).getByRole('button', { name: 'providerShare.approve.approve' }));+ const dialog = await screen.findByTestId('provider-share-approve-dialog');+ expect(dialog.textContent).toContain('providerShare.approve.calloutGroup');+ const approval = { action: 'approve', requestId: 'req-1' };+ expect(command).not.toHaveBeenCalledWith(approval);+ expect(remoteCommand).not.toHaveBeenCalledWith(expect.objectContaining({+ request: { action: 'manage-share', command: approval },+ }));+ fireEvent.click(within(dialog).getByRole('button', { name: 'providerShare.approve.approve' }));+ await waitFor(() => expect(screen.queryByTestId('provider-share-approve-dialog')).toBeNull());+ await waitFor(() => expect(screen.queryByTestId('provider-share-pending-row')).toBeNull());+ if (deviceId) {+ expect(remoteCommand).toHaveBeenCalledWith({+ action: 'remote-manage', deviceId, request: { action: 'manage-share', command: approval },+ });+ expect(command).not.toHaveBeenCalledWith(approval);+ } else expect(command).toHaveBeenCalledWith(approval);+ });++ it('keeps a postponed request pending and closes a selected request removed by a fresh list', async () => {+ currentOwned.quietRequestIds = ['req-1'];+ renderPage('on', { globalHost: true });+ const row = await screen.findByTestId('provider-share-pending-row');+ fireEvent.click(within(row).getByRole('button', { name: 'providerShare.approve.approve' }));+ await screen.findByTestId('provider-share-approve-dialog');+ fireEvent.click(screen.getByRole('button', { name: 'providerShare.approve.later' }));+ await waitFor(() => expect(screen.queryByTestId('provider-share-approve-dialog')).toBeNull());+ expect(getProviderSharePendingRequests().map((item) => item.request.requestId)).toEqual(['req-1']);+ fireEvent.click(within(row).getByRole('button', { name: 'providerShare.approve.approve' }));+ await screen.findByTestId('provider-share-approve-dialog');+ currentOwned = owned();+ currentOwned.shares[0]!.requests = [];+ act(() => { for (const listener of ownedListeners) listener(); });+ await waitFor(() => expect(screen.queryByTestId('provider-share-approve-dialog')).toBeNull());+ expect(screen.queryByTestId('provider-share-pending-row')).toBeNull();+ expect(command).not.toHaveBeenCalledWith(expect.objectContaining({ action: 'approve' }));+ expect(command).not.toHaveBeenCalledWith(expect.objectContaining({ action: 'reject' }));+ });++ it('holds management approval while the local group list is pending', async () => {+ currentOwned.quietRequestIds = ['req-1'];+ let finish!: (groups: Record<string, ProviderGroupConfig>) => void;+ const original = window.electronAPI.providerGroup.command;+ vi.spyOn(window.electronAPI.providerGroup, 'command').mockImplementation((cmd) =>+ cmd.action === 'list' ? new Promise((resolve) => { finish = resolve; }) : original(cmd));+ renderPage('on', { globalHost: true });+ const row = await screen.findByTestId('provider-share-pending-row');+ fireEvent.click(within(row).getByRole('button', { name: 'providerShare.approve.approve' }));+ const dialog = await screen.findByTestId('provider-share-approve-dialog');+ expect((within(dialog).getByRole('button', { name: 'providerShare.approve.approve' }) as HTMLButtonElement).disabled).toBe(true);+ expect(command).not.toHaveBeenCalledWith(expect.objectContaining({ action: 'approve' }));+ await act(async () => { finish({ xd: xdGroup }); });+ expect(dialog.textContent).toContain('providerShare.approve.calloutGroup');+ expect((within(dialog).getByRole('button', { name: 'providerShare.approve.approve' }) as HTMLButtonElement).disabled).toBe(false);+ });++ it('uses one approval dialog for a management selection, a late startup list and repeated requests', async () => {+ let finishStartup!: (state: ProviderShareOwnerState) => void;+ const original = command.getMockImplementation()!;+ let first = true;+ command.mockImplementation((cmd: { action: string }) => {+ if (cmd.action === 'owned' && first) {+ first = false;+ return new Promise((resolve) => { finishStartup = resolve; });+ }+ return original(cmd);+ });+ renderPage('on', { globalHost: true });+ const row = await screen.findByTestId('provider-share-pending-row');+ fireEvent.click(within(row).getByRole('button', { name: 'providerShare.approve.approve' }));+ await screen.findByTestId('provider-share-approve-dialog');+ await act(async () => { finishStartup(currentOwned); });+ const event = { request: currentOwned.shares[0]!.requests[0]!, share: { shareId: 'share-1', providerId: 'xd', providerLabel: 'Cindy AI' } };+ act(() => { for (const listener of requestedListeners) { listener(event); listener(event); } });+ expect(screen.getAllByTestId('provider-share-approve-dialog')).toHaveLength(1);+ fireEvent.click(screen.getByRole('button', { name: 'providerShare.approve.later' }));+ await waitFor(() => expect(screen.queryByTestId('provider-share-approve-dialog')).toBeNull());+ act(() => { for (const listener of requestedListeners) listener(event); });+ expect(screen.queryByTestId('provider-share-approve-dialog')).toBeNull();+ expect(command).not.toHaveBeenCalledWith(expect.objectContaining({ action: 'approve' }));+ });+it('places link creation in the title row and pending requests before group and usage', async () => {renderPage();await screen.findAllByTestId('provider-share-member-row');diff --git a/apps/desktop/src/renderer/features/provider-share/providerShareFormat.ts b/apps/desktop/src/renderer/features/provider-share/providerShareFormat.tsindex 5b46c10781..f9cd37e8bb 100644--- a/apps/desktop/src/renderer/features/provider-share/providerShareFormat.ts+++ b/apps/desktop/src/renderer/features/provider-share/providerShareFormat.ts@@ -123,7 +123,7 @@ export function pendingRequestCountByProvider(export interface ProviderSharePendingRequest {request: ProviderShareRequestItem;share: { shareId: string; providerId: string; providerLabel: string };- /** 分享在同账号另一台电脑上:本机生成了链接,由本机弹窗,处理转交那台电脑。本机的分享不带。 */+ /** 分享在同账号另一台电脑上:本机生成链接或从管理页手动审批时带上,处理转交那台电脑。本机的分享不带。 */hostDeviceId?: string;/** 链接由同账号另一台电脑生成:由那台弹窗,本机只计入提示点与管理页。 */quiet?: boolean;diff --git a/apps/desktop/src/renderer/features/provider-share/providerShareStore.ts b/apps/desktop/src/renderer/features/provider-share/providerShareStore.tsindex 007061c304..a6fd0a0195 100644--- a/apps/desktop/src/renderer/features/provider-share/providerShareStore.ts+++ b/apps/desktop/src/renderer/features/provider-share/providerShareStore.ts@@ -282,6 +282,37 @@ export function useProviderSharePendingRequests(): readonly ProviderSharePendingreturn useSyncExternalStore(subscribePending, getProviderSharePendingRequests, getProviderSharePendingRequests);}+// 管理页手动选中的申请也交给唯一的全局审批宿主展示,避免与迟到的自动弹窗叠在一起。+interface ProviderShareApprovalSelection {+ item: ProviderSharePendingRequest;+ onClose: () => void;+}+let approvalSelection: ProviderShareApprovalSelection | null = null;+const approvalSubscribers = new Set<() => void>();++function setApprovalSelection(next: ProviderShareApprovalSelection | null): void {+ approvalSelection = next;+ for (const listener of approvalSubscribers) listener();+}++/** 页面用最新列表中的申请维护展示意图;刷新后申请消失或离开页面时撤销,不修改申请本身。 */+export function presentProviderShareApproval(item: ProviderSharePendingRequest, onClose: () => void): () => void {+ const selection = { item, onClose };+ setApprovalSelection(selection);+ return () => { if (approvalSelection === selection) setApprovalSelection(null); };+}++function subscribeApprovalSelection(listener: () => void): () => void {+ approvalSubscribers.add(listener);+ return () => { approvalSubscribers.delete(listener); };+}++function getApprovalSelection(): ProviderShareApprovalSelection | null { return approvalSelection; }++export function useProviderShareApprovalSelection(): ProviderShareApprovalSelection | null {+ return useSyncExternalStore(subscribeApprovalSelection, getApprovalSelection, getApprovalSelection);+}+/** 读一次 owned 并发布(审批宿主播种 / 有待审批申请时随推送重读)。 */export async function refreshProviderShareOwnerPending(): Promise<ProviderShareOwnerState | null> {const api = providerShareApi();@@ -311,6 +342,8 @@ export function resetProviderShareStoreForTests(): void {receivedSubscribers.clear();pendingRequests = [];pendingSubscribers.clear();+ approvalSelection = null;+ approvalSubscribers.clear();pendingReshares = [];reshareSubscribers.clear();}diff --git a/docs/product-rules/provider-sharing.md b/docs/product-rules/provider-sharing.mdindex 720e047a56..1f3161b70a 100644--- a/docs/product-rules/provider-sharing.md+++ b/docs/product-rules/provider-sharing.md@@ -288,6 +288,11 @@ Desktop「设置 → 模型供应商」的左栏(2026-10-08 用户裁决):- **生成分享链接**:放在页面标题右侧(2026-10-16 用户反馈:底部难找)。去掉原「分享」标题和重复说明;Agent 在哪运行、用量算谁的由审批弹窗的同意说明(§4.1 第 4 步)讲清。分享未开启的原因紧跟标题提示(§3)。- **待处理**:待审批的申请(同意/拒绝),以及转分享请求(§4.3,同意/拒绝);紧跟标题,排在供应商组与用量前面,为空时整块隐藏。+ 普通申请点击「同意分享」时,先打开与自动提醒共用的审批弹窗,展示运行位置、用量归属与必要告知(§4.1 第 4 步),+ 确认后才提交;同一窗口只显示一个审批弹窗,申请从最新列表消失或离开管理页时关闭手动打开的弹窗。+ 主窗口与副窗口均能手动审批;自动提醒仍只由主窗口处理。+ 跨电脑管理仍由供应商所在电脑执行;稍后处理保留申请。实现与回归见 `ProviderShareGlobalHost.tsx`、+ `ProviderShareManagePage.tsx` 与 `ProviderShareManagePage.test.tsx`。链接 5 分钟即过期,不列出未使用的链接。- **已分享的人**:每人一行,显示头像、昵称、加入时间、最近使用、当前状态(正常/已暂停)与是否有任务正在运行;这个人经自己的供应商组转给别人用、已处理过的请求列在这一行下方(已同意的可撤回,拒绝的可改为同意,§4.3)。