Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

feat(skills): rebuild skill detail page around Overview/Files tabs (MUL-5443) (#6100)

Naiyuan Qing37d66260e8fb
diff --git a/packages/ui/styles/base.css b/packages/ui/styles/base.css
index f96df89004..3c378693e6 100644
--- a/packages/ui/styles/base.css
+++ b/packages/ui/styles/base.css
@@ -2,6 +2,17 @@
* Multica shared base styles — imported by all apps
* ============================================================================= */
+/* The chat launcher overlays the dashboard's bottom-right corner on every
+ * workspace page, so a page-level bar that runs to that corner has to stop
+ * short of it. Named rather than spelled out at each site: the intent is
+ * legible, every site that yields to the launcher is findable by this class,
+ * and the distance stays derived from the launcher's own geometry. Centred
+ * floating toolbars and dialog footers do not need it — nothing else reaches
+ * that corner. */
+@utility pe-chat-launcher {
+ padding-inline-end: var(--chat-launcher-clearance);
+}
+
/* Shiki dual themes: CSS-only light/dark switching via CSS variables */
/* @see https://shiki.style/guide/dual-themes */
.shiki,
diff --git a/packages/ui/styles/tokens.css b/packages/ui/styles/tokens.css
index eeb6836f24..2865cf04aa 100644
--- a/packages/ui/styles/tokens.css
+++ b/packages/ui/styles/tokens.css
@@ -75,6 +75,18 @@
--surface-border: oklch(0.92 0.004 286.32);
--surface-shadow: 0 1px 2px rgb(15 23 42 / 0.04), 0 1px 1px rgb(15 23 42 / 0.03);
--floating-shadow: 0 16px 40px rgb(15 23 42 / 0.14), 0 3px 10px rgb(15 23 42 / 0.08);
+
+ /* The chat launcher is an overlay pinned to the dashboard's bottom-right
+ corner on every workspace page, so that corner is not available to page
+ content. Its geometry lives here rather than in the button so that the
+ clearance is derived from it: anything reaching that corner — a footer's
+ action buttons, a floating toolbar — reserves --chat-launcher-clearance
+ and stays correct if the launcher ever moves or changes size. */
+ --chat-launcher-size: 2.5rem;
+ --chat-launcher-inset: 0.5rem;
+ --chat-launcher-clearance: calc(
+ var(--chat-launcher-size) + var(--chat-launcher-inset) * 2
+ );
/* Menus (dropdown/context/select/popover) hover just above their trigger,
so they carry a lighter shadow than window-level overlays (dialogs,
sheets), which keep --floating-shadow. */
diff --git a/packages/views/agents/components/agent-creation-studio.tsx b/packages/views/agents/components/agent-creation-studio.tsx
index 6d27ae1e39..5b867165b7 100644
--- a/packages/views/agents/components/agent-creation-studio.tsx
+++ b/packages/views/agents/components/agent-creation-studio.tsx
@@ -1729,7 +1729,7 @@ export function StudioFooter({
}) {
const { t } = useT("agents");
return (
- <div className="sticky bottom-0 mt-8 flex items-center justify-between gap-3 border-t bg-background/95 px-5 py-3 backdrop-blur">
+ <div className="pe-chat-launcher sticky bottom-0 mt-8 flex items-center justify-between gap-3 border-t bg-background/95 py-3 pl-5 backdrop-blur">
{error ? (
<p
role="alert"
diff --git a/packages/views/agents/components/agent-detail-page.tsx b/packages/views/agents/components/agent-detail-page.tsx
index 965e7bc8db..c33de67d90 100644
--- a/packages/views/agents/components/agent-detail-page.tsx
+++ b/packages/views/agents/components/agent-detail-page.tsx
@@ -59,6 +59,7 @@ import { ActorAvatar } from "../../common/actor-avatar";
import { AgentPresenceIndicator } from "./agent-presence-indicator";
import { VisibilityBadge } from "./visibility-badge";
import { AgentOverviewPane, type DetailTab } from "./agent-overview-pane";
+import { ExpandableDescription } from "../../common/expandable-description";
import { useT, useTimeAgo } from "../../i18n";
interface AgentDetailPageProps {
@@ -438,9 +439,10 @@ function DetailHeader({
</h1>
<AgentPresenceIndicator detail={presence} />
</div>
- <p className="mt-1 max-w-2xl text-pretty text-sm leading-6 text-muted-foreground">
- {agent.description || t(($) => $.inspector.no_description_placeholder)}
- </p>
+ <ExpandableDescription>
+ {agent.description ||
+ t(($) => $.inspector.no_description_placeholder)}
+ </ExpandableDescription>
<div className="mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-muted-foreground">
<span className="inline-flex min-w-0 items-center gap-1.5">
<Bot className="h-3.5 w-3.5 shrink-0" aria-hidden="true" />
diff --git a/packages/views/chat/components/chat-fab.tsx b/packages/views/chat/components/chat-fab.tsx
index 15bd92c3f6..121c988b19 100644
--- a/packages/views/chat/components/chat-fab.tsx
+++ b/packages/views/chat/components/chat-fab.tsx
@@ -59,7 +59,9 @@ export function ChatFab() {
onClick={handleClick}
aria-label={tooltip}
className={cn(
- "absolute bottom-2 right-2 z-50 flex size-10 touch-manipulation items-center justify-center rounded-full bg-surface-raised text-muted-foreground shadow-[var(--floating-shadow)] ring-1 ring-surface-border transition-[background-color,color,box-shadow] hover:bg-surface-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70 focus-visible:ring-offset-2 focus-visible:ring-offset-page-canvas active:bg-surface-hover",
+ // Geometry comes from the shared tokens so the clearance pages
+ // reserve for this corner is derived from the same numbers.
+ "absolute bottom-[var(--chat-launcher-inset)] right-[var(--chat-launcher-inset)] z-50 flex size-[var(--chat-launcher-size)] touch-manipulation items-center justify-center rounded-full bg-surface-raised text-muted-foreground shadow-[var(--floating-shadow)] ring-1 ring-surface-border transition-[background-color,color,box-shadow] hover:bg-surface-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70 focus-visible:ring-offset-2 focus-visible:ring-offset-page-canvas active:bg-surface-hover",
// Impulse the button itself while a chat task is running — no
// outer ring to keep things calm.
isRunning && "animate-chat-impulse",
diff --git a/packages/views/common/expandable-description.test.tsx b/packages/views/common/expandable-description.test.tsx
new file mode 100644
index 0000000000..171a2c1c7a
--- /dev/null
+++ b/packages/views/common/expandable-description.test.tsx
@@ -0,0 +1,70 @@
+/**
+ * @vitest-environment jsdom
+ */
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { cleanup, screen } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
+import { renderWithI18n } from "../test/i18n";
+import { ExpandableDescription } from "./expandable-description";
+
+// jsdom reports every element as zero-height, so overflow has to be staged.
+// scrollHeight/clientHeight are the pair the component compares.
+function stageOverflow(scrollHeight: number, clientHeight: number) {
+ Object.defineProperty(HTMLParagraphElement.prototype, "scrollHeight", {
+ configurable: true,
+ get: () => scrollHeight,
+ });
+ Object.defineProperty(HTMLParagraphElement.prototype, "clientHeight", {
+ configurable: true,
+ get: () => clientHeight,
+ });
+}
+
+afterEach(() => {
+ cleanup();
+ vi.restoreAllMocks();
+});
+
+describe("ExpandableDescription", () => {
+ it("offers no toggle when the text already fits", async () => {
+ stageOverflow(48, 48);
+ await renderWithI18n(
+ <ExpandableDescription>Short enough</ExpandableDescription>,
+ );
+
+ // A toggle under a two-line description that is only one line long is a
+ // control that reveals nothing.
+ expect(screen.queryByRole("button")).toBeNull();
+ });
+
+ it("clamps by default and reveals the rest on demand", async () => {
+ stageOverflow(120, 48);
+ await renderWithI18n(
+ <ExpandableDescription>A description that runs on</ExpandableDescription>,
+ );
+
+ const text = screen.getByText("A description that runs on");
+ expect(text).toHaveClass("line-clamp-2");
+
+ await userEvent.click(screen.getByRole("button"));
+ expect(text).not.toHaveClass("line-clamp-2");
+
+ // Still offered while expanded — the measurement is skipped in that state,
+ // so nothing may clear the flag and strand the reader in the long form.
+ await userEvent.click(screen.getByRole("button"));
+ expect(text).toHaveClass("line-clamp-2");
+ });
+
+ it("keeps the toggle quiet rather than styling it as a primary action", async () => {
+ stageOverflow(120, 48);
+ await renderWithI18n(
+ <ExpandableDescription>A description that runs on</ExpandableDescription>,
+ );
+
+ // Brand is for primary actions and live state. On a detail page that is
+ // Save and Add-to-agent, not a text expander.
+ const toggle = screen.getByRole("button");
+ expect(toggle.className).toContain("text-muted-foreground");
+ expect(toggle.className).not.toContain("brand");
+ });
+});
diff --git a/packages/views/common/expandable-description.tsx b/packages/views/common/expandable-description.tsx
new file mode 100644
index 0000000000..5758c19e63
--- /dev/null
+++ b/packages/views/common/expandable-description.tsx
@@ -0,0 +1,81 @@
+"use client";
+
+import { useCallback, useLayoutEffect, useRef, useState } from "react";
+import { cn } from "@multica/ui/lib/utils";
+import { useT } from "../i18n";
+
+/**
+ * The description line under a detail page's title. Clamped to two lines, with
+ * a toggle that appears only when there is something clamped to reveal.
+ *
+ * Left unclamped, a long description pushes the meta row and the tab strip
+ * down the page, so how far the content starts depends on how much prose
+ * someone wrote. Two lines is where the agent and skill headers already sit
+ * visually; the toggle is what makes clamping safe, since without it the rest
+ * of the text has nowhere to be — this IS the detail page, so expanding in
+ * place is the only move that does not send the reader somewhere else to read
+ * one paragraph.
+ *
+ * The toggle is deliberately quiet — muted until hovered, matching the
+ * "show more" control on the agent activity tab. Brand colour is reserved for
+ * primary actions and live state; this page's Save and Add-to-agent buttons
+ * are what should be drawing the eye, not a text expander.
+ */
+export function ExpandableDescription({
+ children,
+ className,
+}: {
+ children: React.ReactNode;
+ className?: string;
+}) {
+ const { t } = useT("common");
+ const [expanded, setExpanded] = useState(false);
+ const [clamped, setClamped] = useState(false);
+ const textRef = useRef<HTMLParagraphElement | null>(null);
+
+ // Measured rather than guessed from character count: whether two lines are
+ // enough depends on the container's width and the script being rendered.
+ const measure = useCallback(() => {
+ const element = textRef.current;
+ if (!element) return;
+ // Read while clamped, or an already-expanded element reports no overflow
+ // and the toggle would vanish mid-read.
+ if (expanded) return;
+ setClamped(element.scrollHeight > element.clientHeight + 1);
+ }, [expanded]);
+
+ useLayoutEffect(() => {
+ measure();
+ const element = textRef.current;
+ if (!element || typeof ResizeObserver === "undefined") return;
+ const observer = new ResizeObserver(measure);
+ observer.observe(element);
+ return () => observer.disconnect();
+ }, [measure, children]);
+
+ return (
+ <>
+ <p
+ ref={textRef}
+ className={cn(
+ "mt-1 max-w-2xl text-pretty text-sm leading-6 text-muted-foreground",
+ !expanded && "line-clamp-2",
+ className,
+ )}
+ >
+ {children}
+ </p>
+ {(clamped || expanded) && (
+ <button
+ type="button"
+ onClick={() => setExpanded((value) => !value)}
+ className="mt-0.5 rounded text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:text-foreground focus-visible:outline-none"
+ >
+ {expanded
+ ? t(($) => $.expandable_description.collapse)
+ : t(($) => $.expandable_description.expand)}
+ </button>
+ )}
+ </>
+ );
+}
diff --git a/packages/views/labels/index.ts b/packages/views/labels/index.ts
index e181d794f8..a918e009b0 100644
--- a/packages/views/labels/index.ts
+++ b/packages/views/labels/index.ts
@@ -1 +1,5 @@
export { LabelChip } from "./label-chip";
+export {
+ ResourceLabelPicker,
+ useResourceLabelsEnabled,
+} from "./resource-label-picker";
diff --git a/packages/views/labels/resource-label-picker.tsx b/packages/views/labels/resource-label-picker.tsx
index 516b40db7a..bad3f84391 100644
--- a/packages/views/labels/resource-label-picker.tsx
+++ b/packages/views/labels/resource-label-picker.tsx
@@ -22,6 +22,17 @@ import {
import { useT } from "../i18n";
import { LabelChip } from "./label-chip";
+/**
+ * Whether agent- and skill-scoped labels are available. The server gates the
+ * attach/detach routes on the same release flag, so with it off the picker has
+ * no working endpoint to call — and callers need to know that before they lay
+ * out a row for it, since a row whose only control renders nothing reads as a
+ * broken field rather than an absent feature.
+ */
+export function useResourceLabelsEnabled() {
+ return useFeatureEnabled(RESOURCE_LABELS_FLAG, false);
+}
+
export function ResourceLabelPicker({
resourceType,
resourceId,
@@ -33,7 +44,7 @@ export function ResourceLabelPicker({
}) {
const { t } = useT("labels");
const wsId = useWorkspaceId();
- const resourceLabelsEnabled = useFeatureEnabled(RESOURCE_LABELS_FLAG, false);
+ const resourceLabelsEnabled = useResourceLabelsEnabled();
const [open, setOpen] = useState(false);
const [query, setQuery] = useState("");
const { data: catalog = [] } = useQuery({
diff --git a/packages/views/locales/en/common.json b/packages/views/locales/en/common.json
index b6b934d592..9c796085c1 100644
--- a/packages/views/locales/en/common.json
+++ b/packages/views/locales/en/common.json
@@ -67,5 +67,9 @@
"error_already_bound": "This Slack account is already linked to a different Multica user. Account transfers must go through an explicit unbind first.",
"error_not_member": "You're signed in to a Multica account that isn't a member of this workspace.",
"error_unknown": "Something went wrong. Try again, and if the problem persists, contact the workspace admin."
+ },
+ "expandable_description": {
+ "expand": "Show more",
+ "collapse": "Show less"
}
}
diff --git a/packages/views/locales/en/skills.json b/packages/views/locales/en/skills.json
index 7d47a62ad8..a3d3beb463 100644
--- a/packages/views/locales/en/skills.json
+++ b/packages/views/locales/en/skills.json
@@ -6,10 +6,22 @@
"new_skill": "New skill",
"search_placeholder": "Search skills…",
"scopes": {
- "all": { "label": "All", "description": "All skills in this workspace" },
- "used": { "label": "In use", "description": "Skills assigned to at least one agent" },
- "unused": { "label": "Unused", "description": "Skills not assigned to any agent" },
- "mine": { "label": "Created by me", "description": "Skills you created" }
+ "all": {
+ "label": "All",
+ "description": "All skills in this workspace"
+ },
+ "used": {
+ "label": "In use",
+ "description": "Skills assigned to at least one agent"
+ },
+ "unused": {
+ "label": "Unused",
+ "description": "Skills not assigned to any agent"
+ },
+ "mine": {
+ "label": "Created by me",
+ "description": "Skills you created"
+ }
},
"empty": {
"title": "No skills yet",
@@ -100,13 +112,8 @@
"delete_aria": "Delete skill",
"delete_tooltip": "Delete skill",
"supporting_data_warning": "Some workspace data failed to load. Creator attribution, runtime names, or edit permissions may appear incomplete until the next refresh.",
- "files_label": "Files · {{count}}",
- "add_file_aria": "Add file",
- "add_file_tooltip": "Add file",
"delete_file": "Delete file",
- "name_aria": "Skill name",
"name_placeholder": "skill-name",
- "description_label": "Description",
"description_placeholder": "One sentence describing when an agent should use this skill…",
"subline": {
"origin_runtime_named": "Local runtime · {{name}}",
@@ -115,9 +122,7 @@
"origin_clawhub": "Imported · ClawHub",
"origin_skills_sh": "Imported · Skills.sh",
"origin_github": "Imported · GitHub",
- "origin_workspace": "Workspace",
- "updated_label": "Updated {{when}}",
- "by_creator": "by {{name}}"
+ "origin_workspace": "Workspace"
},
"conflict_banner": {
"title": "Someone else updated this skill",
@@ -127,30 +132,8 @@
"unsaved": "Unsaved changes — will overwrite the live skill on save",
"discard": "Discard",
"save": "Save changes",
- "saving": "Saving…"
- },
- "sidebar": {
- "metadata": "Metadata",
- "created": "Created",
- "updated": "Updated",
- "created_by": "Created by",
- "files": "Files",
- "id": "ID",
- "origin": "Origin",
- "used_by_one": "Used by {{count}} agent",
- "used_by_other": "Used by {{count}} agents",
- "permissions": "Permissions",
- "permissions_owner": "You can edit and delete this skill. Changes take effect on the next agent run.",
- "permissions_locked_creator": "Only the creator ({{name}}) or a workspace admin can edit this skill.",
- "permissions_locked": "Only the creator or a workspace admin can edit this skill.",
- "used_by_empty": "Not assigned to any agent yet. Open an agent's Skills tab to assign."
- },
- "origin_card": {
- "imported_runtime": "Imported from local runtime",
- "imported_clawhub": "Imported from ClawHub",
- "imported_skills_sh": "Imported from Skills.sh",
- "imported_github": "Imported from GitHub",
- "provider": "provider · {{provider}}"
+ "saving": "Saving…",
+ "saved": "All changes saved"
},
"not_found": {
"title": "Skill not found",
@@ -180,8 +163,49 @@
"absolute": "Absolute paths are not allowed.",
"double_dot": "Paths cannot contain \"..\".",
"reserved": "SKILL.md is reserved for the main file.",
- "exists": "A file at this path already exists."
+ "exists": "A file at this path already exists.",
+ "is_directory": "A folder with this name already exists",
+ "under_file": "A file already exists at that location"
}
+ },
+ "header": {
+ "files_one": "{{count}} file",
+ "files_other": "{{count}} files",
+ "used_by_one": "{{count}} agent",
+ "used_by_other": "{{count}} agents",
+ "updated": "Updated {{when}}",
+ "updated_by": "Updated {{when}} by {{name}}"
+ },
+ "tabs": {
+ "aria": "Skill sections",
+ "overview": "Overview",
+ "files_one": "Files {{count}}",
+ "files_other": "Files {{count}}"
+ },
+ "overview": {
+ "properties": "Properties",
+ "properties_hint": "These fields stay in sync with the SKILL.md frontmatter.",
+ "name": "Name",
+ "description": "Description",
+ "description_hint": "{{count}} characters. Agents read this to decide whether to load the skill.",
+ "labels": "Labels",
+ "used_by_one": "Used by {{count}} agent",
+ "used_by_other": "Used by {{count}} agents",
+ "used_by_empty": "Not assigned to any agent yet. Open an agent's Skills tab to assign.",
+ "permissions_owner": "You can edit and delete this skill. Changes take effect on the next agent run.",
+ "permissions_locked_creator": "Only the creator ({{name}}) or a workspace admin can edit this skill.",
+ "permissions_locked": "Only the creator or a workspace admin can edit this skill."
+ },
+ "files": {
+ "list_aria": "Skill files",
+ "main": "Main file",
+ "supporting_one": "Supporting {{count}}",
+ "supporting_other": "Supporting {{count}}",
+ "supporting_empty": "No supporting files.",
+ "add_file": "New file",
+ "mode_aria": "File view",
+ "mode_preview": "Preview",
+ "mode_raw": "Plain text"
}
},
"create": {
@@ -300,13 +324,17 @@
"conflict_name_still_exists": "That name already exists. Choose another name or skip."
},
"file_tree": {
- "no_files": "No files"
+ "no_files": "No files",
+ "actions": {
+ "label": "Actions for {{path}}",
+ "rename": "Rename",
+ "delete": "Delete"
+ }
},
"file_viewer": {
- "edit_tooltip": "Edit",
- "preview_tooltip": "Preview",
"no_content": "*No content yet*",
"markdown_placeholder": "Write markdown content...",
- "raw_placeholder": "File content..."
+ "raw_placeholder": "File content...",
+ "raw_aria": "Plain text content of {{path}}"
}
}
diff --git a/packages/views/locales/ja/common.json b/packages/views/locales/ja/common.json
index 85b1bca9f8..71805b6b47 100644
--- a/packages/views/locales/ja/common.json
+++ b/packages/views/locales/ja/common.json
@@ -67,5 +67,9 @@
"error_already_bound": "この Slack アカウントは別の Multica ユーザーに連携済みです。移行するにはまず明示的に解除する必要があります。",
"error_not_member": "サインインしている Multica アカウントはこのワークスペースのメンバーではありません。",
"error_unknown": "問題が発生しました。もう一度試し、それでも解決しない場合はワークスペース管理者にお問い合わせください。"
+ },
+ "expandable_description": {
+ "expand": "詳細を表示",
+ "collapse": "折りたたむ"
}
}
diff --git a/packages/views/locales/ja/skills.json b/packages/views/locales/ja/skills.json
index d0d8a4b65c..b1a0117030 100644
--- a/packages/views/locales/ja/skills.json
+++ b/packages/views/locales/ja/skills.json
@@ -6,10 +6,22 @@
"new_skill": "新規スキル",
"search_placeholder": "スキルを検索…",
"scopes": {
- "all": { "label": "すべて", "description": "このワークスペースのすべてのスキル" },
- "used": { "label": "使用中", "description": "1 つ以上のエージェントに割り当てられたスキル" },
- "unused": { "label": "未使用", "description": "どのエージェントにも割り当てられていないスキル" },
- "mine": { "label": "自分が作成", "description": "あなたが作成したスキル" }
+ "all": {
+ "label": "すべて",
+ "description": "このワークスペースのすべてのスキル"
+ },
+ "used": {
+ "label": "使用中",
+ "description": "1 つ以上のエージェントに割り当てられたスキル"
+ },
+ "unused": {
+ "label": "未使用",
+ "description": "どのエージェントにも割り当てられていないスキル"
+ },
+ "mine": {
+ "label": "自分が作成",
+ "description": "あなたが作成したスキル"
+ }
},
"empty": {
"title": "まだスキルがありません",
@@ -95,13 +107,8 @@
"delete_aria": "スキルを削除",
"delete_tooltip": "スキルを削除",
"supporting_data_warning": "一部のワークスペースデータを読み込めませんでした。次回の更新まで、作成者の表示、ランタイム名、編集権限が不完全に見える場合があります。",
- "files_label": "ファイル · {{count}}",
- "add_file_aria": "ファイルを追加",
- "add_file_tooltip": "ファイルを追加",
"delete_file": "ファイルを削除",
- "name_aria": "スキル名",
"name_placeholder": "skill-name",
- "description_label": "説明",
"description_placeholder": "エージェントがこのスキルをいつ使うべきかを 1 文で説明してください…",
"subline": {
"origin_runtime_named": "ローカルランタイム · {{name}}",
@@ -110,9 +117,7 @@
"origin_clawhub": "インポート済み · ClawHub",
"origin_skills_sh": "インポート済み · Skills.sh",
"origin_github": "インポート済み · GitHub",
- "origin_workspace": "ワークスペース",
- "updated_label": "{{when}} に更新",
- "by_creator": "{{name}}"
+ "origin_workspace": "ワークスペース"
},
"conflict_banner": {
"title": "他のユーザーがこのスキルを更新しました",
@@ -122,29 +127,8 @@
"unsaved": "未保存の変更 — 保存すると現在のスキルを上書きします",
"discard": "破棄",
"save": "変更を保存",
- "saving": "保存中…"
- },
- "sidebar": {
- "metadata": "メタデータ",
- "created": "作成日",
- "updated": "更新日",
- "created_by": "作成者",
- "files": "ファイル",
- "id": "ID",
- "origin": "ソース",
- "used_by_other": "{{count}} 個のエージェントが使用中",
- "permissions": "権限",
- "permissions_owner": "このスキルを編集および削除できます。変更は次回のエージェント実行から有効になります。",
- "permissions_locked_creator": "このスキルを編集できるのは作成者({{name}})またはワークスペース管理者のみです。",
- "permissions_locked": "このスキルを編集できるのは作成者またはワークスペース管理者のみです。",
- "used_by_empty": "まだどのエージェントにも割り当てられていません。エージェントのスキルタブを開いて割り当ててください。"
- },
- "origin_card": {
- "imported_runtime": "ローカルランタイムからインポート",
- "imported_clawhub": "ClawHub からインポート",
- "imported_skills_sh": "Skills.sh からインポート",
- "imported_github": "GitHub からインポート",
- "provider": "プロバイダー · {{provider}}"
+ "saving": "保存中…",
+ "saved": "変更は保存済みです"
},
"not_found": {
"title": "スキルが見つかりません",
@@ -173,8 +157,44 @@
"absolute": "絶対パスは使用できません。",
"double_dot": "パスに「..」を含めることはできません。",
"reserved": "SKILL.md はメインファイル用に予約されています。",
- "exists": "このパスにはすでにファイルが存在します。"
+ "exists": "このパスにはすでにファイルが存在します。",
+ "is_directory": "同名のフォルダーが既に存在します",
+ "under_file": "その場所はすでにファイルが使用しています"
}
+ },
+ "header": {
+ "files_other": "{{count}} 個のファイル",
+ "used_by_other": "{{count}} 個のエージェントが使用中",
+ "updated": "{{when}}に更新",
+ "updated_by": "{{name}} が{{when}}に更新"
+ },
+ "tabs": {
+ "aria": "スキルのセクション",
+ "overview": "概要",
+ "files_other": "ファイル {{count}}"
+ },
+ "overview": {
+ "properties": "プロパティ",
+ "properties_hint": "これらの項目は SKILL.md のフロントマターと同期します。",
+ "name": "名前",
+ "description": "説明",
+ "description_hint": "{{count}} 文字。エージェントはこの説明を読んでスキルを読み込むか判断します。",
+ "labels": "ラベル",
+ "used_by_other": "{{count}} 個のエージェントが使用中",
+ "used_by_empty": "まだどのエージェントにも割り当てられていません。エージェントのスキルタブを開いて割り当ててください。",
+ "permissions_owner": "このスキルを編集・削除できます。変更は次回のエージェント実行から反映されます。",
+ "permissions_locked_creator": "作成者({{name}})またはワークスペース管理者のみがこのスキルを編集できます。",
+ "permissions_locked": "作成者またはワークスペース管理者のみがこのスキルを編集できます。"
+ },
+ "files": {
+ "list_aria": "スキルのファイル",
+ "main": "メインファイル",
+ "supporting_other": "補助ファイル {{count}}",
+ "supporting_empty": "補助ファイルはありません。",
+ "add_file": "新規ファイル",
+ "mode_aria": "ファイル表示",
+ "mode_preview": "プレビュー",
+ "mode_raw": "プレーンテキスト"
}
},
"create": {
@@ -292,13 +312,17 @@
"conflict_name_still_exists": "その名前はすでに存在します。別の名前を選択するか、スキップしてください。"
},
"file_tree": {
- "no_files": "ファイルなし"
+ "no_files": "ファイルなし",
+ "actions": {
+ "label": "{{path}} の操作",
+ "rename": "名前を変更",
+ "delete": "削除"
+ }
},
"file_viewer": {
- "edit_tooltip": "編集",
- "preview_tooltip": "プレビュー",
"no_content": "*まだ内容がありません*",
"markdown_placeholder": "Markdown の内容を記述...",
- "raw_placeholder": "ファイルの内容..."
+ "raw_placeholder": "ファイルの内容...",
+ "raw_aria": "{{path}} のプレーンテキスト"
}
}
diff --git a/packages/views/locales/ko/common.json b/packages/views/locales/ko/common.json
index fb27cea659..bba9a82ff5 100644
--- a/packages/views/locales/ko/common.json
+++ b/packages/views/locales/ko/common.json
@@ -67,5 +67,9 @@
"error_already_bound": "이 Slack 계정은 이미 다른 Multica 사용자에 연결되어 있어요. 이전하려면 먼저 명시적으로 연결을 해제해야 합니다.",
"error_not_member": "로그인한 Multica 계정이 이 워크스페이스의 멤버가 아니에요.",
"error_unknown": "문제가 발생했어요. 다시 시도해 보고, 계속되면 워크스페이스 관리자에게 문의하세요."
+ },
+ "expandable_description": {
+ "expand": "자세히 보기",
+ "collapse": "접기"
}
}
diff --git a/packages/views/locales/ko/skills.json b/packages/views/locales/ko/skills.json
index 670acc8740..2eba553c0d 100644
--- a/packages/views/locales/ko/skills.json
+++ b/packages/views/locales/ko/skills.json
@@ -6,10 +6,22 @@
"new_skill": "새 스킬",
"search_placeholder": "스킬 검색...",
"scopes": {
- "all": { "label": "전체", "description": "이 워크스페이스의 모든 스킬" },
- "used": { "label": "사용 중", "description": "하나 이상의 에이전트에 할당된 스킬" },
- "unused": { "label": "미사용", "description": "어떤 에이전트에도 할당되지 않은 스킬" },
- "mine": { "label": "내가 만든 스킬", "description": "내가 생성한 스킬" }
+ "all": {
+ "label": "전체",
+ "description": "이 워크스페이스의 모든 스킬"
+ },
+ "used": {
+ "label": "사용 중",
+ "description": "하나 이상의 에이전트에 할당된 스킬"
+ },
+ "unused": {
+ "label": "미사용",
+ "description": "어떤 에이전트에도 할당되지 않은 스킬"
+ },
+ "mine": {
+ "label": "내가 만든 스킬",
+ "description": "내가 생성한 스킬"
+ }
},
"empty": {
"title": "아직 스킬이 없습니다",
@@ -95,13 +107,8 @@
"delete_aria": "스킬 삭제",
"delete_tooltip": "스킬 삭제",
"supporting_data_warning": "일부 워크스페이스 데이터를 불러오지 못했습니다. 다음 새로고침 전까지 생성자 표시, 런타임 이름, 수정 권한이 불완전하게 보일 수 있습니다.",
- "files_label": "파일 · {{count}}",
- "add_file_aria": "파일 추가",
- "add_file_tooltip": "파일 추가",
"delete_file": "파일 삭제",
- "name_aria": "스킬 이름",
"name_placeholder": "skill-name",
- "description_label": "설명",
"description_placeholder": "에이전트가 이 스킬을 언제 써야 하는지 한 문장으로 설명하세요...",
"subline": {
"origin_runtime_named": "로컬 런타임 · {{name}}",
@@ -110,9 +117,7 @@
"origin_clawhub": "가져옴 · ClawHub",
"origin_skills_sh": "가져옴 · Skills.sh",
"origin_github": "가져옴 · GitHub",
- "origin_workspace": "워크스페이스",
- "updated_label": "{{when}} 수정됨",
- "by_creator": "{{name}}님"
+ "origin_workspace": "워크스페이스"
},
"conflict_banner": {
"title": "다른 사람이 이 스킬을 업데이트했습니다",
@@ -122,29 +127,8 @@
"unsaved": "저장하지 않은 변경사항 — 저장하면 현재 스킬을 덮어씁니다",
"discard": "버리기",
"save": "변경사항 저장",
- "saving": "저장하는 중..."
- },
- "sidebar": {
- "metadata": "메타데이터",
- "created": "생성일",
- "updated": "수정일",
- "created_by": "생성자",
- "files": "파일",
- "id": "ID",
- "origin": "출처",
- "used_by_other": "에이전트 {{count}}개가 사용 중",
- "permissions": "권한",
- "permissions_owner": "이 스킬을 수정하고 삭제할 수 있습니다. 변경사항은 다음 에이전트 실행부터 적용됩니다.",
- "permissions_locked_creator": "생성자({{name}}) 또는 워크스페이스 관리자만 이 스킬을 수정할 수 있습니다.",
- "permissions_locked": "생성자 또는 워크스페이스 관리자만 이 스킬을 수정할 수 있습니다.",
- "used_by_empty": "아직 어떤 에이전트에도 할당되지 않았습니다. 에이전트의 스킬 탭에서 할당하세요."
- },
- "origin_card": {
- "imported_runtime": "로컬 런타임에서 가져옴",
- "imported_clawhub": "ClawHub에서 가져옴",
- "imported_skills_sh": "Skills.sh에서 가져옴",
- "imported_github": "GitHub에서 가져옴",
- "provider": "제공자 · {{provider}}"
+ "saving": "저장하는 중...",
+ "saved": "모든 변경 사항이 저장됨"
},
"not_found": {
"title": "스킬을 찾을 수 없습니다",
@@ -173,8 +157,44 @@
"absolute": "절대 경로는 사용할 수 없습니다.",
"double_dot": "경로에 \"..\"을(를) 포함할 수 없습니다.",
"reserved": "SKILL.md는 메인 파일용으로 예약되어 있습니다.",
- "exists": "이 경로에 이미 파일이 있습니다."
+ "exists": "이 경로에 이미 파일이 있습니다.",
+ "is_directory": "같은 이름의 폴더가 이미 있습니다",
+ "under_file": "해당 위치는 이미 파일이 사용 중입니다"
}
+ },
+ "header": {
+ "files_other": "파일 {{count}}개",
+ "used_by_other": "에이전트 {{count}}개가 사용 중",
+ "updated": "{{when}} 업데이트",
+ "updated_by": "{{name}}이(가) {{when}} 업데이트"
+ },
+ "tabs": {
+ "aria": "스킬 섹션",
+ "overview": "개요",
+ "files_other": "파일 {{count}}"
+ },
+ "overview": {
+ "properties": "속성",
+ "properties_hint": "이 필드는 SKILL.md 프런트매터와 동기화됩니다.",
+ "name": "이름",
+ "description": "설명",
+ "description_hint": "{{count}}자. 에이전트는 이 설명을 읽고 스킬을 불러올지 판단합니다.",
+ "labels": "라벨",
+ "used_by_other": "에이전트 {{count}}개가 사용 중",
+ "used_by_empty": "아직 어떤 에이전트에도 할당되지 않았습니다. 에이전트의 스킬 탭에서 할당하세요.",
+ "permissions_owner": "이 스킬을 편집하고 삭제할 수 있습니다. 변경 사항은 다음 에이전트 실행부터 적용됩니다.",
+ "permissions_locked_creator": "작성자({{name}}) 또는 워크스페이스 관리자만 이 스킬을 편집할 수 있습니다.",
+ "permissions_locked": "작성자 또는 워크스페이스 관리자만 이 스킬을 편집할 수 있습니다."
+ },
+ "files": {
+ "list_aria": "스킬 파일",
+ "main": "기본 파일",
+ "supporting_other": "보조 파일 {{count}}",
+ "supporting_empty": "보조 파일이 없습니다.",
+ "add_file": "새 파일",
+ "mode_aria": "파일 보기",
+ "mode_preview": "미리보기",
+ "mode_raw": "일반 텍스트"
}
},
"create": {
@@ -292,13 +312,17 @@
"conflict_name_still_exists": "해당 이름이 이미 있습니다. 다른 이름을 선택하거나 건너뛰세요."
},
"file_tree": {
- "no_files": "파일 없음"
+ "no_files": "파일 없음",
+ "actions": {
+ "label": "{{path}} 작업",
+ "rename": "이름 변경",
+ "delete": "삭제"
+ }
},
"file_viewer": {
- "edit_tooltip": "수정",
- "preview_tooltip": "미리보기",
"no_content": "*아직 내용이 없습니다*",
"markdown_placeholder": "Markdown 내용 작성...",
- "raw_placeholder": "파일 내용..."
+ "raw_placeholder": "파일 내용...",
+ "raw_aria": "{{path}}의 일반 텍스트 내용"
}
}
diff --git a/packages/views/locales/zh-Hans/common.json b/packages/views/locales/zh-Hans/common.json
index 7da92f9b61..bc042904b5 100644
--- a/packages/views/locales/zh-Hans/common.json
+++ b/packages/views/locales/zh-Hans/common.json
@@ -67,5 +67,9 @@
"error_already_bound": "该 Slack 账号已关联到其他 Multica 用户。账户转移需要先显式解绑。",
"error_not_member": "你登录的 Multica 账号不是当前工作区成员。",
"error_unknown": "出现未知错误。请稍后再试,如反复失败请联系工作区管理员。"
+ },
+ "expandable_description": {
+ "expand": "查看详情",
+ "collapse": "收起"
}
}
diff --git a/packages/views/locales/zh-Hans/skills.json b/packages/views/locales/zh-Hans/skills.json
index fdd8696c27..a8631448d0 100644
--- a/packages/views/locales/zh-Hans/skills.json
+++ b/packages/views/locales/zh-Hans/skills.json
@@ -107,13 +107,8 @@
"delete_aria": "删除 skill",
"delete_tooltip": "删除 skill",
"supporting_data_warning": "部分工作区数据加载失败。创建者归属、运行时名称、编辑权限可能要等下次刷新才完整。",
- "files_label": "文件 · {{count}}",
- "add_file_aria": "添加文件",
- "add_file_tooltip": "添加文件",
"delete_file": "删除文件",
- "name_aria": "skill 名称",
"name_placeholder": "skill-name",
- "description_label": "描述",
"description_placeholder": "用一句话描述智能体什么时候应该使用这个 skill...",
"subline": {
"origin_runtime_named": "本地运行时 · {{name}}",
@@ -122,9 +117,7 @@
"origin_clawhub": "导入自 · ClawHub",
"origin_skills_sh": "导入自 · Skills.sh",
"origin_github": "导入自 · GitHub",
- "origin_workspace": "工作区",
- "updated_label": "{{when}}更新",
- "by_creator": "由 {{name}}"
+ "origin_workspace": "工作区"
},
"conflict_banner": {
"title": "其他人更新了这个 skill",
@@ -134,29 +127,8 @@
"unsaved": "未保存的修改——保存会覆盖当前的 skill",
"discard": "丢弃",
"save": "保存修改",
- "saving": "保存中..."
- },
- "sidebar": {
- "metadata": "元数据",
- "created": "创建于",
- "updated": "更新于",
- "created_by": "创建者",
- "files": "文件",
- "id": "ID",
- "origin": "来源",
- "used_by_other": "被 {{count}} 个智能体使用",
- "permissions": "权限",
- "permissions_owner": "你可以编辑和删除这个 skill。修改在智能体下次运行时生效。",
- "permissions_locked_creator": "只有创建者({{name}})或工作区管理员能编辑这个 skill。",
- "permissions_locked": "只有创建者或工作区管理员能编辑这个 skill。",
- "used_by_empty": "还未分配给任何智能体。打开某个智能体的 Skills 标签页进行分配。"
- },
- "origin_card": {
- "imported_runtime": "从本地运行时导入",
- "imported_clawhub": "从 ClawHub 导入",
- "imported_skills_sh": "从 Skills.sh 导入",
- "imported_github": "从 GitHub 导入",
- "provider": "provider · {{provider}}"
+ "saving": "保存中...",
+ "saved": "改动已保存"
},
"not_found": {
"title": "未找到该 skill",
@@ -185,8 +157,44 @@
"absolute": "不允许绝对路径。",
"double_dot": "路径不能包含 \"..\"。",
"reserved": "SKILL.md 已为主文件保留。",
- "exists": "该路径已存在文件。"
+ "exists": "该路径已存在文件。",
+ "is_directory": "已有同名文件夹",
+ "under_file": "该位置已被一个文件占用"
}
+ },
+ "header": {
+ "files_other": "{{count}} 个文件",
+ "used_by_other": "{{count}} 个智能体在用",
+ "updated": "{{when}}更新",
+ "updated_by": "{{name}} 于{{when}}更新"
+ },
+ "tabs": {
+ "aria": "技能分区",
+ "overview": "概览",
+ "files_other": "文件 {{count}}"
+ },
+ "overview": {
+ "properties": "属性",
+ "properties_hint": "这些字段与 SKILL.md 的 frontmatter 保持同步。",
+ "name": "名称",
+ "description": "描述",
+ "description_hint": "{{count}} 个字符。智能体根据这段文字判断是否加载该技能。",
+ "labels": "标签",
+ "used_by_other": "被 {{count}} 个智能体使用",
+ "used_by_empty": "还未分配给任何智能体。打开某个智能体的 Skills 标签页进行分配。",
+ "permissions_owner": "你可以编辑和删除该技能。改动将在智能体下次运行时生效。",
+ "permissions_locked_creator": "只有创建者({{name}})或工作区管理员可以编辑该技能。",
+ "permissions_locked": "只有创建者或工作区管理员可以编辑该技能。"
+ },
+ "files": {
+ "list_aria": "技能文件",
+ "main": "主文件",
+ "supporting_other": "附属文件 {{count}}",
+ "supporting_empty": "暂无附属文件。",
+ "add_file": "新建文件",
+ "mode_aria": "文件视图",
+ "mode_preview": "预览",
+ "mode_raw": "纯文本"
}
},
"create": {
@@ -304,13 +312,17 @@
"conflict_name_still_exists": "这个名称仍然已存在。请换一个名称或跳过。"
},
"file_tree": {
- "no_files": "无文件"
+ "no_files": "无文件",
+ "actions": {
+ "label": "{{path}} 的操作",
+ "rename": "重命名",
+ "delete": "删除"
+ }
},
"file_viewer": {
- "edit_tooltip": "编辑",
- "preview_tooltip": "预览",
"no_content": "*暂无内容*",
"markdown_placeholder": "输入 Markdown 内容...",
- "raw_placeholder": "文件内容..."
+ "raw_placeholder": "文件内容...",
+ "raw_aria": "{{path}} 的纯文本内容"
}
}
diff --git a/packages/views/skills/components/file-tree.test.tsx b/packages/views/skills/components/file-tree.test.tsx
new file mode 100644
index 0000000000..02b17bb8a2
--- /dev/null
+++ b/packages/views/skills/components/file-tree.test.tsx
@@ -0,0 +1,140 @@
+/**
+ * @vitest-environment jsdom
+ */
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { cleanup, screen } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
+import { renderWithI18n } from "../../test/i18n";
+import { FileTree, type FileTreeActions } from "./file-tree";
+
+afterEach(cleanup);
+
+const PATHS = ["SKILL.md", "references/api.md", "notes.txt"];
+
+function makeActions(overrides: Partial<FileTreeActions> = {}): FileTreeActions {
+ return {
+ validatePath: () => "",
+ onRename: vi.fn(),
+ onDelete: vi.fn(),
+ reservedPath: "SKILL.md",
+ ...overrides,
+ };
+}
+
+describe("FileTree row actions", () => {
+ it("offers none without actions, so a read-only tree stays read-only", async () => {
+ await renderWithI18n(
+ <FileTree filePaths={PATHS} selectedPath="SKILL.md" onSelect={vi.fn()} />,
+ );
+
+ expect(screen.queryByRole("button", { name: /notes\.txt/ })).toBeNull();
+ });
+
+ it("withholds them from the reserved file, which owns the skill's content", async () => {
+ await renderWithI18n(
+ <FileTree
+ filePaths={PATHS}
+ selectedPath="SKILL.md"
+ onSelect={vi.fn()}
+ actions={makeActions()}
+ />,
+ );
+
+ // Deleting or renaming SKILL.md is refused by the server, so the row must
+ // not present it as available.
+ const rows = screen.getAllByRole("tab");
+ const skillMd = rows.find((row) => row.textContent === "SKILL.md")!;
+ expect(skillMd.parentElement!.querySelector("[aria-label]")).toBeNull();
+ });
+
+ it("deletes the row acted on, not whichever file happens to be open", async () => {
+ const onDelete = vi.fn();
+ await renderWithI18n(
+ <FileTree
+ filePaths={PATHS}
+ selectedPath="SKILL.md"
+ onSelect={vi.fn()}
+ actions={makeActions({ onDelete })}
+ />,
+ );
+
+ await userEvent.click(screen.getByRole("button", { name: /notes\.txt/ }));
+ await userEvent.click(await screen.findByRole("menuitem", { name: /删除|Delete/ }));
+
+ expect(onDelete).toHaveBeenCalledWith("notes.txt");
+ });
+
+ it("renames in place and reports the new path", async () => {
+ const onRename = vi.fn();
+ await renderWithI18n(
+ <FileTree
+ filePaths={PATHS}
+ selectedPath="notes.txt"
+ onSelect={vi.fn()}
+ actions={makeActions({ onRename })}
+ />,
+ );
+
+ await userEvent.click(screen.getByRole("button", { name: /notes\.txt/ }));
+ await userEvent.click(
+ await screen.findByRole("menuitem", { name: /重命名|Rename/ }),
+ );
+
+ const input = screen.getByRole("textbox");
+ await userEvent.clear(input);
+ await userEvent.type(input, "notes.md{Enter}");
+
+ expect(onRename).toHaveBeenCalledWith("notes.txt", "notes.md");
+ });
+
+ it("keeps a rejected path in the editor rather than committing it", async () => {
+ const onRename = vi.fn();
+ await renderWithI18n(
+ <FileTree
+ filePaths={PATHS}
+ selectedPath="notes.txt"
+ onSelect={vi.fn()}
+ actions={makeActions({
+ onRename,
+ validatePath: () => "already exists",
+ })}
+ />,
+ );
+
+ await userEvent.click(screen.getByRole("button", { name: /notes\.txt/ }));
+ await userEvent.click(
+ await screen.findByRole("menuitem", { name: /重命名|Rename/ }),
+ );
+
+ const input = screen.getByRole("textbox");
+ await userEvent.clear(input);
+ await userEvent.type(input, "references/api.md{Enter}");
+
+ expect(onRename).not.toHaveBeenCalled();
+ expect(screen.getByRole("alert")).toHaveTextContent("already exists");
+ });
+});
+
+describe("FileTree entry points", () => {
+ it("opens the same menu from a right-click on the row", async () => {
+ await renderWithI18n(
+ <FileTree
+ filePaths={PATHS}
+ selectedPath="SKILL.md"
+ onSelect={vi.fn()}
+ actions={makeActions()}
+ />,
+ );
+
+ const row = screen.getAllByRole("tab").find((r) => r.textContent === "notes.txt")!
+ .parentElement!;
+ // Right-click is the entry point that leaves no visual trace, so it is the
+ // one most likely to silently stop working.
+ await userEvent.pointer({ target: row, keys: "[MouseRight]" });
+
+ expect(
+ await screen.findByRole("menuitem", { name: /重命名|Rename/ }),
+ ).toBeInTheDocument();
+ });
+
+});
diff --git a/packages/views/skills/components/file-tree.tsx b/packages/views/skills/components/file-tree.tsx
index 79f2b988c3..10848c36fe 100644
--- a/packages/views/skills/components/file-tree.tsx
+++ b/packages/views/skills/components/file-tree.tsx
@@ -1,6 +1,6 @@
"use client";
-import { useState } from "react";
+import { useRef, useState } from "react";
import {
ChevronRight,
ChevronDown,
@@ -8,10 +8,34 @@ import {
File,
Folder,
FolderOpen,
+ MoreHorizontal,
+ Pencil,
+ Trash2,
} from "lucide-react";
+import { Input } from "@multica/ui/components/ui/input";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+} from "@multica/ui/components/ui/dropdown-menu";
import { cn } from "@multica/ui/lib/utils";
import { useT } from "../../i18n";
+/**
+ * What a row may offer beyond selection. Absent for read-only viewers and for
+ * the reserved primary file, so the tree never shows an action it would then
+ * have to refuse.
+ */
+export interface FileTreeActions {
+ /** Returns an error message, or "" when the path is free to use. */
+ validatePath: (path: string, existing: string[]) => string;
+ onRename: (from: string, to: string) => void;
+ onDelete: (path: string) => void;
+ /** Path that owns the skill's primary content and cannot be moved or removed. */
+ reservedPath: string;
+}
+
// ---------------------------------------------------------------------------
// Tree data structures
// ---------------------------------------------------------------------------
@@ -82,13 +106,20 @@ function TreeNodeItem({
node,
selectedPath,
onSelect,
+ allPaths,
+ actions,
depth = 0,
}: {
node: FileTreeNode;
selectedPath: string;
onSelect: (path: string) => void;
+ allPaths: string[];
+ actions?: FileTreeActions;
depth?: number;
}) {
+ const { t } = useT("skills");
+ const [renaming, setRenaming] = useState(false);
+ const menuButtonRef = useRef<HTMLButtonElement | null>(null);
const [expanded, setExpanded] = useState(true);
const isSelected = node.path === selectedPath;
@@ -101,11 +132,11 @@ function TreeNodeItem({
<button
type="button"
onClick={() => setExpanded(!expanded)}
- className="flex w-full items-center gap-1.5 py-1 text-left text-xs hover:bg-accent/50 rounded-sm"
- style={{ paddingLeft: `${depth * 12 + 8}px` }}
+ className="flex h-8 w-full items-center gap-1.5 rounded-md pr-2.5 text-left text-xs text-muted-foreground transition-colors hover:bg-surface-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ style={{ paddingLeft: `${depth * 12 + 10}px` }}
>
- <ChevronIcon className="h-3 w-3 shrink-0 text-muted-foreground" />
- <FolderIcon className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />
+ <ChevronIcon className="h-3 w-3 shrink-0" />
+ <FolderIcon className="h-3.5 w-3.5 shrink-0" />
<span className="truncate">{node.name}</span>
</button>
{expanded && (
@@ -116,6 +147,8 @@ function TreeNodeItem({
node={child}
selectedPath={selectedPath}
onSelect={onSelect}
+ allPaths={allPaths}
+ actions={actions}
depth={depth + 1}
/>
))}
@@ -126,22 +159,157 @@ function TreeNodeItem({
}
const Icon = getFileIcon(node.name);
+ const editable = !!actions && node.path !== actions.reservedPath;
+
+ if (renaming && actions) {
+ return (
+ <RenameRow
+ node={node}
+ depth={depth}
+ allPaths={allPaths}
+ actions={actions}
+ onDone={() => setRenaming(false)}
+ />
+ );
+ }
return (
- <button
- type="button"
- onClick={() => onSelect(node.path)}
+ <div
className={cn(
- "flex w-full items-center gap-1.5 py-1 text-left text-xs rounded-sm",
+ "group/row relative flex items-center rounded-md",
isSelected
- ? "bg-accent text-accent-foreground"
- : "hover:bg-accent/50",
+ ? "bg-surface-selected"
+ : "hover:bg-surface-hover",
)}
- style={{ paddingLeft: `${depth * 12 + 8 + 16}px` }}
+ // Right-click opens the same menu the trailing button does. The menu
+ // anchors to that button rather than the cursor, which keeps one menu
+ // per row instead of a context-menu root beside a dropdown root.
+ onContextMenu={
+ editable
+ ? (event) => {
+ event.preventDefault();
+ menuButtonRef.current?.click();
+ }
+ : undefined
+ }
>
- <Icon className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />
- <span className="truncate">{node.name}</span>
- </button>
+ <button
+ type="button"
+ role="tab"
+ aria-selected={isSelected}
+ onClick={() => onSelect(node.path)}
+ className={cn(
+ "flex h-8 min-w-0 flex-1 items-center gap-2 rounded-md pr-2.5 text-left text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
+ isSelected
+ ? "font-medium text-surface-selected-foreground"
+ : "text-muted-foreground group-hover/row:text-foreground",
+ )}
+ style={{ paddingLeft: `${depth * 12 + 10}px` }}
+ >
+ <Icon className="h-3.5 w-3.5 shrink-0" />
+ <span className="truncate">{node.name}</span>
+ </button>
+ {editable && (
+ <DropdownMenu>
+ <DropdownMenuTrigger
+ render={
+ <button
+ ref={menuButtonRef}
+ type="button"
+ aria-label={t(($) => $.file_tree.actions.label, {
+ path: node.path,
+ })}
+ // Hidden until the row is hovered or something inside it holds
+ // focus, so a rail of ten files is not a rail of ten buttons.
+ // after:-inset-1 widens the hit area past the 20px glyph.
+ className="mr-1 shrink-0 rounded p-0.5 text-muted-foreground/60 opacity-0 transition-opacity after:absolute after:-inset-1 hover:text-foreground group-hover/row:opacity-100 focus-visible:opacity-100 aria-expanded:opacity-100"
+ onClick={(event) => event.stopPropagation()}
+ >
+ <MoreHorizontal className="h-3.5 w-3.5" />
+ </button>
+ }
+ />
+ <DropdownMenuContent align="end" className="w-36">
+ <DropdownMenuItem onClick={() => setRenaming(true)}>
+ <Pencil />
+ {t(($) => $.file_tree.actions.rename)}
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ variant="destructive"
+ onClick={() => actions.onDelete(node.path)}
+ >
+ <Trash2 />
+ {t(($) => $.file_tree.actions.delete)}
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )}
+ </div>
+ );
+}
+
+/**
+ * Rename happens in the row rather than a dialog: the name is being edited in
+ * the place it is read, and the surrounding paths stay visible to compare
+ * against. Validation is the caller's, so the tree does not carry a second
+ * copy of what counts as a legal path.
+ */
+function RenameRow({
+ node,
+ depth,
+ allPaths,
+ actions,
+ onDone,
+}: {
+ node: FileTreeNode;
+ depth: number;
+ allPaths: string[];
+ actions: FileTreeActions;
+ onDone: () => void;
+}) {
+ const [value, setValue] = useState(node.path);
+ const [error, setError] = useState("");
+
+ const submit = () => {
+ const next = value.trim();
+ if (next === node.path) {
+ onDone();
+ return;
+ }
+ const message = actions.validatePath(
+ next,
+ allPaths.filter((path) => path !== node.path),
+ );
+ if (message) {
+ setError(message);
+ return;
+ }
+ actions.onRename(node.path, next);
+ onDone();
+ };
+
+ return (
+ <div style={{ paddingLeft: `${depth * 12 + 10}px` }} className="pr-1">
+ <Input
+ autoFocus
+ value={value}
+ onChange={(event) => {
+ setValue(event.target.value);
+ setError("");
+ }}
+ onBlur={submit}
+ onKeyDown={(event) => {
+ if (event.key === "Enter") submit();
+ if (event.key === "Escape") onDone();
+ }}
+ className="h-7 font-mono text-xs"
+ />
+ {error && (
+ <p role="alert" className="mt-1 text-xs text-destructive">
+ {error}
+ </p>
+ )}
+ </div>
);
}
@@ -153,10 +321,13 @@ export function FileTree({
filePaths,
selectedPath,
onSelect,
+ actions,
}: {
filePaths: string[];
selectedPath: string;
onSelect: (path: string) => void;
+ /** Omit to render a read-only tree. */
+ actions?: FileTreeActions;
}) {
const { t } = useT("skills");
const tree = buildTree(filePaths);
@@ -170,14 +341,18 @@ export function FileTree({
);
}
+ // No `role="tablist"` here: the caller owns the list semantics so a rail
+ // split into "main" + "supporting" groups stays a single tab list.
return (
- <div className="py-1 px-1">
+ <div className="flex flex-col gap-0.5">
{tree.map((node) => (
<TreeNodeItem
key={node.path}
node={node}
selectedPath={selectedPath}
onSelect={onSelect}
+ allPaths={filePaths}
+ actions={actions}
/>
))}
</div>
diff --git a/packages/views/skills/components/file-viewer.tsx b/packages/views/skills/components/file-viewer.tsx
index 38fa639fcd..16bb8159c1 100644
--- a/packages/views/skills/components/file-viewer.tsx
+++ b/packages/views/skills/components/file-viewer.tsx
@@ -1,126 +1,78 @@
"use client";
-import { useState, useMemo } from "react";
-import { Pencil, Eye } from "lucide-react";
-import { Button } from "@multica/ui/components/ui/button";
+import { useMemo } from "react";
import { Textarea } from "@multica/ui/components/ui/textarea";
-import { Tooltip, TooltipTrigger, TooltipContent } from "@multica/ui/components/ui/tooltip";
-import {
- parseFrontmatter,
- type SkillFrontmatter,
-} from "@multica/core/skills/frontmatter";
+import { parseFrontmatter } from "@multica/core/skills/frontmatter";
import { RichContent } from "../../rich-content";
import { useT } from "../../i18n";
-function isMarkdown(path: string) {
- return path.endsWith(".md") || path.endsWith(".mdx");
-}
+/**
+ * How the body of the selected file is rendered. Owned by the page, not by
+ * this component: the mode is a property of how the user wants to work, not
+ * of the file they happen to have open, so switching files must not silently
+ * bounce them back to preview.
+ */
+export type FileMode = "preview" | "raw";
-// ---------------------------------------------------------------------------
-// Frontmatter display
-// ---------------------------------------------------------------------------
-
-function FrontmatterCard({ data }: { data: SkillFrontmatter }) {
- return (
- <div className="mb-4 rounded-lg border bg-muted/30 px-4 py-3">
- <div className="grid gap-1.5">
- {Object.entries(data).map(([key, value]) => (
- <div key={key} className="flex gap-2 text-xs">
- <span className="shrink-0 font-medium text-muted-foreground min-w-[80px]">
- {key}
- </span>
- <span className="text-foreground whitespace-pre-wrap break-words">
- {value.trimEnd()}
- </span>
- </div>
- ))}
- </div>
- </div>
- );
+export function isMarkdownPath(path: string) {
+ return path.endsWith(".md") || path.endsWith(".mdx");
}
-// ---------------------------------------------------------------------------
-// File viewer
-// ---------------------------------------------------------------------------
-
+/**
+ * Body of a single skill file.
+ *
+ * Frontmatter is stripped from the preview because `name` / `description` are
+ * surfaced as first-class properties on the Overview tab — rendering them
+ * again here was the third copy of the same two fields.
+ */
export function FileViewer({
path,
content,
+ mode,
+ readOnly,
onChange,
}: {
path: string;
content: string;
+ mode: FileMode;
+ readOnly: boolean;
onChange: (content: string) => void;
}) {
const { t } = useT("skills");
- const [editing, setEditing] = useState(false);
- const isMd = isMarkdown(path);
+ const isMd = isMarkdownPath(path);
- const { frontmatter, body } = useMemo(
- () => (isMd ? parseFrontmatter(content) : { frontmatter: null, body: content }),
+ const body = useMemo(
+ () => (isMd ? parseFrontmatter(content).body : content),
[content, isMd],
);
- return (
- <div className="flex h-full flex-col">
- {/* File header */}
- <div className="flex h-10 items-center justify-between gap-3 border-b px-4">
- <span className="text-xs font-mono text-muted-foreground truncate">
- {path}
- </span>
- <div className="flex items-center gap-1">
- {isMd && (
- <Tooltip>
- <TooltipTrigger
- render={
- <Button
- variant="ghost"
- size="icon-sm"
- onClick={() => setEditing(!editing)}
- className="text-muted-foreground"
- >
- {editing ? (
- <Eye className="h-3.5 w-3.5" />
- ) : (
- <Pencil className="h-3.5 w-3.5" />
- )}
- </Button>
- }
- />
- <TooltipContent>
- {editing
- ? t(($) => $.file_viewer.preview_tooltip)
- : t(($) => $.file_viewer.edit_tooltip)}
- </TooltipContent>
- </Tooltip>
- )}
+ // Non-markdown files have nothing to preview; they are always raw.
+ if (isMd && mode === "preview") {
+ return (
+ <div className="h-full overflow-y-auto">
+ <div className="mx-auto max-w-[68ch] px-6 py-7 sm:px-8">
+ <RichContent
+ content={body || t(($) => $.file_viewer.no_content)}
+ density="document"
+ phase="settled"
+ />
</div>
</div>
+ );
+ }
- {/* File content */}
- <div className="flex-1 min-h-0 overflow-y-auto">
- {isMd && !editing ? (
- <div className="p-4 sm:p-6">
- {frontmatter && <FrontmatterCard data={frontmatter} />}
- <RichContent
- content={body || t(($) => $.file_viewer.no_content)}
- density="document"
- phase="settled"
- />
- </div>
- ) : (
- <Textarea
- value={content}
- onChange={(e) => onChange(e.target.value)}
- placeholder={
- isMd
- ? t(($) => $.file_viewer.markdown_placeholder)
- : t(($) => $.file_viewer.raw_placeholder)
- }
- className="h-full min-h-full resize-none rounded-none border-0 font-mono text-sm leading-relaxed focus-visible:ring-0"
- />
- )}
- </div>
- </div>
+ return (
+ <Textarea
+ value={content}
+ readOnly={readOnly}
+ onChange={(e) => onChange(e.target.value)}
+ aria-label={t(($) => $.file_viewer.raw_aria, { path })}
+ placeholder={
+ isMd
+ ? t(($) => $.file_viewer.markdown_placeholder)
+ : t(($) => $.file_viewer.raw_placeholder)
+ }
+ className="h-full min-h-full resize-none rounded-none border-0 px-6 py-5 font-mono text-sm leading-relaxed read-only:cursor-default focus-visible:ring-0 sm:px-8"
+ />
);
}
diff --git a/packages/views/skills/components/skill-detail-page.test.tsx b/packages/views/skills/components/skill-detail-page.test.tsx
new file mode 100644
index 0000000000..95168c0d14
--- /dev/null
+++ b/packages/views/skills/components/skill-detail-page.test.tsx
@@ -0,0 +1,232 @@
+// @vitest-environment jsdom
+
+import { describe, it, expect, vi, beforeEach } from "vitest";
+import { fireEvent, render, screen } from "@testing-library/react";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import type { Skill } 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 { NavigationProvider, type NavigationAdapter } from "../../navigation";
+
+const TEST_RESOURCES = { en: { common: enCommon, skills: enSkills } };
+
+const skillRef = vi.hoisted(() => ({ current: null as unknown }));
+const agentsRef = vi.hoisted(() => ({ current: [] as unknown[] }));
+const membersRef = vi.hoisted(() => ({ current: [] as unknown[] }));
+const canEditRef = vi.hoisted(() => ({ current: true }));
+
+vi.mock("@multica/core/hooks", () => ({ useWorkspaceId: () => "ws-1" }));
+vi.mock("@multica/core/workspace/queries", () => ({
+ skillDetailOptions: (wsId: string, id: string) => ({
+ queryKey: ["skill", wsId, id],
+ queryFn: () => Promise.resolve(skillRef.current),
+ }),
+ agentListOptions: (wsId: string) => ({
+ queryKey: ["agents", wsId],
+ queryFn: () => Promise.resolve(agentsRef.current),
+ }),
+ memberListOptions: (wsId: string) => ({
+ queryKey: ["members", wsId],
+ queryFn: () => Promise.resolve(membersRef.current),
+ }),
+ selectSkillAssignments: () => new Map(),
+ workspaceKeys: {
+ skills: (wsId: string) => ["skills", wsId],
+ agents: (wsId: string) => ["agents", wsId],
+ },
+}));
+vi.mock("@multica/core/runtimes", () => ({
+ runtimeListOptions: (wsId: string) => ({
+ queryKey: ["runtimes", wsId],
+ queryFn: () => Promise.resolve([]),
+ }),
+ runtimeDisplayLabel: (r: { name?: string }) => r.name ?? "runtime",
+}));
+vi.mock("@multica/core/auth", () => {
+ const state = () => ({ user: { id: "user-1" } });
+ return {
+ useAuthStore: Object.assign(
+ (selector?: (s: ReturnType<typeof state>) => unknown) =>
+ selector ? selector(state()) : state(),
+ { getState: state },
+ ),
+ };
+});
+vi.mock("@multica/core/paths", () => ({
+ useWorkspacePaths: () => ({ skills: () => "/acme/skills" }),
+}));
+vi.mock("@multica/core/permissions", () => ({
+ useSkillPermissions: () => ({ canEdit: { allowed: true, reason: null } }),
+}));
+vi.mock("@multica/core/workspace/avatar-url", () => ({
+ resolvePublicFileUrl: (v: string | null) => v,
+}));
+vi.mock("@multica/core/api", () => ({
+ api: { updateSkill: vi.fn(), deleteSkill: vi.fn() },
+}));
+vi.mock("sonner", () => ({ toast: { success: vi.fn(), error: vi.fn() } }));
+vi.mock("../hooks/use-can-edit-skill", () => ({
+ useCanEditSkill: () => canEditRef.current,
+}));
+
+// Heavy leaves that carry no behaviour under test.
+vi.mock("../../rich-content", () => ({
+ RichContent: ({ content }: { content: string }) => (
+ <div data-testid="preview">{content}</div>
+ ),
+}));
+vi.mock("../../labels/resource-label-picker", () => ({
+ ResourceLabelPicker: () => <div data-testid="labels" />,
+ // The row is only laid out when the release flag is on; with it off the
+ // picker renders nothing and the label would sit above an empty field.
+ useResourceLabelsEnabled: () => true,
+}));
+vi.mock("./skill-list-actions", () => ({ AddToAgentDialog: () => null }));
+vi.mock("@multica/ui/components/common/capability-banner", () => ({
+ CapabilityBanner: () => <div data-testid="capability-banner" />,
+}));
+vi.mock("@multica/ui/components/common/actor-avatar", () => ({
+ ActorAvatar: () => <div />,
+}));
+
+import { SkillDetailPage } from "./skill-detail-page";
+
+const LONG_DESCRIPTION =
+ "Animation for product interfaces — when to animate and when not to. " +
+ "Triggers on: animation, easing, cubic-bezier, spring, keyframes.";
+
+const baseSkill: Skill = {
+ id: "skill-1",
+ workspace_id: "ws-1",
+ name: "aiforui-animations",
+ description: LONG_DESCRIPTION,
+ config: {},
+ created_by: "user-1",
+ created_at: "2026-07-28T18:11:37Z",
+ updated_at: "2026-07-28T18:14:40Z",
+ content: "---\nname: aiforui-animations\n---\n\n# Interface Animations\n",
+ files: [
+ { id: "f-1", path: "patterns.md", content: "# Patterns\n" } as Skill["files"][number],
+ ],
+};
+
+function renderPage(searchParams = new URLSearchParams()) {
+ const queryClient = new QueryClient({
+ defaultOptions: { queries: { retry: false } },
+ });
+ const replace = vi.fn();
+ const navigation: NavigationAdapter = {
+ push: vi.fn(),
+ replace,
+ back: vi.fn(),
+ pathname: "/acme/skills/skill-1",
+ searchParams,
+ getShareableUrl: (path) => path,
+ };
+ render(
+ <I18nProvider locale="en" resources={TEST_RESOURCES}>
+ <NavigationProvider value={navigation}>
+ <QueryClientProvider client={queryClient}>
+ <SkillDetailPage skillId="skill-1" />
+ </QueryClientProvider>
+ </NavigationProvider>
+ </I18nProvider>,
+ );
+ return { replace };
+}
+
+beforeEach(() => {
+ vi.clearAllMocks();
+ skillRef.current = baseSkill;
+ agentsRef.current = [];
+ membersRef.current = [{ user_id: "user-1", role: "member" }];
+ canEditRef.current = true;
+});
+
+describe("SkillDetailPage tabs", () => {
+ it("opens on Overview and exposes exactly two tabs", async () => {
+ renderPage();
+ const tabs = await screen.findAllByRole("tab", { name: /Overview|Files/ });
+ expect(tabs.map((t) => t.textContent)).toEqual(["Overview", "Files 2"]);
+ // A Settings tab would only hold a delete button and a read-only
+ // sentence — the skill update payload has no settings-shaped fields.
+ expect(screen.queryByRole("tab", { name: "Settings" })).toBeNull();
+ expect(
+ screen.getByRole("tab", { name: "Overview" }).getAttribute("aria-selected"),
+ ).toBe("true");
+ });
+
+ it("mirrors the active tab into ?view= so the pane survives a reload", async () => {
+ const { replace } = renderPage();
+ fireEvent.click(await screen.findByRole("tab", { name: "Files 2" }));
+ expect(replace).toHaveBeenCalledWith("/acme/skills/skill-1?view=files");
+ });
+
+ it("restores the Files tab from ?view=files", async () => {
+ renderPage(new URLSearchParams("view=files"));
+ expect(
+ (await screen.findByRole("tab", { name: "Files 2" })).getAttribute(
+ "aria-selected",
+ ),
+ ).toBe("true");
+ });
+});
+
+describe("SkillDetailPage file mode", () => {
+ it("keeps plain-text mode when switching files", async () => {
+ renderPage(new URLSearchParams("view=files"));
+
+ fireEvent.click(await screen.findByRole("button", { name: "Plain text" }));
+ expect(screen.getByRole("textbox", { name: /SKILL\.md/ })).toBeTruthy();
+
+ // Mode used to live inside FileViewer, which the per-path `key`
+ // remounted — selecting another file silently snapped back to preview.
+ fireEvent.click(screen.getByRole("tab", { name: "patterns.md" }));
+ expect(screen.getByRole("textbox", { name: /patterns\.md/ })).toBeTruthy();
+ expect(screen.queryByTestId("preview")).toBeNull();
+ });
+
+ it("strips frontmatter from the preview so name/description are not shown twice", async () => {
+ renderPage(new URLSearchParams("view=files"));
+ const preview = await screen.findByTestId("preview");
+ expect(preview.textContent).toContain("# Interface Animations");
+ expect(preview.textContent).not.toContain("name: aiforui-animations");
+ });
+});
+
+describe("SkillDetailPage save bar", () => {
+ it("stays mounted and disabled while clean so committing an edit never shifts the layout", async () => {
+ renderPage();
+ expect(await screen.findByText("All changes saved")).toBeTruthy();
+ expect(
+ screen.getByRole("button", { name: /Save changes/ }).hasAttribute("disabled"),
+ ).toBe(true);
+
+ fireEvent.change(screen.getByLabelText("Description"), {
+ target: { value: "changed" },
+ });
+ expect(
+ screen.getByRole("button", { name: /Save changes/ }).hasAttribute("disabled"),
+ ).toBe(false);
+ });
+
+ it("is absent for read-only viewers, who get the capability banner instead", async () => {
+ canEditRef.current = false;
+ renderPage();
+ expect(await screen.findByTestId("capability-banner")).toBeTruthy();
+ expect(screen.queryByRole("button", { name: /Save changes/ })).toBeNull();
+ });
+});
+
+describe("SkillDetailPage properties", () => {
+ it("renders the whole description in an editable field sized for it", async () => {
+ renderPage();
+ const field = (await screen.findByLabelText("Description")) as HTMLTextAreaElement;
+ expect(field.value).toBe(LONG_DESCRIPTION);
+ expect(Number(field.rows)).toBeGreaterThanOrEqual(4);
+ expect(
+ screen.getByText(`${LONG_DESCRIPTION.length} characters.`, { exact: false }),
+ ).toBeTruthy();
+ });
+});
diff --git a/packages/views/skills/components/skill-detail-page.tsx b/packages/views/skills/components/skill-detail-page.tsx
index fdc3d11c3a..f5a654d0a4 100644
--- a/packages/views/skills/components/skill-detail-page.tsx
+++ b/packages/views/skills/components/skill-detail-page.tsx
@@ -1,19 +1,20 @@
"use client";
-import { useEffect, useMemo, useRef, useState } from "react";
+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import {
AlertCircle,
AlertTriangle,
- ArrowLeft,
+ Clock3,
+ FileText,
HardDrive,
Loader2,
Lock,
- Pencil,
Plus,
Save,
Sparkles,
Trash2,
UserPlus,
+ Users,
} from "lucide-react";
import type {
Agent,
@@ -40,7 +41,6 @@ import {
import { resolvePublicFileUrl } from "@multica/core/workspace/avatar-url";
import {
runtimeDisplayLabel,
- runtimeDisplayName,
runtimeListOptions,
} from "@multica/core/runtimes";
import { ActorAvatar } from "@multica/ui/components/common/actor-avatar";
@@ -54,7 +54,6 @@ import {
DialogTitle,
} from "@multica/ui/components/ui/dialog";
import { Input } from "@multica/ui/components/ui/input";
-import { Label } from "@multica/ui/components/ui/label";
import { Skeleton } from "@multica/ui/components/ui/skeleton";
import { Textarea } from "@multica/ui/components/ui/textarea";
import {
@@ -62,6 +61,7 @@ import {
TooltipContent,
TooltipTrigger,
} from "@multica/ui/components/ui/tooltip";
+import { cn } from "@multica/ui/lib/utils";
import { AppLink, useNavigation } from "../../navigation";
import { BreadcrumbHeader } from "../../layout/breadcrumb-header";
import { useCanEditSkill } from "../hooks/use-can-edit-skill";
@@ -69,23 +69,40 @@ import { useSkillPermissions } from "@multica/core/permissions";
import { CapabilityBanner } from "@multica/ui/components/common/capability-banner";
import { readOrigin, totalFileCount, type OriginInfo } from "../lib/origin";
import { FileTree } from "./file-tree";
-import { FileViewer } from "./file-viewer";
+import { FileViewer, isMarkdownPath, type FileMode } from "./file-viewer";
import {
AddToAgentDialog,
type SkillActionsContext,
} from "./skill-list-actions";
import { useT } from "../../i18n";
-import { ResourceLabelPicker } from "../../labels/resource-label-picker";
+import {
+ ResourceLabelPicker,
+ useResourceLabelsEnabled,
+} from "../../labels/resource-label-picker";
const SKILL_MD = "SKILL.md";
type DraftFile = { id?: string; path: string; content: string };
+/**
+ * Two tabs, not three. A skill has no settings axis to speak of:
+ * `UpdateSkillRequest` carries only name / description / content / config /
+ * files, and edit rights are derived (creator or workspace admin) with no
+ * writable counterpart — so a Settings tab would hold a delete button and a
+ * read-only sentence. Delete lives in the header instead, matching the agent
+ * detail page where Archive sits in the header.
+ */
+type DetailView = "overview" | "files";
+
+function isDetailView(value: string | null): value is DetailView {
+ return value === "overview" || value === "files";
+}
+
// ---------------------------------------------------------------------------
// File path validation + inline add
// ---------------------------------------------------------------------------
-function useValidateNewFilePath() {
+export function useValidateNewFilePath() {
const { t } = useT("skills");
return (path: string, existing: string[]): string => {
const p = path.trim();
@@ -94,6 +111,17 @@ function useValidateNewFilePath() {
if (p.split("/").includes("..")) return t(($) => $.detail.add_file.errors.double_dot);
if (p === SKILL_MD) return t(($) => $.detail.add_file.errors.reserved);
if (existing.includes(p)) return t(($) => $.detail.add_file.errors.exists);
+ // Directories are inferred from paths, not stored, so a file named after
+ // one merges into that folder's node when the tree is built — it drops off
+ // the rail while still sitting in the draft. Rejected in both directions:
+ // a file cannot take a folder's name, and cannot take a name that an
+ // existing file is already nested under.
+ if (existing.some((other) => other.startsWith(`${p}/`))) {
+ return t(($) => $.detail.add_file.errors.is_directory);
+ }
+ if (existing.some((other) => p.startsWith(`${other}/`))) {
+ return t(($) => $.detail.add_file.errors.under_file);
+ }
return "";
};
}
@@ -122,7 +150,7 @@ function AddFileInline({
};
return (
- <div className="border-b bg-muted/30 px-2 py-2">
+ <div className="mt-1.5">
<Input
autoFocus
value={path}
@@ -155,25 +183,143 @@ function AddFileInline({
}
// ---------------------------------------------------------------------------
-// Sidebar sections
+// Header
+// ---------------------------------------------------------------------------
+
+function useOriginLabel(origin: OriginInfo | null, runtime: AgentRuntime | null) {
+ const { t } = useT("skills");
+ if (!origin) return null;
+ if (origin.type === "runtime_local") {
+ return runtime
+ ? t(($) => $.detail.subline.origin_runtime_named, {
+ name: runtimeDisplayLabel(runtime),
+ })
+ : origin.provider
+ ? t(($) => $.detail.subline.origin_runtime_provider, { provider: origin.provider })
+ : t(($) => $.detail.subline.origin_runtime_unknown);
+ }
+ if (origin.type === "clawhub") return t(($) => $.detail.subline.origin_clawhub);
+ if (origin.type === "skills_sh") return t(($) => $.detail.subline.origin_skills_sh);
+ if (origin.type === "github") return t(($) => $.detail.subline.origin_github);
+ return t(($) => $.detail.subline.origin_workspace);
+}
+
+/**
+ * Identity strip under the breadcrumb: mark, name, and the counts that say
+ * what this skill is made of. One line, because everything a reader would
+ * scroll past it for is a field on the Overview tab.
+ *
+ * The description is not repeated here. It used to be, above an editable copy
+ * of itself two tabs' worth of chrome below — every visit to a page whose only
+ * verbs are edit, add and delete paid for a read-only restatement of a field
+ * the next screenful lets you change. The list this page is reached from
+ * already carries the description for anyone deciding whether to open it.
+ *
+ * The agent detail header still has the taller form. Bringing it across is a
+ * separate change to a page this branch does not otherwise touch.
+ */
+function SkillIdentity({
+ skill,
+ origin,
+ originRuntime,
+ agentCount,
+ creator,
+}: {
+ skill: Skill;
+ origin: OriginInfo | null;
+ originRuntime: AgentRuntime | null;
+ agentCount: number;
+ creator: MemberWithUser | null;
+}) {
+ const { t } = useT("skills");
+ const timeAgo = useTimeAgo();
+ const originLabel = useOriginLabel(origin, originRuntime);
+ const isRuntimeOrigin = origin?.type === "runtime_local";
+
+ return (
+ <div className="shrink-0 border-b px-4 py-3 sm:px-6">
+ <div className="mx-auto flex max-w-[1440px] flex-wrap items-center gap-x-4 gap-y-1.5">
+ <div className="flex min-w-0 items-center gap-2.5">
+ <div className="flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border bg-muted text-muted-foreground">
+ <Sparkles className="h-4 w-4" aria-hidden="true" />
+ </div>
+ <h1 className="min-w-0 truncate font-mono text-lg font-semibold tracking-tight">
+ {skill.name}
+ </h1>
+ </div>
+ <div className="flex min-w-0 flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground sm:ml-auto">
+ {originLabel && (
+ <span className="inline-flex min-w-0 items-center gap-1.5">
+ {isRuntimeOrigin ? (
+ <HardDrive className="h-3.5 w-3.5 shrink-0" aria-hidden="true" />
+ ) : (
+ <Sparkles className="h-3.5 w-3.5 shrink-0" aria-hidden="true" />
+ )}
+ <span className="truncate">{originLabel}</span>
+ </span>
+ )}
+ <span className="inline-flex items-center gap-1.5">
+ <FileText className="h-3.5 w-3.5" aria-hidden="true" />
+ {t(($) => $.detail.header.files, { count: totalFileCount(skill) })}
+ </span>
+ <span className="inline-flex items-center gap-1.5">
+ <Users className="h-3.5 w-3.5" aria-hidden="true" />
+ {t(($) => $.detail.header.used_by, { count: agentCount })}
+ </span>
+ <span className="inline-flex items-center gap-1.5">
+ <Clock3 className="h-3.5 w-3.5" aria-hidden="true" />
+ {creator
+ ? t(($) => $.detail.header.updated_by, {
+ when: timeAgo(skill.updated_at),
+ name: creator.name,
+ })
+ : t(($) => $.detail.header.updated, { when: timeAgo(skill.updated_at) })}
+ </span>
+ </div>
+ </div>
+ </div>
+ );
+}
+
+// ---------------------------------------------------------------------------
+// Overview tab
// ---------------------------------------------------------------------------
-function UsedBySection({ agents }: { agents: Agent[] }) {
+function PropertyRow({
+ label,
+ htmlFor,
+ children,
+}: {
+ label: string;
+ htmlFor?: string;
+ children: React.ReactNode;
+}) {
+ return (
+ <div className="grid gap-1.5 py-2.5 sm:grid-cols-[128px_minmax(0,1fr)] sm:gap-4">
+ <label
+ htmlFor={htmlFor}
+ className="pt-1.5 text-xs text-muted-foreground sm:text-sm"
+ >
+ {label}
+ </label>
+ <div className="min-w-0">{children}</div>
+ </div>
+ );
+}
+
+function UsedByList({ agents }: { agents: Agent[] }) {
const { t } = useT("skills");
if (agents.length === 0) {
return (
- <div className="rounded-md border border-dashed px-3 py-4 text-center text-xs text-muted-foreground">
- {t(($) => $.detail.sidebar.used_by_empty)}
+ <div className="rounded-lg border border-dashed px-3 py-6 text-center text-xs text-muted-foreground">
+ {t(($) => $.detail.overview.used_by_empty)}
</div>
);
}
return (
- <ul className="space-y-1.5">
+ <ul className="divide-y overflow-hidden rounded-lg border bg-card">
{agents.map((a) => (
- <li
- key={a.id}
- className="flex items-center gap-2 rounded-md border bg-card px-2.5 py-1.5"
- >
+ <li key={a.id} className="flex items-center gap-2.5 px-3 py-2.5">
<ActorAvatar
name={a.name}
initials={a.name.slice(0, 2).toUpperCase()}
@@ -182,7 +328,7 @@ function UsedBySection({ agents }: { agents: Agent[] }) {
size="md"
/>
<div className="min-w-0 flex-1">
- <div className="truncate text-xs font-medium">{a.name}</div>
+ <div className="truncate text-sm font-medium">{a.name}</div>
{a.description && (
<div className="truncate text-xs text-muted-foreground">
{a.description}
@@ -195,56 +341,289 @@ function UsedBySection({ agents }: { agents: Agent[] }) {
);
}
-function OriginSidebarCard({
- origin,
- runtime,
+function OverviewTab({
+ skill,
+ name,
+ description,
+ canEdit,
+ creatorName,
+ skillAgents,
+ onNameChange,
+ onDescriptionChange,
+ onAddToAgents,
}: {
- origin: OriginInfo;
- runtime: AgentRuntime | null;
+ skill: Skill;
+ name: string;
+ description: string;
+ canEdit: boolean;
+ creatorName: string | null;
+ skillAgents: Agent[];
+ onNameChange: (value: string) => void;
+ onDescriptionChange: (value: string) => void;
+ onAddToAgents: () => void;
}) {
const { t } = useT("skills");
- if (origin.type === "manual") return null;
-
- const isRuntime = origin.type === "runtime_local";
- const label =
- origin.type === "runtime_local"
- ? t(($) => $.detail.origin_card.imported_runtime)
- : origin.type === "clawhub"
- ? t(($) => $.detail.origin_card.imported_clawhub)
- : origin.type === "github"
- ? t(($) => $.detail.origin_card.imported_github)
- : t(($) => $.detail.origin_card.imported_skills_sh);
+ const labelsEnabled = useResourceLabelsEnabled();
return (
- <div className="rounded-md border bg-muted/30 p-3">
- <div className="flex items-center gap-1.5 text-xs font-medium text-muted-foreground">
- {isRuntime ? (
- <HardDrive className="h-3 w-3" />
- ) : (
- <Sparkles className="h-3 w-3" />
- )}
- {label}
- </div>
- {runtime && (
- <div className="mt-1 break-all text-xs text-foreground">
- {runtimeDisplayName(runtime)}
+ <div className="mx-auto w-full max-w-3xl p-4 sm:p-6 md:p-8">
+ <section>
+ <h2 className="text-base font-medium">{t(($) => $.detail.overview.properties)}</h2>
+ <p className="mt-1 text-xs text-muted-foreground">
+ {t(($) => $.detail.overview.properties_hint)}
+ </p>
+ <div className="mt-4 divide-y">
+ <PropertyRow label={t(($) => $.detail.overview.name)} htmlFor="skill-name">
+ <Input
+ id="skill-name"
+ value={name}
+ readOnly={!canEdit}
+ onChange={(e) => onNameChange(e.target.value)}
+ placeholder={t(($) => $.detail.name_placeholder)}
+ className="font-mono text-sm read-only:cursor-default"
+ />
+ </PropertyRow>
+
+ <PropertyRow
+ label={t(($) => $.detail.overview.description)}
+ htmlFor="skill-description"
+ >
+ {/* Real descriptions run 500–900 characters (they carry the
+ trigger vocabulary an agent matches on), so this field is
+ sized for the data rather than the two rows it had before. */}
+ <Textarea
+ id="skill-description"
+ value={description}
+ readOnly={!canEdit}
+ onChange={(e) => onDescriptionChange(e.target.value)}
+ placeholder={t(($) => $.detail.description_placeholder)}
+ rows={6}
+ className="text-sm leading-relaxed read-only:cursor-default"
+ />
+ <p className="mt-1.5 text-xs text-muted-foreground">
+ {t(($) => $.detail.overview.description_hint, {
+ count: description.length,
+ })}
+ </p>
+ </PropertyRow>
+
+ {labelsEnabled && (
+ <PropertyRow label={t(($) => $.detail.overview.labels)}>
+ <ResourceLabelPicker
+ resourceType="skill"
+ resourceId={skill.id}
+ canEdit={canEdit}
+ />
+ </PropertyRow>
+ )}
</div>
- )}
- {origin.source_path && (
- <div className="mt-1 break-all font-mono text-xs text-foreground">
- {origin.source_path}
+ </section>
+
+ <section className="mt-10">
+ <div className="flex items-center justify-between gap-3">
+ <h2 className="min-w-0 text-base font-medium">
+ {t(($) => $.detail.overview.used_by, { count: skillAgents.length })}
+ </h2>
+ <Button
+ variant="outline"
+ size="xs"
+ className="shrink-0 gap-1"
+ onClick={onAddToAgents}
+ >
+ <UserPlus className="h-3 w-3" />
+ {t(($) => $.actions.add_to_agent)}
+ </Button>
</div>
- )}
- {origin.source_url && (
- <div className="mt-1 break-all font-mono text-xs text-foreground">
- {origin.source_url}
+ <div className="mt-3">
+ <UsedByList agents={skillAgents} />
</div>
- )}
- {origin.provider && (
- <div className="mt-1 font-mono text-xs text-muted-foreground">
- {t(($) => $.detail.origin_card.provider, { provider: origin.provider })}
+ </section>
+
+ <p className="mt-10 rounded-lg bg-muted px-3 py-2.5 text-xs leading-relaxed text-muted-foreground">
+ {canEdit
+ ? t(($) => $.detail.overview.permissions_owner)
+ : creatorName
+ ? t(($) => $.detail.overview.permissions_locked_creator, { name: creatorName })
+ : t(($) => $.detail.overview.permissions_locked)}
+ </p>
+ </div>
+ );
+}
+
+// ---------------------------------------------------------------------------
+// Files tab
+// ---------------------------------------------------------------------------
+
+function FilesTab({
+ filePaths,
+ selectedPath,
+ selectedContent,
+ mode,
+ canEdit,
+ addingFile,
+ onSelectPath,
+ onModeChange,
+ onStartAddFile,
+ onAddFile,
+ onCancelAddFile,
+ onDeleteFile,
+ onRenameFile,
+ onContentChange,
+}: {
+ filePaths: string[];
+ selectedPath: string;
+ selectedContent: string;
+ mode: FileMode;
+ canEdit: boolean;
+ addingFile: boolean;
+ onSelectPath: (path: string) => void;
+ onModeChange: (mode: FileMode) => void;
+ onStartAddFile: () => void;
+ onAddFile: (path: string) => void;
+ onCancelAddFile: () => void;
+ onDeleteFile: (path?: string) => void;
+ onRenameFile: (from: string, to: string) => void;
+ onContentChange: (content: string) => void;
+}) {
+ const { t } = useT("skills");
+ const validatePath = useValidateNewFilePath();
+ const supportingPaths = filePaths.filter((p) => p !== SKILL_MD);
+ const isMd = isMarkdownPath(selectedPath);
+ // Absent for read-only viewers so the tree never offers an action it would
+ // then refuse. SKILL.md is excluded inside the tree by reservedPath.
+ const treeActions = canEdit
+ ? {
+ validatePath,
+ onRename: onRenameFile,
+ onDelete: onDeleteFile,
+ reservedPath: SKILL_MD,
+ }
+ : undefined;
+
+ return (
+ <div className="flex min-h-full flex-col md:h-full md:flex-row">
+ {/* The file list IS the second-level navigation, so it uses the same
+ rail treatment as the agent detail page's capability/settings nav
+ instead of inventing a third sidebar style. */}
+ <aside
+ role="tablist"
+ aria-orientation="vertical"
+ aria-label={t(($) => $.detail.files.list_aria)}
+ className="shrink-0 border-b border-surface-border p-3 md:w-52 md:overflow-y-auto md:border-b-0 md:border-r md:p-4"
+ >
+ <p className="px-2.5 pb-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground">
+ {t(($) => $.detail.files.main)}
+ </p>
+ <FileTree
+ filePaths={[SKILL_MD]}
+ selectedPath={selectedPath}
+ onSelect={onSelectPath}
+ />
+
+ <p className="px-2.5 pb-1 pt-3 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground">
+ {t(($) => $.detail.files.supporting, { count: supportingPaths.length })}
+ </p>
+ {supportingPaths.length > 0 ? (
+ <FileTree
+ actions={treeActions}
+ filePaths={supportingPaths}
+ selectedPath={selectedPath}
+ onSelect={onSelectPath}
+ />
+ ) : (
+ !addingFile && (
+ <p className="px-2.5 py-1 text-xs text-muted-foreground">
+ {t(($) => $.detail.files.supporting_empty)}
+ </p>
+ )
+ )}
+
+ {canEdit &&
+ (addingFile ? (
+ <AddFileInline
+ existingPaths={filePaths}
+ onAdd={onAddFile}
+ onCancel={onCancelAddFile}
+ />
+ ) : (
+ <Button
+ type="button"
+ variant="ghost"
+ size="xs"
+ onClick={onStartAddFile}
+ className="mt-2 h-8 w-full justify-start px-2.5 text-muted-foreground"
+ >
+ <Plus className="h-3.5 w-3.5" />
+ {t(($) => $.detail.files.add_file)}
+ </Button>
+ ))}
+ </aside>
+
+ <section className="flex min-h-[32rem] min-w-0 flex-1 flex-col md:min-h-0">
+ <div className="flex h-10 shrink-0 items-center gap-3 border-b px-3 sm:px-4">
+ <span className="truncate font-mono text-xs text-muted-foreground">
+ {selectedPath}
+ </span>
+ <div className="ml-auto flex shrink-0 items-center gap-1">
+ {isMd && (
+ <div
+ role="group"
+ aria-label={t(($) => $.detail.files.mode_aria)}
+ className="flex items-center gap-0.5 rounded-md bg-muted p-0.5"
+ >
+ {(["preview", "raw"] as const).map((value) => (
+ <button
+ key={value}
+ type="button"
+ aria-pressed={mode === value}
+ onClick={() => onModeChange(value)}
+ className={cn(
+ "h-6 rounded px-2 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
+ mode === value
+ ? "bg-surface text-foreground shadow-sm"
+ : "text-muted-foreground hover:text-foreground",
+ )}
+ >
+ {value === "preview"
+ ? t(($) => $.detail.files.mode_preview)
+ : t(($) => $.detail.files.mode_raw)}
+ </button>
+ ))}
+ </div>
+ )}
+ {selectedPath !== SKILL_MD && canEdit && (
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon-sm"
+ onClick={() => onDeleteFile()}
+ className="text-muted-foreground hover:text-destructive"
+ aria-label={t(($) => $.detail.delete_file)}
+ >
+ <Trash2 className="h-3.5 w-3.5" />
+ </Button>
+ }
+ />
+ <TooltipContent>{t(($) => $.detail.delete_file)}</TooltipContent>
+ </Tooltip>
+ )}
+ </div>
</div>
- )}
+
+ <div className="min-h-0 flex-1">
+ <FileViewer
+ key={selectedPath}
+ path={selectedPath}
+ content={selectedContent}
+ mode={mode}
+ readOnly={!canEdit}
+ onChange={onContentChange}
+ />
+ </div>
+ </section>
</div>
);
}
@@ -255,7 +634,6 @@ function OriginSidebarCard({
export function SkillDetailPage({ skillId }: { skillId: string }) {
const { t } = useT("skills");
- const timeAgo = useTimeAgo();
const wsId = useWorkspaceId();
const qc = useQueryClient();
const paths = useWorkspacePaths();
@@ -277,10 +655,7 @@ export function SkillDetailPage({ skillId }: { skillId: string }) {
runtimeListOptions(wsId),
);
- const assignments = useMemo(
- () => selectSkillAssignments(agents),
- [agents],
- );
+ const assignments = useMemo(() => selectSkillAssignments(agents), [agents]);
const canEdit = useCanEditSkill(skill, wsId);
const skillPermissions = useSkillPermissions(skill ?? null, wsId);
@@ -310,6 +685,35 @@ export function SkillDetailPage({ skillId }: { skillId: string }) {
const [addingFile, setAddingFile] = useState(false);
const [conflictPending, setConflictPending] = useState(false);
+ // Preview/raw is a property of how the user wants to work, so it lives here
+ // and survives switching files. It used to live inside FileViewer, which the
+ // per-file `key` remounted — every file switch silently snapped back.
+ const [fileMode, setFileMode] = useState<FileMode>("preview");
+
+ const urlView = navigation.searchParams.get("view");
+ const [activeView, setActiveView] = useState<DetailView>(() =>
+ isDetailView(urlView) ? urlView : "overview",
+ );
+ const lastUrlViewRef = useRef(urlView);
+
+ useEffect(() => {
+ if (urlView === lastUrlViewRef.current) return;
+ lastUrlViewRef.current = urlView;
+ setActiveView(isDetailView(urlView) ? urlView : "overview");
+ }, [urlView]);
+
+ const selectView = useCallback(
+ (next: DetailView) => {
+ setActiveView(next);
+ const params = new URLSearchParams(navigation.searchParams);
+ if (next === "overview") params.delete("view");
+ else params.set("view", next);
+ const query = params.toString();
+ navigation.replace(`${navigation.pathname}${query ? `?${query}` : ""}`);
+ },
+ [navigation],
+ );
+
const draftRef = useRef({ name, description, content, files });
draftRef.current = { name, description, content, files };
@@ -366,10 +770,7 @@ export function SkillDetailPage({ skillId }: { skillId: string }) {
[members, skill?.created_by],
);
- const origin = useMemo(
- () => (skill ? readOrigin(skill) : null),
- [skill],
- );
+ const origin = useMemo(() => (skill ? readOrigin(skill) : null), [skill]);
const originRuntime = useMemo<AgentRuntime | null>(() => {
if (!origin || origin.type !== "runtime_local" || !origin.runtime_id)
return null;
@@ -437,10 +838,7 @@ export function SkillDetailPage({ skillId }: { skillId: string }) {
files: files.filter((f) => f.path.trim()),
};
const updated = await api.updateSkill(skill.id, payload);
- qc.setQueryData(
- skillDetailOptions(wsId, skill.id).queryKey,
- updated,
- );
+ qc.setQueryData(skillDetailOptions(wsId, skill.id).queryKey, updated);
seedFromSkill(updated);
seededKeyRef.current = `${wsId}:${updated.id}@${updated.updated_at}`;
setConflictPending(false);
@@ -491,10 +889,22 @@ export function SkillDetailPage({ skillId }: { skillId: string }) {
setAddingFile(false);
};
- const handleDeleteFile = () => {
- if (selectedPath === SKILL_MD) return;
- setFiles((prev) => prev.filter((f) => f.path !== selectedPath));
- setSelectedPath(SKILL_MD);
+ // Defaults to the open file so the editor's own delete button keeps working;
+ // the tree passes the row that was acted on, which need not be the open one.
+ const handleDeleteFile = (path: string = selectedPath) => {
+ if (path === SKILL_MD) return;
+ setFiles((prev) => prev.filter((f) => f.path !== path));
+ if (path === selectedPath) setSelectedPath(SKILL_MD);
+ };
+
+ const handleRenameFile = (from: string, to: string) => {
+ if (from === SKILL_MD) return;
+ setFiles((prev) =>
+ prev.map((f) => (f.path === from ? { ...f, path: to } : f)),
+ );
+ // Follow the file: the rail is keyed by path, so leaving the selection on
+ // the old one would land on a row that no longer exists.
+ if (from === selectedPath) setSelectedPath(to);
};
const handleFileContentChange = (newContent: string) => {
@@ -510,8 +920,7 @@ export function SkillDetailPage({ skillId }: { skillId: string }) {
}
};
- const supportingQueryDown =
- !!agentsError || !!membersError || !!runtimesError;
+ const supportingQueryDown = !!agentsError || !!membersError || !!runtimesError;
if (isLoading) {
return (
@@ -540,7 +949,6 @@ export function SkillDetailPage({ skillId }: { skillId: string }) {
render={<AppLink href={paths.skills()} />}
nativeButton={false}
>
- <ArrowLeft className="h-3 w-3" />
{t(($) => $.detail.all_skills)}
</Button>
</div>
@@ -561,23 +969,13 @@ export function SkillDetailPage({ skillId }: { skillId: string }) {
);
}
- // --- Sub-line metadata for the header ---
- const originLabel = (() => {
- if (!origin) return null;
- if (origin.type === "runtime_local") {
- return originRuntime
- ? t(($) => $.detail.subline.origin_runtime_named, {
- name: runtimeDisplayLabel(originRuntime),
- })
- : origin.provider
- ? t(($) => $.detail.subline.origin_runtime_provider, { provider: origin.provider })
- : t(($) => $.detail.subline.origin_runtime_unknown);
- }
- if (origin.type === "clawhub") return t(($) => $.detail.subline.origin_clawhub);
- if (origin.type === "skills_sh") return t(($) => $.detail.subline.origin_skills_sh);
- if (origin.type === "github") return t(($) => $.detail.subline.origin_github);
- return t(($) => $.detail.subline.origin_workspace);
- })();
+ const TABS: { id: DetailView; label: string }[] = [
+ { id: "overview", label: t(($) => $.detail.tabs.overview) },
+ {
+ id: "files",
+ label: t(($) => $.detail.tabs.files, { count: totalFileCount(skill) }),
+ },
+ ];
return (
<div className="flex flex-1 min-h-0 flex-col">
@@ -596,6 +994,15 @@ export function SkillDetailPage({ skillId }: { skillId: string }) {
{t(($) => $.detail.read_only)}
</span>
)}
+ <Button
+ variant="outline"
+ size="xs"
+ className="gap-1"
+ onClick={() => setShowAddToAgents(true)}
+ >
+ <UserPlus className="h-3 w-3" />
+ {t(($) => $.actions.add_to_agent)}
+ </Button>
{canEdit && (
<Tooltip>
<TooltipTrigger
@@ -619,7 +1026,7 @@ export function SkillDetailPage({ skillId }: { skillId: string }) {
/>
{!canEdit && (
- <div className="px-4 pt-3">
+ <div className="px-4 pt-3 sm:px-6">
<CapabilityBanner
reason={skillPermissions.canEdit.reason}
resource="skill"
@@ -631,306 +1038,154 @@ export function SkillDetailPage({ skillId }: { skillId: string }) {
{supportingQueryDown && (
<div
role="status"
- className="flex shrink-0 items-start gap-2 border-b bg-warning/10 px-4 py-2 text-xs text-muted-foreground"
+ className="flex shrink-0 items-start gap-2 border-b bg-warning/10 px-4 py-2 text-xs text-muted-foreground sm:px-6"
>
<AlertTriangle className="mt-0.5 h-3.5 w-3.5 shrink-0 text-warning" />
<span>{t(($) => $.detail.supporting_data_warning)}</span>
</div>
)}
- {/* Body: file tree | editor | sidebar */}
- <div className="flex flex-1 min-h-0 flex-col overflow-y-auto md:flex-row md:overflow-hidden">
- {/* File tree */}
- <aside className="flex max-h-44 w-full shrink-0 flex-col border-b md:max-h-none md:w-56 md:border-b-0 md:border-r">
- <div className="flex h-10 shrink-0 items-center justify-between border-b px-3">
- <span className="text-xs font-medium uppercase tracking-wider text-muted-foreground">
- {t(($) => $.detail.files_label, { count: totalFileCount(skill) })}
- </span>
- {canEdit && (
- <Tooltip>
- <TooltipTrigger
- render={
- <Button
- type="button"
- variant="ghost"
- size="icon-sm"
- onClick={() => setAddingFile(true)}
- className="text-muted-foreground"
- aria-label={t(($) => $.detail.add_file_aria)}
- >
- <Plus className="h-3.5 w-3.5" />
- </Button>
- }
- />
- <TooltipContent>{t(($) => $.detail.add_file_tooltip)}</TooltipContent>
- </Tooltip>
- )}
- </div>
- {addingFile && (
- <AddFileInline
- existingPaths={filePaths}
- onAdd={handleAddFile}
- onCancel={() => setAddingFile(false)}
- />
- )}
- <div className="flex-1 overflow-y-auto">
- <FileTree
- filePaths={filePaths}
- selectedPath={selectedPath}
- onSelect={setSelectedPath}
- />
- </div>
- {selectedPath !== SKILL_MD && canEdit && (
- <div className="border-t px-3 py-2">
- <Button
- type="button"
- variant="ghost"
- size="xs"
- onClick={handleDeleteFile}
- className="text-muted-foreground hover:text-destructive"
- >
- <Trash2 className="h-3 w-3" />
- {t(($) => $.detail.delete_file)}
- </Button>
- </div>
- )}
- </aside>
+ <SkillIdentity
+ skill={skill}
+ origin={origin}
+ originRuntime={originRuntime}
+ agentCount={skillAgents.length}
+ creator={creator}
+ />
- {/* Editor */}
- <section className="flex min-h-[32rem] min-w-0 shrink-0 flex-col md:min-h-0 md:flex-1 md:shrink">
- {/* Name + description + subline */}
- <div className="space-y-2 border-b px-4 py-4 sm:px-5">
- <Input
- value={name}
- readOnly={!canEdit}
- onChange={(e) => setName(e.target.value)}
- placeholder={t(($) => $.detail.name_placeholder)}
- className="h-9 border-0 bg-transparent px-0 text-lg font-semibold shadow-none focus-visible:ring-0 read-only:cursor-default dark:bg-transparent"
- aria-label={t(($) => $.detail.name_aria)}
- />
- <div className="space-y-1">
- <Label
- htmlFor="skill-description"
- className="text-xs text-muted-foreground"
- >
- <Pencil className="h-3 w-3" />
- {t(($) => $.detail.description_label)}
- </Label>
- <Textarea
- id="skill-description"
- value={description}
- readOnly={!canEdit}
- onChange={(e) => setDescription(e.target.value)}
- placeholder={t(($) => $.detail.description_placeholder)}
- rows={2}
- className="resize-none text-sm read-only:cursor-default"
- />
- </div>
- <ResourceLabelPicker
- resourceType="skill"
- resourceId={skill.id}
- canEdit={canEdit}
- />
- <div className="flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground">
- {originLabel && (
- <span className="inline-flex items-center gap-1">
- {origin?.type === "runtime_local" ? (
- <HardDrive className="h-3 w-3" />
- ) : (
- <Sparkles className="h-3 w-3" />
- )}
- {originLabel}
- </span>
- )}
- <span className="inline-flex items-center gap-2">
- <span aria-hidden>·</span>
- <span>
- {t(($) => $.detail.subline.updated_label, {
- when: timeAgo(skill.updated_at),
- })}
- </span>
- </span>
- {creator && (
- <span className="inline-flex items-center gap-2">
- <span aria-hidden>·</span>
- <span className="inline-flex items-center gap-1">
- <ActorAvatar
- name={creator.name}
- initials={creator.name.slice(0, 2).toUpperCase()}
- avatarUrl={resolvePublicFileUrl(creator.avatar_url)}
- size="xs"
- />
- {t(($) => $.detail.subline.by_creator, { name: creator.name })}
- </span>
- </span>
+ <div
+ className="shrink-0 overflow-x-auto border-b px-4 sm:px-6"
+ role="tablist"
+ aria-label={t(($) => $.detail.tabs.aria)}
+ >
+ <div className="mx-auto flex max-w-[1440px] items-center gap-6">
+ {TABS.map((tab) => (
+ <button
+ key={tab.id}
+ type="button"
+ role="tab"
+ aria-selected={activeView === tab.id}
+ onClick={() => selectView(tab.id)}
+ className={cn(
+ "relative shrink-0 py-3 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",
+ activeView === tab.id
+ ? "text-foreground after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 after:bg-foreground"
+ : "text-muted-foreground hover:text-foreground",
)}
- </div>
- </div>
-
- {/* Conflict banner */}
- {conflictPending && canEdit && (
- <div
- role="status"
- aria-live="polite"
- className="flex items-start gap-2 border-b border-warning/30 bg-warning/10 px-4 py-2 text-xs"
>
- <AlertTriangle className="mt-0.5 h-3.5 w-3.5 shrink-0 text-warning" />
- <div className="flex-1">
- <div className="font-medium text-foreground">
- {t(($) => $.detail.conflict_banner.title)}
- </div>
- <div className="mt-0.5 text-muted-foreground">
- {t(($) => $.detail.conflict_banner.body)}
- </div>
- </div>
- </div>
- )}
+ {tab.label}
+ </button>
+ ))}
+ </div>
+ </div>
- {/* File viewer */}
- <div className="flex-1 min-h-0">
- <FileViewer
- key={selectedPath}
- path={selectedPath}
- content={selectedContent}
- onChange={handleFileContentChange}
- />
+ {conflictPending && canEdit && (
+ <div
+ role="status"
+ aria-live="polite"
+ className="flex shrink-0 items-start gap-2 border-b border-warning/30 bg-warning/10 px-4 py-2 text-xs sm:px-6"
+ >
+ <AlertTriangle className="mt-0.5 h-3.5 w-3.5 shrink-0 text-warning" />
+ <div className="flex-1">
+ <div className="font-medium text-foreground">
+ {t(($) => $.detail.conflict_banner.title)}
+ </div>
+ <div className="mt-0.5 text-muted-foreground">
+ {t(($) => $.detail.conflict_banner.body)}
+ </div>
</div>
+ </div>
+ )}
- {/* Save bar */}
- {isDirty && canEdit && (
- <div
- role="status"
- aria-live="polite"
- className="flex flex-wrap items-center gap-2 border-t bg-muted/30 px-4 py-2"
- >
+ <div
+ className={cn(
+ "min-h-0 flex-1 overflow-y-auto",
+ activeView === "files" && "md:overflow-hidden",
+ )}
+ >
+ {activeView === "overview" ? (
+ <OverviewTab
+ skill={skill}
+ name={name}
+ description={description}
+ canEdit={canEdit}
+ creatorName={creator?.name ?? null}
+ skillAgents={skillAgents}
+ onNameChange={setName}
+ onDescriptionChange={setDescription}
+ onAddToAgents={() => setShowAddToAgents(true)}
+ />
+ ) : (
+ <FilesTab
+ filePaths={filePaths}
+ selectedPath={selectedPath}
+ selectedContent={selectedContent}
+ mode={fileMode}
+ canEdit={canEdit}
+ addingFile={addingFile}
+ onSelectPath={setSelectedPath}
+ onModeChange={setFileMode}
+ onStartAddFile={() => setAddingFile(true)}
+ onAddFile={handleAddFile}
+ onCancelAddFile={() => setAddingFile(false)}
+ onDeleteFile={handleDeleteFile}
+ onRenameFile={handleRenameFile}
+ onContentChange={handleFileContentChange}
+ />
+ )}
+ </div>
+
+ {/* Page-level so it covers edits made on either tab, and always present
+ while editable so committing a change never shifts the layout. */}
+ {canEdit && (
+ <div
+ role="status"
+ aria-live="polite"
+ className="pe-chat-launcher flex shrink-0 flex-wrap items-center gap-2 border-t bg-muted/30 py-2 pl-4 sm:pl-6"
+ >
+ {isDirty ? (
+ <>
<span className="h-1.5 w-1.5 rounded-full bg-brand" />
<span className="text-xs text-muted-foreground">
{t(($) => $.detail.save_bar.unsaved)}
</span>
- <div className="ml-auto flex items-center gap-1.5">
- <Button
- type="button"
- variant="ghost"
- size="xs"
- onClick={handleDiscard}
- >
- {t(($) => $.detail.save_bar.discard)}
- </Button>
- <Button
- type="button"
- size="xs"
- onClick={handleSave}
- disabled={saving || !name.trim()}
- >
- {saving ? (
- <>
- <Loader2 className="h-3 w-3 animate-spin" />
- {t(($) => $.detail.save_bar.saving)}
- </>
- ) : (
- <>
- <Save className="h-3 w-3" />
- {t(($) => $.detail.save_bar.save)}
- </>
- )}
- </Button>
- </div>
- </div>
+ </>
+ ) : (
+ <span className="text-xs text-muted-foreground">
+ {t(($) => $.detail.save_bar.saved)}
+ </span>
)}
- </section>
-
- {/* Sidebar */}
- <aside className="flex w-full shrink-0 flex-col gap-4 border-t bg-muted/20 px-4 py-4 md:w-72 md:overflow-y-auto md:border-l md:border-t-0">
- <div>
- <h3 className="mb-2 text-xs font-medium uppercase tracking-wider text-muted-foreground">
- {t(($) => $.detail.sidebar.metadata)}
- </h3>
- <dl className="space-y-1.5 text-xs">
- <div className="flex gap-2">
- <dt className="min-w-20 text-muted-foreground">
- {t(($) => $.detail.sidebar.created)}
- </dt>
- <dd className="min-w-0 flex-1">
- {timeAgo(skill.created_at)}
- </dd>
- </div>
- <div className="flex gap-2">
- <dt className="min-w-20 text-muted-foreground">
- {t(($) => $.detail.sidebar.updated)}
- </dt>
- <dd className="min-w-0 flex-1">
- {timeAgo(skill.updated_at)}
- </dd>
- </div>
- {creator && (
- <div className="flex gap-2">
- <dt className="min-w-20 text-muted-foreground">
- {t(($) => $.detail.sidebar.created_by)}
- </dt>
- <dd className="min-w-0 flex-1">{creator.name}</dd>
- </div>
+ <div className="ml-auto flex items-center gap-1.5">
+ <Button
+ type="button"
+ variant="ghost"
+ size="xs"
+ onClick={handleDiscard}
+ disabled={!isDirty || saving}
+ >
+ {t(($) => $.detail.save_bar.discard)}
+ </Button>
+ <Button
+ type="button"
+ size="xs"
+ onClick={handleSave}
+ disabled={!isDirty || saving || !name.trim()}
+ >
+ {saving ? (
+ <>
+ <Loader2 className="h-3 w-3 animate-spin" />
+ {t(($) => $.detail.save_bar.saving)}
+ </>
+ ) : (
+ <>
+ <Save className="h-3 w-3" />
+ {t(($) => $.detail.save_bar.save)}
+ </>
)}
- <div className="flex gap-2">
- <dt className="min-w-20 text-muted-foreground">
- {t(($) => $.detail.sidebar.files)}
- </dt>
- <dd className="min-w-0 flex-1">{totalFileCount(skill)}</dd>
- </div>
- <div
- className="flex gap-2"
- title={skill.id}
- >
- <dt className="min-w-20 text-muted-foreground">
- {t(($) => $.detail.sidebar.id)}
- </dt>
- <dd className="min-w-0 flex-1 truncate font-mono text-muted-foreground">
- {skill.id.slice(0, 8)}…
- </dd>
- </div>
- </dl>
- </div>
-
- {origin && origin.type !== "manual" && (
- <div>
- <h3 className="mb-2 text-xs font-medium uppercase tracking-wider text-muted-foreground">
- {t(($) => $.detail.sidebar.origin)}
- </h3>
- <OriginSidebarCard origin={origin} runtime={originRuntime} />
- </div>
- )}
-
- <div>
- <div className="mb-2 flex items-center justify-between gap-2">
- <h3 className="min-w-0 truncate text-xs font-medium uppercase tracking-wider text-muted-foreground">
- {t(($) => $.detail.sidebar.used_by, { count: skillAgents.length })}
- </h3>
- <Button
- variant="outline"
- size="xs"
- onClick={() => setShowAddToAgents(true)}
- className="h-6 shrink-0 gap-1"
- >
- <UserPlus className="h-3 w-3" />
- {t(($) => $.actions.add_to_agent)}
- </Button>
- </div>
- <UsedBySection agents={skillAgents} />
- </div>
-
- <div>
- <h3 className="mb-2 text-xs font-medium uppercase tracking-wider text-muted-foreground">
- {t(($) => $.detail.sidebar.permissions)}
- </h3>
- <p className="text-xs leading-relaxed text-muted-foreground">
- {canEdit
- ? t(($) => $.detail.sidebar.permissions_owner)
- : creator
- ? t(($) => $.detail.sidebar.permissions_locked_creator, { name: creator.name })
- : t(($) => $.detail.sidebar.permissions_locked)}
- </p>
+ </Button>
</div>
- </aside>
- </div>
+ </div>
+ )}
{/* Delete confirmation */}
<Dialog
diff --git a/packages/views/skills/components/skill-file-path.test.tsx b/packages/views/skills/components/skill-file-path.test.tsx
new file mode 100644
index 0000000000..c5338868c8
--- /dev/null
+++ b/packages/views/skills/components/skill-file-path.test.tsx
@@ -0,0 +1,55 @@
+/**
+ * @vitest-environment jsdom
+ */
+import { afterEach, describe, expect, it } from "vitest";
+import { cleanup } from "@testing-library/react";
+import { renderWithI18n } from "../../test/i18n";
+import { useValidateNewFilePath } from "./skill-detail-page";
+
+afterEach(cleanup);
+
+/**
+ * The validator is a hook because its messages are translated, so it is
+ * exercised through a probe rather than called directly. FileTree delegates to
+ * it instead of carrying a second copy of what counts as a legal path, which is
+ * why these cases live here and not in the tree's own tests.
+ */
+async function check(path: string, existing: string[]) {
+ let result = "unset";
+ function Probe() {
+ result = useValidateNewFilePath()(path, existing);
+ return null;
+ }
+ await renderWithI18n(<Probe />);
+ return result;
+}
+
+describe("useValidateNewFilePath", () => {
+ it("accepts a nested path, which is the only way a folder gets made", async () => {
+ // Directories are not stored; they exist because a path contains a slash.
+ // Typing one is the whole folder-creation flow.
+ expect(await check("references/api.md", ["notes.txt"])).toBe("");
+ });
+
+ it("refuses a name that existing files are already nested under", async () => {
+ // buildTree merges a file of this name into the folder's node, so the file
+ // drops off the rail while still sitting in the draft — saved, invisible.
+ expect(await check("references", ["references/api.md"])).not.toBe("");
+ });
+
+ it("refuses nesting under a path that is a file", async () => {
+ expect(await check("notes.txt/extra.md", ["notes.txt"])).not.toBe("");
+ });
+
+ it("refuses the reserved primary path", async () => {
+ // SKILL.md maps to skill.Content; the server drops it from the files list.
+ expect(await check("SKILL.md", [])).not.toBe("");
+ });
+
+ it("refuses absolute paths, escapes, duplicates and blanks", async () => {
+ expect(await check("/abs.md", [])).not.toBe("");
+ expect(await check("../escape.md", [])).not.toBe("");
+ expect(await check("notes.txt", ["notes.txt"])).not.toBe("");
+ expect(await check("", [])).not.toBe("");
+ });
+});