From 3916897c98916bdbc3f05eb750bec4135fba3105 Mon Sep 17 00:00:00 2001 From: Willie Date: Fri, 20 Nov 2026 17:07:26 +0800 Subject: [PATCH] feat(ui): check only the selected skills on the Updates tab (#965) After a full check, a skill whose remote did not answer shows "Check failed". The only ways to look at it again were to check everything once more, which with many skills takes a while and re-runs the ones that already answered, or to update it without knowing whether an update exists (#963). Ticking rows on the Skills Updates tab now offers "Check N selected". It checks those tracked repos and skills only, and every other row keeps the result it had. GET /api/check/stream takes the names to limit the check to, as GET /api/update/stream already does. The action is not offered for agents: the dashboard check does not cover them, so it would report each one as failed. Closes #963 Release-As: 0.30.13 --- internal/server/handler_check.go | 27 ++++++- .../server/handler_check_resolution_test.go | 30 +++++++ internal/server/handler_check_stream.go | 10 ++- ui/src/api/install.ts | 6 +- ui/src/i18n/locales/de.json | 1 + ui/src/i18n/locales/en.json | 1 + ui/src/i18n/locales/es.json | 1 + ui/src/i18n/locales/fa.json | 1 + ui/src/i18n/locales/fr.json | 1 + ui/src/i18n/locales/id.json | 1 + ui/src/i18n/locales/ja.json | 1 + ui/src/i18n/locales/ko.json | 1 + ui/src/i18n/locales/pt-BR.json | 1 + ui/src/i18n/locales/zh-CN.json | 1 + ui/src/i18n/locales/zh-TW.json | 1 + ui/src/pages/UpdatePage.tsx | 81 +++++++++++-------- 16 files changed, 128 insertions(+), 37 deletions(-) diff --git a/internal/server/handler_check.go b/internal/server/handler_check.go index 5bce9e8c1..756837828 100644 --- a/internal/server/handler_check.go +++ b/internal/server/handler_check.go @@ -4,6 +4,7 @@ import ( "context" "net/http" "path/filepath" + "strings" "skillshare/internal/check" "skillshare/internal/install" @@ -27,12 +28,32 @@ type skillCheckResult struct { Message string `json:"message,omitempty"` } +// checkNames reads the names query param (comma-separated): the tracked repos +// and skills a check is limited to. Without it, nil: everything is checked. +func checkNames(r *http.Request) map[string]bool { + param := r.URL.Query().Get("names") + if param == "" { + return nil + } + only := map[string]bool{} + for name := range strings.SplitSeq(param, ",") { + if name = strings.TrimSpace(name); name != "" { + only[name] = true + } + } + return only +} + // planSkillCheck plans the update check of every installed skill outside a -// followed checkout. It takes s.mu.RLock, so the caller must not hold s.mu. -func (s *Server) planSkillCheck(sourceDir, projectRoot string, walk sourcewalk.Options) *check.Resolution { +// followed checkout, or of those in only when it is not nil. It takes +// s.mu.RLock, so the caller must not hold s.mu. +func (s *Server) planSkillCheck(sourceDir, projectRoot string, walk sourcewalk.Options, only map[string]bool) *check.Resolution { names, _ := install.GetUpdatableSkills(sourceDir) var skills []check.Skill for _, name := range names { + if only != nil && !only[name] { + continue + } if followedCheckout(filepath.Join(sourceDir, name), walk.Follow) != "" { continue } @@ -80,7 +101,7 @@ func (s *Server) handleCheck(w http.ResponseWriter, r *http.Request) { s.mu.RUnlock() repos, linked := dashboardRepos(sourceDir, walk) - plan := s.planSkillCheck(sourceDir, projectRoot, walk) + plan := s.planSkillCheck(sourceDir, projectRoot, walk, nil) var repoResults []repoCheckResult for _, repo := range repos { diff --git a/internal/server/handler_check_resolution_test.go b/internal/server/handler_check_resolution_test.go index 0456f906c..c12711bc2 100644 --- a/internal/server/handler_check_resolution_test.go +++ b/internal/server/handler_check_resolution_test.go @@ -137,3 +137,33 @@ func TestHandleCheckStream_EventSequence(t *testing.T) { t.Errorf("skills:\n got %+v\nwant %+v", payload.Skills, want) } } + +func TestHandleCheckStream_NamesLimitTheCheck(t *testing.T) { + s, src := newTestServer(t) + checktest.Seed(t, t.TempDir(), src) + addTrackedRepoWithBrokenIndex(t, src, "_team") + addTrackedRepoWithBrokenIndex(t, src, "_other") + s.reloadSkillsStore() + + rr := httptest.NewRecorder() + s.handleCheckStream(rr, httptest.NewRequest(http.MethodGet, "/api/check/stream?names=_team,changed", nil)) + + blocks := strings.Split(strings.TrimSpace(rr.Body.String()), "\n\n") + if len(blocks) < 3 { + t.Fatalf("expected at least discovering, start and done, got %q", rr.Body.String()) + } + if want := "event: start\ndata: " + `{"repos":1,"sources":1,"total":2}`; blocks[1] != want { + t.Errorf("second event = %q, want %q", blocks[1], want) + } + _, done, ok := strings.Cut(blocks[len(blocks)-1], "event: done\ndata: ") + if !ok { + t.Fatalf("last event = %q, want done", blocks[len(blocks)-1]) + } + payload := decodeCheckPayload(t, done) + if len(payload.TrackedRepos) != 1 || payload.TrackedRepos[0].Name != "_team" { + t.Errorf("tracked repos = %+v, want only _team", payload.TrackedRepos) + } + if len(payload.Skills) != 1 || payload.Skills[0].Name != "changed" { + t.Errorf("skills = %+v, want only changed", payload.Skills) + } +} diff --git a/internal/server/handler_check_stream.go b/internal/server/handler_check_stream.go index 03ae839cd..ecda5c8f7 100644 --- a/internal/server/handler_check_stream.go +++ b/internal/server/handler_check_stream.go @@ -3,6 +3,7 @@ package server import ( "net/http" "path/filepath" + "slices" "sync" "sync/atomic" "time" @@ -19,6 +20,9 @@ import ( // // "total" counts actual work units (repos + remote URL groups), NOT individual skills. // This ensures the progress bar advances evenly — one tick per network call. +// +// Query params: names (comma-separated) limits the check to those tracked repos +// and skills; the events then cover only them. func (s *Server) handleCheckStream(w http.ResponseWriter, r *http.Request) { safeSend, ok := initSSE(w) if !ok { @@ -38,9 +42,13 @@ func (s *Server) handleCheckStream(w http.ResponseWriter, r *http.Request) { // Immediate feedback before the potentially slow discovery walk. safeSend("discovering", map[string]string{"phase": "scanning source directory"}) + only := checkNames(r) repos, linked := dashboardRepos(sourceDir, walk) + if only != nil { + repos = slices.DeleteFunc(repos, func(repo string) bool { return !only[repo] }) + } // Group skills by remote (fast, local only). - plan := s.planSkillCheck(sourceDir, projectRoot, walk) + plan := s.planSkillCheck(sourceDir, projectRoot, walk, only) // Total = repos + URL groups (the actual network-bound work units). total := len(repos) + plan.Remotes() diff --git a/ui/src/api/install.ts b/ui/src/api/install.ts index 5ea0d8ec0..f51eb1bbc 100644 --- a/ui/src/api/install.ts +++ b/ui/src/api/install.ts @@ -38,9 +38,13 @@ export const installApi = { onProgress: (checked: number) => void, onDone: (data: CheckResult) => void, onError: (err: Error) => void, + /** Tracked repos and skills to check; every one of them when omitted. */ + names?: string[], ): EventSource => createSSEStream( - BASE + '/check/stream', + BASE + + '/check/stream' + + (names?.length ? `?${new URLSearchParams({ names: names.join(',') })}` : ''), { discovering: () => onDiscovering(), start: (d) => onStart(d.total), diff --git a/ui/src/i18n/locales/de.json b/ui/src/i18n/locales/de.json index c35407ca7..ad36abb3b 100644 --- a/ui/src/i18n/locales/de.json +++ b/ui/src/i18n/locales/de.json @@ -949,6 +949,7 @@ "update.empty.title": "Keine aktualisierbaren Skills", "update.empty.agentsTitle": "Keine aktualisierbaren Agents", "update.empty.agentsDescription": "Von GitHub oder aus einem getrackten Repo installierte Agents lassen sich hier aktualisieren.", + "update.header.checkSelected": "Ausgewählte prüfen ({count})", "update.header.updateSelected": "Ausgewählte aktualisieren ({count})", "update.status.blocked": "Blockiert", "update.status.failed": "Fehlgeschlagen", diff --git a/ui/src/i18n/locales/en.json b/ui/src/i18n/locales/en.json index 70c133c8e..12c4e2598 100644 --- a/ui/src/i18n/locales/en.json +++ b/ui/src/i18n/locales/en.json @@ -871,6 +871,7 @@ "update.empty.title": "No updatable skills", "update.empty.agentsTitle": "No updatable agents", "update.empty.agentsDescription": "Agents installed from GitHub or a tracked repo can be updated here.", + "update.header.checkSelected": "Check {count} selected", "update.header.updateSelected": "Update {count} selected", "update.status.blocked": "Blocked", "update.status.failed": "Failed", diff --git a/ui/src/i18n/locales/es.json b/ui/src/i18n/locales/es.json index e15dea735..a71e8eb40 100644 --- a/ui/src/i18n/locales/es.json +++ b/ui/src/i18n/locales/es.json @@ -949,6 +949,7 @@ "update.empty.title": "Sin skills actualizables", "update.empty.agentsTitle": "Sin agents actualizables", "update.empty.agentsDescription": "Los agents instalados desde GitHub o un repo rastreado se pueden actualizar aquí.", + "update.header.checkSelected": "Comprobar seleccionados ({count})", "update.header.updateSelected": "Actualizar seleccionados ({count})", "update.status.blocked": "Bloqueado", "update.status.failed": "Fallido", diff --git a/ui/src/i18n/locales/fa.json b/ui/src/i18n/locales/fa.json index 42f3d5ccc..d27161d53 100644 --- a/ui/src/i18n/locales/fa.json +++ b/ui/src/i18n/locales/fa.json @@ -949,6 +949,7 @@ "update.empty.title": "هیچ اسکیل قابل به‌روزرسانی وجود ندارد", "update.empty.agentsTitle": "هیچ ایجنت قابل به‌روزرسانی وجود ندارد", "update.empty.agentsDescription": "ایجنت‌هایی که از GitHub یا یک مخزن ردیابی‌شده نصب شده‌اند را می‌توان اینجا به‌روزرسانی کرد.", + "update.header.checkSelected": "بررسی انتخاب‌شده‌ها ({count})", "update.header.updateSelected": "به‌روزرسانی انتخاب‌شده‌ها ({count})", "update.status.blocked": "مسدود شده", "update.status.failed": "ناموفق", diff --git a/ui/src/i18n/locales/fr.json b/ui/src/i18n/locales/fr.json index d4009b474..13808a007 100644 --- a/ui/src/i18n/locales/fr.json +++ b/ui/src/i18n/locales/fr.json @@ -949,6 +949,7 @@ "update.empty.title": "Aucun skill pouvant être mis à jour", "update.empty.agentsTitle": "Aucun agent pouvant être mis à jour", "update.empty.agentsDescription": "Les agents installés depuis GitHub ou un dépôt suivi peuvent être mis à jour ici.", + "update.header.checkSelected": "Vérifier la sélection ({count})", "update.header.updateSelected": "Mettre à jour la sélection ({count})", "update.status.blocked": "Bloqué", "update.status.failed": "Échec", diff --git a/ui/src/i18n/locales/id.json b/ui/src/i18n/locales/id.json index 3e1e6d183..f53a904fa 100644 --- a/ui/src/i18n/locales/id.json +++ b/ui/src/i18n/locales/id.json @@ -949,6 +949,7 @@ "update.empty.title": "Tidak ada skill yang dapat diperbarui", "update.empty.agentsTitle": "Tidak ada agent yang dapat diperbarui", "update.empty.agentsDescription": "Agent yang dipasang dari GitHub atau repo terlacak dapat diperbarui di sini.", + "update.header.checkSelected": "Periksa Terpilih ({count})", "update.header.updateSelected": "Perbarui Terpilih ({count})", "update.status.blocked": "Diblokir", "update.status.failed": "Gagal", diff --git a/ui/src/i18n/locales/ja.json b/ui/src/i18n/locales/ja.json index 4d8be6a67..964c4c1a7 100644 --- a/ui/src/i18n/locales/ja.json +++ b/ui/src/i18n/locales/ja.json @@ -949,6 +949,7 @@ "update.empty.title": "更新可能なスキルがありません", "update.empty.agentsTitle": "更新可能なエージェントがありません", "update.empty.agentsDescription": "GitHub や追跡中のリポジトリからインストールしたエージェントはここで更新できます。", + "update.header.checkSelected": "選択した項目を確認({count})", "update.header.updateSelected": "選択した項目を更新({count})", "update.status.blocked": "ブロック済み", "update.status.failed": "失敗", diff --git a/ui/src/i18n/locales/ko.json b/ui/src/i18n/locales/ko.json index 0b3f7da3b..7ed454e04 100644 --- a/ui/src/i18n/locales/ko.json +++ b/ui/src/i18n/locales/ko.json @@ -949,6 +949,7 @@ "update.empty.title": "업데이트 가능한 skills 없음", "update.empty.agentsTitle": "업데이트 가능한 agents 없음", "update.empty.agentsDescription": "GitHub 또는 추적 중인 저장소에서 설치한 agents는 여기에서 업데이트할 수 있습니다.", + "update.header.checkSelected": "선택 항목 확인 ({count})", "update.header.updateSelected": "선택 항목 업데이트 ({count})", "update.status.blocked": "차단됨", "update.status.failed": "실패", diff --git a/ui/src/i18n/locales/pt-BR.json b/ui/src/i18n/locales/pt-BR.json index 66b376b1b..276ae675a 100644 --- a/ui/src/i18n/locales/pt-BR.json +++ b/ui/src/i18n/locales/pt-BR.json @@ -949,6 +949,7 @@ "update.empty.title": "Nenhuma skill atualizável", "update.empty.agentsTitle": "Nenhum agent atualizável", "update.empty.agentsDescription": "Agents instalados do GitHub ou de um repo rastreado podem ser atualizados aqui.", + "update.header.checkSelected": "Verificar Selecionados ({count})", "update.header.updateSelected": "Atualizar Selecionados ({count})", "update.status.blocked": "Bloqueado", "update.status.failed": "Falhou", diff --git a/ui/src/i18n/locales/zh-CN.json b/ui/src/i18n/locales/zh-CN.json index b83523da7..b0e833e03 100644 --- a/ui/src/i18n/locales/zh-CN.json +++ b/ui/src/i18n/locales/zh-CN.json @@ -949,6 +949,7 @@ "update.empty.title": "没有可更新的 skill", "update.empty.agentsTitle": "没有可更新的 agent", "update.empty.agentsDescription": "从 GitHub 或追踪仓库安装的 agent 可在这里更新。", + "update.header.checkSelected": "检查所选({count})", "update.header.updateSelected": "更新所选({count})", "update.status.blocked": "已拦截", "update.status.failed": "失败", diff --git a/ui/src/i18n/locales/zh-TW.json b/ui/src/i18n/locales/zh-TW.json index 477b37cb2..82f4b3160 100644 --- a/ui/src/i18n/locales/zh-TW.json +++ b/ui/src/i18n/locales/zh-TW.json @@ -949,6 +949,7 @@ "update.empty.title": "沒有可更新的 skills", "update.empty.agentsTitle": "沒有可更新的 agents", "update.empty.agentsDescription": "從 GitHub 或追蹤中的 repo 安裝的 agents 可以在這裡更新。", + "update.header.checkSelected": "檢查已選取({count})", "update.header.updateSelected": "更新已選取({count})", "update.status.blocked": "已封鎖", "update.status.failed": "失敗", diff --git a/ui/src/pages/UpdatePage.tsx b/ui/src/pages/UpdatePage.tsx index c7807d6f6..f506ff96a 100644 --- a/ui/src/pages/UpdatePage.tsx +++ b/ui/src/pages/UpdatePage.tsx @@ -306,37 +306,43 @@ export default function UpdatePage({ kind }: { kind: Kind }) { [updatable, setStatuses, queryClient], ); - const runCheck = useCallback(() => { - esRef.current?.close(); - setChecking(true); - setPruned(0); - setRun(new Map()); - setFinished(false); - setStatuses((prev) => { - const next = new Map(prev); - for (const item of updatable) next.set(checkKey(item), { status: 'checking' }); - return next; - }); - esRef.current = api.checkStream( - () => {}, - () => {}, - () => {}, - (result) => { - applyCheckResult(result); - setChecking(false); - }, - (err) => { - toast(err.message, 'error'); - setStatuses((prev) => { - const next = new Map(prev); - const checkedAt = new Date().toISOString(); - for (const item of updatable) next.set(checkKey(item), { status: 'error', checkedAt }); - return next; - }); - setChecking(false); - }, - ); - }, [updatable, applyCheckResult, setStatuses, toast]); + // Checks the given units, leaving every other result as it is; all of them when omitted. + const runCheck = useCallback( + (only?: UpdateUnit[]) => { + const items = only ? only.flatMap((u) => u.items) : updatable; + esRef.current?.close(); + setChecking(true); + setPruned(0); + setRun(new Map()); + setFinished(false); + setStatuses((prev) => { + const next = new Map(prev); + for (const item of items) next.set(checkKey(item), { status: 'checking' }); + return next; + }); + esRef.current = api.checkStream( + () => {}, + () => {}, + () => {}, + (result) => { + applyCheckResult(result); + setChecking(false); + }, + (err) => { + toast(err.message, 'error'); + setStatuses((prev) => { + const next = new Map(prev); + const checkedAt = new Date().toISOString(); + for (const item of items) next.set(checkKey(item), { status: 'error', checkedAt }); + return next; + }); + setChecking(false); + }, + only?.map((u) => u.name), + ); + }, + [updatable, applyCheckResult, setStatuses, toast], + ); /* -- Update -- */ @@ -810,10 +816,21 @@ export default function UpdatePage({ kind }: { kind: Kind }) { onChange={setForce} disabled={busy} /> - + {/* The check does not cover agents, so only skills can be checked by selection. */} + {kind === 'skill' && shown.length > 0 && ( + + )} {shown.length > 0 && (