Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(skillhub): 读取失败时不合成人工拒审状态
xd-bobo0d5cc6e8bd0c
diff --git a/apps/desktop/src/renderer/features/skillhub/__tests__/ScanResultDialog.test.tsx b/apps/desktop/src/renderer/features/skillhub/__tests__/ScanResultDialog.test.tsxindex 7056a5f652..af6386ce58 100644--- a/apps/desktop/src/renderer/features/skillhub/__tests__/ScanResultDialog.test.tsx+++ b/apps/desktop/src/renderer/features/skillhub/__tests__/ScanResultDialog.test.tsx@@ -72,6 +72,15 @@ describe('ScanResultDialog pending review presentation', () => {expect(document.body.textContent).not.toContain('Stale private notes');});+ it('presents a lookup failure as unavailable without inventing a rejection or missing reason', () => {+ render(<ScanResultDialog open onClose={vi.fn()} result={{+ status: 'scan_status_unavailable', gates: [{ name: 'scan-status', status: 'unavailable' }],+ }} />);+ expect(screen.queryByRole('heading', { name: 'skillhub.scanResult.rejectedTitle' })).toBeNull();+ expect(screen.queryByText('skillhub.scanResult.rejectionReasonUnavailable')).toBeNull();+ expect(document.body.textContent).toContain('skillhub.scanResult.statusLabel.unavailable');+ });+it('presents passed machine checks as success instead of failure', () => {render(<ScanResultDialogdiff --git a/apps/desktop/src/renderer/features/skillhub/hooks/__tests__/useRejectionFeedback.test.ts b/apps/desktop/src/renderer/features/skillhub/hooks/__tests__/useRejectionFeedback.test.tsindex 2bf4567207..23c6748835 100644--- a/apps/desktop/src/renderer/features/skillhub/hooks/__tests__/useRejectionFeedback.test.ts+++ b/apps/desktop/src/renderer/features/skillhub/hooks/__tests__/useRejectionFeedback.test.ts@@ -3,6 +3,7 @@ import { act, cleanup, renderHook } from '@testing-library/react';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { setDataOwnerGeneration } from '@/contexts/dataOwnerGeneration';import { usePublicationFeedback, useRejectionFeedback } from '../useRejectionFeedback';+import { effectivePublishedStatus, effectivePublishedStatusVersion } from '../../lib/publishedStatus';const target = { entryKey: 'local:helper', name: 'helper', version: '1.1.0', canManage: true };const response = { success: true, status: 'rejected', gates: [], rejectionReason: 'Remove private notes' };@@ -116,10 +117,26 @@ describe('useRejectionFeedback', () => {expect(result.current.result).toBeNull();});- it('keeps the historical fallback when the lookup fails', async () => {- getScanStatus.mockRejectedValueOnce(new Error('Unavailable'));- const { result } = renderHook(() => useRejectionFeedback(target));- await act(() => result.current.open());- expect(result.current.result).toEqual({ status: 'rejected', gates: [] });+ describe.each(['rejected', 'failed', 'blocked'])('a manageable version with native status %s', (status) => {+ const source = { latestVersion: target.version, moderationStatus: status };+ const version = effectivePublishedStatus(source) === 'rejected' ? effectivePublishedStatusVersion(source) : null;++ it.each(['exception', 'error response'])('does not invent manual rejection on lookup %s', async (failure) => {+ if (failure === 'exception') getScanStatus.mockRejectedValueOnce(new Error('Unavailable'));+ else getScanStatus.mockResolvedValueOnce({ success: false, error: 'Unavailable' });+ const { result } = renderHook(() => useRejectionFeedback({ ...target, version }));+ await act(() => result.current.open());+ expect(getScanStatus).toHaveBeenCalledWith({ slug: target.name, version: target.version });+ expect(result.current.result).toEqual({+ status: 'scan_status_unavailable', gates: [{ name: 'scan-status', status: 'unavailable' }],+ });+ });++ it('preserves the native status when lookup succeeds without a rejection reason', async () => {+ getScanStatus.mockResolvedValueOnce({ success: true, status, gates: [] });+ const { result } = renderHook(() => useRejectionFeedback({ ...target, version }));+ await act(() => result.current.open());+ expect(result.current.result).toEqual({ status, gates: [], rejectionReason: undefined });+ });});});diff --git a/apps/desktop/src/renderer/features/skillhub/hooks/useRejectionFeedback.ts b/apps/desktop/src/renderer/features/skillhub/hooks/useRejectionFeedback.tsindex 7dec9d4677..24b7669a0b 100644--- a/apps/desktop/src/renderer/features/skillhub/hooks/useRejectionFeedback.ts+++ b/apps/desktop/src/renderer/features/skillhub/hooks/useRejectionFeedback.ts@@ -50,7 +50,7 @@ export function useRejectionFeedback({ entryKey, name, version, canManage }: Rejscope,result: response?.success? { status: response.status, gates: response.gates as ScanResultPayload['gates'], rejectionReason: response.rejectionReason }- : { status: 'rejected', gates: [] },+ : { status: 'scan_status_unavailable', gates: [{ name: 'scan-status', status: 'unavailable' }] },});}, [scope]);diff --git a/docs/dev-rules/protocol-compatibility.md b/docs/dev-rules/protocol-compatibility.mdindex 31e4b9ce10..38dd600e30 100644--- a/docs/dev-rules/protocol-compatibility.md+++ b/docs/dev-rules/protocol-compatibility.md@@ -134,6 +134,8 @@仅适用于 `rejected`,不能把处理失败 `failed` 或旧扫描失败 `blocked` 套进该例外。人工拒审原因缺省时始终明确提示缺省,即使已有自动扫描失败项;扫描发现继续独立展示,不能替代审核方提供的拒绝原因。管理读取失败版本不会改变其原始状态或套用人工拒审文案。+ `/scan` 读取失败与“已拒审但未提供原因”分开:详情和预览均回退为状态暂不可用,+ 不因请求失败合成 `rejected`;成功读取的旧记录仍保留真实状态与缺原因提示。- Skill 标签全部由 Platform 管理;客户端通过 Skill Tab 已有的 `/categories` 能力获取可选标签,发布和编辑时只在兼容字段 `tags: string[]` 中提交已存在的稳定 slug(可为空数组),不提交标签名称或多语言内容。- 服务端返回的 `tags` / `categories` 字段继续保持 wire 兼容,客户端不得再引入作者标签语义。