diff --git a/cmd/skillshare/doctor_shared_paths.go b/cmd/skillshare/doctor_shared_paths.go index 0b8da5238..69af581d9 100644 --- a/cmd/skillshare/doctor_shared_paths.go +++ b/cmd/skillshare/doctor_shared_paths.go @@ -99,7 +99,7 @@ func checkSharedTargetPaths(cfg *config.Config, result *doctorResult, isProject }) conflicts := make(map[string]config.SkillsFolderConflict) - for _, c := range config.SkillsFolderConflicts(cfg.Targets) { + for _, c := range config.SkillsFolderConflicts(cfg.Targets, cfg.Mode) { conflicts[c.Path] = c } @@ -109,7 +109,7 @@ func checkSharedTargetPaths(cfg *config.Config, result *doctorResult, isProject detail := fmt.Sprintf("%s ← %s", c.path, strings.Join(c.targets, ", ")) suggestion := sharedTargetPathsSuggestion(c.path, c.targets, isProject) if conflict, ok := conflicts[c.path]; ok { - detail += " (different filters, so they undo each other on every sync)" + detail += " (different settings, so they undo each other on every sync)" suggestion = folderConflictSuggestion(conflict, isProject) } ui.Warning("Shared path %s", detail) diff --git a/cmd/skillshare/sync_overlap_hint.go b/cmd/skillshare/sync_overlap_hint.go index 5ca9b4789..9c0140150 100644 --- a/cmd/skillshare/sync_overlap_hint.go +++ b/cmd/skillshare/sync_overlap_hint.go @@ -20,8 +20,8 @@ func printSyncOverlapHint(targets map[string]config.TargetConfig, isProject, jso return } explained := map[string]bool{} - for _, c := range config.SkillsFolderConflicts(targets) { - ui.Warning("%s sync skills to %s with different filters, so each sync undoes the other", + for _, c := range config.SkillsFolderConflicts(targets, defaultMode) { + ui.Warning("%s sync skills to %s with different settings, so each sync undoes the other", joinAnd(c.Targets), shortenPath(c.Path)) for _, name := range c.Stop { fmt.Println(ui.DimText(" keep one: " + skillsOffCommand(name, isProject))) diff --git a/cmd/skillshare/sync_overlap_hint_test.go b/cmd/skillshare/sync_overlap_hint_test.go index 8c426269e..76e056c4b 100644 --- a/cmd/skillshare/sync_overlap_hint_test.go +++ b/cmd/skillshare/sync_overlap_hint_test.go @@ -18,7 +18,7 @@ func TestPrintSyncOverlapHint_NamesConflictAndFix(t *testing.T) { out := captureStdout(t, func() { printSyncOverlapHint(targets, true, false, "", nil) }) for _, want := range []string{ - "codex and universal sync skills to " + filepath.FromSlash("/tmp/agents/skills") + " with different filters, so each sync undoes the other", + "codex and universal sync skills to " + filepath.FromSlash("/tmp/agents/skills") + " with different settings, so each sync undoes the other", "keep one: skillshare target codex --skills=false -p", } { if !strings.Contains(out, want) { diff --git a/internal/config/path_overlap.go b/internal/config/path_overlap.go index b90ce853a..57c2c9ce1 100644 --- a/internal/config/path_overlap.go +++ b/internal/config/path_overlap.go @@ -1,6 +1,7 @@ package config import ( + "cmp" "path/filepath" "slices" "sort" @@ -98,8 +99,8 @@ func SkillsPathKeptBy(targets map[string]TargetConfig, name string, leaving map[ } // SkillsFolderConflict is a skills folder that two or more targets with skills -// on sync into with different include or exclude filters, so each sync -// undoes the others' links. Keep is the target to leave on; Stop the rest. +// on sync into with different settings, so each sync undoes the others' +// links. Keep is the target to leave on; Stop the rest. type SkillsFolderConflict struct { Path string `json:"path"` Targets []string `json:"targets"` @@ -108,10 +109,11 @@ type SkillsFolderConflict struct { } // SkillsFolderConflicts returns the shared skills folders whose targets' -// filters differ, sorted by path. Targets with identical settings agree on -// the folder's contents and are not a conflict. universal is kept when it is -// in the group, otherwise the alphabetically first target. -func SkillsFolderConflicts(targets map[string]TargetConfig) []SkillsFolderConflict { +// settings differ, sorted by path. defaultMode is the global mode a target +// without its own inherits. Targets with identical settings agree on the +// folder's contents and are not a conflict. universal is kept when it is in +// the group, otherwise the alphabetically first target. +func SkillsFolderConflicts(targets map[string]TargetConfig, defaultMode string) []SkillsFolderConflict { byFolder := make(map[string][]string) for name, tc := range targets { if !tc.SkillsConfig().IsEnabled() { @@ -132,7 +134,7 @@ func SkillsFolderConflicts(targets map[string]TargetConfig) []SkillsFolderConfli differ := false for _, n := range names[1:] { other := targets[n] - if !sameSkillsSettings(first.SkillsConfig(), other.SkillsConfig()) { + if !sameSkillsSettings(first.SkillsConfig(), other.SkillsConfig(), defaultMode) { differ = true break } @@ -156,8 +158,17 @@ func SkillsFolderConflicts(targets map[string]TargetConfig) []SkillsFolderConfli return out } -func sameSkillsSettings(a, b ResourceTargetConfig) bool { - return sameSet(a.Include, b.Include) && sameSet(a.Exclude, b.Exclude) +func sameSkillsSettings(a, b ResourceTargetConfig, defaultMode string) bool { + mode := cmp.Or(a.Mode, defaultMode, "merge") + if mode != cmp.Or(b.Mode, defaultMode, "merge") { + return false + } + // symlink mode links the whole folder to the source, so no per-skill setting applies. + if mode == "symlink" { + return true + } + return EffectiveTargetNaming(a.TargetNaming) == EffectiveTargetNaming(b.TargetNaming) && + sameSet(a.Include, b.Include) && sameSet(a.Exclude, b.Exclude) } func sameSet(a, b []string) bool { diff --git a/internal/config/path_overlap_test.go b/internal/config/path_overlap_test.go index 37992b7f8..d88e42d48 100644 --- a/internal/config/path_overlap_test.go +++ b/internal/config/path_overlap_test.go @@ -67,7 +67,7 @@ func TestSkillsFolderConflicts_DifferentFilters(t *testing.T) { "universal": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills", Exclude: []string{"feature-radar*"}}}, "codex": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills/"}}, "claude": {Skills: &ResourceTargetConfig{Path: "/tmp/claude/skills"}}, - }) + }, "") want := []SkillsFolderConflict{{Path: "/tmp/agents/skills", Targets: []string{"codex", "universal"}, Keep: "universal", Stop: []string{"codex"}}} if !slices.EqualFunc(got, want, conflictEqual) { t.Errorf("SkillsFolderConflicts = %+v, want %+v", got, want) @@ -78,7 +78,7 @@ func TestSkillsFolderConflicts_SameSettingsNoConflict(t *testing.T) { got := SkillsFolderConflicts(map[string]TargetConfig{ "universal": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills", Include: []string{"a", "b"}}}, "codex": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills", Include: []string{"b", "a"}}}, - }) + }, "") if len(got) != 0 { t.Errorf("expected no conflict, got %+v", got) } @@ -89,18 +89,80 @@ func TestSkillsFolderConflicts_DifferentFiltersKeepsFirstName(t *testing.T) { "warp": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills", Include: []string{"x*"}}}, "amp": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills"}}, "witsy": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills"}}, - }) + }, "") want := []SkillsFolderConflict{{Path: "/tmp/agents/skills", Targets: []string{"amp", "warp", "witsy"}, Keep: "amp", Stop: []string{"warp", "witsy"}}} if !slices.EqualFunc(got, want, conflictEqual) { t.Errorf("SkillsFolderConflicts = %+v, want %+v", got, want) } } +func TestSkillsFolderConflicts_DifferentTargetNaming(t *testing.T) { + got := SkillsFolderConflicts(map[string]TargetConfig{ + "aflat": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills", Mode: "merge", TargetNaming: "flat"}}, + "bstd": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills", Mode: "merge", TargetNaming: "standard"}}, + }, "") + want := []SkillsFolderConflict{{Path: "/tmp/agents/skills", Targets: []string{"aflat", "bstd"}, Keep: "aflat", Stop: []string{"bstd"}}} + if !slices.EqualFunc(got, want, conflictEqual) { + t.Errorf("SkillsFolderConflicts = %+v, want %+v", got, want) + } +} + +func TestSkillsFolderConflicts_DifferentMode(t *testing.T) { + got := SkillsFolderConflicts(map[string]TargetConfig{ + "amerge": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills", Mode: "merge"}}, + "bcopy": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills", Mode: "copy"}}, + }, "") + want := []SkillsFolderConflict{{Path: "/tmp/agents/skills", Targets: []string{"amerge", "bcopy"}, Keep: "amerge", Stop: []string{"bcopy"}}} + if !slices.EqualFunc(got, want, conflictEqual) { + t.Errorf("SkillsFolderConflicts = %+v, want %+v", got, want) + } +} + +func TestSkillsFolderConflicts_SymlinkIgnoresTargetNaming(t *testing.T) { + got := SkillsFolderConflicts(map[string]TargetConfig{ + "aflat": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills", Mode: "symlink", TargetNaming: "flat"}}, + "bstd": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills", TargetNaming: "standard"}}, + }, "symlink") + if len(got) != 0 { + t.Errorf("expected no conflict, got %+v", got) + } +} + +func TestSkillsFolderConflicts_SymlinkIgnoresFilters(t *testing.T) { + got := SkillsFolderConflicts(map[string]TargetConfig{ + "universal": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills", Mode: "symlink", Exclude: []string{"x"}}}, + "codex": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills", Mode: "symlink"}}, + }, "") + if len(got) != 0 { + t.Errorf("expected no conflict, got %+v", got) + } +} + +func TestSkillsFolderConflicts_UnsetEqualsDefault(t *testing.T) { + got := SkillsFolderConflicts(map[string]TargetConfig{ + "unset": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills"}}, + "explicit": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills", Mode: "merge", TargetNaming: "flat"}}, + }, "") + if len(got) != 0 { + t.Errorf("expected no conflict, got %+v", got) + } +} + +func TestSkillsFolderConflicts_UnsetModeInheritsDefault(t *testing.T) { + got := SkillsFolderConflicts(map[string]TargetConfig{ + "unset": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills"}}, + "explicit": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills", Mode: "copy"}}, + }, "copy") + if len(got) != 0 { + t.Errorf("expected no conflict, got %+v", got) + } +} + func TestSkillsFolderConflicts_IgnoresSkillsOff(t *testing.T) { got := SkillsFolderConflicts(map[string]TargetConfig{ "universal": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills", Exclude: []string{"x"}}}, "codex": disabledAt("/tmp/agents/skills"), - }) + }, "") if len(got) != 0 { t.Errorf("expected no conflict with skills off, got %+v", got) } @@ -109,3 +171,21 @@ func TestSkillsFolderConflicts_IgnoresSkillsOff(t *testing.T) { func conflictEqual(a, b SkillsFolderConflict) bool { return filepath.ToSlash(a.Path) == filepath.ToSlash(b.Path) && a.Keep == b.Keep && slices.Equal(a.Targets, b.Targets) && slices.Equal(a.Stop, b.Stop) } + +func TestSkillsSharedWith(t *testing.T) { + targets := map[string]TargetConfig{ + "universal": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills"}}, + "codex": {Skills: &ResourceTargetConfig{Path: "/tmp/agents/skills/"}}, + "off": disabledAt("/tmp/agents/skills"), + "claude": {Skills: &ResourceTargetConfig{Path: "/tmp/claude/skills"}}, + } + if got := SkillsSharedWith(targets, "universal"); !slices.Equal(got, []string{"codex"}) { + t.Errorf("SkillsSharedWith(universal) = %v, want [codex]", got) + } + if got := SkillsSharedWith(targets, "off"); got != nil { + t.Errorf("SkillsSharedWith(off) = %v, want nil for a target with skills off", got) + } + if got := SkillsSharedWith(targets, "claude"); got != nil { + t.Errorf("SkillsSharedWith(claude) = %v, want nil", got) + } +} diff --git a/internal/config/skills_readers.go b/internal/config/skills_readers.go index 023880367..556b6f0ec 100644 --- a/internal/config/skills_readers.go +++ b/internal/config/skills_readers.go @@ -33,6 +33,27 @@ func SkillsAlsoReadBy(targets map[string]TargetConfig, name, projectRoot string) return names } +// SkillsSharedWith names the other targets with skills on that write to the +// same skills folder as target name, or nil when name has skills off itself. +func SkillsSharedWith(targets map[string]TargetConfig, name string) []string { + tc, ok := targets[name] + if !ok || !tc.SkillsConfig().IsEnabled() { + return nil + } + folder := skillsFolder(tc) + if folder == "" { + return nil + } + var names []string + for other, otc := range targets { + if other != name && otc.SkillsConfig().IsEnabled() && skillsFolder(otc) == folder { + names = append(names, other) + } + } + sort.Strings(names) + return names +} + // SkillsReadFrom names the configured targets with skills on whose skills // folder the built-in tool name reads. name need not be configured, so the // add-target list can say a tool already sees another target's skills. diff --git a/internal/server/handler_sync.go b/internal/server/handler_sync.go index 45d313d03..338b03ccf 100644 --- a/internal/server/handler_sync.go +++ b/internal/server/handler_sync.go @@ -140,8 +140,8 @@ type syncOutcome struct { // folderConflicts returns the skills folders whose targets undo each other's // sync, never nil, plus how many targets overlap in a way they don't explain. // harmless is passed on to config.DetectPathOverlap. -func folderConflicts(targets map[string]config.TargetConfig, isProject bool, harmless func(scanner, writer string) bool) ([]config.SkillsFolderConflict, int) { - conflicts := config.SkillsFolderConflicts(targets) +func folderConflicts(targets map[string]config.TargetConfig, isProject bool, defaultMode string, harmless func(scanner, writer string) bool) ([]config.SkillsFolderConflict, int) { + conflicts := config.SkillsFolderConflicts(targets, defaultMode) explained := map[string]bool{} for _, c := range conflicts { for _, name := range c.Targets { @@ -406,7 +406,7 @@ func (s *Server) syncResources(start time.Time, dryRun, force bool, kind, projec } s.writeOpsLog("sync", status, start, logArgs, "") - conflicts, overlap := folderConflicts(s.cfg.Targets, s.IsProjectMode(), + conflicts, overlap := folderConflicts(s.cfg.Targets, s.IsProjectMode(), globalMode, ssync.HarmlessOverlap(s.cfg.Targets, globalMode, allSkills)) // Targets sync from a map; a fixed order keeps the dashboard's notices still. slices.SortFunc(unmatched, func(a, b unmatchedInclude) int { return strings.Compare(a.Target, b.Target) }) @@ -614,7 +614,7 @@ func (s *Server) handleDiff(w http.ResponseWriter, r *http.Request) { globalMode := s.cfg.Mode ignorePatterns := ssync.EffectiveFileIgnorePatterns(s.cfg.Ignore) targets := s.cloneTargets() - conflicts, _ := folderConflicts(targets, s.IsProjectMode(), nil) + conflicts, _ := folderConflicts(targets, s.IsProjectMode(), globalMode, nil) s.mu.RUnlock() if globalMode == "" { diff --git a/internal/server/handler_targets.go b/internal/server/handler_targets.go index 92719e632..fc3787346 100644 --- a/internal/server/handler_targets.go +++ b/internal/server/handler_targets.go @@ -50,6 +50,9 @@ type targetItem struct { // skills off whose tool reads this target's folder. SkillsReadFrom []string `json:"skillsReadFrom,omitempty"` SkillsAlsoReadBy []string `json:"skillsAlsoReadBy,omitempty"` + // SkillsSharedWith names the other targets with skills on that write to this + // target's skills folder, so the page can warn when their settings differ. + SkillsSharedWith []string `json:"skillsSharedWith,omitempty"` } var removeTargetPath = os.Remove @@ -173,6 +176,7 @@ func (s *Server) handleListTargets(w http.ResponseWriter, r *http.Request) { item.Status = status.String() } item.SkillsAlsoReadBy = config.SkillsAlsoReadBy(targets, name, projectRoot) + item.SkillsSharedWith = config.SkillsSharedWith(targets, name) var agentSummary *targetsummary.AgentSummary if isProjectMode { diff --git a/internal/server/handler_targets_skills_test.go b/internal/server/handler_targets_skills_test.go index a5eee2385..5ed379661 100644 --- a/internal/server/handler_targets_skills_test.go +++ b/internal/server/handler_targets_skills_test.go @@ -44,6 +44,7 @@ type skillsTargetItem struct { SkillsEnabled bool `json:"skillsEnabled"` SkillsReadFrom []string `json:"skillsReadFrom"` SkillsAlsoReadBy []string `json:"skillsAlsoReadBy"` + SkillsSharedWith []string `json:"skillsSharedWith"` LinkedCount int `json:"linkedCount"` } @@ -99,6 +100,19 @@ func TestSkillsOffPreview_SharedFolder(t *testing.T) { } } +func TestListTargets_NamesTargetsSharingASkillsFolder(t *testing.T) { + shared := filepath.Join(t.TempDir(), "agents", "skills") + s, _ := newTestServerWithTargets(t, map[string]string{"universal": shared, "codex": shared, "claude": filepath.Join(t.TempDir(), "claude", "skills")}) + + items := listSkillsTargets(t, s) + if !slices.Equal(items["universal"].SkillsSharedWith, []string{"codex"}) || !slices.Equal(items["codex"].SkillsSharedWith, []string{"universal"}) { + t.Errorf("universal = %+v, codex = %+v", items["universal"], items["codex"]) + } + if len(items["claude"].SkillsSharedWith) != 0 { + t.Errorf("claude = %+v, want no sharing", items["claude"]) + } +} + func TestUpdateTarget_SkillsOffDetachesAndPersists(t *testing.T) { s, _, _, gemini := newSkillsOffServer(t) diff --git a/skills/skillshare/references/targets.md b/skills/skillshare/references/targets.md index 449a9c3c4..60c4fffee 100644 --- a/skills/skillshare/references/targets.md +++ b/skills/skillshare/references/targets.md @@ -77,7 +77,7 @@ a folder an enabled target also writes to is left alone. `sync`/`diff`/`status`/ skip the target's skills. `--skills` cannot be combined with include/exclude flags in one command. Works with `-p`. -When `sync` warns that two targets "sync skills to with different filters, so each +When `sync` warns that two targets "sync skills to with different settings, so each sync undoes the other", run the `skillshare target --skills=false` it prints. ## Project Targets (`-p`) diff --git a/tests/integration/sync_shared_path_test.go b/tests/integration/sync_shared_path_test.go index 9ee928750..9009cd0b7 100644 --- a/tests/integration/sync_shared_path_test.go +++ b/tests/integration/sync_shared_path_test.go @@ -280,7 +280,7 @@ targets: } // TestSync_SharedPath_DifferentFiltersWarns covers two targets sharing a -// skills folder with different filters: each sync undoes the other, so sync +// skills folder with different settings: each sync undoes the other, so sync // names them and says how to keep one. func TestSync_SharedPath_DifferentFiltersWarns(t *testing.T) { sb := testutil.NewSandbox(t) @@ -305,7 +305,7 @@ targets: result := sb.RunCLI("sync") result.AssertSuccess(t) - result.AssertOutputContains(t, "codex and universal sync skills to ~/.agents/skills with different filters, so each sync undoes the other") + result.AssertOutputContains(t, "codex and universal sync skills to ~/.agents/skills with different settings, so each sync undoes the other") result.AssertOutputContains(t, "keep one: skillshare target codex --skills=false") result.AssertOutputNotContains(t, "Skill path overlap") } diff --git a/ui/src/api/types/targets.ts b/ui/src/api/types/targets.ts index e8a9ac9d6..caf54a129 100644 --- a/ui/src/api/types/targets.ts +++ b/ui/src/api/types/targets.ts @@ -67,6 +67,8 @@ export interface Target { skillsReadFrom?: string[]; /** Targets with skills off that read this target's skills folder. */ skillsAlsoReadBy?: string[]; + /** Other targets with skills on that write to this target's skills folder. */ + skillsSharedWith?: string[]; } export interface SkillsDetach { diff --git a/ui/src/components/sync/FolderConflictNotice.tsx b/ui/src/components/sync/FolderConflictNotice.tsx new file mode 100644 index 000000000..8736feeef --- /dev/null +++ b/ui/src/components/sync/FolderConflictNotice.tsx @@ -0,0 +1,77 @@ +import { TriangleAlert } from 'lucide-react'; +import type { FolderConflict, Target } from '../../api/client'; +import { useI18n, useT } from '../../i18n'; +import { shortenHome } from '../../lib/paths'; +import Button from '../Button'; +import { NAMES, TargetLinks } from '../targets/FilterSection'; +import { joinList } from '../targets/targetView'; + +/** Include and exclude as a short phrase; sorted, because the server compares them as sets. */ +function filterSummary(x: Target, t: ReturnType, locale: string) { + const parts = [ + x.include.length > 0 && t('sync.folderConflict.filters.include', { names: joinList([...x.include].sort(), locale) }), + x.exclude.length > 0 && t('sync.folderConflict.filters.exclude', { names: joinList([...x.exclude].sort(), locale) }), + ].filter(Boolean); + return parts.length > 0 ? parts.join(' · ') : t('sync.folderConflict.filters.all'); +} + +/** A folder that targets sync into with different settings: what to stop, and which settings differ. */ +export default function FolderConflictNotice({ conflict, targets, onStop }: { conflict: FolderConflict; targets: Target[]; onStop: (name: string) => void }) { + const t = useT(); + const { locale } = useI18n(); + // The target kept first, as its column. + const columns = [conflict.keep, ...conflict.stop].map((name) => targets.find((x) => x.name === name)).filter((x): x is Target => !!x); + // Symlink links the whole folder, so naming and filters say nothing there (null). + const rows = [ + { key: 'mode', label: 'targetDetail.syncMode', tag: true, value: (x: Target) => x.mode }, + { key: 'naming', label: 'targetDetail.naming', tag: true, value: (x: Target) => (x.mode === 'symlink' ? null : x.targetNaming) }, + { key: 'filters', label: 'sync.folderConflict.filters', tag: false, value: (x: Target) => (x.mode === 'symlink' ? null : filterSummary(x, t, locale)) }, + ].filter((r) => new Set(columns.map(r.value).filter((v) => v !== null)).size > 1); + + return ( +
+
+ + {t('sync.folderConflict.text', { names: joinList(conflict.targets, locale), path: shortenHome(conflict.path) })} + {conflict.stop.map((name) => ( + + ))} +
+ {rows.length > 0 && ( +
+ + {columns.map((x) => )} + + + + ))} + + + + {rows.map((r) => ( + + + {columns.map((x) => { + const v = r.value(x); + return ( + + ); + })} + + ))} + +
+ {x.name === conflict.keep ? t('sync.folderConflict.keeps', { name: x.name }) : x.name} +
{t(r.label)} + {v === null ? t('sync.folderConflict.na') : r.tag ? {v} : v} +
+
+
+ )} +
+ ); +} diff --git a/ui/src/components/targets/FilterSection.tsx b/ui/src/components/targets/FilterSection.tsx index 67c0c7718..2c37fb541 100644 --- a/ui/src/components/targets/FilterSection.tsx +++ b/ui/src/components/targets/FilterSection.tsx @@ -177,27 +177,34 @@ export function ModePicker({ kind, mode, onChange, disabled }: { kind: Kind; mod } // Stands in for the names in a sentence, which are then put back as links. -const NAMES = '\u0000'; +export const NAMES = '\u0000'; + +/** A sentence with its NAMES placeholder replaced by links to those targets. */ +export function TargetLinks({ sentence, names }: { sentence: string; names: string[] }) { + const t = useT(); + const [before, after = ''] = sentence.split(NAMES); + return ( +

+ {before} + {names.map((n, i) => ( + + {i > 0 && t('instructions.shared.listSep')} + {n} + + ))} + {after} +

+ ); +} /** Other targets tied to this folder, as a note so it does not read as a filter pattern. */ function TargetRow({ sentence, names }: { sentence: string; names: string[] }) { - const t = useT(); - const [before, after = ''] = sentence.split(NAMES); return (
-

- {before} - {names.map((n, i) => ( - - {i > 0 && t('instructions.shared.listSep')} - {n} - - ))} - {after} -

+
); } diff --git a/ui/src/i18n/locales/de.json b/ui/src/i18n/locales/de.json index 5d4b4f246..2b2fcec88 100644 --- a/ui/src/i18n/locales/de.json +++ b/ui/src/i18n/locales/de.json @@ -1784,7 +1784,7 @@ "targetDetail.mode.merge.skill": "Ein Symlink pro Skill. Skills, die du in diesem Ziel erstellt hast, bleiben unberührt.", "targetDetail.mode.merge.agent": "Ein Symlink pro Agent-Datei. Agents, die du in diesem Ziel erstellt hast, bleiben unberührt.", "targetDetail.mode.copy": "Echte Kopien. Für Tools, die Symlinks nicht folgen können.", - "targetDetail.mode.symlink": "Der ganze Ordner wird zu einem Symlink. Filter gelten in diesem Modus nicht.", + "targetDetail.mode.symlink": "Der ganze Ordner wird zu einem Symlink. Filter und Benennung gelten in diesem Modus nicht.", "targetDetail.naming": "Benennung", "targetDetail.namingFlat": "Verschachtelte Skills bekommen flache, mit __ verbundene Namen.", "targetDetail.namingStandard": "Skills verwenden den Namen aus SKILL.md.", @@ -1792,6 +1792,11 @@ "targetDetail.prefixedNeedsCopy": "prefixed braucht den copy-Modus, weil es den Namen in jeder Kopie umschreibt.", "targetDetail.prefixedNeedsCopyTitle": "Braucht den copy-Modus", "targetDetail.pending": "ausstehend", + "targetDetail.shared.mode": "{other} synchronisiert ebenfalls Skills nach {path}, mit {theirs}. Mit {mine} würde jede Synchronisierung die andere rückgängig machen.", + "targetDetail.shared.naming": "{other} synchronisiert ebenfalls Skills nach {path}, mit {theirs}-Benennung. Mit {mine} würde jede Synchronisierung die andere rückgängig machen.", + "targetDetail.shared.use": "{value} wie {other} verwenden", + "targetDetail.shared.filters": "{other} synchronisiert ebenfalls Skills nach {path}, mit anderen Filtern. Jede Synchronisierung würde wieder hinzufügen oder entfernen, was die andere herausfiltert.", + "targetDetail.shared.useFilters": "Dieselben Filter wie {other} verwenden", "targetDetail.skipped.one": "{count} Skill kann die Standardbenennung nicht nutzen und wird übersprungen. Probiere flat.", "targetDetail.skipped.other": "{count} Skills können die Standardbenennung nicht nutzen und werden übersprungen. Probiere flat.", "targetDetail.collect": "Sammeln", @@ -1903,8 +1908,15 @@ "sync.local.hint": "Die Synchronisierung lässt sie unberührt. Sammeln holt sie in deine Quelle.", "sync.local.collect": "Sammeln", "sync.forceHint": "Dateien ersetzen, die in einem Ziel bearbeitet wurden", - "sync.folderConflict.text": "{names} synchronisieren Skills mit unterschiedlichen Filtern in denselben Ordner {path}, sodass jede Synchronisierung die andere rückgängig macht.", + "sync.folderConflict.text": "{names} synchronisieren Skills mit unterschiedlichen Einstellungen in denselben Ordner {path}, sodass jede Synchronisierung die andere rückgängig macht.", "sync.folderConflict.stop": "Skills für {name} nicht mehr synchronisieren", + "sync.folderConflict.keeps": "{name} · schreibt weiter", + "sync.folderConflict.filters": "Filter", + "sync.folderConflict.filters.include": "enthält {names}", + "sync.folderConflict.filters.exclude": "schließt {names} aus", + "sync.folderConflict.filters.all": "alle Skills", + "sync.folderConflict.na": "entfällt", + "sync.folderConflict.hint": "Nur die abweichenden Zeilen sind aufgeführt. Um beide beizubehalten, gib {names} auf der Zielseite dieselben Einstellungen.", "sync.error.showDetails": "Diagnose anzeigen", "sync.error.hideDetails": "Diagnose ausblenden", "sync.last.title": "Letzte Skills-/Agents-Sync", diff --git a/ui/src/i18n/locales/en.json b/ui/src/i18n/locales/en.json index 8d9d1e45b..b169e39d1 100644 --- a/ui/src/i18n/locales/en.json +++ b/ui/src/i18n/locales/en.json @@ -1784,7 +1784,7 @@ "targetDetail.mode.merge.skill": "One symlink per skill. Skills you made inside this target are left alone.", "targetDetail.mode.merge.agent": "One symlink per agent file. Agents you made inside this target are left alone.", "targetDetail.mode.copy": "Real copies. For tools that cannot follow symlinks.", - "targetDetail.mode.symlink": "The whole folder becomes one symlink. Filters do not apply in this mode.", + "targetDetail.mode.symlink": "The whole folder becomes one symlink. Filters and naming do not apply in this mode.", "targetDetail.naming": "Naming", "targetDetail.namingFlat": "Nested skills get flat names joined with __.", "targetDetail.namingStandard": "Skills use the name from SKILL.md.", @@ -1792,6 +1792,11 @@ "targetDetail.prefixedNeedsCopy": "prefixed needs copy mode, because it rewrites the name inside each copy.", "targetDetail.prefixedNeedsCopyTitle": "Needs copy mode", "targetDetail.pending": "pending", + "targetDetail.shared.mode": "{other} also syncs skills to {path}, with {theirs}. With {mine}, each sync would undo the other.", + "targetDetail.shared.naming": "{other} also syncs skills to {path}, with {theirs} naming. With {mine}, each sync would undo the other.", + "targetDetail.shared.use": "Use {value} like {other}", + "targetDetail.shared.filters": "{other} also syncs skills to {path}, with different filters. Each sync would add back or remove what the other filters out.", + "targetDetail.shared.useFilters": "Use the same filters as {other}", "targetDetail.skipped.one": "{count} skill can't use standard naming and is skipped. Try flat.", "targetDetail.skipped.other": "{count} skills can't use standard naming and are skipped. Try flat.", "targetDetail.collect": "Collect", @@ -1903,8 +1908,15 @@ "sync.local.hint": "Sync leaves them alone. Collect brings them into your source.", "sync.local.collect": "Collect", "sync.forceHint": "Replace files that were edited inside a target", - "sync.folderConflict.text": "{names} sync skills to the same folder {path} with different filters, so each sync undoes the other.", + "sync.folderConflict.text": "{names} sync skills to the same folder {path} with different settings, so each sync undoes the other.", "sync.folderConflict.stop": "Stop syncing skills for {name}", + "sync.folderConflict.keeps": "{name} · keeps writing", + "sync.folderConflict.filters": "Filters", + "sync.folderConflict.filters.include": "includes {names}", + "sync.folderConflict.filters.exclude": "excludes {names}", + "sync.folderConflict.filters.all": "all skills", + "sync.folderConflict.na": "n/a", + "sync.folderConflict.hint": "Only the rows that differ are listed. To keep both, give {names} the same settings on the target page.", "sync.error.showDetails": "Show diagnostics", "sync.error.hideDetails": "Hide diagnostics", "sync.last.title": "Last skills and agents sync", diff --git a/ui/src/i18n/locales/es.json b/ui/src/i18n/locales/es.json index b5e4831be..851872989 100644 --- a/ui/src/i18n/locales/es.json +++ b/ui/src/i18n/locales/es.json @@ -1784,7 +1784,7 @@ "targetDetail.mode.merge.skill": "Un enlace simbólico por skill. Los skills que creaste dentro de este destino no se tocan.", "targetDetail.mode.merge.agent": "Un enlace simbólico por archivo de agent. Los agents que creaste dentro de este destino no se tocan.", "targetDetail.mode.copy": "Copias reales. Para herramientas que no pueden seguir enlaces simbólicos.", - "targetDetail.mode.symlink": "La carpeta completa se convierte en un enlace simbólico. Los filtros no se aplican en este modo.", + "targetDetail.mode.symlink": "La carpeta completa se convierte en un enlace simbólico. Los filtros y los nombres no se aplican en este modo.", "targetDetail.naming": "Nombres", "targetDetail.namingFlat": "Los skills anidados reciben nombres planos unidos con __.", "targetDetail.namingStandard": "Los skills usan el nombre de SKILL.md.", @@ -1792,6 +1792,11 @@ "targetDetail.prefixedNeedsCopy": "prefixed necesita el modo copy, porque reescribe el nombre dentro de cada copia.", "targetDetail.prefixedNeedsCopyTitle": "Necesita el modo copy", "targetDetail.pending": "pendiente", + "targetDetail.shared.mode": "{other} también sincroniza skills en {path}, con {theirs}. Con {mine}, cada sincronización desharía la otra.", + "targetDetail.shared.naming": "{other} también sincroniza skills en {path}, con nombres {theirs}. Con {mine}, cada sincronización desharía la otra.", + "targetDetail.shared.use": "Usar {value} como {other}", + "targetDetail.shared.filters": "{other} también sincroniza skills en {path}, con otros filtros. Cada sincronización volvería a añadir o quitaría lo que la otra filtra.", + "targetDetail.shared.useFilters": "Usar los mismos filtros que {other}", "targetDetail.skipped.one": "{count} skill no puede usar nombres estándar y se omite. Prueba flat.", "targetDetail.skipped.other": "{count} skills no pueden usar nombres estándar y se omiten. Prueba flat.", "targetDetail.collect": "Recopilar", @@ -1903,8 +1908,15 @@ "sync.local.hint": "La sincronización no los toca. Recopilar los trae a tu origen.", "sync.local.collect": "Recopilar", "sync.forceHint": "Reemplazar archivos editados dentro de un destino", - "sync.folderConflict.text": "{names} sincronizan skills en la misma carpeta {path} con filtros distintos, así que cada sincronización deshace la otra.", + "sync.folderConflict.text": "{names} sincronizan skills en la misma carpeta {path} con ajustes distintos, así que cada sincronización deshace la otra.", "sync.folderConflict.stop": "Dejar de sincronizar skills con {name}", + "sync.folderConflict.keeps": "{name} · sigue escribiendo", + "sync.folderConflict.filters": "Filtros", + "sync.folderConflict.filters.include": "incluye {names}", + "sync.folderConflict.filters.exclude": "excluye {names}", + "sync.folderConflict.filters.all": "todos los skills", + "sync.folderConflict.na": "n/d", + "sync.folderConflict.hint": "Solo se muestran las filas que difieren. Para conservar ambos, da a {names} los mismos ajustes en la página del destino.", "sync.error.showDetails": "Mostrar diagnóstico", "sync.error.hideDetails": "Ocultar diagnóstico", "sync.last.title": "Última sync de skills y agents", diff --git a/ui/src/i18n/locales/fa.json b/ui/src/i18n/locales/fa.json index e6d92b696..fa2f248b9 100644 --- a/ui/src/i18n/locales/fa.json +++ b/ui/src/i18n/locales/fa.json @@ -1784,7 +1784,7 @@ "targetDetail.mode.merge.skill": "یک symlink برای هر اسکیل. اسکیل‌هایی که داخل این هدف ساخته‌اید دست نمی‌خورند.", "targetDetail.mode.merge.agent": "یک symlink برای هر فایل Agent. Agentهایی که داخل این هدف ساخته‌اید دست نمی‌خورند.", "targetDetail.mode.copy": "کپی واقعی. برای ابزارهایی که نمی‌توانند symlink را دنبال کنند.", - "targetDetail.mode.symlink": "کل پوشه یک symlink می‌شود. فیلترها در این حالت اعمال نمی‌شوند.", + "targetDetail.mode.symlink": "کل پوشه یک symlink می‌شود. فیلترها و نام‌گذاری در این حالت اعمال نمی‌شوند.", "targetDetail.naming": "نام‌گذاری", "targetDetail.namingFlat": "اسکیل‌های تودرتو نام تخت با __ می‌گیرند.", "targetDetail.namingStandard": "اسکیل‌ها از نام داخل SKILL.md استفاده می‌کنند.", @@ -1792,6 +1792,11 @@ "targetDetail.prefixedNeedsCopy": "prefixed به حالت copy نیاز دارد، چون نام را درون هر کپی بازنویسی می‌کند.", "targetDetail.prefixedNeedsCopyTitle": "به حالت copy نیاز دارد", "targetDetail.pending": "در انتظار", + "targetDetail.shared.mode": "{other} هم Skills را در {path} همگام‌سازی می‌کند، با {theirs}. با {mine}، هر همگام‌سازی کار دیگری را خنثی می‌کند.", + "targetDetail.shared.naming": "{other} هم Skills را در {path} همگام‌سازی می‌کند، با نام‌گذاری {theirs}. با {mine}، هر همگام‌سازی کار دیگری را خنثی می‌کند.", + "targetDetail.shared.use": "استفاده از {value} مثل {other}", + "targetDetail.shared.filters": "{other} هم Skills را در {path} همگام‌سازی می‌کند، با فیلترهای متفاوت. هر همگام‌سازی چیزی را که دیگری فیلتر می‌کند دوباره اضافه یا حذف می‌کند.", + "targetDetail.shared.useFilters": "استفاده از همان فیلترهای {other}", "targetDetail.skipped.one": "{count} اسکیل نمی‌تواند از نام‌گذاری standard استفاده کند و نادیده گرفته می‌شود. flat را امتحان کنید.", "targetDetail.skipped.other": "{count} اسکیل نمی‌توانند از نام‌گذاری standard استفاده کنند و نادیده گرفته می‌شوند. flat را امتحان کنید.", "targetDetail.collect": "جمع‌آوری", @@ -1903,8 +1908,15 @@ "sync.local.hint": "همگام‌سازی به آن‌ها دست نمی‌زند. جمع‌آوری آن‌ها را به منبع شما می‌آورد.", "sync.local.collect": "جمع‌آوری", "sync.forceHint": "فایل‌هایی را که داخل هدف ویرایش شده‌اند جایگزین کن", - "sync.folderConflict.text": "{names} Skills را با فیلترهای متفاوت در یک پوشه ({path}) همگام‌سازی می‌کنند، بنابراین هر همگام‌سازی کار دیگری را خنثی می‌کند.", + "sync.folderConflict.text": "{names} Skills را با تنظیمات متفاوت در یک پوشه ({path}) همگام‌سازی می‌کنند، بنابراین هر همگام‌سازی کار دیگری را خنثی می‌کند.", "sync.folderConflict.stop": "توقف همگام‌سازی Skills برای {name}", + "sync.folderConflict.keeps": "{name} · همچنان می‌نویسد", + "sync.folderConflict.filters": "فیلترها", + "sync.folderConflict.filters.include": "شامل {names}", + "sync.folderConflict.filters.exclude": "به‌جز {names}", + "sync.folderConflict.filters.all": "همه Skills", + "sync.folderConflict.na": "ندارد", + "sync.folderConflict.hint": "فقط ردیف‌هایی که تفاوت دارند فهرست شده‌اند. برای نگه داشتن هر دو، همین تنظیمات را در صفحه هدف برای {names} هم بگذارید.", "sync.error.showDetails": "نمایش جزئیات عیب‌یابی", "sync.error.hideDetails": "پنهان کردن جزئیات عیب‌یابی", "sync.last.title": "آخرین همگام‌سازی skills و agents", diff --git a/ui/src/i18n/locales/fr.json b/ui/src/i18n/locales/fr.json index b4ce5d4cb..e642e21dc 100644 --- a/ui/src/i18n/locales/fr.json +++ b/ui/src/i18n/locales/fr.json @@ -1784,7 +1784,7 @@ "targetDetail.mode.merge.skill": "Un lien symbolique par skill. Les skills créés dans cette cible ne sont pas touchés.", "targetDetail.mode.merge.agent": "Un lien symbolique par fichier d’agent. Les agents créés dans cette cible ne sont pas touchés.", "targetDetail.mode.copy": "De vraies copies. Pour les outils qui ne suivent pas les liens symboliques.", - "targetDetail.mode.symlink": "Tout le dossier devient un lien symbolique. Les filtres ne s’appliquent pas dans ce mode.", + "targetDetail.mode.symlink": "Tout le dossier devient un lien symbolique. Les filtres et le nommage ne s’appliquent pas dans ce mode.", "targetDetail.naming": "Nommage", "targetDetail.namingFlat": "Les skills imbriqués reçoivent des noms à plat joints par __.", "targetDetail.namingStandard": "Les skills utilisent le nom de SKILL.md.", @@ -1792,6 +1792,11 @@ "targetDetail.prefixedNeedsCopy": "prefixed nécessite le mode copy, car il réécrit le nom dans chaque copie.", "targetDetail.prefixedNeedsCopyTitle": "Nécessite le mode copy", "targetDetail.pending": "en attente", + "targetDetail.shared.mode": "{other} synchronise aussi des skills vers {path}, avec {theirs}. Avec {mine}, chaque synchronisation annulerait l’autre.", + "targetDetail.shared.naming": "{other} synchronise aussi des skills vers {path}, avec le nommage {theirs}. Avec {mine}, chaque synchronisation annulerait l’autre.", + "targetDetail.shared.use": "Utiliser {value} comme {other}", + "targetDetail.shared.filters": "{other} synchronise aussi des skills vers {path}, avec d’autres filtres. Chaque synchronisation rajouterait ou retirerait ce que l’autre filtre.", + "targetDetail.shared.useFilters": "Utiliser les mêmes filtres que {other}", "targetDetail.skipped.one": "{count} skill ne peut pas utiliser le nommage standard et est ignoré. Essayez flat.", "targetDetail.skipped.other": "{count} skills ne peuvent pas utiliser le nommage standard et sont ignorés. Essayez flat.", "targetDetail.collect": "Collecter", @@ -1903,8 +1908,15 @@ "sync.local.hint": "La synchronisation n'y touche pas. Collecter les ramène dans votre source.", "sync.local.collect": "Collecter", "sync.forceHint": "Remplacer les fichiers modifiés dans une cible", - "sync.folderConflict.text": "{names} synchronisent les skills dans le même dossier {path} avec des filtres différents : chaque synchronisation annule l’autre.", + "sync.folderConflict.text": "{names} synchronisent les skills dans le même dossier {path} avec des paramètres différents : chaque synchronisation annule l’autre.", "sync.folderConflict.stop": "Arrêter de synchroniser les skills vers {name}", + "sync.folderConflict.keeps": "{name} · continue d’écrire", + "sync.folderConflict.filters": "Filtres", + "sync.folderConflict.filters.include": "inclut {names}", + "sync.folderConflict.filters.exclude": "exclut {names}", + "sync.folderConflict.filters.all": "tous les skills", + "sync.folderConflict.na": "s.o.", + "sync.folderConflict.hint": "Seules les lignes qui diffèrent sont listées. Pour garder les deux, donnez à {names} les mêmes paramètres sur la page de la cible.", "sync.error.showDetails": "Afficher le diagnostic", "sync.error.hideDetails": "Masquer le diagnostic", "sync.last.title": "Dernière synchro skills et agents", diff --git a/ui/src/i18n/locales/id.json b/ui/src/i18n/locales/id.json index 1e1354cb1..e763f08db 100644 --- a/ui/src/i18n/locales/id.json +++ b/ui/src/i18n/locales/id.json @@ -1784,7 +1784,7 @@ "targetDetail.mode.merge.skill": "Satu symlink per skill. Skill yang Anda buat di dalam target ini tidak diubah.", "targetDetail.mode.merge.agent": "Satu symlink per file agent. Agent yang Anda buat di dalam target ini tidak diubah.", "targetDetail.mode.copy": "Salinan asli. Untuk alat yang tidak bisa mengikuti symlink.", - "targetDetail.mode.symlink": "Seluruh folder menjadi satu symlink. Filter tidak berlaku dalam mode ini.", + "targetDetail.mode.symlink": "Seluruh folder menjadi satu symlink. Filter dan penamaan tidak berlaku dalam mode ini.", "targetDetail.naming": "Penamaan", "targetDetail.namingFlat": "Skill bertingkat mendapat nama datar yang digabung dengan __.", "targetDetail.namingStandard": "Skill memakai nama dari SKILL.md.", @@ -1792,6 +1792,11 @@ "targetDetail.prefixedNeedsCopy": "prefixed butuh mode copy, karena menulis ulang nama di dalam setiap salinan.", "targetDetail.prefixedNeedsCopyTitle": "Butuh mode copy", "targetDetail.pending": "tertunda", + "targetDetail.shared.mode": "{other} juga menyinkronkan skill ke {path}, dengan {theirs}. Dengan {mine}, setiap sinkronisasi akan membatalkan yang lain.", + "targetDetail.shared.naming": "{other} juga menyinkronkan skill ke {path}, dengan penamaan {theirs}. Dengan {mine}, setiap sinkronisasi akan membatalkan yang lain.", + "targetDetail.shared.use": "Pakai {value} seperti {other}", + "targetDetail.shared.filters": "{other} juga menyinkronkan skill ke {path}, dengan filter yang berbeda. Setiap sinkronisasi akan menambahkan kembali atau menghapus apa yang disaring yang lain.", + "targetDetail.shared.useFilters": "Pakai filter yang sama dengan {other}", "targetDetail.skipped.one": "{count} skill tidak bisa memakai penamaan standard dan dilewati. Coba flat.", "targetDetail.skipped.other": "{count} skill tidak bisa memakai penamaan standard dan dilewati. Coba flat.", "targetDetail.collect": "Kumpulkan", @@ -1903,8 +1908,15 @@ "sync.local.hint": "Sinkronisasi tidak menyentuhnya. Kumpulkan membawanya ke sumber Anda.", "sync.local.collect": "Kumpulkan", "sync.forceHint": "Ganti file yang diedit di dalam target", - "sync.folderConflict.text": "{names} menyinkronkan skill ke folder yang sama {path} dengan filter berbeda, sehingga setiap sinkronisasi membatalkan yang lain.", + "sync.folderConflict.text": "{names} menyinkronkan skill ke folder yang sama {path} dengan pengaturan berbeda, sehingga setiap sinkronisasi membatalkan yang lain.", "sync.folderConflict.stop": "Berhenti menyinkronkan skill ke {name}", + "sync.folderConflict.keeps": "{name} · tetap menulis", + "sync.folderConflict.filters": "Filter", + "sync.folderConflict.filters.include": "menyertakan {names}", + "sync.folderConflict.filters.exclude": "mengecualikan {names}", + "sync.folderConflict.filters.all": "semua skill", + "sync.folderConflict.na": "n/a", + "sync.folderConflict.hint": "Hanya baris yang berbeda yang ditampilkan. Agar keduanya tetap jalan, beri {names} pengaturan yang sama di halaman target.", "sync.error.showDetails": "Tampilkan diagnostik", "sync.error.hideDetails": "Sembunyikan diagnostik", "sync.last.title": "Sync skills dan agents terakhir", diff --git a/ui/src/i18n/locales/ja.json b/ui/src/i18n/locales/ja.json index b626b09d8..6f6513f34 100644 --- a/ui/src/i18n/locales/ja.json +++ b/ui/src/i18n/locales/ja.json @@ -1784,7 +1784,7 @@ "targetDetail.mode.merge.skill": "スキルごとに 1 つの symlink。このターゲット内で作ったスキルはそのままです。", "targetDetail.mode.merge.agent": "Agent ファイルごとに 1 つの symlink。このターゲット内で作った Agent はそのままです。", "targetDetail.mode.copy": "実ファイルのコピー。symlink をたどれないツール向けです。", - "targetDetail.mode.symlink": "フォルダー全体を 1 つの symlink にします。このモードではフィルターは適用されません。", + "targetDetail.mode.symlink": "フォルダー全体を 1 つの symlink にします。このモードではフィルターと命名は適用されません。", "targetDetail.naming": "命名", "targetDetail.namingFlat": "ネストしたスキルは __ でつないだフラット名になります。", "targetDetail.namingStandard": "スキルは SKILL.md の名前を使います。", @@ -1792,6 +1792,11 @@ "targetDetail.prefixedNeedsCopy": "prefixed は各コピー内の名前を書き換えるため、copy モードが必要です。", "targetDetail.prefixedNeedsCopyTitle": "copy モードが必要です", "targetDetail.pending": "未保存", + "targetDetail.shared.mode": "{other} も {path} に Skills を同期していて、{theirs} を使っています。{mine} にすると、同期のたびに互いの結果を打ち消します。", + "targetDetail.shared.naming": "{other} も {path} に Skills を同期していて、命名は {theirs} です。{mine} にすると、同期のたびに互いの結果を打ち消します。", + "targetDetail.shared.use": "{other} に合わせて {value} にする", + "targetDetail.shared.filters": "{other} も {path} に Skills を同期していて、フィルターが異なります。同期のたびに、もう一方が除外したものを追加し直したり削除したりします。", + "targetDetail.shared.useFilters": "{other} と同じフィルターにする", "targetDetail.skipped.one": "{count} 件のスキルは standard 命名を使えないためスキップされます。flat を試してください。", "targetDetail.skipped.other": "{count} 件のスキルは standard 命名を使えないためスキップされます。flat を試してください。", "targetDetail.collect": "収集", @@ -1903,8 +1908,15 @@ "sync.local.hint": "同期では変更されません。収集するとソースに取り込めます。", "sync.local.collect": "収集", "sync.forceHint": "ターゲット内で編集されたファイルを置き換えます", - "sync.folderConflict.text": "{names} は同じフォルダ {path} に異なるフィルターで Skills を同期しているため、同期のたびに互いの結果を打ち消します。", + "sync.folderConflict.text": "{names} は同じフォルダ {path} に異なる設定で Skills を同期しているため、同期のたびに互いの結果を打ち消します。", "sync.folderConflict.stop": "{name} の Skills の同期を停止", + "sync.folderConflict.keeps": "{name} · 書き込みを続ける", + "sync.folderConflict.filters": "フィルター", + "sync.folderConflict.filters.include": "{names} を含める", + "sync.folderConflict.filters.exclude": "{names} を除外", + "sync.folderConflict.filters.all": "すべてのスキル", + "sync.folderConflict.na": "対象外", + "sync.folderConflict.hint": "異なる行だけを表示しています。両方を残すには、ターゲットのページで {names} に同じ設定を指定してください。", "sync.error.showDetails": "診断情報を表示", "sync.error.hideDetails": "診断情報を隠す", "sync.last.title": "前回の skills・agents 同期", diff --git a/ui/src/i18n/locales/ko.json b/ui/src/i18n/locales/ko.json index f94e7901a..80efd1f8d 100644 --- a/ui/src/i18n/locales/ko.json +++ b/ui/src/i18n/locales/ko.json @@ -1784,7 +1784,7 @@ "targetDetail.mode.merge.skill": "skill마다 symlink 하나. 이 대상 안에서 만든 skill은 그대로 둡니다.", "targetDetail.mode.merge.agent": "agent 파일마다 symlink 하나. 이 대상 안에서 만든 agent는 그대로 둡니다.", "targetDetail.mode.copy": "실제 복사본. symlink를 따라가지 못하는 도구용입니다.", - "targetDetail.mode.symlink": "폴더 전체가 symlink 하나가 됩니다. 이 모드에서는 필터가 적용되지 않습니다.", + "targetDetail.mode.symlink": "폴더 전체가 symlink 하나가 됩니다. 이 모드에서는 필터와 이름 규칙이 적용되지 않습니다.", "targetDetail.naming": "이름 지정", "targetDetail.namingFlat": "중첩된 skill은 __로 이은 평면 이름을 받습니다.", "targetDetail.namingStandard": "skill은 SKILL.md의 이름을 사용합니다.", @@ -1792,6 +1792,11 @@ "targetDetail.prefixedNeedsCopy": "prefixed는 각 복사본 안의 이름을 다시 쓰기 때문에 copy 모드가 필요합니다.", "targetDetail.prefixedNeedsCopyTitle": "copy 모드가 필요합니다", "targetDetail.pending": "저장 전", + "targetDetail.shared.mode": "{other}도 {path}에 Skills를 동기화하며 {theirs}를 사용합니다. {mine}을(를) 쓰면 동기화할 때마다 서로의 결과를 되돌립니다.", + "targetDetail.shared.naming": "{other}도 {path}에 Skills를 동기화하며 이름 규칙은 {theirs}입니다. {mine}을(를) 쓰면 동기화할 때마다 서로의 결과를 되돌립니다.", + "targetDetail.shared.use": "{other}처럼 {value} 사용", + "targetDetail.shared.filters": "{other}도 {path}에 Skills를 동기화하며 필터가 다릅니다. 동기화할 때마다 다른 target이 걸러낸 항목을 다시 추가하거나 제거합니다.", + "targetDetail.shared.useFilters": "{other}와 같은 필터 사용", "targetDetail.skipped.one": "skill {count}개는 standard 이름을 쓸 수 없어 건너뜁니다. flat을 사용해 보세요.", "targetDetail.skipped.other": "skill {count}개는 standard 이름을 쓸 수 없어 건너뜁니다. flat을 사용해 보세요.", "targetDetail.collect": "수집", @@ -1903,8 +1908,15 @@ "sync.local.hint": "동기화는 이 항목을 건드리지 않습니다. 수집하면 소스로 가져옵니다.", "sync.local.collect": "수집", "sync.forceHint": "대상 안에서 수정된 파일을 교체합니다", - "sync.folderConflict.text": "{names}이(가) 같은 폴더 {path}에 서로 다른 필터로 Skills를 동기화해서, 동기화할 때마다 서로의 결과를 되돌립니다.", + "sync.folderConflict.text": "{names}이(가) 같은 폴더 {path}에 서로 다른 설정으로 Skills를 동기화해서, 동기화할 때마다 서로의 결과를 되돌립니다.", "sync.folderConflict.stop": "{name}의 Skills 동기화 중지", + "sync.folderConflict.keeps": "{name} · 계속 기록", + "sync.folderConflict.filters": "필터", + "sync.folderConflict.filters.include": "{names} 포함", + "sync.folderConflict.filters.exclude": "{names} 제외", + "sync.folderConflict.filters.all": "모든 skill", + "sync.folderConflict.na": "해당 없음", + "sync.folderConflict.hint": "다른 항목만 표시합니다. 둘 다 유지하려면 대상 페이지에서 {names}에 같은 설정을 지정하세요.", "sync.error.showDetails": "진단 표시", "sync.error.hideDetails": "진단 숨기기", "sync.last.title": "마지막 skills 및 agents 동기화", diff --git a/ui/src/i18n/locales/pt-BR.json b/ui/src/i18n/locales/pt-BR.json index 564000136..97d02c8d2 100644 --- a/ui/src/i18n/locales/pt-BR.json +++ b/ui/src/i18n/locales/pt-BR.json @@ -1784,7 +1784,7 @@ "targetDetail.mode.merge.skill": "Um symlink por skill. As skills criadas dentro deste destino não são alteradas.", "targetDetail.mode.merge.agent": "Um symlink por arquivo de agent. Os agents criados dentro deste destino não são alterados.", "targetDetail.mode.copy": "Cópias reais. Para ferramentas que não seguem symlinks.", - "targetDetail.mode.symlink": "A pasta inteira vira um symlink. Os filtros não se aplicam neste modo.", + "targetDetail.mode.symlink": "A pasta inteira vira um symlink. Filtros e nomes não se aplicam neste modo.", "targetDetail.naming": "Nomes", "targetDetail.namingFlat": "Skills aninhadas recebem nomes planos unidos por __.", "targetDetail.namingStandard": "Skills usam o nome do SKILL.md.", @@ -1792,6 +1792,11 @@ "targetDetail.prefixedNeedsCopy": "prefixed precisa do modo copy, porque reescreve o nome dentro de cada cópia.", "targetDetail.prefixedNeedsCopyTitle": "Precisa do modo copy", "targetDetail.pending": "pendente", + "targetDetail.shared.mode": "{other} também sincroniza skills em {path}, com {theirs}. Com {mine}, cada sincronização desfaria a outra.", + "targetDetail.shared.naming": "{other} também sincroniza skills em {path}, com nomes {theirs}. Com {mine}, cada sincronização desfaria a outra.", + "targetDetail.shared.use": "Usar {value} como {other}", + "targetDetail.shared.filters": "{other} também sincroniza skills em {path}, com outros filtros. Cada sincronização adicionaria de volta ou removeria o que a outra filtra.", + "targetDetail.shared.useFilters": "Usar os mesmos filtros que {other}", "targetDetail.skipped.one": "{count} skill não pode usar nomes standard e é ignorada. Tente flat.", "targetDetail.skipped.other": "{count} skills não podem usar nomes standard e são ignoradas. Tente flat.", "targetDetail.collect": "Coletar", @@ -1903,8 +1908,15 @@ "sync.local.hint": "A sincronização não mexe neles. Coletar traz para a sua origem.", "sync.local.collect": "Coletar", "sync.forceHint": "Substituir arquivos editados dentro de um destino", - "sync.folderConflict.text": "{names} sincronizam skills na mesma pasta {path} com filtros diferentes, então cada sincronização desfaz a outra.", + "sync.folderConflict.text": "{names} sincronizam skills na mesma pasta {path} com configurações diferentes, então cada sincronização desfaz a outra.", "sync.folderConflict.stop": "Parar de sincronizar skills com {name}", + "sync.folderConflict.keeps": "{name} · continua gravando", + "sync.folderConflict.filters": "Filtros", + "sync.folderConflict.filters.include": "inclui {names}", + "sync.folderConflict.filters.exclude": "exclui {names}", + "sync.folderConflict.filters.all": "todos os skills", + "sync.folderConflict.na": "n/d", + "sync.folderConflict.hint": "Só as linhas que diferem são listadas. Para manter os dois, dê a {names} as mesmas configurações na página do destino.", "sync.error.showDetails": "Mostrar diagnóstico", "sync.error.hideDetails": "Ocultar diagnóstico", "sync.last.title": "Última sync de skills e agents", diff --git a/ui/src/i18n/locales/zh-CN.json b/ui/src/i18n/locales/zh-CN.json index 8a9243e7d..89ed71553 100644 --- a/ui/src/i18n/locales/zh-CN.json +++ b/ui/src/i18n/locales/zh-CN.json @@ -1784,7 +1784,7 @@ "targetDetail.mode.merge.skill": "每个 Skill 一个 symlink。在这个目标里创建的 Skill 不受影响。", "targetDetail.mode.merge.agent": "每个 Agent 文件一个 symlink。在这个目标里创建的 Agent 不受影响。", "targetDetail.mode.copy": "真实副本。适用于无法跟随 symlink 的工具。", - "targetDetail.mode.symlink": "整个文件夹变成一个 symlink。此模式下筛选不生效。", + "targetDetail.mode.symlink": "整个文件夹变成一个 symlink。此模式下筛选和命名不生效。", "targetDetail.naming": "命名", "targetDetail.namingFlat": "嵌套 Skill 使用以 __ 连接的扁平名称。", "targetDetail.namingStandard": "Skill 使用 SKILL.md 中的名称。", @@ -1792,6 +1792,11 @@ "targetDetail.prefixedNeedsCopy": "prefixed 需要 copy 模式,因为它会改写每份副本里的名称。", "targetDetail.prefixedNeedsCopyTitle": "需要 copy 模式", "targetDetail.pending": "未保存", + "targetDetail.shared.mode": "{other} 也把 Skills 同步到 {path},使用 {theirs}。改用 {mine} 后,每次同步都会抵消对方的结果。", + "targetDetail.shared.naming": "{other} 也把 Skills 同步到 {path},命名为 {theirs}。改用 {mine} 后,每次同步都会抵消对方的结果。", + "targetDetail.shared.use": "和 {other} 一样使用 {value}", + "targetDetail.shared.filters": "{other} 也把 Skills 同步到 {path},但筛选不同。每次同步都会把对方筛掉的内容加回来或删掉。", + "targetDetail.shared.useFilters": "使用和 {other} 相同的筛选", "targetDetail.skipped.one": "{count} 个 Skill 无法使用 standard 命名而被跳过。试试 flat。", "targetDetail.skipped.other": "{count} 个 Skill 无法使用 standard 命名而被跳过。试试 flat。", "targetDetail.collect": "收集", @@ -1903,8 +1908,15 @@ "sync.local.hint": "同步不会动它们,收集可以将其纳入来源。", "sync.local.collect": "收集", "sync.forceHint": "替换在目标中修改过的文件", - "sync.folderConflict.text": "{names} 同步到同一个文件夹 {path},但筛选不同,每次同步都会互相加回、删掉。", + "sync.folderConflict.text": "{names} 同步到同一个文件夹 {path},但设置不同,每次同步都会互相加回、删掉。", "sync.folderConflict.stop": "停止同步 {name} 的 Skills", + "sync.folderConflict.keeps": "{name} · 持续写入", + "sync.folderConflict.filters": "筛选", + "sync.folderConflict.filters.include": "包含 {names}", + "sync.folderConflict.filters.exclude": "排除 {names}", + "sync.folderConflict.filters.all": "所有 Skills", + "sync.folderConflict.na": "不适用", + "sync.folderConflict.hint": "只列出有差异的项。要同时保留两者,请到目标页面把 {names} 的设置改成一致。", "sync.error.showDetails": "显示诊断信息", "sync.error.hideDetails": "隐藏诊断信息", "sync.last.title": "上次 skills 与 agents 同步", diff --git a/ui/src/i18n/locales/zh-TW.json b/ui/src/i18n/locales/zh-TW.json index 5e247813e..e914f581b 100644 --- a/ui/src/i18n/locales/zh-TW.json +++ b/ui/src/i18n/locales/zh-TW.json @@ -1784,7 +1784,7 @@ "targetDetail.mode.merge.skill": "每個 Skill 一個 symlink。在這個目標裡建立的 Skills 不受影響。", "targetDetail.mode.merge.agent": "每個 Agent 檔案一個 symlink。在這個目標裡建立的 Agents 不受影響。", "targetDetail.mode.copy": "實體副本。適用於無法跟隨 symlink 的工具。", - "targetDetail.mode.symlink": "整個資料夾變成一個 symlink。這個模式下篩選不會生效。", + "targetDetail.mode.symlink": "整個資料夾變成一個 symlink。這個模式下篩選與命名不會生效。", "targetDetail.naming": "命名", "targetDetail.namingFlat": "巢狀 Skill 使用以 __ 串接的扁平名稱。", "targetDetail.namingStandard": "Skill 使用 SKILL.md 裡的名稱。", @@ -1792,6 +1792,11 @@ "targetDetail.prefixedNeedsCopy": "prefixed 需要 copy 模式,因為它會改寫每份副本裡的名稱。", "targetDetail.prefixedNeedsCopyTitle": "需要 copy 模式", "targetDetail.pending": "未儲存", + "targetDetail.shared.mode": "{other} 也把 Skills 同步到 {path},使用 {theirs}。改用 {mine} 後,每次同步都會抵銷對方的結果。", + "targetDetail.shared.naming": "{other} 也把 Skills 同步到 {path},命名為 {theirs}。改用 {mine} 後,每次同步都會抵銷對方的結果。", + "targetDetail.shared.use": "和 {other} 一樣使用 {value}", + "targetDetail.shared.filters": "{other} 也把 Skills 同步到 {path},但篩選不同。每次同步都會把對方篩掉的內容加回來或刪掉。", + "targetDetail.shared.useFilters": "使用和 {other} 相同的篩選", "targetDetail.skipped.one": "{count} 個 Skill 無法使用 standard 命名而被略過。試試 flat。", "targetDetail.skipped.other": "{count} 個 Skills 無法使用 standard 命名而被略過。試試 flat。", "targetDetail.collect": "收集", @@ -1903,8 +1908,15 @@ "sync.local.hint": "同步不會動到它們,收集可以將其納入來源。", "sync.local.collect": "收集", "sync.forceHint": "取代在目標中修改過的檔案", - "sync.folderConflict.text": "{names} 同步到同一個資料夾 {path},但篩選不同,每次同步都會互相加回、刪掉。", + "sync.folderConflict.text": "{names} 同步到同一個資料夾 {path},但設定不同,每次同步都會互相加回、刪掉。", "sync.folderConflict.stop": "停止同步 {name} 的 Skills", + "sync.folderConflict.keeps": "{name} · 持續寫入", + "sync.folderConflict.filters": "篩選", + "sync.folderConflict.filters.include": "包含 {names}", + "sync.folderConflict.filters.exclude": "排除 {names}", + "sync.folderConflict.filters.all": "所有 Skills", + "sync.folderConflict.na": "不適用", + "sync.folderConflict.hint": "只列出有差異的項目。要同時保留兩者,請到目標頁面把 {names} 的設定改成一致。", "sync.error.showDetails": "顯示診斷資訊", "sync.error.hideDetails": "隱藏診斷資訊", "sync.last.title": "上次 skills 與 agents 同步", diff --git a/ui/src/pages/SyncPage.test.tsx b/ui/src/pages/SyncPage.test.tsx index f870b146e..1ea53d8c0 100644 --- a/ui/src/pages/SyncPage.test.tsx +++ b/ui/src/pages/SyncPage.test.tsx @@ -17,9 +17,9 @@ vi.mock('../api/client', async (load) => ({ vi.mock('../api/mcp', async (load) => ({ ...await load(), mcpApi: { list: vi.fn() } })); vi.mock('../api/hooks', async (load) => ({ ...await load(), hooksApi: { list: vi.fn(() => Promise.reject(new Error('offline'))) } })); -const target = (name: string) => ({ +const target = (name: string, over: Partial = {}) => ({ name, path: '/home/me/.agents/skills', mode: 'merge', targetNaming: 'flat', status: 'merged', linkedCount: 3, localCount: 0, - include: [], exclude: [], expectedSkillCount: 3, skillsEnabled: true, + include: [], exclude: [], expectedSkillCount: 3, skillsEnabled: true, ...over, }) as Target; describe('Sync page folder conflicts', () => { @@ -44,11 +44,26 @@ describe('Sync page folder conflicts', () => { , ); - expect(await screen.findByText(/codex and universal sync skills to the same folder .*\.agents\/skills with different filters, so each sync undoes the other\./)).toBeInTheDocument(); + expect(await screen.findByText(/codex and universal sync skills to the same folder .*\.agents\/skills with different settings, so each sync undoes the other\./)).toBeInTheDocument(); await user.click(screen.getByRole('button', { name: 'Stop syncing skills for codex' })); await user.click(await screen.findByRole('button', { name: 'Stop syncing' })); await waitFor(() => expect(api.updateTarget).toHaveBeenCalledWith('codex', { skills_enabled: false })); }); + + it('lists only the settings that differ, keep target first, and links the one to change', async () => { + vi.mocked(api.listTargets).mockResolvedValue({ targets: [target('codex', { mode: 'copy', exclude: ['feature-radar*'] }), target('universal')], sourceSkillCount: 3 }); + render( + + + , + ); + const columns = await screen.findAllByRole('columnheader'); + expect(columns.map((c) => c.textContent)).toEqual(['universal · keeps writing', 'codex']); + expect(screen.getAllByRole('rowheader').map((r) => r.textContent)).toEqual(['Sync mode', 'Filters']); + const cells = screen.getAllByRole('cell').map((c) => c.textContent); + expect(cells).toEqual(['merge', 'copy', 'all skills', 'excludes feature-radar*']); + expect(screen.getByRole('link', { name: 'codex' })).toHaveAttribute('href', '/targets/codex'); + }); }); describe('Sync page last sync', () => { diff --git a/ui/src/pages/SyncPage.tsx b/ui/src/pages/SyncPage.tsx index 5010a5349..e5d901824 100644 --- a/ui/src/pages/SyncPage.tsx +++ b/ui/src/pages/SyncPage.tsx @@ -15,6 +15,7 @@ import { hookLabel, hookMessage, rootName } from '../components/hooks/hooksView' import MCPNotices from '../components/mcp/MCPNotices'; import { describeMessage, mcpClient, targetLabel } from '../components/mcp/mcpView'; import { changeSets, countChanges, countEdited, discardable, receivesSkill, tally, extraGroups, groupByFolder, groupInSync, HOOKS_CHANGED, hooksGroups, MCP_CHANGED, mcpGroups, otherWarnings, resourceGroups, runSync, type ChangeGroup, type Part, type RowIcon, type SyncFailure } from '../components/sync/syncView'; +import FolderConflictNotice from '../components/sync/FolderConflictNotice'; import SyncResult from '../components/sync/SyncResult'; import UnmatchedNotices from '../components/sync/UnmatchedNotices'; import SyncError from '../components/sync/SyncError'; @@ -333,17 +334,7 @@ export default function SyncPage() { {t('sync.openDoctor')} )} - {conflicts.map((c) => ( -
- - {t('sync.folderConflict.text', { names: joinList(c.targets, locale), path: shortenHome(c.path) })} - {c.stop.map((name) => ( - - ))} -
- ))} + {conflicts.map((c) => )} {!loading && !diff.error && groups.length > 0 && (
diff --git a/ui/src/pages/TargetDetailPage.test.tsx b/ui/src/pages/TargetDetailPage.test.tsx index 06993ffff..b722c7c92 100644 --- a/ui/src/pages/TargetDetailPage.test.tsx +++ b/ui/src/pages/TargetDetailPage.test.tsx @@ -3,53 +3,85 @@ import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { MemoryRouter, Route, Routes } from 'react-router-dom'; import { beforeEach, describe, expect, it, vi } from 'vitest'; -import { api } from '../api/client'; -import type { Target } from '../api/client'; +import { api, type Target } from '../api/client'; import { ToastProvider } from '../components/Toast'; import { I18nProvider } from '../i18n'; import TargetDetailPage from './TargetDetailPage'; -vi.mock('../api/client', async (load) => { - const actual = await load(); - return { - ...actual, - api: { - ...actual.api, - listTargets: vi.fn(), getTargetInstructions: vi.fn(), listTargetFiles: vi.fn(), - previewSyncMatrix: vi.fn(), listExtraExtensions: vi.fn(), - }, - }; -}); -vi.mock('../hooks/useSharedQueries', () => { - const idle = () => ({ data: undefined }); - return { useAvailableTargetsQuery: idle, useHooksQuery: idle, useMcpQuery: idle }; -}); +const offline = vi.hoisted(() => () => Promise.reject(new Error('offline'))); +vi.mock('../api/client', async (load) => ({ + ...await load(), + api: { + listTargets: vi.fn(), previewSyncMatrix: vi.fn(() => Promise.resolve({ entries: [] })), availableTargets: vi.fn(offline), + getTargetInstructions: vi.fn(offline), listTargetFiles: vi.fn(offline), listExtraExtensions: vi.fn(offline), updateTarget: vi.fn(), + }, +})); +vi.mock('../api/mcp', async (load) => ({ ...await load(), mcpApi: { list: vi.fn(offline) } })); +vi.mock('../api/hooks', async (load) => ({ ...await load(), hooksApi: { list: vi.fn(offline) } })); -const never = () => new Promise(() => {}); +const target = (name: string, over: Partial = {}) => ({ + name, path: '/home/me/.agents/skills', mode: 'merge', targetNaming: 'flat', status: 'merged', linkedCount: 3, localCount: 0, + include: [], exclude: [], expectedSkillCount: 3, skillsEnabled: true, ...over, +}) as Target; -function renderPage(mode: string, targetNaming: string) { - const target = { name: 'claude', path: '/home/dev/.claude/skills', mode, targetNaming, skillsEnabled: true, linkedCount: 0, localCount: 0, include: [], exclude: [] } as unknown as Target; - vi.mocked(api.listTargets).mockResolvedValue({ targets: [target] } as Awaited>); - const client = new QueryClient({ defaultOptions: { queries: { retry: false } } }); - return render( - - - } /> - +function renderPage(codex: Partial, universal: Partial = {}) { + vi.mocked(api.listTargets).mockResolvedValue({ + targets: [target('codex', { skillsSharedWith: ['universal'], ...codex }), target('universal', { skillsSharedWith: ['codex'], ...universal })], + sourceSkillCount: 3, + }); + render( + + + } /> + , ); } -const needsCopy = 'prefixed needs copy mode, because it rewrites the name inside each copy.'; +describe('Target page shared skills folder', () => { + beforeEach(() => vi.clearAllMocks()); -describe('TargetDetailPage naming', () => { - beforeEach(() => { - vi.clearAllMocks(); - for (const fn of [api.getTargetInstructions, api.listTargetFiles, api.previewSyncMatrix, api.listExtraExtensions]) vi.mocked(fn).mockImplementation(never); + it('warns under the mode picker and sets the draft to the other target\'s mode', async () => { + const user = userEvent.setup(); + renderPage({ mode: 'copy' }); + expect(await screen.findByText(/universal also syncs skills to .*\.agents\/skills, with merge\. With copy, each sync would undo the other\./)).toBeInTheDocument(); + await user.click(screen.getByRole('button', { name: 'Use merge like universal' })); + expect(screen.queryByText(/each sync would undo the other/)).toBeNull(); }); + it('warns under the naming control, and only once the modes agree', async () => { + const user = userEvent.setup(); + renderPage({ targetNaming: 'standard' }); + expect(await screen.findByText(/universal also syncs skills to .*\.agents\/skills, with flat naming\. With standard, each sync would undo the other\./)).toBeInTheDocument(); + await user.click(screen.getByRole('button', { name: 'Use flat like universal' })); + expect(screen.queryByText(/each sync would undo the other/)).toBeNull(); + }); + + it('warns under the filters when only they differ, and copies the other target\'s filters', async () => { + const user = userEvent.setup(); + renderPage({ exclude: ['feature-radar*'] }); + expect(await screen.findByText(/universal also syncs skills to .*\.agents\/skills, with different filters\. Each sync would add back or remove what the other filters out\./)).toBeInTheDocument(); + await user.click(screen.getByRole('button', { name: 'Use the same filters as universal' })); + expect(screen.queryByText(/with different filters/)).toBeNull(); + }); + + it('stays quiet when both resolve to symlink, whatever the naming', async () => { + renderPage({ mode: 'symlink', targetNaming: 'standard' }, { mode: 'symlink' }); + await screen.findByText('Sync mode'); + expect(screen.queryByText(/each sync would undo the other/)).toBeNull(); + }); +}); + +const needsCopy = 'prefixed needs copy mode, because it rewrites the name inside each copy.'; + +describe('Target page naming', () => { + beforeEach(() => vi.clearAllMocks()); + + // Both targets share the folder with the same settings, so no shared-folder warning interferes. + const renderAlone = (mode: string, targetNaming: string) => renderPage({ mode, targetNaming }, { mode, targetNaming }); + it('keeps prefixed visible but disabled outside copy mode, and says why', async () => { - renderPage('merge', 'flat'); + renderAlone('merge', 'flat'); const prefixed = await screen.findByRole('button', { name: 'prefixed' }); expect(prefixed).toBeDisabled(); @@ -59,7 +91,7 @@ describe('TargetDetailPage naming', () => { it('enables prefixed in copy mode and marks the unsaved naming as pending', async () => { const user = userEvent.setup(); - renderPage('copy', 'flat'); + renderAlone('copy', 'flat'); const prefixed = await screen.findByRole('button', { name: 'prefixed' }); expect(prefixed).toBeEnabled(); @@ -73,7 +105,7 @@ describe('TargetDetailPage naming', () => { it('puts the saved naming back when leaving copy mode with prefixed drafted', async () => { const user = userEvent.setup(); - renderPage('copy', 'standard'); + renderAlone('copy', 'standard'); await user.click(await screen.findByRole('button', { name: 'prefixed' })); await user.click(screen.getByRole('radio', { name: /merge/ })); @@ -84,11 +116,20 @@ describe('TargetDetailPage naming', () => { it('falls back to flat when leaving copy mode with prefixed already saved', async () => { const user = userEvent.setup(); - renderPage('copy', 'prefixed'); + renderAlone('copy', 'prefixed'); await user.click(await screen.findByRole('radio', { name: /merge/ })); expect(screen.getByRole('button', { name: 'flat' })).toHaveAttribute('aria-pressed', 'true'); expect(screen.getByText('pending')).toBeInTheDocument(); }); + + it('drops prefixed when taking the other target\'s mode from the shared-folder warning', async () => { + const user = userEvent.setup(); + renderPage({ mode: 'copy', targetNaming: 'prefixed' }); + + await user.click(await screen.findByRole('button', { name: 'Use merge like universal' })); + + expect(screen.getByRole('button', { name: 'flat' })).toHaveAttribute('aria-pressed', 'true'); + }); }); diff --git a/ui/src/pages/TargetDetailPage.tsx b/ui/src/pages/TargetDetailPage.tsx index f3ea21da6..4d16efca7 100644 --- a/ui/src/pages/TargetDetailPage.tsx +++ b/ui/src/pages/TargetDetailPage.tsx @@ -1,7 +1,7 @@ import { useEffect, useState } from 'react'; import { Link, useNavigate, useParams, useSearchParams } from 'react-router-dom'; import { keepPreviousData, useQuery, useQueryClient } from '@tanstack/react-query'; -import { ArrowDownToLine, CirclePause, Folder, Info, Plus, Target as TargetIcon } from 'lucide-react'; +import { ArrowDownToLine, CirclePause, Folder, Info, Plus, Target as TargetIcon, TriangleAlert } from 'lucide-react'; import { api, type Target } from '../api/client'; import Button from '../components/Button'; import CollectDialog from '../components/CollectDialog'; @@ -176,6 +176,27 @@ function TargetEditor({ target, targets }: { target: Target; targets: Target[] } { value: 'standard', label: 'standard' }, { value: 'prefixed', label: 'prefixed', disabled: prefixedOff, title: prefixedOff ? t('targetDetail.prefixedNeedsCopyTitle') : undefined }, ]; + // Another target writing this folder with other settings than the draft: each sync would undo the other's. + const sharing = (target.skillsSharedWith ?? []).map((n) => targets.find((x) => x.name === n)).filter((x): x is Target => !!x); + const modeClash = agent ? undefined : sharing.find((o) => o.mode !== draft.mode); + // Symlink links the whole folder, so naming only matters once the modes agree on something else. + const namingClash = modeClash ? undefined : sharing.find((o) => o.targetNaming !== draft.naming); + const sameList = (a: string[], b: string[]) => a.length === b.length && [...a].sort().join('\n') === [...b].sort().join('\n'); + const filtersClash = modeClash || draft.mode === 'symlink' ? undefined : sharing.find((o) => !sameList(o.include, draft.include) || !sameList(o.exclude, draft.exclude)); + const sharedNote = (o: Target, field: 'mode' | 'naming') => { + const theirs = field === 'mode' ? o.mode : o.targetNaming; + return ( +
+ +
+ {t(`targetDetail.shared.${field}`, { other: o.name, path: shortenHome(target.path), theirs, mine: draft[field] })} + +
+
+ ); + }; const tabCount = (k: (typeof tabs)[number]) => k === 'skill' && !skillsOn ? null : (k === 'mcp' ? mcp.data && serverCount(mcp.data, client) @@ -292,6 +313,17 @@ function TargetEditor({ target, targets }: { target: Target; targets: Target[] } )}
+ {!agent && filtersClash && ( +
+ +
+ {t('targetDetail.shared.filters', { other: filtersClash.name, path: shortenHome(target.path) })} + +
+
+ )}