diff --git a/internal/server/handler_git.go b/internal/server/handler_git.go index 8203a0378..3f88cdc4d 100644 --- a/internal/server/handler_git.go +++ b/internal/server/handler_git.go @@ -677,6 +677,7 @@ type pullResponse struct { DryRun bool `json:"dryRun"` Message string `json:"message,omitempty"` Warnings []string `json:"warnings,omitempty"` + Unmatched []unmatchedInclude `json:"unmatched,omitempty"` } // handlePull pulls changes and syncs to targets @@ -843,6 +844,7 @@ func (s *Server) handlePull(w http.ResponseWriter, r *http.Request) { } else { resp.SyncResults = out.results resp.Warnings = append(resp.Warnings, out.warnings...) + resp.Unmatched = out.unmatched if out.pathOverlap > 0 { resp.Warnings = append(resp.Warnings, fmt.Sprintf("Skill path overlap across %d target(s) — see Health Check for details", out.pathOverlap)) } diff --git a/internal/server/handler_git_test.go b/internal/server/handler_git_test.go index b547a53a2..4e4124105 100644 --- a/internal/server/handler_git_test.go +++ b/internal/server/handler_git_test.go @@ -703,6 +703,33 @@ func TestHandlePull_EmptyRemoteReturnsCode(t *testing.T) { } } +func TestHandlePull_ReportsUnmatchedIncludeFromItsSync(t *testing.T) { + s, src := newTestServer(t) + addSkill(t, src, "alpha") + s.cfg.Targets["claude"] = config.TargetConfig{Skills: &config.ResourceTargetConfig{Path: filepath.Join(t.TempDir(), "claude-skills"), Include: []string{"missing"}}} + if err := s.cfg.Save(); err != nil { + t.Fatal(err) + } + initServerGitRepo(t, src) + testutil.RunGit(t, src, "add", "-A") + testutil.RunGit(t, src, "commit", "-m", "alpha") + remote := filepath.Join(t.TempDir(), "remote.git") + testutil.RunGit(t, "", "init", "--bare", remote) + testutil.RunGit(t, src, "remote", "add", "origin", remote) + testutil.RunGit(t, src, "push", "-u", "origin", "HEAD") + + rr := postPull(s, `{"alwaysSync":true}`) + var resp struct { + Unmatched []unmatchedInclude `json:"unmatched"` + } + if err := json.Unmarshal(rr.Body.Bytes(), &resp); err != nil { + t.Fatal(err) + } + if rr.Code != http.StatusOK || len(resp.Unmatched) != 1 || resp.Unmatched[0].Target != "claude" { + t.Fatalf("expected the unmatched include for claude, got %d: %s", rr.Code, rr.Body.String()) + } +} + func TestHandlePull_ReportsExtrasSyncWarnings(t *testing.T) { s, _, remote, _ := setupExtrasScopePull(t) pushRemoteFile(t, remote, "other/readme.md", "# other\n") diff --git a/ui/src/api/types/git.ts b/ui/src/api/types/git.ts index 42e5475eb..c2f9fa13f 100644 --- a/ui/src/api/types/git.ts +++ b/ui/src/api/types/git.ts @@ -1,4 +1,4 @@ -import type { SyncResult } from './sync'; +import type { SyncResult, UnmatchedInclude } from './sync'; // Git types export interface GitStatus { @@ -55,6 +55,8 @@ export interface PullResponse { dryRun?: boolean; message?: string; warnings?: string[]; + /** Targets whose include filter selects no skill, from the sync after the pull */ + unmatched?: UnmatchedInclude[]; } export interface GitConflictVersion { diff --git a/ui/src/pages/GitSyncPage.test.tsx b/ui/src/pages/GitSyncPage.test.tsx index ac4fed3fd..413f9729c 100644 --- a/ui/src/pages/GitSyncPage.test.tsx +++ b/ui/src/pages/GitSyncPage.test.tsx @@ -50,6 +50,15 @@ describe('updates from another computer', () => { ], }; + it('explains an include filter that selects no skill after the pull syncs', async () => { + vi.mocked(api.gitStatus).mockResolvedValue({ ...status, hasRemote: true, isDirty: false, files: [], ahead: 1, behind: 1 }); + vi.mocked(api.pull).mockResolvedValue({ success: true, upToDate: false, commits: [], stats: { filesChanged: 1, insertions: 1, deletions: 0 }, syncResults: [], + unmatched: [{ target: 'claude', patterns: ['*review*'], all: true }] }); + mount(); + fireEvent.click(await screen.findByRole('button', { name: 'Pull and merge' })); + expect(await screen.findByRole('link', { name: 'Edit filter' })).toHaveAttribute('href', '/targets/claude'); + }); + it('compares conflicts and requires a choice for every file before applying', async () => { vi.mocked(api.gitStatus).mockResolvedValue({ ...status, hasRemote: true, isDirty: false, files: [], ahead: 1, behind: 1 }); vi.mocked(api.pull).mockRejectedValueOnce(new ApiError(409, 'conflict', { code: 'pull_conflict', params: conflicts })); diff --git a/ui/src/pages/GitSyncPage.tsx b/ui/src/pages/GitSyncPage.tsx index c3902d3db..6b29ced13 100644 --- a/ui/src/pages/GitSyncPage.tsx +++ b/ui/src/pages/GitSyncPage.tsx @@ -14,6 +14,7 @@ import { PageSkeleton } from '../components/Skeleton'; import { useToast } from '../components/Toast'; import { parseStatusLine } from '../components/git/gitView'; import PullConflictDialog from '../components/git/PullConflictDialog'; +import UnmatchedNotices from '../components/sync/UnmatchedNotices'; import type { GitPullConflict, GitPullResolution } from '../api/types/git'; import { useAppContext } from '../context/AppContext'; import { useT, plural } from '../i18n'; @@ -275,6 +276,7 @@ export default function GitSyncPage() { )} {pulled?.warnings?.map((w) =>