feat(artifacts): storefront layout and Uninstall for installed skills/plugins

- Artifacts page laid out like an app store: hero search, category chips,
  shelves by kind, app-icon cards with one primary pill and a detail sheet
- POST /api/artifacts/:id/uninstall: a skill's copies in ~/.claude/skills and
  ~/.agents/skills are moved to ~/.claude/agenthub-replaced-skills/
  (-uninstalled-<time>), never deleted; a plugin runs
  `claude plugin uninstall --scope user --keep-data` as the caller;
  ENOTINSTALLED when nothing is there; allowed while installs are off
- Uninstall on the card, the ⋯ menu and the detail sheet, after a confirm
This commit is contained in:
2026-10-21 16:10:30 +07:00
parent 383b9ae231
commit c042519bc9
11 changed files with 1066 additions and 235 deletions
+33 -2
View File
@@ -70,7 +70,8 @@
"form.save": "Add",
"form.cancel": "Cancel",
"added": "Added",
"files": "{{count}} files",
"files_one": "{{count}} file",
"files_other": "{{count}} files",
"close": "Close",
"fromSession": "From a session",
"form.saveEdit": "Save",
@@ -129,6 +130,12 @@
"reinstallHint": "Write this version over your installed copy",
"reinstallTitle": "Reinstall “{{title}}”?",
"reinstallBody": "Your installed ~/.claude/skills/{{name}}/ and ~/.agents/skills/{{name}}/ are replaced with this version. The current copy is moved to ~/.claude/agenthub-replaced-skills/, not deleted.",
"uninstall": "Uninstall",
"uninstallHint": "Remove it from your account",
"uninstallTitle": "Uninstall “{{title}}”?",
"uninstallSkillBody": "~/.claude/skills/{{name}}/ and ~/.agents/skills/{{name}}/ are moved to ~/.claude/agenthub-replaced-skills/, not deleted. Sessions already open keep it until they reload.",
"uninstallPluginBody": "Runs claude plugin uninstall {{name}} for your account; the plugin's data folder is kept. Open sessions keep it until /reload-plugins.",
"uninstalled": "Uninstalled {{name}}",
"deleteBodyShared": "It is shared, so it also disappears from the Hub for everyone. To keep it but stop sharing, use Unshare instead. Anything already installed from it stays installed.",
"deleteBodyKeep": "It leaves your library but stays in the Hub, because it is shared. To take it off the Hub too, use Remove from Hub afterwards (or Unshare first).",
"deleteKept": "Removed from your library — still in the Hub",
@@ -143,5 +150,29 @@
"preview.frontmatter": "Frontmatter (SKILL.md header)",
"preview.whenUsed": "When Claude uses it",
"preview.noDescription": "No description",
"preview.installsAs": "Installs as ~/.claude/skills/{{slug}}/ and ~/.agents/skills/{{slug}}/"
"preview.installsAs": "Installs as ~/.claude/skills/{{slug}}/ and ~/.agents/skills/{{slug}}/",
"blurb.skill": "Reusable instructions Claude follows",
"blurb.plugin": "Bundles of skills, commands and hooks",
"blurb.page": "Pages your sessions published on claude.ai",
"blurb.file": "Documents and outputs worth keeping",
"clearSearch": "Clear search",
"categories": "Categories",
"seeAll": "See all",
"results_one": "{{count}} result",
"results_other": "{{count}} results",
"empty.title": "Your library is empty",
"empty.hubTitle": "The Hub is quiet",
"empty.searchTitle": "No matches",
"empty.search": "Nothing matches this search or category — try other words, or pick All.",
"details": "Details",
"more": "More actions",
"about": "About",
"stat.kind": "Type",
"stat.installs": "Installs",
"stat.files": "Files",
"stat.size": "Size",
"stat.updated": "Updated",
"detail.runAs": "Run it as",
"detail.market": "Marketplace",
"detail.added": "Added {{date}}"
}
+33 -2
View File
@@ -70,7 +70,8 @@
"form.save": "Thêm",
"form.cancel": "Huỷ",
"added": "Đã thêm",
"files": "{{count}} file",
"files_one": "{{count}} file",
"files_other": "{{count}} file",
"close": "Đóng",
"fromSession": "Từ một phiên",
"form.saveEdit": "Lưu",
@@ -129,6 +130,12 @@
"reinstallHint": "Ghi bản này đè lên bản bạn đã cài",
"reinstallTitle": "Cài lại “{{title}}”?",
"reinstallBody": "Bản đã cài ở ~/.claude/skills/{{name}}/ và ~/.agents/skills/{{name}}/ sẽ được thay bằng bản này. Bản hiện tại được chuyển vào ~/.claude/agenthub-replaced-skills/, không bị xoá.",
"uninstall": "Gỡ cài đặt",
"uninstallHint": "Gỡ khỏi tài khoản của bạn",
"uninstallTitle": "Gỡ cài đặt “{{title}}”?",
"uninstallSkillBody": "~/.claude/skills/{{name}}/ và ~/.agents/skills/{{name}}/ sẽ được chuyển vào ~/.claude/agenthub-replaced-skills/, không bị xoá. Các phiên đang mở vẫn giữ nó cho tới khi tải lại.",
"uninstallPluginBody": "Chạy claude plugin uninstall {{name}} cho tài khoản của bạn; thư mục dữ liệu của plugin được giữ lại. Các phiên đang mở vẫn giữ nó cho tới khi /reload-plugins.",
"uninstalled": "Đã gỡ {{name}}",
"deleteBodyShared": "Mục này đang được chia sẻ nên cũng sẽ biến mất khỏi Hub với mọi người. Muốn giữ lại nhưng thôi chia sẻ thì dùng Bỏ chia sẻ. Những gì đã cài từ nó vẫn được giữ.",
"deleteBodyKeep": "Mục này rời khỏi thư viện của bạn nhưng vẫn ở trên Hub vì đang được chia sẻ. Muốn gỡ khỏi Hub luôn thì sau đó bấm Gỡ khỏi Hub (hoặc Bỏ chia sẻ trước).",
"deleteKept": "Đã xoá khỏi thư viện — vẫn còn trên Hub",
@@ -143,5 +150,29 @@
"preview.frontmatter": "Frontmatter (phần đầu SKILL.md)",
"preview.whenUsed": "Khi nào Claude dùng",
"preview.noDescription": "Chưa có mô tả",
"preview.installsAs": "Cài vào ~/.claude/skills/{{slug}}/ và ~/.agents/skills/{{slug}}/"
"preview.installsAs": "Cài vào ~/.claude/skills/{{slug}}/ và ~/.agents/skills/{{slug}}/",
"blurb.skill": "Bộ hướng dẫn tái sử dụng cho Claude",
"blurb.plugin": "Gói skill, lệnh và hook",
"blurb.page": "Trang mà phiên đã publish lên claude.ai",
"blurb.file": "Tài liệu và kết quả đáng giữ lại",
"clearSearch": "Xoá tìm kiếm",
"categories": "Danh mục",
"seeAll": "Xem tất cả",
"results_one": "{{count}} kết quả",
"results_other": "{{count}} kết quả",
"empty.title": "Thư viện đang trống",
"empty.hubTitle": "Hub chưa có gì",
"empty.searchTitle": "Không tìm thấy",
"empty.search": "Không có mục nào khớp tìm kiếm hoặc danh mục này — thử từ khác, hoặc chọn Tất cả.",
"details": "Chi tiết",
"more": "Thao tác khác",
"about": "Giới thiệu",
"stat.kind": "Loại",
"stat.installs": "Lượt cài",
"stat.files": "File",
"stat.size": "Dung lượng",
"stat.updated": "Cập nhật",
"detail.runAs": "Gọi bằng",
"detail.market": "Marketplace",
"detail.added": "Thêm lúc {{date}}"
}
+5
View File
@@ -3007,6 +3007,11 @@ export const api = {
method: "POST",
body: JSON.stringify({ replace }),
}),
/** POST /api/artifacts/:id/uninstall — a skill moved aside, a plugin `claude plugin uninstall`. */
uninstall: (id: number) =>
request<{ uninstalled: string; paths: string[] }>(`/artifacts/${id}/uninstall`, {
method: "POST",
}),
/** GET /api/artifacts/:id/installs — who installed it, when, and where. */
installs: (id: number) => request<ArtifactInstalls>(`/artifacts/${id}/installs`),
/** One of the snapshot's own files, served sandboxed. */
File diff suppressed because it is too large Load Diff
+48 -4
View File
@@ -10,8 +10,9 @@
* server cannot read opens the by-hand form), a skill is uploaded from one
* Markdown file under the name the user types, or written in the dialog.
* A card's right-click menu runs the same actions (Preview, Delete). A file
* the sandbox cannot show (Office, zip, PDF) offers Download only, and the
* Add menu closes on Escape or a click outside it.
* the sandbox cannot show (Office, zip, PDF) offers Download only, the
* Add menu closes on Escape or a click outside it, the front page is shelved
* by kind until a category is picked, and a card opens its detail sheet.
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
*/
import { describe, it, expect, vi, beforeEach } from "vitest";
@@ -32,6 +33,7 @@ vi.mock("../../lib/api", () => ({
update: vi.fn(),
remove: vi.fn(),
install: vi.fn(),
uninstall: vi.fn(),
installs: vi.fn(),
setInstallsEnabled: vi.fn(),
skills: vi.fn(),
@@ -294,6 +296,30 @@ describe("Artifacts", () => {
await waitFor(() => expect(api.artifacts.install).toHaveBeenLastCalledWith(2, true));
});
it("uninstalls an installed plugin only after a confirmation", async () => {
vi.mocked(api.artifacts.list).mockResolvedValue({
items: [
item({ id: 4, kind: "plugin", title: "tool", source: "tool@market", installed: true }),
],
});
vi.mocked(api.artifacts.uninstall).mockReset();
open();
const card = await screen.findByTestId("artifact-4");
const user = userEvent.setup();
vi.mocked(confirmDialog).mockResolvedValueOnce(false);
await user.click(within(card).getByRole("button", { name: "Uninstall" }));
await waitFor(() => expect(confirmDialog).toHaveBeenCalled());
expect(api.artifacts.uninstall).not.toHaveBeenCalled();
vi.mocked(confirmDialog).mockResolvedValueOnce(true);
vi.mocked(api.artifacts.uninstall).mockResolvedValueOnce({
uninstalled: "tool@market",
paths: [],
});
await user.click(within(card).getByRole("button", { name: "Uninstall" }));
await waitFor(() => expect(api.artifacts.uninstall).toHaveBeenCalledWith(4));
});
it("installs a skill only after a confirmation, and asks before replacing", async () => {
const user = userEvent.setup();
open();
@@ -315,8 +341,8 @@ describe("Artifacts", () => {
it("previews a file in a sandboxed iframe that may run nothing", async () => {
const user = userEvent.setup();
open();
await screen.findByText("report.html");
await user.click(screen.getAllByRole("button", { name: "Preview" })[0]!);
const card = await screen.findByTestId("artifact-1");
await user.click(within(card).getByRole("button", { name: "Preview" }));
const frame = await screen.findByTestId("artifact-preview");
expect(frame.getAttribute("sandbox")).toBe("");
expect(frame.getAttribute("src")).toBe("/api/artifacts/1/raw?path=report.html");
@@ -425,4 +451,22 @@ describe("Artifacts", () => {
await user.click(screen.getByText("report.html"));
expect(screen.queryByRole("button", { name: "Skill" })).toBeNull();
});
it("shelves the front page by kind, and a card opens its detail sheet", async () => {
const user = userEvent.setup();
open();
await screen.findByText("deploy");
const shelves = screen.getAllByRole("heading", { level: 2 }).map((h) => h.textContent);
expect(shelves).toEqual(["Skills1", "Files1"]);
await user.click(screen.getAllByRole("button", { name: "See all" })[0]!);
await waitFor(() =>
expect(api.artifacts.list).toHaveBeenLastCalledWith(
expect.objectContaining({ kind: "skill" })
)
);
await user.click(screen.getByText("deploy"));
const sheet = await screen.findByTestId("artifact-detail");
expect(within(sheet).getByText("/deploy")).toBeInTheDocument();
expect(within(sheet).getByRole("button", { name: "Install" })).toBeInTheDocument();
});
});