Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
feat(skills): bulk update from source (#6930)
Guillaume2014ae3613bb
diff --git a/apps/docs/content/docs/skills.ja.mdx b/apps/docs/content/docs/skills.ja.mdxindex b990a4464b..92d78e1a4d 100644--- a/apps/docs/content/docs/skills.ja.mdx+++ b/apps/docs/content/docs/skills.ja.mdx@@ -52,6 +52,8 @@ multica skill refresh <skill-id>ソースから更新できるのは、スキルの作成者とワークスペースの `owner`・`admin` です。手動で作成したスキル、アーカイブファイルからインポートしたスキル、ランタイムからコピーしたスキルにはホストされたソースがないため、この方法では更新できません。再インポートしてください。+複数のスキルをまとめて更新するには、スキル一覧で選択して選択ツールバーの**更新**を使います。ホストされたソースを持つ選択中のスキルはすべてソースから再ダウンロードされ、ソースのないものはスキップされます。+## スキルの内容すべてのスキルには、主ファイル `SKILL.md` があります。ここに次の内容を書きます。diff --git a/apps/docs/content/docs/skills.ko.mdx b/apps/docs/content/docs/skills.ko.mdxindex e8aa6e3534..c0d682eb72 100644--- a/apps/docs/content/docs/skills.ko.mdx+++ b/apps/docs/content/docs/skills.ko.mdx@@ -52,6 +52,8 @@ multica skill refresh <skill-id>스킬의 생성자와 워크스페이스 `owner`, `admin`이 소스에서 업데이트할 수 있습니다. 수동으로 만들었거나, 압축 파일에서 가져왔거나, 런타임에서 복사한 스킬은 호스팅된 소스가 없어 이 방법으로 업데이트할 수 없습니다. 다시 가져오세요.+여러 스킬을 한 번에 업데이트하려면 스킬 목록에서 선택한 뒤 선택 도구 모음의 **업데이트**를 사용하세요. 호스팅된 소스가 있는 선택된 스킬은 모두 소스에서 다시 다운로드되며, 소스가 없는 스킬은 건너뜁니다.+## 스킬 내용모든 스킬에는 기본 파일 `SKILL.md`가 있습니다. 이 파일에 다음 내용을 명확히 작성하세요.diff --git a/apps/docs/content/docs/skills.mdx b/apps/docs/content/docs/skills.mdxindex 5c958c55c3..15ed6ea9ba 100644--- a/apps/docs/content/docs/skills.mdx+++ b/apps/docs/content/docs/skills.mdx@@ -52,6 +52,8 @@ The skill is re-downloaded from its source and replaced in place:The skill's creator and workspace `owner`s / `admin`s can update from source. Skills created manually, imported from an archive file, or copied from a runtime have no hosted source and cannot be updated this way — re-import them instead.+To update several skills at once, select them in the skills list and pick **Update** in the selection toolbar. Every selected skill with a hosted source is re-downloaded from its source; skills without one are skipped.+## Skill contentsEvery skill contains a main file, `SKILL.md`. Spell out:diff --git a/apps/docs/content/docs/skills.zh.mdx b/apps/docs/content/docs/skills.zh.mdxindex 087cf506af..7311843a55 100644--- a/apps/docs/content/docs/skills.zh.mdx+++ b/apps/docs/content/docs/skills.zh.mdx@@ -52,6 +52,8 @@ Skill 会从来源重新下载并就地替换:Skill 的创建者以及工作区 `owner`、`admin` 都可以从来源更新。手动创建、从压缩包导入、或从运行时复制的 skill 没有托管来源,无法这样更新 —— 请重新导入。+要一次更新多个 skill,在列表中选中它们,然后在选择工具栏中点击**更新**。所有选中的、有托管来源的 skill 都会从来源重新下载;没有托管来源的会被跳过。+## Skill 的内容每个 skill 都包含一个主文件 `SKILL.md`。在这里写清:diff --git a/packages/views/locales/en/skills.json b/packages/views/locales/en/skills.jsonindex da15a03d6c..abd5612f1a 100644--- a/packages/views/locales/en/skills.json+++ b/packages/views/locales/en/skills.json@@ -87,6 +87,18 @@"deleted_toast_one": "Deleted {{count}} skill","deleted_toast_other": "Deleted {{count}} skills","delete_failed_toast": "Failed to delete skills",+ "update": "Update",+ "update_none": "Selection has no imported skills you can update",+ "update_dialog_title": "Update skills from source?",+ "update_summary_selected_one": "{{count}} skill will be updated from its source",+ "update_summary_selected_other": "{{count}} skills will be updated from their sources",+ "update_summary_skipped_one": "{{count}} can't be updated from a source — skipped",+ "update_summary_skipped_other": "{{count}} can't be updated from a source — skipped",+ "update_confirm": "Update {{count}}",+ "update_updating": "Updating {{done}}/{{total}}…",+ "updated_toast_one": "Updated {{count}} skill from source",+ "updated_toast_other": "Updated {{count}} skills from source",+ "update_partial_toast": "Updated {{count}}, {{failed}} failed","add_dialog_description": "Select the agents that should get the selected skills.","cancel": "Cancel","add_confirm": "Add ({{num}})",diff --git a/packages/views/locales/ja/skills.json b/packages/views/locales/ja/skills.jsonindex 8d90c811dd..6e1f7def5c 100644--- a/packages/views/locales/ja/skills.json+++ b/packages/views/locales/ja/skills.json@@ -84,6 +84,15 @@"delete_dialog_desc_other": "選択した {{count}} 件のスキルを完全に削除し、すべてのエージェントから取り外します。","deleted_toast_other": "{{count}} 件のスキルを削除しました","delete_failed_toast": "スキルの削除に失敗しました",+ "update": "更新",+ "update_none": "選択内容に更新できるインポート済みスキルがありません",+ "update_dialog_title": "ソースからスキルを更新しますか?",+ "update_summary_selected_other": "{{count}} 件をソースから更新します",+ "update_summary_skipped_other": "{{count}} 件はソースから更新できないためスキップします",+ "update_confirm": "{{count}} 件を更新",+ "update_updating": "更新中 {{done}}/{{total}}…",+ "updated_toast_other": "ソースから {{count}} 件のスキルを更新しました",+ "update_partial_toast": "{{count}} 件を更新、{{failed}} 件は失敗しました","add_dialog_description": "選択したスキルを追加するエージェントを選んでください。","cancel": "キャンセル","add_confirm": "追加({{num}})",diff --git a/packages/views/locales/ko/skills.json b/packages/views/locales/ko/skills.jsonindex e5eacf7cd0..b188907afd 100644--- a/packages/views/locales/ko/skills.json+++ b/packages/views/locales/ko/skills.json@@ -84,6 +84,15 @@"delete_dialog_desc_other": "선택한 스킬 {{count}}개를 영구 삭제하고 모든 에이전트에서 제거합니다.","deleted_toast_other": "스킬 {{count}}개를 삭제했습니다","delete_failed_toast": "스킬 삭제에 실패했습니다",+ "update": "업데이트",+ "update_none": "선택 항목에 업데이트할 수 있는 가져온 스킬이 없습니다",+ "update_dialog_title": "소스에서 스킬을 업데이트할까요?",+ "update_summary_selected_other": "{{count}}개를 소스에서 업데이트합니다",+ "update_summary_skipped_other": "{{count}}개는 소스에서 업데이트할 수 없어 건너뜁니다",+ "update_confirm": "{{count}}개 업데이트",+ "update_updating": "업데이트하는 중 {{done}}/{{total}}...",+ "updated_toast_other": "소스에서 스킬 {{count}}개를 업데이트했습니다",+ "update_partial_toast": "{{count}}개 업데이트, {{failed}}개 실패","add_dialog_description": "선택한 스킬을 추가할 에이전트를 선택하세요.","cancel": "취소","add_confirm": "추가 ({{num}})",diff --git a/packages/views/locales/zh-Hans/skills.json b/packages/views/locales/zh-Hans/skills.jsonindex f5d94cbee1..fa7351b8ce 100644--- a/packages/views/locales/zh-Hans/skills.json+++ b/packages/views/locales/zh-Hans/skills.json@@ -84,6 +84,15 @@"delete_dialog_desc_other": "将永久删除选中的 {{count}} 个 skill,并从所有智能体上移除。","deleted_toast_other": "已删除 {{count}} 个 skill","delete_failed_toast": "删除 skill 失败",+ "update": "更新",+ "update_none": "所选内容中没有你可以更新的已导入 skill",+ "update_dialog_title": "从来源更新 skill?",+ "update_summary_selected_other": "将从来源更新 {{count}} 个 skill",+ "update_summary_skipped_other": "{{count}} 个无法从来源更新,跳过",+ "update_confirm": "更新 {{count}} 个",+ "update_updating": "更新中 {{done}}/{{total}}...",+ "updated_toast_other": "已从来源更新 {{count}} 个 skill",+ "update_partial_toast": "已更新 {{count}} 个,{{failed}} 个失败","add_dialog_description": "选择要获得所选 skill 的智能体。","cancel": "取消","add_confirm": "添加({{num}})",diff --git a/packages/views/skills/components/skill-list-actions.test.tsx b/packages/views/skills/components/skill-list-actions.test.tsxnew file mode 100644index 0000000000..a550e081b2--- /dev/null+++ b/packages/views/skills/components/skill-list-actions.test.tsx@@ -0,0 +1,141 @@+// @vitest-environment jsdom++import { describe, it, expect, vi, beforeEach } from "vitest";+import { render, screen, waitFor } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import type { SkillSummary } from "@multica/core/types";+import { I18nProvider } from "@multica/core/i18n/react";+import enCommon from "../../locales/en/common.json";+import enSkills from "../../locales/en/skills.json";+import type { SkillRow } from "./skills-page";+import type { SkillActionsContext } from "./skill-list-actions";++const TEST_RESOURCES = { en: { common: enCommon, skills: enSkills } };++vi.mock("@multica/core/api", () => ({+ api: { refreshSkill: vi.fn() },+}));+vi.mock("sonner", () => ({ toast: { success: vi.fn(), error: vi.fn() } }));++import { api } from "@multica/core/api";+import { toast } from "sonner";+import { UpdateSkillsDialog } from "./skill-list-actions";++const refreshSkill = vi.mocked(api.refreshSkill);++function makeRow(id: string): SkillRow {+ const skill: SkillSummary = {+ id,+ workspace_id: "ws-1",+ name: `skill-${id}`,+ description: "",+ config: {+ origin: { type: "github", source_url: `https://github.com/acme/${id}` },+ },+ created_by: "user-1",+ created_at: "2026-01-01T00:00:00Z",+ updated_at: "2026-01-01T00:00:00Z",+ };+ return {+ skill,+ agents: [],+ creator: null,+ runtime: null,+ originType: "github",+ canEdit: true,+ };+}++const ctx: SkillActionsContext = {+ wsId: "ws-1",+ agents: [],+ currentUserId: "user-1",+ isAdmin: true,+};++function renderDialog(+ rows: SkillRow[],+ skippedCount = 0,+ onUpdated?: () => void,+) {+ const queryClient = new QueryClient({+ defaultOptions: { queries: { retry: false } },+ });+ render(+ <I18nProvider locale="en" resources={TEST_RESOURCES}>+ <QueryClientProvider client={queryClient}>+ <UpdateSkillsDialog+ rows={rows}+ skippedCount={skippedCount}+ ctx={ctx}+ open+ onOpenChange={() => {}}+ onUpdated={onUpdated}+ />+ </QueryClientProvider>+ </I18nProvider>,+ );+}++beforeEach(() => {+ vi.clearAllMocks();+});++describe("UpdateSkillsDialog", () => {+ it("summarizes the updatable selection and the skipped entries", async () => {+ renderDialog([makeRow("a"), makeRow("b")], 1);++ expect(+ await screen.findByText("2 skills will be updated from their sources"),+ ).toBeTruthy();+ // The never-updatable selection entries passed via skippedCount.+ expect(+ screen.getByText("1 can't be updated from a source — skipped"),+ ).toBeTruthy();+ expect(screen.getByRole("button", { name: /Update 2/ })).toBeTruthy();+ });++ it("omits the skipped line when the whole selection is updatable", async () => {+ renderDialog([makeRow("a")]);++ expect(+ await screen.findByText("1 skill will be updated from its source"),+ ).toBeTruthy();+ expect(screen.queryByText(/skipped/)).toBeNull();+ });++ it("refreshes every updatable skill and clears the selection on success", async () => {+ refreshSkill.mockResolvedValue({} as never);+ const onUpdated = vi.fn();+ renderDialog([makeRow("a"), makeRow("b")], 0, onUpdated);++ await userEvent.click(+ await screen.findByRole("button", { name: /Update 2/ }),+ );++ await waitFor(() => expect(onUpdated).toHaveBeenCalled());+ expect(refreshSkill.mock.calls.map(([id]) => id)).toEqual(["a", "b"]);+ expect(toast.success).toHaveBeenCalled();+ });++ it("continues past a failing item and reports a partial toast", async () => {+ refreshSkill.mockImplementation((id: string) =>+ id === "a"+ ? Promise.reject(new Error("name conflict"))+ : Promise.resolve({} as never),+ );+ const onUpdated = vi.fn();+ renderDialog([makeRow("a"), makeRow("b")], 0, onUpdated);++ await userEvent.click(+ await screen.findByRole("button", { name: /Update 2/ }),+ );++ await waitFor(() => expect(toast.error).toHaveBeenCalled());+ // The failure on "a" must not strand "b".+ expect(refreshSkill.mock.calls.map(([id]) => id)).toEqual(["a", "b"]);+ // Partial success keeps the selection: onUpdated only fires on a clean run.+ expect(onUpdated).not.toHaveBeenCalled();+ });+});diff --git a/packages/views/skills/components/skill-list-actions.tsx b/packages/views/skills/components/skill-list-actions.tsxindex 48fa828036..6a48615a59 100644--- a/packages/views/skills/components/skill-list-actions.tsx+++ b/packages/views/skills/components/skill-list-actions.tsx@@ -510,6 +510,141 @@ export function DeleteSkillsDialog({);}+// ---------------------------------------------------------------------------+// Bulk update-from-source (batch toolbar)+// ---------------------------------------------------------------------------++/**+ * Confirm-and-run dialog for updating several imported skills from their+ * sources. Every updatable selection entry is re-downloaded — deliberately+ * no upstream freshness probe first (product call on #6930): re-fetching an+ * already-current skill costs one download on an explicit Update click,+ * which beats probing every source to find out it was current.+ *+ * Refreshes run sequentially with per-item failure tolerance (unlike bulk+ * delete's all-or-nothing loop): a single 409 from an upstream rename+ * collision must not strand the rest of the batch. A partial failure keeps+ * the selection (`onUpdated` only fires on a clean run) so retry is one+ * click away.+ */+export function UpdateSkillsDialog({+ rows,+ skippedCount,+ ctx,+ open,+ onOpenChange,+ onUpdated,+}: {+ /** The updatable subset of the selection (canEdit + refreshable origin). */+ rows: SkillRow[];+ /** Selection entries that are not updatable (manual, runtime, no permission). */+ skippedCount: number;+ ctx: SkillActionsContext;+ open: boolean;+ onOpenChange: (open: boolean) => void;+ /** Fired only after a fully successful run, so a partial failure keeps the selection for retry. */+ onUpdated?: () => void;+}) {+ const { t } = useT("skills");+ const qc = useQueryClient();+ const [updating, setUpdating] = useState(false);+ const [progress, setProgress] = useState(0);++ const handleConfirm = async () => {+ setUpdating(true);+ let updated = 0;+ let failed = 0;+ try {+ for (const row of rows) {+ setProgress(updated + failed + 1);+ try {+ await api.refreshSkill(row.skill.id);+ updated++;+ } catch {+ failed++;+ }+ }+ qc.invalidateQueries({ queryKey: workspaceKeys.skills(ctx.wsId) });+ qc.invalidateQueries({ queryKey: workspaceKeys.agents(ctx.wsId) });+ if (failed === 0) {+ toast.success(t(($) => $.actions.updated_toast, { count: updated }));+ onOpenChange(false);+ onUpdated?.();+ } else {+ toast.error(+ t(($) => $.actions.update_partial_toast, { count: updated, failed }),+ );+ onOpenChange(false);+ }+ } finally {+ setUpdating(false);+ setProgress(0);+ }+ };++ return (+ <Dialog+ open={open}+ onOpenChange={(v) => {+ if (!updating) onOpenChange(v);+ }}+ >+ <DialogContent className="sm:max-w-md">+ <DialogHeader>+ <DialogTitle>{t(($) => $.actions.update_dialog_title)}</DialogTitle>+ </DialogHeader>+ <ul className="space-y-1 text-caption text-muted-foreground">+ <li>+ {t(($) => $.actions.update_summary_selected, {+ count: rows.length,+ })}+ </li>+ {skippedCount > 0 && (+ <li>+ {t(($) => $.actions.update_summary_skipped, {+ count: skippedCount,+ })}+ </li>+ )}+ </ul>+ <div className="rounded-md bg-warning/10 px-3 py-2 text-caption text-muted-foreground">+ {t(($) => $.detail.refresh.dialog.warning)}+ </div>+ <DialogFooter>+ <Button+ type="button"+ variant="ghost"+ onClick={() => onOpenChange(false)}+ disabled={updating}+ >+ {t(($) => $.actions.cancel)}+ </Button>+ <Button+ type="button"+ onClick={handleConfirm}+ disabled={updating || rows.length === 0}+ >+ {updating ? (+ <>+ <Loader2 className="h-3 w-3 animate-spin" />+ {t(($) => $.actions.update_updating, {+ done: progress,+ total: rows.length,+ })}+ </>+ ) : (+ <>+ <RotateCw className="h-3 w-3" />+ {t(($) => $.actions.update_confirm, { count: rows.length })}+ </>+ )}+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>+ );+}+// ---------------------------------------------------------------------------// Row kebab// ---------------------------------------------------------------------------@@ -631,11 +766,28 @@ export function SkillBatchToolbar({}) {const { t } = useT("skills");const [addOpen, setAddOpen] = useState(false);+ const [updateOpen, setUpdateOpen] = useState(false);const [deleteOpen, setDeleteOpen] = useState(false);if (rows.length === 0) return null;const allDeletable = rows.every((r) => r.canEdit);+ const updatable = rows.filter(+ (r) => r.canEdit && isRefreshableOrigin(readOrigin(r.skill)),+ );++ const updateButton = (+ <Button+ variant="ghost"+ size="sm"+ disabled={updatable.length === 0}+ onClick={() => setUpdateOpen(true)}+ className={cn(updatable.length === 0 && "pointer-events-none")}+ >+ <RotateCw className="mr-1 size-3.5" />+ {t(($) => $.actions.update)}+ </Button>+ );const deleteButton = (<Button@@ -679,6 +831,19 @@ export function SkillBatchToolbar({{t(($) => $.actions.add_to_agent)}</Button>+ {updatable.length > 0 ? (+ updateButton+ ) : (+ <Tooltip>+ <TooltipTrigger+ render={<span className="inline-flex">{updateButton}</span>}+ />+ <TooltipContent side="top">+ {t(($) => $.actions.update_none)}+ </TooltipContent>+ </Tooltip>+ )}+{allDeletable ? (deleteButton) : (@@ -699,6 +864,14 @@ export function SkillBatchToolbar({open={addOpen}onOpenChange={setAddOpen}/>+ <UpdateSkillsDialog+ rows={updatable}+ skippedCount={rows.length - updatable.length}+ ctx={ctx}+ open={updateOpen}+ onOpenChange={setUpdateOpen}+ onUpdated={onClear}+ /><DeleteSkillsDialogrows={rows}ctx={ctx}