From 9ac28615db9cdf9f63c8b09bd2e82ce6dae3f378 Mon Sep 17 00:00:00 2001 From: Willie Date: Mon, 16 Nov 2026 23:49:06 +0800 Subject: [PATCH] fix(ui): count symlink-mode targets in the Skills list (#928) * fix(ui): count symlink-mode targets in the Skills list A symlink-mode target links the whole source folder, so every skill is live there. The skill detail page and the Sync page count it, but the Skills list read only `synced` matrix entries: the Targets column, the tree pane and the target filter left such a target out, and the Agents page reported a symlink-mode agent target as not supporting agents. A skill whose targets all had skills switched off was labelled "No agent targets", wording meant for agents. It now reads "Skills off". Nothing else reaches that label any more, so the key is removed. The list now applies receivesSkill, the same rule as the other pages. Closes #926 * fix(ui): rename the "All" target option to "No limit" The option clears a skill's own `targets:` field. Labelled "All", it read as "synced to every target", so a skill showing "All" next to a single target icon looked like a bug (#925). "No limit" says what the field does and pairs with the existing "Limited" tag. Closes #925 --- ui/src/i18n/locales/de.json | 3 +-- ui/src/i18n/locales/en.json | 3 +-- ui/src/i18n/locales/es.json | 3 +-- ui/src/i18n/locales/fa.json | 3 +-- ui/src/i18n/locales/fr.json | 3 +-- ui/src/i18n/locales/id.json | 3 +-- ui/src/i18n/locales/ja.json | 3 +-- ui/src/i18n/locales/ko.json | 3 +-- ui/src/i18n/locales/pt-BR.json | 3 +-- ui/src/i18n/locales/zh-CN.json | 3 +-- ui/src/i18n/locales/zh-TW.json | 3 +-- ui/src/lib/resourceGrouping.ts | 17 +++++++++++++++- ui/src/pages/ResourcesPage.test.tsx | 30 ++++++++++++++++++++++++++++- ui/src/pages/ResourcesPage.tsx | 16 +++++++-------- 14 files changed, 63 insertions(+), 33 deletions(-) diff --git a/ui/src/i18n/locales/de.json b/ui/src/i18n/locales/de.json index 76a1b57ae..8bb83977e 100644 --- a/ui/src/i18n/locales/de.json +++ b/ui/src/i18n/locales/de.json @@ -774,7 +774,6 @@ "resources.toast.enabled": "{kind} {name} aktiviert", "resources.toast.nowAvailableIn": "{name} jetzt verfügbar in {target}", "resources.tree.filteredOut.label": "Herausgefiltert", - "resources.tree.noAgentTargets.label": "Keine Agent-Ziele", "resources.tree.mixed": "Gemischte Ziele", "resources.tree.allDisabled": "alle deaktiviert", "resources.tree.someDisabled": "{count} deaktiviert", @@ -868,7 +867,7 @@ "syncResult.updated": "{count} aktualisiert", "syncResult.upToDate.one": "{count} Ziel ist bereits aktuell", "syncResult.upToDate.other": "{count} Ziele sind bereits aktuell", - "targetMenu.allTargets": "Alle", + "targetMenu.allTargets": "Uneingeschränkt", "targets.addTarget": "Ziel hinzufügen", "targets.sharedPath": "Agent-übergreifend", "targets.skillsOff": "Skills aus", diff --git a/ui/src/i18n/locales/en.json b/ui/src/i18n/locales/en.json index b22c026c2..0c7271c0f 100644 --- a/ui/src/i18n/locales/en.json +++ b/ui/src/i18n/locales/en.json @@ -767,7 +767,6 @@ "resources.toast.enabled": "{kind} {name} enabled", "resources.toast.nowAvailableIn": "{name} now available in {target}", "resources.tree.filteredOut.label": "Filtered out", - "resources.tree.noAgentTargets.label": "No agent targets", "resources.tree.mixed": "Mixed targets", "resources.tree.allDisabled": "all disabled", "resources.tree.someDisabled": "{count} disabled", @@ -842,7 +841,7 @@ "sync.result.why.config": "This target's settings are invalid, so it was skipped.", "sync.toast.failed.one": "Sync finished with {count} failure", "sync.toast.failed.other": "Sync finished with {count} failures", - "targetMenu.allTargets": "All", + "targetMenu.allTargets": "No limit", "targets.addTarget": "Add target", "targets.sharedPath": "Shared across agents", "targets.skillsOff": "Skills off", diff --git a/ui/src/i18n/locales/es.json b/ui/src/i18n/locales/es.json index 1d04bc8c5..3ae37d1be 100644 --- a/ui/src/i18n/locales/es.json +++ b/ui/src/i18n/locales/es.json @@ -774,7 +774,6 @@ "resources.toast.enabled": "{kind} {name} activado", "resources.toast.nowAvailableIn": "{name} ahora disponible en {target}", "resources.tree.filteredOut.label": "Filtrado", - "resources.tree.noAgentTargets.label": "Sin destinos de agentes", "resources.tree.mixed": "Destinos mixtos", "resources.tree.allDisabled": "todos deshabilitados", "resources.tree.someDisabled": "{count} deshabilitados", @@ -868,7 +867,7 @@ "syncResult.updated": "{count} actualizados", "syncResult.upToDate.one": "{count} destino ya está al día", "syncResult.upToDate.other": "{count} destinos ya están al día", - "targetMenu.allTargets": "Todos", + "targetMenu.allTargets": "Sin límite", "targets.addTarget": "Añadir destino", "targets.sharedPath": "Compartido entre Agents", "targets.skillsOff": "Skills desactivados", diff --git a/ui/src/i18n/locales/fa.json b/ui/src/i18n/locales/fa.json index bad238c0e..6edbb49b0 100644 --- a/ui/src/i18n/locales/fa.json +++ b/ui/src/i18n/locales/fa.json @@ -774,7 +774,6 @@ "resources.toast.enabled": "{kind} {name} فعال شد", "resources.toast.nowAvailableIn": "{name} اکنون در {target} در دسترس است", "resources.tree.filteredOut.label": "فیلتر شده", - "resources.tree.noAgentTargets.label": "هیچ هدف عاملی وجود ندارد", "resources.tree.mixed": "هدف‌های متفاوت", "resources.tree.allDisabled": "همه غیرفعال", "resources.tree.someDisabled": "{count} غیرفعال", @@ -868,7 +867,7 @@ "syncResult.updated": "{count} به‌روز شد", "syncResult.upToDate.one": "{count} هدف به‌روز است", "syncResult.upToDate.other": "{count} هدف به‌روز هستند", - "targetMenu.allTargets": "همه", + "targetMenu.allTargets": "بدون محدودیت", "targets.addTarget": "افزودن هدف", "targets.sharedPath": "مشترک بین Agentها", "targets.skillsOff": "Skills خاموش", diff --git a/ui/src/i18n/locales/fr.json b/ui/src/i18n/locales/fr.json index ac008e739..74071fe1f 100644 --- a/ui/src/i18n/locales/fr.json +++ b/ui/src/i18n/locales/fr.json @@ -774,7 +774,6 @@ "resources.toast.enabled": "{kind} {name} activé", "resources.toast.nowAvailableIn": "{name} maintenant disponible dans {target}", "resources.tree.filteredOut.label": "Filtré", - "resources.tree.noAgentTargets.label": "Aucune cible d'agent", "resources.tree.mixed": "Cibles mixtes", "resources.tree.allDisabled": "tous désactivés", "resources.tree.someDisabled": "{count} désactivé(s)", @@ -868,7 +867,7 @@ "syncResult.updated": "{count} mis à jour", "syncResult.upToDate.one": "{count} cible déjà à jour", "syncResult.upToDate.other": "{count} cibles déjà à jour", - "targetMenu.allTargets": "Tous", + "targetMenu.allTargets": "Sans restriction", "targets.addTarget": "Ajouter une cible", "targets.sharedPath": "Partagé entre Agents", "targets.skillsOff": "Skills désactivés", diff --git a/ui/src/i18n/locales/id.json b/ui/src/i18n/locales/id.json index 34ec8178f..553ec722c 100644 --- a/ui/src/i18n/locales/id.json +++ b/ui/src/i18n/locales/id.json @@ -774,7 +774,6 @@ "resources.toast.enabled": "{kind} {name} diaktifkan", "resources.toast.nowAvailableIn": "{name} sekarang tersedia di {target}", "resources.tree.filteredOut.label": "Difilter keluar", - "resources.tree.noAgentTargets.label": "Tidak ada target agen", "resources.tree.mixed": "Target campuran", "resources.tree.allDisabled": "semua nonaktif", "resources.tree.someDisabled": "{count} nonaktif", @@ -868,7 +867,7 @@ "syncResult.updated": "{count} diperbarui", "syncResult.upToDate.one": "{count} target sudah terbaru", "syncResult.upToDate.other": "{count} target sudah terbaru", - "targetMenu.allTargets": "Semua", + "targetMenu.allTargets": "Tanpa batas", "targets.addTarget": "Tambah Target", "targets.sharedPath": "Dipakai bersama antar Agent", "targets.skillsOff": "Skill nonaktif", diff --git a/ui/src/i18n/locales/ja.json b/ui/src/i18n/locales/ja.json index 2fcef691e..e4b594551 100644 --- a/ui/src/i18n/locales/ja.json +++ b/ui/src/i18n/locales/ja.json @@ -774,7 +774,6 @@ "resources.toast.enabled": "{kind} {name} を有効化しました", "resources.toast.nowAvailableIn": "{name} が {target} で利用可能になりました", "resources.tree.filteredOut.label": "除外済み", - "resources.tree.noAgentTargets.label": "エージェントターゲットなし", "resources.tree.mixed": "ターゲットが混在", "resources.tree.allDisabled": "すべて無効", "resources.tree.someDisabled": "{count} 件無効", @@ -868,7 +867,7 @@ "syncResult.updated": "{count} 件更新済み", "syncResult.upToDate.one": "{count} 件のターゲットは最新です", "syncResult.upToDate.other": "{count} 件のターゲットは最新です", - "targetMenu.allTargets": "すべて", + "targetMenu.allTargets": "限定なし", "targets.addTarget": "ターゲットを追加", "targets.sharedPath": "複数の Agent で共有", "targets.skillsOff": "Skills オフ", diff --git a/ui/src/i18n/locales/ko.json b/ui/src/i18n/locales/ko.json index 00bc30dff..593fc8de0 100644 --- a/ui/src/i18n/locales/ko.json +++ b/ui/src/i18n/locales/ko.json @@ -774,7 +774,6 @@ "resources.toast.enabled": "{kind} {name} 활성화됨", "resources.toast.nowAvailableIn": "{name}이(가) {target}에서 이제 사용 가능합니다", "resources.tree.filteredOut.label": "필터로 제외됨", - "resources.tree.noAgentTargets.label": "에이전트 대상 없음", "resources.tree.mixed": "대상 혼합", "resources.tree.allDisabled": "모두 비활성화됨", "resources.tree.someDisabled": "{count}개 비활성화됨", @@ -868,7 +867,7 @@ "syncResult.updated": "{count}개 업데이트됨", "syncResult.upToDate.one": "{count}개 대상은 이미 최신입니다", "syncResult.upToDate.other": "{count}개 대상은 이미 최신입니다", - "targetMenu.allTargets": "전체", + "targetMenu.allTargets": "제한 없음", "targets.addTarget": "대상 추가", "targets.sharedPath": "여러 Agent가 공유", "targets.skillsOff": "Skills 끔", diff --git a/ui/src/i18n/locales/pt-BR.json b/ui/src/i18n/locales/pt-BR.json index eb1aef222..aee1c1e30 100644 --- a/ui/src/i18n/locales/pt-BR.json +++ b/ui/src/i18n/locales/pt-BR.json @@ -774,7 +774,6 @@ "resources.toast.enabled": "{kind} {name} ativado", "resources.toast.nowAvailableIn": "{name} agora disponível em {target}", "resources.tree.filteredOut.label": "Filtrado", - "resources.tree.noAgentTargets.label": "Sem destinos de agentes", "resources.tree.mixed": "Destinos mistos", "resources.tree.allDisabled": "todos desativados", "resources.tree.someDisabled": "{count} desativados", @@ -868,7 +867,7 @@ "syncResult.updated": "{count} atualizado(s)", "syncResult.upToDate.one": "{count} destino já está atualizado", "syncResult.upToDate.other": "{count} destinos já estão atualizados", - "targetMenu.allTargets": "Todos", + "targetMenu.allTargets": "Sem limite", "targets.addTarget": "Adicionar Destino", "targets.sharedPath": "Compartilhado entre Agents", "targets.skillsOff": "Skills desativados", diff --git a/ui/src/i18n/locales/zh-CN.json b/ui/src/i18n/locales/zh-CN.json index 806d8310c..f7a152feb 100644 --- a/ui/src/i18n/locales/zh-CN.json +++ b/ui/src/i18n/locales/zh-CN.json @@ -774,7 +774,6 @@ "resources.toast.enabled": "{kind} {name} 已启用", "resources.toast.nowAvailableIn": "{name} 现已在 {target} 中可用", "resources.tree.filteredOut.label": "已被过滤", - "resources.tree.noAgentTargets.label": "无 agent 目标", "resources.tree.mixed": "目标不一致", "resources.tree.allDisabled": "全部已禁用", "resources.tree.someDisabled": "{count} 个已禁用", @@ -868,7 +867,7 @@ "syncResult.updated": "已更新 {count} 个", "syncResult.upToDate.one": "{count} 个目标已是最新", "syncResult.upToDate.other": "{count} 个目标已是最新", - "targetMenu.allTargets": "全部", + "targetMenu.allTargets": "不限定", "targets.addTarget": "添加目标", "targets.sharedPath": "多个 Agent 共用", "targets.skillsOff": "Skills 关闭", diff --git a/ui/src/i18n/locales/zh-TW.json b/ui/src/i18n/locales/zh-TW.json index af6ca030d..58f4fa619 100644 --- a/ui/src/i18n/locales/zh-TW.json +++ b/ui/src/i18n/locales/zh-TW.json @@ -774,7 +774,6 @@ "resources.toast.enabled": "{kind} {name} 已啟用", "resources.toast.nowAvailableIn": "{name} 現在可在 {target} 中使用", "resources.tree.filteredOut.label": "已被篩選排除", - "resources.tree.noAgentTargets.label": "無 agent 目標", "resources.tree.mixed": "目標不一致", "resources.tree.allDisabled": "全部已停用", "resources.tree.someDisabled": "{count} 個已停用", @@ -868,7 +867,7 @@ "syncResult.updated": "已更新 {count} 個", "syncResult.upToDate.one": "{count} 個目標已是最新", "syncResult.upToDate.other": "{count} 個目標已是最新", - "targetMenu.allTargets": "全部", + "targetMenu.allTargets": "不限定", "targets.addTarget": "新增目標", "targets.sharedPath": "多個 Agent 共用", "targets.skillsOff": "Skills 關閉", diff --git a/ui/src/lib/resourceGrouping.ts b/ui/src/lib/resourceGrouping.ts index e94c8f548..2cce2c970 100644 --- a/ui/src/lib/resourceGrouping.ts +++ b/ui/src/lib/resourceGrouping.ts @@ -1,6 +1,7 @@ import type { Skill, SourceLink, SyncMatrixEntry } from '../api/client'; import type { useT } from '../i18n'; import { resolveSource, type SourceType } from '../components/SourceBadge'; +import { receivesSkill } from '../components/sync/syncView'; import { parseRemoteURL } from './parseRemoteURL'; import { folderOf, formatTrackedRepoName } from './resourceNames'; @@ -25,7 +26,7 @@ export function syncedByTarget(items: Skill[], matrix: SyncMatrixEntry[]): Map s.flatName)); const byTarget = new Map>(); for (const e of matrix) { - if (e.status !== 'synced' || !names.has(e.skill)) continue; + if (!receivesSkill(e) || !names.has(e.skill)) continue; let set = byTarget.get(e.target); if (!set) byTarget.set(e.target, (set = new Set())); set.add(e.skill); @@ -36,6 +37,20 @@ export function syncedByTarget(items: Skill[], matrix: SyncMatrixEntry[]): Map (name.includes('@') ? name.slice(0, name.lastIndexOf('@')) : ''); +/** + * Where one item goes, from its matrix entries: the targets that get it, the projects it could + * sync to, and why it reaches no target: `off` when every target has skills switched off, + * `filtered` when filters or its own targets field keep it out. + */ +export function targetReach(entries: SyncMatrixEntry[]): { synced: string[]; reachable: string[]; none: 'off' | 'filtered' | null } { + const synced = entries.filter(receivesSkill).map((e) => e.target).sort(); + // 'na' without the symlink reason is a target with skills off: nothing can sync there. + const open = entries.filter((e) => e.status !== 'na' || receivesSkill(e)); + const reachable = [...new Set(open.map((e) => projectOf(e.target)).filter(Boolean))].sort(); + const none = synced.length > 0 || entries.length === 0 ? null : open.length === 0 ? 'off' : 'filtered'; + return { synced, reachable, none }; +} + /** * Folds each project's targets into one filter entry keyed `@`, holding what any of its * tools receives; global targets keep their own entries. diff --git a/ui/src/pages/ResourcesPage.test.tsx b/ui/src/pages/ResourcesPage.test.tsx index 91938e553..caab52695 100644 --- a/ui/src/pages/ResourcesPage.test.tsx +++ b/ui/src/pages/ResourcesPage.test.tsx @@ -7,7 +7,7 @@ import { api } from '../api/client'; import type { Skill, SyncMatrixEntry } from '../api/client'; import { I18nProvider } from '../i18n'; import { ToastProvider } from '../components/Toast'; -import { byTargetOrProject, splitTargets, syncedByTarget } from '../lib/resourceGrouping'; +import { byTargetOrProject, splitTargets, syncedByTarget, targetReach } from '../lib/resourceGrouping'; import ResourcesPage from './ResourcesPage'; vi.mock('../context/AppContext', () => ({ useAppContext: () => ({ isProjectMode: false }) })); @@ -24,6 +24,9 @@ const skill = (flatName: string): Skill => ({ const entry = (s: string, target: string, status: SyncMatrixEntry['status']): SyncMatrixEntry => ({ skill: s, target, status, reason: '' }); +// The matrix reports both as 'na': a symlinked folder carries every skill, a target with skills off gets none. +const symlinked = (s: string, target: string): SyncMatrixEntry => ({ ...entry(s, target, 'na'), reasonCode: 'sync_matrix.symlink_filters_not_applicable' }); +const skillsOff = (s: string, target: string) => entry(s, target, 'na'); describe('splitTargets', () => { it('groups project targets by project and keeps global tools apart', () => { @@ -58,6 +61,31 @@ describe('syncedByTarget', () => { expect([...index.keys()]).toEqual(['claude']); expect([...index.get('claude')!]).toEqual(['a', 'b']); }); + + it('counts a symlink-mode target but not one with skills off', () => { + const index = syncedByTarget([skill('a')], [symlinked('a', 'pi'), skillsOff('a', 'copilot')]); + + expect([...index.keys()]).toEqual(['pi']); + }); +}); + +describe('targetReach', () => { + it('lists a symlink-mode target among the targets that get the item', () => { + expect(targetReach([entry('a', 'claude', 'synced'), symlinked('a', 'pi'), skillsOff('a', 'copilot')]).synced).toEqual(['claude', 'pi']); + }); + + it.each([ + ['off', [skillsOff('a', 'copilot')]], + ['filtered', [skillsOff('a', 'copilot'), entry('a', 'claude', 'excluded')]], + [null, [symlinked('a', 'pi')]], + [null, []], + ] as const)('gives %s as the reason for reaching no target', (none, entries) => { + expect(targetReach([...entries]).none).toBe(none); + }); + + it('leaves a project with skills off out of the projects the item could reach', () => { + expect(targetReach([skillsOff('a', 'blog@claude'), entry('a', 'app@claude', 'not_included')]).reachable).toEqual(['app']); + }); }); /* -- Tree view ----------------------------------- */ diff --git a/ui/src/pages/ResourcesPage.tsx b/ui/src/pages/ResourcesPage.tsx index fb1b4bda2..b26464bf2 100644 --- a/ui/src/pages/ResourcesPage.tsx +++ b/ui/src/pages/ResourcesPage.tsx @@ -41,7 +41,7 @@ import { globToRegex } from '../lib/glob'; import { parseRemoteURL } from '../lib/parseRemoteURL'; import { folderOf, formatTrackedRepoName, resourceHref } from '../lib/resourceNames'; import { - byTargetOrProject, countLabel, groupByFolder, groupBySource, descendantCount, limitGroups, nestSkills, parentPath, projectOf, repoOf, sortSkills, sourceLinkOf, sourceName, splitTargets, syncedByTarget, withAncestors, + byTargetOrProject, countLabel, groupByFolder, groupBySource, descendantCount, limitGroups, nestSkills, parentPath, projectOf, repoOf, sortSkills, sourceLinkOf, sourceName, splitTargets, syncedByTarget, targetReach, withAncestors, SOURCE_LABEL, SOURCE_ORDER, type FolderGroup, type Group, type Nest, type SortType, type SourceFilter, } from '../lib/resourceGrouping'; @@ -396,7 +396,7 @@ export default function ResourcesPage({ kind }: { kind: Kind }) { const someSelected = !allSelected && filtered.some((s) => selected.has(s.flatName)); const trashCount = (trashData?.items ?? []).filter((i) => (i.kind ?? 'skill') === kind).length; - // Which targets can receive agents at all. Only agents get 'na' entries in the matrix. + // Which targets can receive agents at all: the matrix has agent entries only for those. const agentSupport = useMemo(() => { if (!isAgent) return null; const names = new Set(items.map((s) => s.flatName)); @@ -404,20 +404,18 @@ export default function ResourcesPage({ kind }: { kind: Kind }) { const supported = new Set(); for (const e of matrix) { targets.add(e.target); - if (names.has(e.skill) && e.status !== 'na') supported.add(e.target); + if (names.has(e.skill)) supported.add(e.target); } return { supported: [...supported].sort(), total: targets.size }; }, [isAgent, items, matrix]); const rowInfo = (s: Skill): { synced: string[]; reachable: string[]; tone: Tone; label: string } => { const entries = getSkillTargets(s.flatName); - const synced = entries.filter((e) => e.status === 'synced').map((e) => e.target).sort(); - const applicable = entries.some((e) => e.status !== 'na'); - // Projects this item could sync to, whether or not it does: the tooltip names the ones it misses. - const reachable = [...new Set(entries.filter((e) => e.status !== 'na').map((e) => projectOf(e.target)).filter(Boolean))].sort(); + // `reachable`: projects this item could sync to, whether or not it does. The tooltip names the ones it misses. + const { synced, reachable, none } = targetReach(entries); if (s.disabled) return { synced, reachable, tone: 'off', label: t('resources.status.disabled') }; - if (entries.length > 0 && !applicable) return { synced, reachable, tone: 'off', label: t('resources.tree.noAgentTargets.label') }; - if (applicable && synced.length === 0) return { synced, reachable, tone: 'off', label: t('resources.tree.filteredOut.label') }; + if (none === 'off') return { synced, reachable, tone: 'off', label: t('targets.skillsOff') }; + if (none === 'filtered') return { synced, reachable, tone: 'off', label: t('resources.tree.filteredOut.label') }; return { synced, reachable, tone: 'ok', label: t('resources.status.enabled') }; }; const syncedCell = (s: Skill) => {