mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-18 18:04:17 +00:00
fix(ui): show a target with skills off as off on the skill page (#927)
The sync matrix reports a target as `na` both when it is in symlink mode and when skills are switched off for it. The skill detail page read every `na` as symlink mode, so a skills-off target showed "Symlink mode, filters do not apply" with its switch on and counted toward "4 of 4", although nothing syncs there. Next to a Skills list that shows only the targets the skill reaches, the two pages contradicted each other (#925). Use receivesSkill, the rule the Sync page already applies, so only a symlinked folder counts as carrying the skill, and label the other case "Skills off".
This commit is contained in:
@@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { api, type DiffTarget, type Target } from '../../api/client';
|
||||
import { hooksApi, type HookPlan } from '../../api/hooks';
|
||||
import { mcpApi, type MCPPlan } from '../../api/mcp';
|
||||
import { changeSets, countChanges, countEdited, discardable, extraGroups, failureExplanation, groupByFolder, groupInSync, HOOKS_CHANGED, hooksGroups, MCP_CHANGED, mcpGroups, otherWarnings, pendingCount, resourceGroups, runSync, skippedHintKeys, type SyncFailure } from './syncView';
|
||||
import { changeSets, countChanges, countEdited, discardable, extraGroups, failureExplanation, groupByFolder, groupInSync, HOOKS_CHANGED, hooksGroups, MCP_CHANGED, mcpGroups, otherWarnings, pendingCount, receivesSkill, resourceGroups, runSync, skippedHintKeys, type SyncFailure } from './syncView';
|
||||
|
||||
vi.mock('../../api/client', async (load) => ({ ...await load<typeof import('../../api/client')>(), api: { sync: vi.fn(), syncExtras: vi.fn() } }));
|
||||
vi.mock('../../api/mcp', async (load) => ({ ...await load<typeof import('../../api/mcp')>(), mcpApi: { preview: vi.fn(), configure: vi.fn() } }));
|
||||
@@ -318,3 +318,13 @@ describe('skippedHintKeys', () => {
|
||||
expect(skippedHintKeys({ target: 'codex', items: [], ...counts })).toEqual(key);
|
||||
});
|
||||
});
|
||||
|
||||
// The matrix reports both as 'na'; only a symlinked folder carries the skill (issue #925).
|
||||
describe('receivesSkill', () => {
|
||||
it.each([
|
||||
['symlink mode — filters not applicable', 'sync_matrix.symlink_filters_not_applicable', true],
|
||||
['skills off for this target', undefined, false],
|
||||
])('reads %s as %s → %s', (reason, reasonCode, expected) => {
|
||||
expect(receivesSkill({ skill: 'pdf', target: 'copilot', status: 'na', reason, reasonCode })).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -19,6 +19,7 @@ import { repoOf, sourceLinkOf } from '../lib/resourceGrouping';
|
||||
import { targetFilterPatch } from '../lib/targetFilter';
|
||||
import { useSyncMatrix } from '../hooks/useSyncMatrix';
|
||||
import { projectUrl } from '../components/projects/projectView';
|
||||
import { receivesSkill } from '../components/sync/syncView';
|
||||
import { formatDateTime, formatRelativeTime, useI18n, useT, plural } from '../i18n';
|
||||
import AgentIcon from '../components/AgentIcon';
|
||||
import Button from '../components/Button';
|
||||
@@ -586,7 +587,7 @@ function TargetsSection({ resource }: { resource: Skill }) {
|
||||
const entry = entries.get(target.name);
|
||||
const action = diffQuery.data?.diffs.find((d) => d.target === target.name)?.items
|
||||
.find((i) => i.skill === resource.flatName && (i.kind ?? 'skill') === 'skill')?.action;
|
||||
return { target, entry, action, on: entry?.status === 'synced' || entry?.status === 'na' };
|
||||
return { target, entry, action, on: !!entry && receivesSkill(entry) };
|
||||
});
|
||||
const supported = rows.filter((r) => r.entry);
|
||||
|
||||
@@ -620,7 +621,8 @@ function TargetsSection({ resource }: { resource: Skill }) {
|
||||
case 'skill_target_mismatch':
|
||||
return t('resourceDetail.targets.mismatch');
|
||||
case 'na':
|
||||
return t('resourceDetail.targets.symlink');
|
||||
// Skills switched off for the target is 'na' too, but nothing syncs there.
|
||||
return t(receivesSkill(entry) ? 'resourceDetail.targets.symlink' : 'targets.skillsOff');
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@@ -695,7 +697,7 @@ export function ProjectsList({ resource, diffs, statusText }: {
|
||||
}
|
||||
const projects = [...byProject.values()].sort((a, b) => a.name.localeCompare(b.name));
|
||||
if (projects.length === 0) return null;
|
||||
const on = (p: (typeof projects)[number]) => p.rows.some((r) => r.entry.status === 'synced' || r.entry.status === 'na');
|
||||
const on = (p: (typeof projects)[number]) => p.rows.some((r) => receivesSkill(r.entry));
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user