Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(ide): add a Skills tab that pastes saved Markdown prompts into terminal panes
rubenluetke10-beep2075c87f4492
diff --git a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsxindex e3c09e4773..009485a13a 100644--- a/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/AgenticTerminal.tsx@@ -98,6 +98,9 @@ import {type PaneDropPayload,} from "./paneDrop";import { usePaneFileDrag } from "./paneFileDrag";+import { PANE_PASTE_EVENT, announceSkillRefused, pasteSkillText, type PanePasteDetail, type SkillDragPayload } from "./skillDrag";+import { SkillDropCard } from "./sidePanel/skills/SkillDropCard";+import { useIdeSkillsStore } from "@/store/ideSkills";import {AgentPickerMenu,offersAgentChoice,@@ -2706,7 +2709,30 @@ export function AgenticTerminal({[name, onAttachError],);- const { dragging, handlers: dragHandlers } = usePaneFileDrag(+ /*+ * A skill from the side panel's Skills tab: its Markdown goes into the+ * agent's prompt as ONE bracketed paste — the same thing Ctrl+V does — so a+ * multi-line text never submits itself line by line. Not sent: the user+ * still says what to do with it.+ */+ const pasteSkill = useCallback(+ (skill: SkillDragPayload) => {+ const term = termRef.current;+ if (!term || !skill.content) return;+ onFocus?.();+ takeOwnershipRef.current?.();+ if (!pasteSkillText(term, skill.content)) {+ announceSkillRefused(name);+ return;+ }+ setJustDelivered(true);+ window.setTimeout(() => setJustDelivered(false), 1_200);+ useIdeSkillsStore.getState().recordUse(skill.id, name);+ },+ [name, onFocus],+ );++ const { dragging, carrying, handlers: dragHandlers } = usePaneFileDrag(useCallback((dt: DataTransfer) => {onFocus?.();@@ -2715,7 +2741,20 @@ export function AgenticTerminal({},[attach, onFocus],),+ pasteSkill,);+ const skillInFlight = useIdeSkillsStore((state) => (carrying === "skill" ? state.dragging : null));++ // "Paste into …" on a skill card: the same paste, addressed by name.+ useEffect(() => {+ const onPaste = (event: Event) => {+ const detail = (event as CustomEvent<PanePasteDetail>).detail;+ if (detail?.pane !== name || (workspaceId && detail.workspaceId !== workspaceId)) return;+ pasteSkill(detail.skill);+ };+ window.addEventListener(PANE_PASTE_EVENT, onPaste);+ return () => window.removeEventListener(PANE_PASTE_EVENT, onPaste);+ }, [name, workspaceId, pasteSkill]);// Clipboard images only — pasted TEXT belongs to xterm, which turns it into a// proper bracketed paste the agent's prompt box understands.@@ -3009,7 +3048,11 @@ export function AgenticTerminal({</div>)}</div>- {(dragging || attaching) && (+ {dragging && carrying === "skill" && !attaching && (+ <SkillDropCard skill={skillInFlight} target={name}+ blocked={Boolean(skillInFlight?.multiline) && !termRef.current?.modes.bracketedPasteMode} />+ )}+ {((dragging && carrying !== "skill") || attaching) && (<div className="pointer-events-none absolute inset-0 flex items-center justify-center bg-background backdrop-blur-[2px]">{/* A real card fill separates this from the pane behind it, so itneeds no rim of its own — and the two glyphs are decorationdiff --git a/jarvis/ui/web/frontend/src/components/agentic/paneFileDrag.ts b/jarvis/ui/web/frontend/src/components/agentic/paneFileDrag.tsindex 5f9f80a610..98610a4582 100644--- a/jarvis/ui/web/frontend/src/components/agentic/paneFileDrag.ts+++ b/jarvis/ui/web/frontend/src/components/agentic/paneFileDrag.ts@@ -26,6 +26,11 @@ import {} from "react";import { dragCarriesFiles } from "./paneDrop";import { useDragSessionEnd } from "./dragSessionEnd";+import {+ dragCarriesSkill,+ readSkillDrag,+ type SkillDragPayload,+} from "./skillDrag";export interface PaneFileDragHandlers {onDragEnter: (e: ReactDragEvent) => void;@@ -37,6 +42,8 @@ export interface PaneFileDragHandlers {export interface PaneFileDrag {/** True while a file drag is over this pane — drives the drop overlay. */dragging: boolean;+ /** What is being carried over the pane while `dragging`: a file or a skill. */+ carrying: "files" | "skill" | null;/** Spread onto the pane's root element. */handlers: PaneFileDragHandlers;}@@ -46,11 +53,19 @@ export interface PaneFileDrag {** `onFiles` runs on a drop that actually carried files; it is handed the live* `DataTransfer` and must read it SYNCHRONOUSLY (see ./paneDrop).+ *+ * `onSkill`, when given, makes the pane a target for a skill carried out of+ * the side panel's Skills tab too (see ./skillDrag); without it a skill drag+ * passes over the pane as unnoticed as selected text.*/export function usePaneFileDrag(onFiles: (dt: DataTransfer) => void,+ onSkill?: (skill: SkillDragPayload) => void,): PaneFileDrag {const [dragging, setDragging] = useState(false);+ const [carrying, setCarrying] = useState<"files" | "skill" | null>(null);+ const takesSkill = (dt: DataTransfer | null) =>+ Boolean(onSkill) && dragCarriesSkill(dt);// Counted, not a boolean: a drag moving across the pane fires enter/leave for// every child element it crosses, and a boolean flickers.const depth = useRef(0);@@ -58,6 +73,7 @@ export function usePaneFileDrag(const disarm = useCallback(() => {depth.current = 0;setDragging(false);+ setCarrying(null);}, []);// The backstop, and the only thing this pane can actually rely on: a drag@@ -72,7 +88,8 @@ export function usePaneFileDrag(// for a dropped link or text is to NAVIGATE, which would replace the// whole IDE — every agent in the grid with it.e.preventDefault();- if (!dragCarriesFiles(e.dataTransfer)) return;+ const skill = takesSkill(e.dataTransfer);+ if (!skill && !dragCarriesFiles(e.dataTransfer)) return;// No reset needed here, and deliberately not attempted: `dragging` has// not flipped yet inside the batch that crossed into a child, so a reset// read off it would zero the count mid-drag. What keeps the counter from@@ -81,25 +98,36 @@ export function usePaneFileDrag(// permanent rather than momentary.depth.current += 1;setDragging(true);+ setCarrying(skill ? "skill" : "files");},onDragOver: (e) => {e.preventDefault();// An honest cursor: "copy" only where a drop will actually do something.- e.dataTransfer.dropEffect = dragCarriesFiles(e.dataTransfer)- ? "copy"- : "none";+ e.dataTransfer.dropEffect =+ dragCarriesFiles(e.dataTransfer) || takesSkill(e.dataTransfer)+ ? "copy"+ : "none";},onDragLeave: () => {depth.current = Math.max(0, depth.current - 1);- if (depth.current === 0) setDragging(false);+ if (depth.current === 0) {+ setDragging(false);+ setCarrying(null);+ }},onDrop: (e) => {e.preventDefault();disarm();+ // A skill first: its drag also carries `text/plain`, never a file.+ if (onSkill && takesSkill(e.dataTransfer)) {+ const skill = readSkillDrag(e.dataTransfer);+ if (skill) onSkill(skill);+ return;+ }if (!dragCarriesFiles(e.dataTransfer)) return;onFiles(e.dataTransfer);},};- return { dragging, handlers };+ return { dragging, carrying, handlers };}diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/sidePanelTabs.tsx b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/sidePanelTabs.tsxindex 8ce2c7893f..3aea6d949e 100644--- a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/sidePanelTabs.tsx+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/sidePanelTabs.tsx@@ -1,10 +1,11 @@import type { ReactNode } from "react";-import { Bot, Building2, FileDiff, FolderTree, GitBranch, type LucideIcon } from "lucide-react";+import { Bot, Building2, FileDiff, FolderTree, GitBranch, Library, type LucideIcon } from "lucide-react";import type { SidePanelTabId } from "@/store/ideSidePanel";import { AgentsOverview } from "./AgentsOverview";import { ExplorerPanel } from "./explorer/ExplorerPanel";import { GitOverviewTab } from "./git/GitOverviewTab";import { OfficeTab } from "./OfficeTab";+import { SkillsTab } from "./skills/SkillsTab";/** One function the side panel can show. */export interface SidePanelTabDef {@@ -47,6 +48,12 @@ export const SIDE_PANEL_TABS: readonly SidePanelTabDef[] = [icon: GitBranch,render: () => <GitOverviewTab />,},+ {+ id: "skills",+ labelKey: "ide_side_panel.tabs.skills",+ icon: Library,+ render: () => <SkillsTab />,+ },{id: "office",labelKey: "ide_side_panel.tabs.office",diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/SkillCard.tsx b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/SkillCard.tsxnew file mode 100644index 0000000000..79591a07fc--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/SkillCard.tsx@@ -0,0 +1,281 @@+import { memo, useEffect, useRef, useState, type DragEvent, type KeyboardEvent } from "react";+import {+ AlignLeft,+ Check,+ Copy,+ CopyPlus,+ CornerDownLeft,+ Download,+ Eye,+ GripVertical,+ Hash,+ MoreHorizontal,+ Pencil,+ Repeat2,+ Trash2,+} from "lucide-react";+import { fill, useT } from "@/i18n";+import { cn } from "@/lib/utils";+import type { IdeSkill } from "@/lib/ideSkillsApi";+import { useIdeSkillsStore } from "@/store/ideSkills";+import { SKILL_DRAG_TYPE, loadSkillDrag } from "@/components/agentic/skillDrag";+import { SkillMenu, type SkillMenuItem } from "./SkillMenu";+import { SkillSeal, approxTokens, compactCount, lineCount, skillStyle } from "./skillVisuals";++/** How long a card shows where it just landed. */+const LANDED_MS = 2_600;++export type DropSide = "before" | "after" | null;++interface SkillCardProps {+ skill: IdeSkill;+ /** The pane "Paste into …" goes to; null when no pane is selected. */+ targetPane: string | null;+ /** Manual order: the card can be dragged within the list. */+ reorderable: boolean;+ /** Where a card carried over this one would land, for the insertion line. */+ dropSide: DropSide;+ onPaste: (skill: IdeSkill) => void;+ onOpen: (skill: IdeSkill, mode: "preview" | "edit") => void;+ onDuplicate: (skill: IdeSkill) => void;+ onDelete: (skill: IdeSkill) => void;+ onCopy: (skill: IdeSkill) => void;+ onExport: (skill: IdeSkill) => void;+ onReorderOver: (skill: IdeSkill, side: DropSide) => void;+ onReorderDrop: (skill: IdeSkill) => void;+}++/**+ * One skill in the library: a card the user picks up and drops on a terminal.+ *+ * The whole card is the handle. While it is carried it fades in place, the+ * cursor carries a compact chip of it (`ghost`), and every pane it passes+ * over announces it by name. After a landing the card says where it went.+ */+export const SkillCard = memo(function SkillCard({+ skill,+ targetPane,+ reorderable,+ dropSide,+ onPaste,+ onOpen,+ onDuplicate,+ onDelete,+ onCopy,+ onExport,+ onReorderOver,+ onReorderDrop,+}: SkillCardProps) {+ const t = useT();+ const setDragging = useIdeSkillsStore((state) => state.setDragging);+ const landing = useIdeSkillsStore((state) => (state.landing?.skillId === skill.id ? state.landing : null));+ const [carried, setCarried] = useState(false);+ const [menuOpen, setMenuOpen] = useState(false);+ const [confirmDelete, setConfirmDelete] = useState(false);+ const [landed, setLanded] = useState<string | null>(null);+ const ghost = useRef<HTMLDivElement>(null);+ const menuButton = useRef<HTMLButtonElement>(null);++ useEffect(() => {+ if (!landing || Date.now() - landing.at > LANDED_MS) return;+ setLanded(landing.pane);+ const timer = window.setTimeout(() => setLanded(null), LANDED_MS);+ return () => window.clearTimeout(timer);+ }, [landing]);++ const lines = lineCount(skill.content);+ const tokens = approxTokens(skill.content);++ const startDrag = (event: DragEvent<HTMLDivElement>) => {+ loadSkillDrag(event.dataTransfer, { id: skill.id, title: skill.title, content: skill.content, hue: skill.hue });+ if (ghost.current) event.dataTransfer.setDragImage(ghost.current, 22, 22);+ const multiline = skill.content.includes("\n");+ setDragging({ id: skill.id, title: skill.title, hue: skill.hue, icon: skill.icon, multiline });+ setCarried(true);+ };+ const endDrag = () => {+ setDragging(null);+ setCarried(false);+ };++ // A card carried over another card of the same list: an insertion line, then a move.+ const overCard = (event: DragEvent<HTMLDivElement>) => {+ if (!reorderable || !Array.from(event.dataTransfer.types).includes(SKILL_DRAG_TYPE)) return;+ event.preventDefault();+ event.dataTransfer.dropEffect = "move";+ const box = event.currentTarget.getBoundingClientRect();+ onReorderOver(skill, event.clientY < box.top + box.height / 2 ? "before" : "after");+ };++ const onKey = (event: KeyboardEvent<HTMLDivElement>) => {+ if (event.target !== event.currentTarget) return;+ if (event.key === "Enter" && targetPane) {+ event.preventDefault();+ onPaste(skill);+ } else if (event.key === " ") {+ event.preventDefault();+ onOpen(skill, "preview");+ } else if (event.key === "F2" || event.key.toLowerCase() === "e") {+ event.preventDefault();+ onOpen(skill, "edit");+ }+ };++ const items: SkillMenuItem[] = [+ { id: "preview", label: t("ide_side_panel.skills.action_preview"), icon: Eye, onSelect: () => onOpen(skill, "preview"), hint: t("ide_side_panel.skills.key_space") },+ { id: "edit", label: t("ide_side_panel.skills.action_edit"), icon: Pencil, onSelect: () => onOpen(skill, "edit"), hint: "E" },+ { id: "duplicate", label: t("ide_side_panel.skills.action_duplicate"), icon: CopyPlus, onSelect: () => onDuplicate(skill) },+ { id: "copy", label: t("ide_side_panel.skills.action_copy"), icon: Copy, onSelect: () => onCopy(skill) },+ { id: "export", label: t("ide_side_panel.skills.action_export"), icon: Download, onSelect: () => onExport(skill) },+ confirmDelete+ ? { id: "delete-confirm", label: t("ide_side_panel.skills.action_delete_confirm"), icon: Trash2, tone: "danger", onSelect: () => onDelete(skill) }+ : { id: "delete", label: t("ide_side_panel.skills.action_delete"), icon: Trash2, tone: "danger", keepOpen: true, onSelect: () => setConfirmDelete(true) },+ ];++ return (+ <div+ role="listitem"+ className="relative"+ onDragOver={overCard}+ onDrop={(event) => {+ if (!reorderable || !Array.from(event.dataTransfer.types).includes(SKILL_DRAG_TYPE)) return;+ event.preventDefault();+ onReorderDrop(skill);+ }}+ >+ {dropSide && (+ <span+ aria-hidden+ className={cn(+ "pointer-events-none absolute inset-x-2 z-10 h-0.5 rounded-full bg-accent",+ dropSide === "before" ? "-top-[5px]" : "-bottom-[5px]",+ )}+ />+ )}+ <div+ data-testid={`skill-card-${skill.id}`}+ tabIndex={0}+ draggable+ onDragStart={startDrag}+ onDragEnd={endDrag}+ onKeyDown={onKey}+ onDoubleClick={() => onOpen(skill, "preview")}+ aria-label={fill(t("ide_side_panel.skills.card_aria"), { title: skill.title })}+ aria-describedby={`skill-${skill.id}-desc`}+ style={skillStyle(skill.hue)}+ className={cn(+ "group/skill relative flex cursor-grab select-none gap-3 overflow-hidden rounded-xl border bg-card/70 p-3 pl-2.5 outline-none",+ "transition-[border-color,box-shadow,opacity,transform] duration-200 ease-out motion-reduce:transition-none",+ "hover:border-[hsl(var(--skill)/0.45)] hover:shadow-[0_8px_24px_-16px_hsl(var(--skill)/0.55)]",+ "focus-visible:border-[hsl(var(--skill)/0.6)] focus-visible:ring-2 focus-visible:ring-ring",+ "active:cursor-grabbing",+ landed ? "border-[hsl(var(--skill)/0.7)] shadow-[0_0_0_3px_hsl(var(--skill)/0.18)]" : "border-border",+ carried && "scale-[0.98] opacity-40",+ )}+ >+ {/* The hue's light, rising from the seal's corner on hover. */}+ <span+ aria-hidden+ className="pointer-events-none absolute -left-10 -top-12 h-40 w-40 rounded-full bg-[radial-gradient(closest-side,hsl(var(--skill)/0.16),transparent)] opacity-60 transition-opacity duration-300 group-hover/skill:opacity-100"+ />+ {/* The spine: a thin line of the hue down the leading edge. */}+ <span+ aria-hidden+ className="pointer-events-none absolute inset-y-3 left-0 w-[3px] rounded-r-full bg-[hsl(var(--skill))] opacity-0 transition-opacity duration-200 group-hover/skill:opacity-90 group-focus-visible/skill:opacity-90"+ />+ <GripVertical+ aria-hidden+ className="relative mt-2.5 h-4 w-4 shrink-0 text-muted-foreground/40 transition-colors group-hover/skill:text-muted-foreground"+ />+ <SkillSeal hue={skill.hue} icon={skill.icon} title={skill.title} description={skill.description} className="relative mt-0.5" />+ <div className="relative min-w-0 flex-1">+ {/* Only the title row leaves room for the two actions at the right. */}+ <button+ type="button"+ onClick={() => onOpen(skill, "preview")}+ className="block max-w-[calc(100%-56px)] truncate text-left text-sm font-semibold text-foreground-strong outline-none hover:underline hover:decoration-[hsl(var(--skill)/0.6)] hover:underline-offset-4"+ >+ {skill.title}+ </button>+ <p id={`skill-${skill.id}-desc`} className="mt-0.5 line-clamp-2 text-xs leading-5 text-muted-foreground">+ {skill.description || t("ide_side_panel.skills.no_description")}+ </p>+ <div className="mt-2 flex h-5 items-center gap-2.5 text-xs text-muted-foreground">+ {landed ? (+ <span data-testid={`skill-landed-${skill.id}`} className="flex min-w-0 items-center gap-1 font-medium text-[hsl(var(--skill))] animate-in fade-in-0 slide-in-from-bottom-1 duration-200">+ <Check className="h-3.5 w-3.5 shrink-0" aria-hidden />+ <span className="truncate">{fill(t("ide_side_panel.skills.landed"), { pane: landed })}</span>+ </span>+ ) : (+ <>+ <span className="flex items-center gap-1 tabular-nums" title={t("ide_side_panel.skills.meta_lines")}>+ <AlignLeft className="h-3 w-3" aria-hidden />+ {compactCount(lines)}+ </span>+ <span className="flex items-center gap-1 tabular-nums" title={t("ide_side_panel.skills.meta_tokens")}>+ <Hash className="h-3 w-3" aria-hidden />+ {fill(t("ide_side_panel.skills.tokens_short"), { n: compactCount(tokens) })}+ </span>+ {skill.use_count > 0 && (+ <span className="flex items-center gap-1 tabular-nums" title={t("ide_side_panel.skills.meta_used")}>+ <Repeat2 className="h-3 w-3" aria-hidden />+ {fill(t("ide_side_panel.skills.used_short"), { n: compactCount(skill.use_count) })}+ </span>+ )}+ </>+ )}+ </div>+ </div>+ {/* Actions sit in reserved room at the right, so showing them moves nothing. */}+ <div className="absolute right-2 top-2 flex items-center gap-0.5 opacity-0 transition-opacity duration-150 group-hover/skill:opacity-100 group-focus-within/skill:opacity-100 [@media(hover:none)]:opacity-100">+ <button+ type="button"+ data-testid={`skill-paste-${skill.id}`}+ disabled={!targetPane}+ onClick={() => onPaste(skill)}+ title={targetPane ? fill(t("ide_side_panel.skills.paste_into"), { pane: targetPane }) : t("ide_side_panel.skills.paste_no_target")}+ aria-label={targetPane ? fill(t("ide_side_panel.skills.paste_into"), { pane: targetPane }) : t("ide_side_panel.skills.paste_no_target")}+ className="inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-[hsl(var(--skill)/0.14)] hover:text-[hsl(var(--skill))] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-40 disabled:hover:bg-transparent disabled:hover:text-muted-foreground"+ >+ <CornerDownLeft className="h-4 w-4" aria-hidden />+ </button>+ <button+ ref={menuButton}+ type="button"+ data-testid={`skill-more-${skill.id}`}+ aria-haspopup="menu"+ aria-expanded={menuOpen}+ aria-label={fill(t("ide_side_panel.skills.more"), { title: skill.title })}+ title={t("ide_side_panel.skills.more_short")}+ onClick={() => { setConfirmDelete(false); setMenuOpen((value) => !value); }}+ className="inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"+ >+ <MoreHorizontal className="h-4 w-4" aria-hidden />+ </button>+ </div>+ </div>+ <SkillMenu+ anchor={menuButton}+ open={menuOpen}+ onClose={() => { setMenuOpen(false); setConfirmDelete(false); }}+ items={items}+ label={fill(t("ide_side_panel.skills.more"), { title: skill.title })}+ />+ {/* The chip the cursor carries. Rendered off-screen (a drag image must be+ laid out to be captured), themed like everything else. */}+ <div aria-hidden className="pointer-events-none fixed -left-[9999px] -top-[9999px]">+ <div+ ref={ghost}+ style={skillStyle(skill.hue)}+ className="flex max-w-[260px] items-center gap-2.5 rounded-xl border border-[hsl(var(--skill)/0.45)] bg-popover py-2 pl-2 pr-3.5 text-foreground"+ >+ <SkillSeal hue={skill.hue} icon={skill.icon} title={skill.title} description={skill.description} size="sm" />+ <span className="min-w-0">+ <span className="block truncate text-sm font-semibold">{skill.title}</span>+ <span className="block text-xs text-muted-foreground">{fill(t("ide_side_panel.skills.ghost_meta"), { lines: compactCount(lines) })}</span>+ </span>+ </div>+ </div>+ </div>+ );+});diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/SkillDropCard.tsx b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/SkillDropCard.tsxnew file mode 100644index 0000000000..7ab9c4c5d3--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/SkillDropCard.tsx@@ -0,0 +1,57 @@+import { CornerDownLeft, OctagonAlert } from "lucide-react";+import { fill, useT } from "@/i18n";+import type { SkillInFlight } from "@/store/ideSkills";+import { SkillSeal, skillStyle } from "./skillVisuals";++/**+ * What a terminal pane shows while a skill hovers over it.+ *+ * The pane dims, a glow of the skill's own hue rises in its middle and a+ * dashed landing frame says "here": the user sees WHICH skill lands in WHICH+ * pane before letting go. The drag itself is still sealed at this point, so+ * the skill's name comes from the store the card filled on drag start; a drag+ * from another window has none and gets the plain wording.+ *+ * `blocked`: the pane is a plain shell without bracketed paste and the skill+ * spans lines — it would run line by line, so the card says it will not land.+ */+export function SkillDropCard({ skill, target, blocked = false }: {+ skill: SkillInFlight | null;+ target: string;+ blocked?: boolean;+}) {+ const t = useT();+ const hue = skill?.hue ?? "blue";+ return (+ <div+ data-testid="pane-skill-drop"+ style={skillStyle(hue)}+ className="pointer-events-none absolute inset-0 z-40 flex items-center justify-center overflow-hidden bg-background/80 backdrop-blur-[3px] animate-in fade-in duration-150 motion-reduce:animate-none"+ >+ <div aria-hidden className="absolute left-1/2 top-1/2 h-[140%] w-[140%] -translate-x-1/2 -translate-y-1/2 bg-[radial-gradient(closest-side,hsl(var(--skill)/0.22),transparent)]" />+ <div aria-hidden className="absolute inset-3 rounded-xl border-2 border-dashed border-[hsl(var(--skill)/0.55)]" />+ <div className="relative mx-6 flex max-w-sm items-center gap-3.5 rounded-2xl border border-[hsl(var(--skill)/0.35)] bg-popover/95 px-4 py-3.5 shadow-float animate-in zoom-in-95 duration-200 motion-reduce:animate-none">+ <SkillSeal hue={hue} icon={skill?.icon ?? "auto"} title={skill?.title ?? ""} size="lg" />+ <div className="min-w-0">+ <p className="text-xs font-medium uppercase tracking-wider text-[hsl(var(--skill))]">+ {t("ide_side_panel.skills.drop_eyebrow")}+ </p>+ <p className="truncate font-display text-base text-foreground-strong">+ {skill?.title || t("ide_side_panel.skills.drop_unknown")}+ </p>+ {blocked ? (+ <p className="mt-0.5 flex items-start gap-1 text-xs text-warning">+ <OctagonAlert className="mt-0.5 h-3 w-3 shrink-0" aria-hidden />+ {fill(t("ide_side_panel.skills.drop_blocked"), { pane: target })}+ </p>+ ) : (+ <p className="mt-0.5 flex items-center gap-1 truncate text-xs text-muted-foreground">+ <CornerDownLeft className="h-3 w-3 shrink-0" aria-hidden />+ {fill(t("ide_side_panel.skills.drop_into"), { pane: target })}+ </p>+ )}+ </div>+ </div>+ </div>+ );+}diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/SkillEditor.tsx b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/SkillEditor.tsxnew file mode 100644index 0000000000..ac332399c2--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/SkillEditor.tsx@@ -0,0 +1,436 @@+import { useEffect, useMemo, useRef, useState, type DragEvent } from "react";+import { createPortal } from "react-dom";+import { ClipboardPaste, CornerDownLeft, FileUp, Loader2, Sparkles, X } from "lucide-react";+import { fill, useT } from "@/i18n";+import { cn } from "@/lib/utils";+import { robustPaste } from "@/lib/clipboard";+import ReactMarkdown from "react-markdown";+import remarkGfm from "remark-gfm";+import { SKILL_HUES, SKILL_ICONS, type IdeSkill, type IdeSkillDraft, type SkillHue, type SkillIcon } from "@/lib/ideSkillsApi";+import {+ SKILL_ICON,+ SkillSeal,+ approxTokens,+ compactCount,+ lineCount,+ skillIconFor,+ skillStyle,+ splitSkillFrontmatter,+} from "./skillVisuals";+import { MARKDOWN_ACCEPT, deriveSkillDescription, readMarkdownFile, suggestSkillTitle } from "./skillImport";++export type EditorMode = "write" | "preview" | "split";++export interface SkillEditorSeed {+ /** The skill being edited; absent for a new one. */+ skill?: IdeSkill;+ /** Prefill for a new one (a pasted text, an imported file). */+ draft?: Partial<IdeSkillDraft>;+ mode?: EditorMode;+}++/**+ * Writing, pasting or importing a skill — and reading one at full size.+ *+ * A dialog over the whole IDE rather than a form inside the side panel: a+ * Markdown prompt wants room, and the panel can be as narrow as 260 px. The+ * seal in the header is the card's own and follows every change, so the+ * colour and glyph are chosen by looking at the result. Ctrl+Enter saves;+ * a Markdown file dropped anywhere on the dialog replaces the text.+ */+export function SkillEditor({ seed, onClose, onSave, onPaste, targetPane }: {+ seed: SkillEditorSeed;+ onClose: () => void;+ onSave: (draft: IdeSkillDraft, id?: string) => Promise<void>;+ /** Paste the skill as it is saved into the selected pane. */+ onPaste?: (skill: IdeSkill) => void;+ targetPane: string | null;+}) {+ const t = useT();+ const editing = seed.skill;+ const [title, setTitle] = useState(editing?.title ?? seed.draft?.title ?? "");+ const [content, setContent] = useState(editing?.content ?? seed.draft?.content ?? "");+ // A summary the library derived stays empty here, so it follows the text;+ // only one the user wrote themselves shows as their own.+ const [description, setDescription] = useState(() =>+ editing+ ? editing.description === deriveSkillDescription(editing.content) ? "" : editing.description+ : seed.draft?.description ?? "",+ );+ const [hue, setHue] = useState<SkillHue>(editing?.hue ?? seed.draft?.hue ?? SKILL_HUES[Math.floor(Math.random() * SKILL_HUES.length)]);+ const [icon, setIcon] = useState<SkillIcon>(editing?.icon ?? seed.draft?.icon ?? "auto");+ const [mode, setMode] = useState<EditorMode>(seed.mode ?? (editing ? "preview" : "write"));+ const [saving, setSaving] = useState(false);+ const [error, setError] = useState<string | null>(null);+ const [confirmDiscard, setConfirmDiscard] = useState(false);+ const [fileOver, setFileOver] = useState(false);+ const fileInput = useRef<HTMLInputElement>(null);+ const textArea = useRef<HTMLTextAreaElement>(null);+ const titleInput = useRef<HTMLInputElement>(null);+ const dialog = useRef<HTMLElement>(null);++ const suggested = useMemo(() => suggestSkillTitle(content), [content]);+ const { fields, body } = useMemo(() => splitSkillFrontmatter(content), [content]);+ const derivedDescription = useMemo(() => deriveSkillDescription(content), [content]);+ const effectiveTitle = title.trim() || suggested;+ const dirty =+ title !== (editing?.title ?? seed.draft?.title ?? "") ||+ content !== (editing?.content ?? seed.draft?.content ?? "") ||+ hue !== (editing?.hue ?? hue) ||+ icon !== (editing?.icon ?? seed.draft?.icon ?? "auto");+ const canSave = Boolean(effectiveTitle && content.trim()) && !saving;++ useEffect(() => {+ // A new skill starts in the text; an existing one opens to be read.+ const frame = requestAnimationFrame(() => {+ if (mode !== "preview") textArea.current?.focus();+ else dialog.current?.focus();+ });+ return () => cancelAnimationFrame(frame);+ // Only on open: later mode switches keep focus where the user put it.+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, []);++ const close = () => {+ if (dirty && !confirmDiscard) {+ setConfirmDiscard(true);+ return;+ }+ onClose();+ };++ const save = async (alsoPaste = false) => {+ if (!canSave) return;+ setSaving(true);+ setError(null);+ try {+ await onSave(+ {+ title: effectiveTitle,+ content,+ // Empty means "derive it": the backend reads the text again.+ description: description.trim() || undefined,+ hue,+ icon,+ },+ editing?.id,+ );+ if (alsoPaste && editing && onPaste) onPaste({ ...editing, title: effectiveTitle, content, hue, icon });+ onClose();+ } catch (failure) {+ setError(failure instanceof Error ? failure.message : String(failure));+ setSaving(false);+ }+ };++ const takeText = (text: string, filename = "") => {+ setContent(text.replace(/\r\n?/g, "\n"));+ if (!title.trim()) setTitle(suggestSkillTitle(text, filename));+ setConfirmDiscard(false);+ };++ const importFile = async (file: File | undefined) => {+ if (!file) return;+ try {+ takeText(await readMarkdownFile(file), file.name);+ } catch (failure) {+ setError(failure instanceof Error ? failure.message : String(failure));+ }+ };++ const pasteClipboard = async () => {+ const text = await robustPaste();+ if (text) takeText(text);+ else setError(t("ide_side_panel.skills.clipboard_empty"));+ };++ const dropFile = (event: DragEvent<HTMLElement>) => {+ if (!Array.from(event.dataTransfer.types).includes("Files")) return;+ event.preventDefault();+ setFileOver(false);+ void importFile(event.dataTransfer.files?.[0]);+ };++ const words = content.trim() ? content.trim().split(/\s+/).length : 0;+ const AutoIcon = skillIconFor("auto", effectiveTitle, description || derivedDescription);++ return createPortal(+ <div+ className="fixed inset-0 z-[90] flex items-center justify-center bg-background/70 p-3 backdrop-blur-sm animate-in fade-in-0 duration-150 motion-reduce:animate-none sm:p-6"+ role="presentation"+ onMouseDown={(event) => { if (event.target === event.currentTarget) close(); }}+ >+ <section+ ref={dialog}+ tabIndex={-1}+ role="dialog"+ aria-modal="true"+ aria-label={editing ? fill(t("ide_side_panel.skills.editor_edit_aria"), { title: editing.title }) : t("ide_side_panel.skills.editor_new_aria")}+ data-testid="skill-editor"+ data-ide-dialog+ style={skillStyle(hue)}+ onKeyDown={(event) => {+ if (event.key === "Escape") {+ event.stopPropagation();+ close();+ } else if (event.key === "Enter" && (event.ctrlKey || event.metaKey)) {+ event.preventDefault();+ void save(event.shiftKey);+ }+ }}+ onDragOver={(event) => {+ if (!Array.from(event.dataTransfer.types).includes("Files")) return;+ event.preventDefault();+ event.dataTransfer.dropEffect = "copy";+ setFileOver(true);+ }}+ onDragLeave={(event) => { if (event.currentTarget === event.target) setFileOver(false); }}+ onDrop={dropFile}+ className="relative flex h-[min(820px,100%)] w-full max-w-5xl flex-col overflow-hidden rounded-2xl border border-border-strong bg-card shadow-float outline-none animate-in zoom-in-[0.98] duration-200 motion-reduce:animate-none"+ >+ {/* The hue's light across the top edge: the dialog wears the skill. */}+ <div aria-hidden className="pointer-events-none absolute inset-x-0 top-0 h-40 bg-[radial-gradient(120%_100%_at_0%_0%,hsl(var(--skill)/0.16),transparent_60%)]" />+ <div aria-hidden className="pointer-events-none absolute inset-x-0 top-0 h-px bg-[linear-gradient(90deg,transparent,hsl(var(--skill)/0.7),transparent)]" />++ <header className="relative flex items-start gap-4 px-5 pb-4 pt-5">+ <SkillSeal hue={hue} icon={icon} title={effectiveTitle} description={description || derivedDescription} size="lg" />+ <div className="min-w-0 flex-1">+ <label htmlFor="skill-title" className="text-xs font-medium uppercase tracking-wider text-[hsl(var(--skill))]">+ {editing ? t("ide_side_panel.skills.editor_eyebrow_edit") : t("ide_side_panel.skills.editor_eyebrow_new")}+ </label>+ <input+ id="skill-title"+ ref={titleInput}+ data-testid="skill-editor-title"+ value={title}+ maxLength={120}+ onChange={(event) => { setTitle(event.target.value); setConfirmDiscard(false); }}+ placeholder={suggested || t("ide_side_panel.skills.title_placeholder")}+ className="mt-0.5 w-full bg-transparent font-display text-xl text-foreground-strong outline-none placeholder:text-foreground-faint"+ />+ <input+ aria-label={t("ide_side_panel.skills.description_label")}+ value={description}+ maxLength={280}+ onChange={(event) => setDescription(event.target.value)}+ placeholder={derivedDescription || t("ide_side_panel.skills.description_placeholder")}+ className="mt-1 w-full bg-transparent text-sm text-foreground-secondary outline-none placeholder:text-foreground-faint"+ />+ </div>+ <button+ type="button"+ aria-label={t("ide_side_panel.skills.close")}+ onClick={close}+ className="inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"+ >+ <X className="h-4 w-4" aria-hidden />+ </button>+ </header>++ {/* Look: colour and glyph, picked by watching the seal above. */}+ <div className="relative flex flex-wrap items-center gap-x-6 gap-y-3 border-y border-border/70 bg-background/30 px-5 py-2.5">+ <div role="radiogroup" aria-label={t("ide_side_panel.skills.colour_label")} className="flex items-center gap-1.5">+ <span className="mr-1 text-xs text-muted-foreground">{t("ide_side_panel.skills.colour_label")}</span>+ {SKILL_HUES.map((entry) => (+ <button+ key={entry}+ type="button"+ role="radio"+ aria-checked={hue === entry}+ aria-label={t(`ide_side_panel.skills.hue.${entry}`)}+ title={t(`ide_side_panel.skills.hue.${entry}`)}+ onClick={() => setHue(entry)}+ style={skillStyle(entry)}+ className={cn(+ "h-5 w-5 rounded-full bg-[hsl(var(--skill))] transition-transform focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",+ hue === entry ? "scale-110 ring-2 ring-[hsl(var(--skill)/0.45)] ring-offset-2 ring-offset-card" : "opacity-70 hover:scale-110 hover:opacity-100",+ )}+ />+ ))}+ </div>+ <div role="radiogroup" aria-label={t("ide_side_panel.skills.icon_label")} className="flex flex-wrap items-center gap-0.5">+ <span className="mr-1.5 text-xs text-muted-foreground">{t("ide_side_panel.skills.icon_label")}</span>+ {SKILL_ICONS.map((entry) => {+ const Glyph = entry === "auto" ? AutoIcon : SKILL_ICON[entry];+ const selected = icon === entry;+ return (+ <button+ key={entry}+ type="button"+ role="radio"+ aria-checked={selected}+ aria-label={t(`ide_side_panel.skills.icon.${entry}`)}+ title={t(`ide_side_panel.skills.icon.${entry}`)}+ onClick={() => setIcon(entry)}+ className={cn(+ "relative inline-flex h-7 w-7 items-center justify-center rounded-md transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",+ selected ? "bg-[hsl(var(--skill)/0.16)] text-[hsl(var(--skill))]" : "text-muted-foreground hover:bg-secondary hover:text-foreground",+ )}+ >+ <Glyph className="h-4 w-4" aria-hidden />+ {entry === "auto" && <Sparkles className="absolute -right-0.5 -top-0.5 h-2.5 w-2.5 text-[hsl(var(--skill))]" aria-hidden />}+ </button>+ );+ })}+ </div>+ </div>++ {/* Write / Preview / Side by side, plus the two ways text arrives. */}+ <div className="relative flex items-center gap-1 px-5">+ <div role="tablist" aria-label={t("ide_side_panel.skills.view_label")} className="flex items-center gap-4">+ {(["write", "preview", "split"] as const).map((entry) => (+ <button+ key={entry}+ type="button"+ role="tab"+ aria-selected={mode === entry}+ data-testid={`skill-editor-mode-${entry}`}+ onClick={() => setMode(entry)}+ className={cn(+ "relative py-2.5 text-sm transition-colors focus-visible:outline-none",+ entry === "split" && "hidden md:block",+ mode === entry ? "font-medium text-foreground" : "text-muted-foreground hover:text-foreground",+ )}+ >+ {t(`ide_side_panel.skills.view_${entry}`)}+ {mode === entry && <span aria-hidden className="absolute inset-x-0 -bottom-px h-0.5 rounded-full bg-[hsl(var(--skill))]" />}+ </button>+ ))}+ </div>+ <div className="ml-auto flex items-center gap-1">+ <button+ type="button"+ onClick={() => void pasteClipboard()}+ className="inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-sm text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"+ >+ <ClipboardPaste className="h-4 w-4" aria-hidden />+ <span className="hidden sm:inline">{t("ide_side_panel.skills.paste_clipboard")}</span>+ </button>+ <button+ type="button"+ onClick={() => fileInput.current?.click()}+ className="inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-sm text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"+ >+ <FileUp className="h-4 w-4" aria-hidden />+ <span className="hidden sm:inline">{t("ide_side_panel.skills.import_file")}</span>+ </button>+ <input+ ref={fileInput}+ type="file"+ accept={MARKDOWN_ACCEPT}+ className="hidden"+ onChange={(event) => { void importFile(event.target.files?.[0]); event.target.value = ""; }}+ />+ </div>+ </div>++ <div className={cn("relative grid min-h-0 flex-1 border-t border-border/70", mode === "split" ? "md:grid-cols-2" : "grid-cols-1")}>+ {mode !== "preview" && (+ <div className={cn("relative min-h-0", mode === "split" && "md:border-r md:border-border/70")}>+ <textarea+ ref={textArea}+ data-testid="skill-editor-content"+ value={content}+ spellCheck={false}+ onChange={(event) => { setContent(event.target.value); setConfirmDiscard(false); }}+ onPaste={(event) => {+ // A fresh skill takes its title from the first paste.+ if (title.trim() || content.trim()) return;+ const text = event.clipboardData.getData("text/plain");+ if (text) setTitle(suggestSkillTitle(text));+ }}+ placeholder={t("ide_side_panel.skills.content_placeholder")}+ className="h-full w-full resize-none bg-transparent px-5 py-4 font-mono text-sm leading-6 text-foreground outline-none placeholder:text-foreground-faint"+ />+ </div>+ )}+ {mode !== "write" && (+ <div className="min-h-0 overflow-y-auto px-6 py-5" data-testid="skill-editor-preview">+ {fields.length > 0 && (+ <dl className="mb-4 flex flex-wrap gap-1.5">+ {fields.map(([key, value]) => (+ <div key={key} className="flex max-w-full items-center gap-1.5 rounded-md border border-border bg-background/40 px-2 py-0.5 text-xs">+ <dt className="font-mono text-[hsl(var(--skill))]">{key}</dt>+ <dd className="truncate text-muted-foreground">{value}</dd>+ </div>+ ))}+ </dl>+ )}+ {body.trim() ? (+ <div className="prose prose-sm prose-neutral max-w-none text-foreground dark:prose-invert prose-headings:font-display prose-headings:tracking-tight prose-h1:text-xl prose-h2:text-base prose-a:text-accent prose-code:text-foreground prose-code:before:content-none prose-code:after:content-none prose-pre:border prose-pre:border-border prose-pre:bg-background/60 prose-li:my-0.5 prose-strong:text-foreground-strong [overflow-wrap:anywhere]">+ {/* Links stay text here: a preview is read, never navigated away from. */}+ <ReactMarkdown remarkPlugins={[remarkGfm]} components={{ a: ({ children }) => <span className="text-accent underline underline-offset-2">{children}</span> }}>+ {body}+ </ReactMarkdown>+ </div>+ ) : (+ <p className="text-sm text-muted-foreground">{t("ide_side_panel.skills.preview_empty")}</p>+ )}+ </div>+ )}+ </div>++ <footer className="relative flex flex-wrap items-center gap-3 border-t border-border/70 bg-background/30 px-5 py-3">+ <p className="flex items-center gap-3 text-xs tabular-nums text-muted-foreground">+ <span>{fill(t("ide_side_panel.skills.stat_lines"), { n: compactCount(lineCount(content)) })}</span>+ <span aria-hidden className="h-3 w-px bg-border" />+ <span>{fill(t("ide_side_panel.skills.stat_words"), { n: compactCount(words) })}</span>+ <span aria-hidden className="h-3 w-px bg-border" />+ <span>{fill(t("ide_side_panel.skills.stat_tokens"), { n: compactCount(content ? approxTokens(content) : 0) })}</span>+ </p>+ <div className="ml-auto flex items-center gap-2">+ {error && <p role="alert" className="max-w-xs truncate text-xs text-destructive" title={error}>{error}</p>}+ {confirmDiscard ? (+ <>+ <span className="text-xs text-muted-foreground">{t("ide_side_panel.skills.discard_question")}</span>+ <button type="button" onClick={onClose} className="h-8 rounded-md px-3 text-sm text-destructive transition-colors hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">+ {t("ide_side_panel.skills.discard_yes")}+ </button>+ <button type="button" onClick={() => setConfirmDiscard(false)} className="h-8 rounded-md px-3 text-sm text-foreground transition-colors hover:bg-secondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">+ {t("ide_side_panel.skills.discard_keep")}+ </button>+ </>+ ) : (+ <button type="button" onClick={close} className="h-8 rounded-md px-3 text-sm text-foreground transition-colors hover:bg-secondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">+ {t("ide_side_panel.skills.cancel")}+ </button>+ )}+ {editing && onPaste && targetPane && (+ <button+ type="button"+ disabled={!canSave}+ onClick={() => void save(true)}+ title={`${fill(t("ide_side_panel.skills.save_and_paste"), { pane: targetPane })} (Ctrl+Shift+Enter)`}+ className="hidden h-8 items-center gap-1.5 rounded-md border border-border-strong px-3 text-sm text-foreground transition-colors hover:bg-secondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-40 sm:inline-flex"+ >+ <CornerDownLeft className="h-3.5 w-3.5" aria-hidden />+ <span className="max-w-[12rem] truncate">{fill(t("ide_side_panel.skills.save_and_paste"), { pane: targetPane })}</span>+ </button>+ )}+ <button+ type="button"+ data-testid="skill-editor-save"+ disabled={!canSave}+ onClick={() => void save()}+ title="Ctrl+Enter"+ className="inline-flex h-8 items-center gap-1.5 rounded-md bg-[hsl(var(--skill))] px-3.5 text-sm font-medium text-background shadow-[0_6px_18px_-8px_hsl(var(--skill)/0.8)] transition-[filter,opacity] hover:brightness-110 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-card disabled:opacity-40 disabled:shadow-none"+ >+ {saving && <Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden />}+ {editing ? t("ide_side_panel.skills.save_changes") : t("ide_side_panel.skills.save_new")}+ </button>+ </div>+ </footer>++ {fileOver && (+ <div className="pointer-events-none absolute inset-2 z-10 flex items-center justify-center rounded-xl border-2 border-dashed border-[hsl(var(--skill)/0.6)] bg-card/90 animate-in fade-in-0 duration-100">+ <p className="flex items-center gap-2 text-sm font-medium text-foreground">+ <FileUp className="h-4 w-4 text-[hsl(var(--skill))]" aria-hidden />+ {t("ide_side_panel.skills.drop_file_editor")}+ </p>+ </div>+ )}+ </section>+ </div>,+ document.body,+ );+}diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/SkillMenu.tsx b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/SkillMenu.tsxnew file mode 100644index 0000000000..a6d98bcbdf--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/SkillMenu.tsx@@ -0,0 +1,121 @@+import { useEffect, useLayoutEffect, useRef, useState, type ReactNode, type RefObject } from "react";+import { createPortal } from "react-dom";+import type { LucideIcon } from "lucide-react";+import { cn } from "@/lib/utils";++export interface SkillMenuItem {+ id: string;+ label: string;+ icon: LucideIcon;+ onSelect: () => void;+ tone?: "danger";+ /** Shown at the right edge: a shortcut or a state. */+ hint?: ReactNode;+ /** Keep the menu open after this item (a two-step delete). */+ keepOpen?: boolean;+}++const WIDTH = 216;++/**+ * A small action menu anchored to a button, drawn in a portal.+ *+ * The skill list scrolls inside a clipped panel, so a menu positioned inside+ * it would be cut off at the panel's edge; drawn at the document root with+ * fixed coordinates it is never clipped, and it opens upward when there is+ * no room below.+ */+export function SkillMenu({ anchor, open, onClose, items, label }: {+ anchor: RefObject<HTMLElement | null>;+ open: boolean;+ onClose: () => void;+ items: SkillMenuItem[];+ label: string;+}) {+ const menu = useRef<HTMLDivElement>(null);+ const [place, setPlace] = useState<{ top: number; left: number } | null>(null);++ useLayoutEffect(() => {+ if (!open || !anchor.current) {+ setPlace(null);+ return;+ }+ const rect = anchor.current.getBoundingClientRect();+ const height = menu.current?.offsetHeight ?? items.length * 34 + 8;+ const below = rect.bottom + 6 + height <= window.innerHeight - 8;+ setPlace({+ top: below ? rect.bottom + 6 : Math.max(8, rect.top - 6 - height),+ left: Math.min(Math.max(8, rect.right - WIDTH), window.innerWidth - WIDTH - 8),+ });+ }, [open, anchor, items.length]);++ useEffect(() => {+ if (!open) return;+ const onPointer = (event: MouseEvent) => {+ const target = event.target as Node;+ if (menu.current?.contains(target) || anchor.current?.contains(target)) return;+ onClose();+ };+ const onKey = (event: KeyboardEvent) => {+ if (event.key === "Escape") {+ event.stopPropagation();+ onClose();+ }+ };+ const onScroll = () => onClose();+ document.addEventListener("mousedown", onPointer);+ document.addEventListener("keydown", onKey, true);+ window.addEventListener("resize", onScroll);+ return () => {+ document.removeEventListener("mousedown", onPointer);+ document.removeEventListener("keydown", onKey, true);+ window.removeEventListener("resize", onScroll);+ };+ }, [open, onClose, anchor]);++ useEffect(() => {+ if (open && place) menu.current?.querySelector<HTMLButtonElement>("button")?.focus();+ }, [open, place]);++ if (!open) return null;+ return createPortal(+ <div+ ref={menu}+ role="menu"+ aria-label={label}+ style={{ top: place?.top ?? -9999, left: place?.left ?? -9999, width: WIDTH }}+ className="fixed z-[95] rounded-xl border border-border bg-popover p-1 shadow-float animate-in fade-in-0 zoom-in-95 duration-100 motion-reduce:animate-none"+ onKeyDown={(event) => {+ if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return;+ event.preventDefault();+ const buttons = Array.from(menu.current?.querySelectorAll<HTMLButtonElement>("button") ?? []);+ const index = buttons.indexOf(document.activeElement as HTMLButtonElement);+ const next = buttons[(index + (event.key === "ArrowDown" ? 1 : -1) + buttons.length) % buttons.length];+ next?.focus();+ }}+ >+ {items.map((item) => (+ <button+ key={item.id}+ type="button"+ role="menuitem"+ data-testid={`skill-menu-${item.id}`}+ onClick={() => {+ item.onSelect();+ if (!item.keepOpen) onClose();+ }}+ className={cn(+ "flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-left text-sm outline-none transition-colors",+ "focus-visible:bg-secondary hover:bg-secondary",+ item.tone === "danger" ? "text-destructive" : "text-foreground",+ )}+ >+ <item.icon className={cn("h-4 w-4 shrink-0", item.tone === "danger" ? "text-destructive" : "text-muted-foreground")} aria-hidden />+ <span className="min-w-0 flex-1 truncate">{item.label}</span>+ {item.hint && <span className="shrink-0 text-xs text-muted-foreground">{item.hint}</span>}+ </button>+ ))}+ </div>,+ document.body,+ );+}diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/SkillsHero.tsx b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/SkillsHero.tsxnew file mode 100644index 0000000000..b93d75355c--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/SkillsHero.tsx@@ -0,0 +1,140 @@+import { ClipboardPaste, FileUp, Plus, Sparkles } from "lucide-react";+import { useT } from "@/i18n";+import { SkillSeal, skillStyle } from "./skillVisuals";++/*+ * The motion for the empty library's picture, scoped by class names nobody+ * else uses. Kept beside the picture rather than in the global stylesheet:+ * nothing outside this one illustration moves this way.+ */+const HERO_CSS = `+@keyframes jarvis-skill-float { 0%,100% { transform: translateY(0) rotate(var(--tilt)); } 50% { transform: translateY(-5px) rotate(var(--tilt)); } }+@keyframes jarvis-skill-dash { to { stroke-dashoffset: -24; } }+@keyframes jarvis-skill-caret { 0%,49% { opacity: 1; } 50%,100% { opacity: 0; } }+@keyframes jarvis-skill-fly { 0% { transform: translate(0,0) rotate(-6deg); opacity: 0; } 12% { opacity: 1; } 70% { transform: translate(108px,60px) rotate(0deg); opacity: 1; } 85%,100% { transform: translate(112px,66px) scale(.6); opacity: 0; } }+.jarvis-skill-float { animation: jarvis-skill-float 5.5s ease-in-out infinite; }+.jarvis-skill-dash { animation: jarvis-skill-dash 1.4s linear infinite; }+.jarvis-skill-caret { animation: jarvis-skill-caret 1.1s steps(1) infinite; }+.jarvis-skill-fly { animation: jarvis-skill-fly 4.2s cubic-bezier(.45,.05,.3,1) infinite; animation-delay: .8s; opacity: 0; }+@media (prefers-reduced-motion: reduce) {+ .jarvis-skill-float, .jarvis-skill-dash, .jarvis-skill-caret { animation: none; }+ .jarvis-skill-fly { display: none; }+}+`;++const FAN = [+ { hue: "violet", icon: "brain", tilt: "-6deg", x: 0, y: 2, delay: "0s", title: "Plan" },+ { hue: "amber", icon: "shield", tilt: "-1deg", x: 14, y: 38, delay: "-1.8s", title: "Review" },+ { hue: "rose", icon: "bug", tilt: "5deg", x: 28, y: 74, delay: "-3.6s", title: "Fix" },+] as const;++function MiniCard({ hue, icon, title }: { hue: string; icon: string; title: string }) {+ return (+ <div style={skillStyle(hue)} className="flex w-[118px] items-center gap-2 rounded-lg border border-[hsl(var(--skill)/0.4)] bg-card p-1.5 shadow-[0_10px_24px_-14px_hsl(var(--skill)/0.7)]">+ <SkillSeal hue={hue} icon={icon} title={title} size="sm" />+ <div className="min-w-0 flex-1 space-y-1">+ <div className="h-1.5 w-4/5 rounded-full bg-foreground/25" />+ <div className="h-1.5 w-3/5 rounded-full bg-[hsl(var(--skill)/0.35)]" />+ </div>+ </div>+ );+}++/** The picture: three skills fanned out, one flying into a terminal prompt. */+function HeroPicture() {+ return (+ <div aria-hidden className="relative mx-auto h-[150px] w-[268px]">+ <style>{HERO_CSS}</style>+ <div className="absolute inset-0 rounded-[28px] bg-[radial-gradient(60%_70%_at_30%_30%,hsl(var(--accent)/0.12),transparent_70%)]" />+ {FAN.map((card) => (+ <div+ key={card.title}+ className="jarvis-skill-float absolute"+ style={{ left: card.x, top: card.y, ["--tilt" as string]: card.tilt, transform: `rotate(${card.tilt})`, animationDelay: card.delay }}+ >+ <MiniCard hue={card.hue} icon={card.icon} title={card.title} />+ </div>+ ))}+ <svg className="absolute left-[128px] top-[12px] h-[60px] w-[80px] text-muted-foreground/60" viewBox="0 0 80 60" fill="none">+ <path className="jarvis-skill-dash" d="M2 8 C 40 2, 66 18, 70 52" stroke="currentColor" strokeWidth="1.5" strokeDasharray="4 4" strokeLinecap="round" />+ <path d="M64 47 L70 56 L75 46" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />+ </svg>+ <div className="jarvis-skill-fly absolute left-[80px] top-[12px]">+ <div style={skillStyle("amber")} className="h-5 w-12 rounded-md border border-[hsl(var(--skill)/0.5)] bg-[hsl(var(--skill)/0.2)]" />+ </div>+ <div className="absolute bottom-0 right-0 w-[120px] overflow-hidden rounded-lg border border-border-strong bg-background shadow-[0_14px_30px_-18px_hsl(var(--foreground)/0.5)]">+ <div className="flex items-center gap-1 border-b border-border px-2 py-1.5">+ <span className="h-1.5 w-1.5 rounded-full bg-border-strong" />+ <span className="h-1.5 w-1.5 rounded-full bg-border-strong" />+ <span className="h-1.5 w-1.5 rounded-full bg-border-strong" />+ </div>+ <div className="space-y-1.5 px-2 py-2 font-mono text-xs leading-none">+ <div className="h-1.5 w-3/4 rounded-full bg-muted-foreground/25" />+ <div className="h-1.5 w-1/2 rounded-full bg-muted-foreground/20" />+ <div className="flex items-center gap-1 pt-0.5 text-accent">+ <span>></span>+ <span className="jarvis-skill-caret inline-block h-3 w-1.5 bg-accent" />+ </div>+ </div>+ </div>+ </div>+ );+}++/** The empty library: what a skill is, shown rather than told, and three ways in. */+export function SkillsHero({ onNew, onPaste, onImport, onExamples, addingExamples }: {+ onNew: () => void;+ onPaste: () => void;+ onImport: () => void;+ onExamples: () => void;+ addingExamples: boolean;+}) {+ const t = useT();+ return (+ <div data-testid="skills-empty" className="flex flex-col items-center px-5 pb-8 pt-6 text-center">+ <HeroPicture />+ <h3 className="mt-6 font-display text-lg text-foreground-strong">{t("ide_side_panel.skills.empty_title")}</h3>+ <p className="mt-1.5 max-w-[19rem] text-sm leading-6 text-muted-foreground">{t("ide_side_panel.skills.empty_body")}</p>+ <div className="mt-5 grid w-full max-w-[19rem] gap-2">+ <button+ type="button"+ data-testid="skills-empty-new"+ onClick={onNew}+ className="inline-flex h-9 items-center justify-center gap-2 rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"+ >+ <Plus className="h-4 w-4" aria-hidden />+ {t("ide_side_panel.skills.new")}+ </button>+ <div className="grid grid-cols-2 gap-2">+ <button+ type="button"+ onClick={onPaste}+ className="inline-flex h-9 items-center justify-center gap-1.5 rounded-md border border-border-strong px-2 text-sm text-foreground transition-colors hover:bg-secondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"+ >+ <ClipboardPaste className="h-4 w-4 text-muted-foreground" aria-hidden />+ {t("ide_side_panel.skills.paste_short")}+ </button>+ <button+ type="button"+ onClick={onImport}+ className="inline-flex h-9 items-center justify-center gap-1.5 rounded-md border border-border-strong px-2 text-sm text-foreground transition-colors hover:bg-secondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"+ >+ <FileUp className="h-4 w-4 text-muted-foreground" aria-hidden />+ {t("ide_side_panel.skills.import_short")}+ </button>+ </div>+ <button+ type="button"+ data-testid="skills-empty-examples"+ disabled={addingExamples}+ onClick={onExamples}+ className="mt-1 inline-flex h-8 items-center justify-center gap-1.5 rounded-md text-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50"+ >+ <Sparkles className="h-3.5 w-3.5" aria-hidden />+ {t("ide_side_panel.skills.add_examples")}+ </button>+ </div>+ <p className="mt-4 text-xs text-foreground-faint">{t("ide_side_panel.skills.drop_files_hint")}</p>+ </div>+ );+}diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/SkillsTab.test.tsx b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/SkillsTab.test.tsxnew file mode 100644index 0000000000..a5fc49bb79--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/SkillsTab.test.tsx@@ -0,0 +1,141 @@+import { act, cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import type { IdeSkill } from "@/lib/ideSkillsApi";+import { useIdeSkillsStore } from "@/store/ideSkills";+import { PANE_PASTE_EVENT, SKILL_DRAG_TYPE, type PanePasteDetail } from "@/components/agentic/skillDrag";+import { SkillsTab } from "./SkillsTab";++/** An in-memory stand-in for `/api/agentic-ide/skills`. */+function fakeLibrary(initial: IdeSkill[] = []) {+ const skills = [...initial];+ let next = 1;+ const json = (body: unknown, status = 200) => new Response(JSON.stringify(body), { status, headers: { "Content-Type": "application/json" } });+ const fetchFake = async (input: RequestInfo | URL, init?: RequestInit) => {+ const url = String(input);+ const method = init?.method ?? "GET";+ const body = init?.body ? JSON.parse(String(init.body)) : {};+ const id = url.split("/api/agentic-ide/skills/")[1]?.split("/")[0];+ if (method === "GET" && url.endsWith("/skills")) return json({ skills });+ if (method === "POST" && url.endsWith("/skills")) {+ const skill: IdeSkill = {+ id: `s${next++}`, title: body.title, content: body.content, description: body.description ?? "",+ hue: body.hue ?? "blue", icon: body.icon ?? "auto", created_at: "", updated_at: "", use_count: 0, last_used_at: null,+ };+ skills.unshift(skill);+ return json(skill, 201);+ }+ if (method === "POST" && url.endsWith("/used")) {+ const skill = skills.find((entry) => entry.id === id)!;+ skill.use_count += 1;+ return json(skill);+ }+ return json({ detail: "unexpected" }, 500);+ };+ return { skills, fetchFake };+}++const REVIEW: IdeSkill = {+ id: "r1", title: "Code review", content: "# Code review\n\nCheck the diff.", description: "Check the diff.",+ hue: "amber", icon: "shield", created_at: "", updated_at: "", use_count: 2, last_used_at: null,+};++beforeEach(() => {+ localStorage.clear();+ useIdeSkillsStore.setState({ skills: [], status: "idle", error: null, landing: null, dragging: null, target: null });+});++afterEach(() => {+ cleanup();+ vi.unstubAllGlobals();+});++describe("SkillsTab", () => {+ it("offers three ways in when the library is empty, and adds the examples", async () => {+ const library = fakeLibrary();+ vi.stubGlobal("fetch", library.fetchFake);+ render(<SkillsTab />);++ const examples = await screen.findByTestId("skills-empty-examples");+ fireEvent.click(examples);++ await waitFor(() => expect(library.skills).toHaveLength(3));+ // The first example of the list ends up on top.+ expect(await screen.findByRole("button", { name: "Plan before coding" })).toBeTruthy();+ expect(screen.queryByTestId("skills-empty")).toBeNull();+ });++ it("filters by title, summary and text", async () => {+ vi.stubGlobal("fetch", fakeLibrary([REVIEW, { ...REVIEW, id: "r2", title: "Release notes", content: "ship it", description: "" }]).fetchFake);+ render(<SkillsTab />);+ await screen.findByRole("button", { name: "Code review" });++ fireEvent.change(screen.getByTestId("skills-search"), { target: { value: "diff" } });++ expect(screen.getByRole("button", { name: "Code review" })).toBeTruthy();+ expect(screen.queryByRole("button", { name: "Release notes" })).toBeNull();+ });++ it("pastes into the selected pane from the card's button", async () => {+ vi.stubGlobal("fetch", fakeLibrary([REVIEW]).fetchFake);+ useIdeSkillsStore.setState({ target: { workspaceId: "w1", pane: "mika" } });+ const received: PanePasteDetail[] = [];+ const listen = (event: Event) => received.push((event as CustomEvent<PanePasteDetail>).detail);+ window.addEventListener(PANE_PASTE_EVENT, listen);+ render(<SkillsTab />);++ fireEvent.click(await screen.findByTestId("skill-paste-r1"));+ window.removeEventListener(PANE_PASTE_EVENT, listen);++ expect(received).toEqual([{ workspaceId: "w1", pane: "mika", skill: { id: "r1", title: "Code review", content: REVIEW.content, hue: "amber" } }]);+ });++ it("loads the drag with the skill and announces it while it is carried", async () => {+ vi.stubGlobal("fetch", fakeLibrary([REVIEW]).fetchFake);+ render(<SkillsTab />);+ const card = await screen.findByTestId("skill-card-r1");+ const data = new Map<string, string>();+ const dataTransfer = {+ setData: (type: string, value: string) => data.set(type, value),+ setDragImage: vi.fn(),+ effectAllowed: "",+ };++ fireEvent.dragStart(card, { dataTransfer });++ expect(JSON.parse(data.get(SKILL_DRAG_TYPE) ?? "{}")).toMatchObject({ id: "r1", content: REVIEW.content });+ expect(data.get("text/plain")).toBe(REVIEW.content);+ expect(useIdeSkillsStore.getState().dragging).toMatchObject({ id: "r1", title: "Code review" });++ fireEvent.dragEnd(card);+ expect(useIdeSkillsStore.getState().dragging).toBeNull();+ });++ it("saves a pasted text as a new skill from the editor", async () => {+ const library = fakeLibrary([REVIEW]);+ vi.stubGlobal("fetch", library.fetchFake);+ render(<SkillsTab />);+ fireEvent.click(await screen.findByTestId("skills-new"));++ fireEvent.change(screen.getByTestId("skill-editor-content"), { target: { value: "# House style\n\nShort sentences." } });+ // No title typed: the heading is suggested and used.+ expect((screen.getByTestId("skill-editor-title") as HTMLInputElement).placeholder).toBe("House style");+ await act(async () => {+ fireEvent.click(screen.getByTestId("skill-editor-save"));+ });++ await waitFor(() => expect(library.skills[0]?.title).toBe("House style"));+ expect(screen.queryByTestId("skill-editor")).toBeNull();+ expect(screen.getByRole("button", { name: "House style" })).toBeTruthy();+ });++ it("shows where a skill just landed and counts the paste", async () => {+ vi.stubGlobal("fetch", fakeLibrary([REVIEW]).fetchFake);+ render(<SkillsTab />);+ await screen.findByTestId("skill-card-r1");++ act(() => useIdeSkillsStore.getState().recordUse("r1", "mika"));++ expect(await screen.findByTestId("skill-landed-r1")).toBeTruthy();+ expect(useIdeSkillsStore.getState().skills[0].use_count).toBe(3);+ });+});diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/SkillsTab.tsx b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/SkillsTab.tsxnew file mode 100644index 0000000000..8bcafa8621--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/SkillsTab.tsx@@ -0,0 +1,473 @@+import { useCallback, useEffect, useMemo, useRef, useState, type DragEvent } from "react";+import {+ ArrowDownAZ,+ ArrowUpDown,+ Check,+ Clock3,+ FileUp,+ GripVertical,+ Library,+ Loader2,+ MousePointerClick,+ Plus,+ RotateCcw,+ Search,+ TrendingUp,+ X,+ type LucideIcon,+} from "lucide-react";+import { fill, useT } from "@/i18n";+import { cn } from "@/lib/utils";+import { robustCopy, robustPaste } from "@/lib/clipboard";+import { deriveIdeSkillFields, type IdeSkill, type IdeSkillDraft } from "@/lib/ideSkillsApi";+import { useEventStore } from "@/store/events";+import { useIdeSkillsStore } from "@/store/ideSkills";+import { pasteSkillIntoPane } from "@/components/agentic/skillDrag";+import { SkillCard, type DropSide } from "./SkillCard";+import { SkillEditor, type SkillEditorSeed } from "./SkillEditor";+import { SkillMenu, type SkillMenuItem } from "./SkillMenu";+import { SkillsHero } from "./SkillsHero";+import { MARKDOWN_ACCEPT, isMarkdownFile, readMarkdownFile, suggestSkillTitle } from "./skillImport";+import { STARTER_SKILLS } from "./starterSkills";++type SortKey = "manual" | "used" | "recent" | "name";+const SORT_KEY = "jarvis.agenticIde.skillsSort.v1";+const SORTS: readonly { key: SortKey; icon: LucideIcon }[] = [+ { key: "manual", icon: GripVertical },+ { key: "used", icon: TrendingUp },+ { key: "recent", icon: Clock3 },+ { key: "name", icon: ArrowDownAZ },+];++function storedSort(): SortKey {+ try {+ const value = localStorage.getItem(SORT_KEY);+ return SORTS.some((sort) => sort.key === value) ? (value as SortKey) : "manual";+ } catch {+ return "manual";+ }+}++function sortSkills(skills: IdeSkill[], key: SortKey): IdeSkill[] {+ if (key === "manual") return skills;+ const sorted = [...skills];+ if (key === "used") sorted.sort((a, b) => b.use_count - a.use_count || (b.last_used_at ?? "").localeCompare(a.last_used_at ?? ""));+ if (key === "recent") sorted.sort((a, b) => (b.last_used_at ?? b.updated_at).localeCompare(a.last_used_at ?? a.updated_at));+ if (key === "name") sorted.sort((a, b) => a.title.localeCompare(b.title, undefined, { sensitivity: "base" }));+ return sorted;+}++function matches(skill: IdeSkill, query: string): boolean {+ const needle = query.trim().toLocaleLowerCase();+ if (!needle) return true;+ return [skill.title, skill.description, skill.content].some((field) => field.toLocaleLowerCase().includes(needle));+}++function slugify(title: string): string {+ return title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "skill";+}++/**+ * The side panel's Skills tab: a library of saved Markdown prompts.+ *+ * A skill is pasted, Markdown and all, into a coding agent's prompt by+ * dragging its card onto a terminal pane — or with its "Paste into …" button,+ * which goes to the pane selected in the grid. Text comes in three ways: typed+ * or pasted in the editor, a Markdown file picked or dropped on the tab+ * (several at once are saved straight away), or the three examples an empty+ * library offers.+ */+export function SkillsTab() {+ const t = useT();+ const skills = useIdeSkillsStore((state) => state.skills);+ const status = useIdeSkillsStore((state) => state.status);+ const loadError = useIdeSkillsStore((state) => state.error);+ const load = useIdeSkillsStore((state) => state.load);+ const create = useIdeSkillsStore((state) => state.create);+ const update = useIdeSkillsStore((state) => state.update);+ const remove = useIdeSkillsStore((state) => state.remove);+ const move = useIdeSkillsStore((state) => state.move);+ const target = useIdeSkillsStore((state) => state.target);+ const carrying = useIdeSkillsStore((state) => state.dragging);+ const pushToast = useEventStore((state) => state.pushToast);++ const [query, setQuery] = useState("");+ const [sort, setSortState] = useState<SortKey>(storedSort);+ const [sortOpen, setSortOpen] = useState(false);+ const [editor, setEditor] = useState<SkillEditorSeed | null>(null);+ const [fileOver, setFileOver] = useState(false);+ const [importing, setImporting] = useState(false);+ const [addingExamples, setAddingExamples] = useState(false);+ const [dropMark, setDropMark] = useState<{ id: string; side: DropSide } | null>(null);+ const fileInput = useRef<HTMLInputElement>(null);+ const sortButton = useRef<HTMLButtonElement>(null);+ const searchInput = useRef<HTMLInputElement>(null);+ const fileDepth = useRef(0);++ useEffect(() => {+ void load();+ }, [load]);++ const setSort = (key: SortKey) => {+ setSortState(key);+ try {+ localStorage.setItem(SORT_KEY, key);+ } catch {+ /* a convenience only: the order still applies for this session */+ }+ };++ const visible = useMemo(() => sortSkills(skills.filter((skill) => matches(skill, query)), sort), [skills, query, sort]);+ const reorderable = sort === "manual" && !query.trim();+ const fail = useCallback((error: unknown) => pushToast("error", error instanceof Error ? error.message : String(error)), [pushToast]);++ const paste = useCallback((skill: IdeSkill) => {+ if (!target) return;+ pasteSkillIntoPane({ ...target, skill: { id: skill.id, title: skill.title, content: skill.content, hue: skill.hue } });+ }, [target]);++ const openEditor = useCallback((skill: IdeSkill, mode: "preview" | "edit") => {+ setEditor({ skill, mode: mode === "edit" ? "write" : "preview" });+ }, []);++ const duplicate = useCallback((skill: IdeSkill) => {+ create({+ title: fill(t("ide_side_panel.skills.copy_title"), { title: skill.title }).slice(0, 120),+ content: skill.content,+ hue: skill.hue,+ icon: skill.icon,+ }).catch(fail);+ }, [create, fail, t]);++ const deleteSkill = useCallback((skill: IdeSkill) => {+ remove(skill.id)+ .then(() => pushToast("info", fill(t("ide_side_panel.skills.deleted"), { title: skill.title })))+ .catch(fail);+ }, [remove, pushToast, fail, t]);++ const copy = useCallback((skill: IdeSkill) => {+ void robustCopy(skill.content).then((ok) =>+ pushToast(ok ? "success" : "error", ok ? fill(t("ide_side_panel.skills.copied"), { title: skill.title }) : t("ide_side_panel.skills.copy_failed")),+ );+ }, [pushToast, t]);++ const exportSkill = useCallback((skill: IdeSkill) => {+ const url = URL.createObjectURL(new Blob([skill.content], { type: "text/markdown;charset=utf-8" }));+ const link = document.createElement("a");+ link.href = url;+ link.download = `${slugify(skill.title)}.md`;+ document.body.appendChild(link);+ link.click();+ link.remove();+ window.setTimeout(() => URL.revokeObjectURL(url), 1_000);+ }, []);++ const reorderOver = useCallback((skill: IdeSkill, side: DropSide) => {+ setDropMark((current) => (side ? { id: skill.id, side } : current?.id === skill.id ? null : current));+ }, []);++ const reorderDrop = useCallback((skill: IdeSkill) => {+ const moving = useIdeSkillsStore.getState().dragging;+ const mark = dropMark;+ setDropMark(null);+ if (!moving || moving.id === skill.id) return;+ let beforeId: string | null = skill.id;+ if (mark?.side === "after") {+ const index = skills.findIndex((entry) => entry.id === skill.id);+ beforeId = skills.slice(index + 1).find((entry) => entry.id !== moving.id)?.id ?? null;+ }+ move(moving.id, beforeId).catch(fail);+ }, [dropMark, skills, move, fail]);++ // Several files are saved as they are; one opens in the editor to be named.+ const importFiles = useCallback(async (files: File[]) => {+ const markdown = files.filter(isMarkdownFile);+ if (markdown.length === 0) {+ if (files.length) pushToast("warning", t("ide_side_panel.skills.import_not_markdown"));+ return;+ }+ if (markdown.length === 1) {+ try {+ const text = await readMarkdownFile(markdown[0]);+ setEditor({ draft: { title: suggestSkillTitle(text, markdown[0].name), content: text }, mode: "split" });+ } catch (error) {+ fail(error);+ }+ return;+ }+ setImporting(true);+ let saved = 0;+ for (const file of [...markdown].reverse()) {+ try {+ const text = await readMarkdownFile(file);+ const derived = await deriveIdeSkillFields(text, file.name);+ await create({ title: derived.title || suggestSkillTitle(text, file.name) || file.name, content: text });+ saved += 1;+ } catch (error) {+ fail(error);+ }+ }+ setImporting(false);+ if (saved) pushToast("success", fill(t("ide_side_panel.skills.imported"), { n: saved }));+ }, [create, fail, pushToast, t]);++ const pasteFromClipboard = useCallback(async () => {+ const text = await robustPaste();+ if (!text?.trim()) {+ pushToast("info", t("ide_side_panel.skills.clipboard_empty"));+ setEditor({ mode: "write" });+ return;+ }+ setEditor({ draft: { title: suggestSkillTitle(text), content: text }, mode: "split" });+ }, [pushToast, t]);++ const addExamples = useCallback(async () => {+ setAddingExamples(true);+ try {+ for (const starter of [...STARTER_SKILLS].reverse()) await create(starter);+ } catch (error) {+ fail(error);+ } finally {+ setAddingExamples(false);+ }+ }, [create, fail]);++ const save = useCallback(async (draft: IdeSkillDraft, id?: string) => {+ if (id) await update(id, { ...draft, description: draft.description ?? "" });+ else await create(draft);+ }, [create, update]);++ // A Markdown file from the desktop, dropped anywhere on the tab.+ const fileDrag = {+ onDragEnter: (event: DragEvent<HTMLDivElement>) => {+ if (!Array.from(event.dataTransfer.types).includes("Files")) return;+ event.preventDefault();+ fileDepth.current += 1;+ setFileOver(true);+ },+ onDragOver: (event: DragEvent<HTMLDivElement>) => {+ if (!Array.from(event.dataTransfer.types).includes("Files")) return;+ event.preventDefault();+ event.dataTransfer.dropEffect = "copy";+ },+ onDragLeave: () => {+ fileDepth.current = Math.max(0, fileDepth.current - 1);+ if (fileDepth.current === 0) setFileOver(false);+ },+ onDrop: (event: DragEvent<HTMLDivElement>) => {+ if (!Array.from(event.dataTransfer.types).includes("Files")) return;+ event.preventDefault();+ fileDepth.current = 0;+ setFileOver(false);+ void importFiles(Array.from(event.dataTransfer.files ?? []));+ },+ };++ const sortItems: SkillMenuItem[] = SORTS.map(({ key, icon }) => ({+ id: `sort-${key}`,+ label: t(`ide_side_panel.skills.sort_${key}`),+ icon,+ hint: sort === key ? <Check className="h-3.5 w-3.5 text-accent" aria-hidden /> : undefined,+ onSelect: () => setSort(key),+ }));++ const empty = status === "ready" && skills.length === 0;++ return (+ <div data-testid="ide-skills-tab" className="relative flex h-full min-h-0 flex-col" {...fileDrag}>+ <div className="shrink-0 space-y-3 px-3 pb-3 pt-3.5">+ <div className="flex items-start gap-2.5">+ <span aria-hidden className="mt-0.5 inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-[linear-gradient(135deg,hsl(var(--accent)/0.22),hsl(var(--viz-reasoning)/0.18))] text-accent shadow-[inset_0_0_0_1px_hsl(var(--accent)/0.25)]">+ <Library className="h-4 w-4" />+ </span>+ <div className="min-w-0 flex-1">+ <h2 className="flex items-baseline gap-2 font-display text-base text-foreground-strong">+ {t("ide_side_panel.tabs.skills")}+ {skills.length > 0 && <span className="text-xs font-normal tabular-nums text-muted-foreground">{skills.length}</span>}+ </h2>+ <p className="truncate text-xs text-muted-foreground">{t("ide_side_panel.skills.subtitle")}</p>+ </div>+ {!empty && (+ <button+ type="button"+ data-testid="skills-new"+ onClick={() => setEditor({ mode: "write" })}+ className="inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md bg-primary px-2.5 text-sm font-medium text-primary-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"+ >+ <Plus className="h-4 w-4" aria-hidden />+ {t("ide_side_panel.skills.new_short")}+ </button>+ )}+ </div>++ {!empty && (+ <div className="flex items-center gap-1.5">+ <label className="group/search relative flex h-8 min-w-0 flex-1 items-center rounded-md border border-border bg-input/60 transition-colors focus-within:border-accent focus-within:ring-2 focus-within:ring-ring/40">+ <Search className="pointer-events-none absolute left-2.5 h-3.5 w-3.5 text-muted-foreground" aria-hidden />+ <input+ ref={searchInput}+ data-testid="skills-search"+ value={query}+ onChange={(event) => setQuery(event.target.value)}+ onKeyDown={(event) => { if (event.key === "Escape" && query) { event.stopPropagation(); setQuery(""); } }}+ placeholder={t("ide_side_panel.skills.search_placeholder")}+ aria-label={t("ide_side_panel.skills.search_label")}+ className="h-full w-full bg-transparent pl-8 pr-7 text-sm text-foreground outline-none placeholder:text-foreground-faint"+ />+ {query && (+ <button+ type="button"+ aria-label={t("ide_side_panel.skills.search_clear")}+ onClick={() => { setQuery(""); searchInput.current?.focus(); }}+ className="absolute right-1.5 inline-flex h-5 w-5 items-center justify-center rounded text-muted-foreground hover:bg-secondary hover:text-foreground"+ >+ <X className="h-3.5 w-3.5" aria-hidden />+ </button>+ )}+ </label>+ <button+ ref={sortButton}+ type="button"+ aria-haspopup="menu"+ aria-expanded={sortOpen}+ aria-label={fill(t("ide_side_panel.skills.sort_label"), { order: t(`ide_side_panel.skills.sort_${sort}`) })}+ title={fill(t("ide_side_panel.skills.sort_label"), { order: t(`ide_side_panel.skills.sort_${sort}`) })}+ onClick={() => setSortOpen((value) => !value)}+ className={cn(+ "inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-border transition-colors hover:bg-secondary hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",+ sort === "manual" ? "text-muted-foreground" : "text-accent",+ )}+ >+ <ArrowUpDown className="h-3.5 w-3.5" aria-hidden />+ </button>+ <button+ type="button"+ data-testid="skills-import"+ disabled={importing}+ onClick={() => fileInput.current?.click()}+ aria-label={t("ide_side_panel.skills.import_file")}+ title={t("ide_side_panel.skills.import_file")}+ className="inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-border text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50"+ >+ {importing ? <Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden /> : <FileUp className="h-3.5 w-3.5" aria-hidden />}+ </button>+ <SkillMenu anchor={sortButton} open={sortOpen} onClose={() => setSortOpen(false)} items={sortItems} label={t("ide_side_panel.skills.sort_menu")} />+ </div>+ )}+ <input+ ref={fileInput}+ type="file"+ multiple+ accept={MARKDOWN_ACCEPT}+ className="hidden"+ data-testid="skills-file-input"+ onChange={(event) => { void importFiles(Array.from(event.target.files ?? [])); event.target.value = ""; }}+ />+ </div>++ <div className="relative min-h-0 flex-1 overflow-y-auto overscroll-contain px-3 pb-3">+ {status === "loading" && skills.length === 0 && (+ <div className="space-y-2" aria-busy="true" aria-label={t("ide_side_panel.skills.loading")}>+ {[0, 1, 2].map((index) => (+ <div key={index} className="flex gap-3 rounded-xl border border-border bg-card/40 p-3">+ <div className="h-9 w-9 animate-pulse rounded-[10px] bg-secondary" />+ <div className="flex-1 space-y-2 pt-1">+ <div className="h-3 w-1/2 animate-pulse rounded bg-secondary" />+ <div className="h-2.5 w-4/5 animate-pulse rounded bg-secondary" />+ </div>+ </div>+ ))}+ </div>+ )}+ {status === "error" && skills.length === 0 && (+ <div className="flex flex-col items-center gap-3 px-4 py-10 text-center">+ <p className="text-sm text-muted-foreground">{fill(t("ide_side_panel.skills.load_failed"), { error: loadError ?? "" })}</p>+ <button+ type="button"+ onClick={() => void load(true)}+ className="inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1 text-sm text-foreground hover:bg-secondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"+ >+ <RotateCcw className="h-3.5 w-3.5" aria-hidden />+ {t("ide_side_panel.skills.retry")}+ </button>+ </div>+ )}+ {empty && (+ <SkillsHero+ onNew={() => setEditor({ mode: "write" })}+ onPaste={() => void pasteFromClipboard()}+ onImport={() => fileInput.current?.click()}+ onExamples={() => void addExamples()}+ addingExamples={addingExamples}+ />+ )}+ {skills.length > 0 && visible.length === 0 && (+ <p className="px-4 py-10 text-center text-sm text-muted-foreground">{fill(t("ide_side_panel.skills.no_match"), { query: query.trim() })}</p>+ )}+ {visible.length > 0 && (+ <div role="list" aria-label={t("ide_side_panel.skills.list_label")} className="space-y-2" onDragLeave={(event) => {+ if (!event.currentTarget.contains(event.relatedTarget as Node | null)) setDropMark(null);+ }}>+ {visible.map((skill) => (+ <SkillCard+ key={skill.id}+ skill={skill}+ targetPane={target?.pane ?? null}+ reorderable={reorderable}+ dropSide={dropMark?.id === skill.id && carrying?.id !== skill.id ? dropMark.side : null}+ onPaste={paste}+ onOpen={openEditor}+ onDuplicate={duplicate}+ onDelete={deleteSkill}+ onCopy={copy}+ onExport={exportSkill}+ onReorderOver={reorderOver}+ onReorderDrop={reorderDrop}+ />+ ))}+ </div>+ )}+ </div>++ {/* Where a click pastes, or — while a card is carried — where to drop it. */}+ {skills.length > 0 && (+ <div className="shrink-0 border-t border-border/60 px-3 py-2">+ {carrying ? (+ <p className="flex items-center gap-1.5 text-xs font-medium text-foreground animate-in fade-in-0 duration-150">+ <MousePointerClick className="h-3.5 w-3.5 text-accent" aria-hidden />+ {t("ide_side_panel.skills.hint_dragging")}+ </p>+ ) : target ? (+ <p className="flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground">+ <span aria-hidden className="relative flex h-2 w-2 shrink-0">+ <span className="absolute inline-flex h-full w-full rounded-full bg-success/60 motion-safe:animate-ping" />+ <span className="relative inline-flex h-2 w-2 rounded-full bg-success" />+ </span>+ <span className="truncate">{fill(t("ide_side_panel.skills.hint_target"), { pane: target.pane })}</span>+ </p>+ ) : (+ <p className="text-xs text-muted-foreground">{t("ide_side_panel.skills.hint_no_target")}</p>+ )}+ </div>+ )}++ {fileOver && (+ <div className="pointer-events-none absolute inset-2 z-20 flex flex-col items-center justify-center gap-2 rounded-xl border-2 border-dashed border-accent/60 bg-card/90 text-center backdrop-blur-[2px] animate-in fade-in-0 duration-100">+ <FileUp className="h-6 w-6 text-accent" aria-hidden />+ <p className="text-sm font-medium text-foreground">{t("ide_side_panel.skills.drop_files_title")}</p>+ <p className="max-w-[16rem] text-xs text-muted-foreground">{t("ide_side_panel.skills.drop_files_body")}</p>+ </div>+ )}++ {editor && (+ <SkillEditor+ seed={editor}+ onClose={() => setEditor(null)}+ onSave={save}+ onPaste={paste}+ targetPane={target?.pane ?? null}+ />+ )}+ </div>+ );+}diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/skillImport.test.ts b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/skillImport.test.tsnew file mode 100644index 0000000000..501e57b51d--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/skillImport.test.ts@@ -0,0 +1,64 @@+import { describe, expect, it } from "vitest";+import { deriveSkillDescription, isMarkdownFile, readMarkdownFile, suggestSkillTitle } from "./skillImport";+import { splitSkillFrontmatter, skillIconFor, SKILL_ICON, compactCount } from "./skillVisuals";++const SKILL_MD = "---\nname: pr-review\ndescription: >-\n Review a pull\n request.\n---\n# Heading\n\nBody.";++describe("suggesting a skill's title", () => {+ it("prefers the frontmatter name, then the first heading", () => {+ expect(suggestSkillTitle(SKILL_MD)).toBe("pr-review");+ expect(suggestSkillTitle("intro\n\n## Write tests first ##\n")).toBe("Write tests first");+ });++ it("falls back to the file name, never to a bare SKILL.md", () => {+ expect(suggestSkillTitle("plain words", "house_style.md")).toBe("house style");+ expect(suggestSkillTitle("plain words", "SKILL.md")).toBe("plain words");+ });++ it("ignores a byte-order mark in front of the frontmatter", () => {+ expect(suggestSkillTitle(`${String.fromCharCode(0xfeff)}${SKILL_MD}`)).toBe("pr-review");+ });+});++describe("deriving a skill's summary", () => {+ it("reads a folded frontmatter description", () => {+ expect(deriveSkillDescription(SKILL_MD)).toBe("Review a pull request.");+ });++ it("takes the first prose line, skipping headings, fences and tables", () => {+ expect(deriveSkillDescription("# T\n\n```\ncode\n```\n| a |\n> **Lead** `line`\n")).toBe("Lead line");+ });+});++describe("reading an imported file", () => {+ it("accepts Markdown and text, normalises line endings", async () => {+ const file = new File(["# A\r\nB\r\n"], "a.md", { type: "" });+ expect(isMarkdownFile(file)).toBe(true);+ await expect(readMarkdownFile(file)).resolves.toBe("# A\nB\n");+ });++ it("refuses anything that is not text", async () => {+ await expect(readMarkdownFile(new File(["x"], "a.png", { type: "image/png" }))).rejects.toThrow("not a Markdown");+ await expect(readMarkdownFile(new File([`a${String.fromCharCode(0)}b`], "a.md"))).rejects.toThrow("not a text file");+ });+});++describe("how a skill looks", () => {+ it("splits frontmatter fields from the body", () => {+ const { fields, body } = splitSkillFrontmatter(SKILL_MD);+ expect(fields).toEqual([["name", "pr-review"]]);+ expect(body.startsWith("# Heading")).toBe(true);+ });++ it("picks a glyph from the words when left on auto", () => {+ expect(skillIconFor("auto", "Fix the login bug")).toBe(SKILL_ICON.bug);+ expect(skillIconFor("auto", "Something else")).toBe(SKILL_ICON.sparkles);+ expect(skillIconFor("rocket", "Fix the login bug")).toBe(SKILL_ICON.rocket);+ });++ it("keeps counts short", () => {+ expect(compactCount(999)).toBe("999");+ expect(compactCount(1200)).toBe("1.2k");+ expect(compactCount(12_400)).toBe("12k");+ });+});diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/skillImport.ts b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/skillImport.tsnew file mode 100644index 0000000000..6573a2cc1f--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/skillImport.ts@@ -0,0 +1,113 @@+/**+ * Turning a Markdown file or a pasted text into a skill draft.+ *+ * Title and summary follow the backend's `derive_title` / `derive_description`+ * (frontmatter first, then the first heading or prose line) so what the editor+ * suggests is what the library would pick; the backend stays the authority for+ * files saved without the editor.+ */++/** What the file pickers offer. `.txt` too: plenty of prompts live in plain text. */+export const MARKDOWN_ACCEPT = ".md,.markdown,.mdx,.txt,text/markdown,text/plain";++/** Larger than any prompt a terminal should receive in one paste. */+export const MAX_IMPORT_BYTES = 400_000;++const MARKDOWN_NAME = /\.(md|markdown|mdx|txt)$/i;+const BYTE_ORDER_MARK = 0xfeff;+const FRONTMATTER = /^---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/;+const HEADING = /^\s{0,3}#{1,6}\s+(.+?)\s*#*\s*$/;++export function isMarkdownFile(file: File): boolean {+ return MARKDOWN_NAME.test(file.name) || file.type === "text/markdown" || file.type === "text/plain";+}++export class SkillImportError extends Error {}++function withoutBom(text: string): string {+ return text.charCodeAt(0) === BYTE_ORDER_MARK ? text.slice(1) : text;+}++/** `File.text()`, with the older reader for engines that lack it. */+function readText(file: File): Promise<string> {+ if (typeof file.text === "function") return file.text();+ return new Promise((resolve, reject) => {+ const reader = new FileReader();+ reader.onload = () => resolve(String(reader.result ?? ""));+ reader.onerror = () => reject(reader.error ?? new SkillImportError(`${file.name}: could not be read.`));+ reader.readAsText(file);+ });+}++/** A file's text, refusing binaries and anything too large to paste. */+export async function readMarkdownFile(file: File): Promise<string> {+ if (!isMarkdownFile(file)) throw new SkillImportError(`${file.name}: not a Markdown or text file.`);+ if (file.size > MAX_IMPORT_BYTES) throw new SkillImportError(`${file.name}: larger than ${Math.round(MAX_IMPORT_BYTES / 1000)} KB.`);+ const text = await readText(file);+ if (text.includes(String.fromCharCode(0))) throw new SkillImportError(`${file.name}: not a text file.`);+ return withoutBom(text).replace(/\r\n?/g, "\n");+}++function clean(value: string, limit: number): string {+ return value.replace(/\s+/g, " ").trim().slice(0, limit);+}++/** The frontmatter block's text and the body after it. */+function splitFront(content: string): { front: string | null; body: string } {+ const text = withoutBom(content);+ const match = FRONTMATTER.exec(text);+ return match ? { front: match[1], body: text.slice(match[0].length) } : { front: null, body: text };+}++/** One scalar field of a frontmatter block, folded block scalars included. */+function frontField(front: string, key: string): string {+ const match = new RegExp(`^${key}\\s*:\\s*(.+?)\\s*$`, "m").exec(front);+ if (!match) return "";+ const value = match[1].replace(/^["']|["']$/g, "");+ if (!/^[>|]-?$/.test(value)) return value;+ const folded: string[] = [];+ for (const line of front.slice(match.index + match[0].length).split(/\r?\n/)) {+ if (line.trim() && !/^[ \t]/.test(line)) break;+ if (line.trim()) folded.push(line.trim());+ }+ return folded.join(" ");+}++/** "pr-review.md" → "pr review"; a bare SKILL.md names nothing. */+function titleFromFilename(filename: string): string {+ const stem = filename.split(/[\\/]/).pop()?.replace(/\.[^.]+$/, "") ?? "";+ if (stem.toUpperCase() === "SKILL") return "";+ return clean(stem.replace(/[-_]+/g, " "), 120);+}++export function suggestSkillTitle(content: string, filename = ""): string {+ const { front, body } = splitFront(content);+ const name = front ? frontField(front, "name") : "";+ if (name) return clean(name, 120);+ for (const line of body.split("\n")) {+ const heading = HEADING.exec(line);+ if (heading) return clean(heading[1], 120);+ }+ const fromName = titleFromFilename(filename);+ if (fromName) return fromName;+ const first = body.split("\n").find((line) => line.trim());+ return first ? clean(first.replace(/^[#>\-*`\s]+/, ""), 120) : "";+}++/** The one-line summary the library derives: frontmatter `description`, else the first prose line. */+export function deriveSkillDescription(content: string): string {+ const { front, body } = splitFront(content);+ const described = front ? frontField(front, "description") : "";+ if (described) return clean(described, 280);+ let fence = false;+ for (const line of body.split("\n")) {+ const trimmed = line.trim();+ if (/^(```|~~~)/.test(trimmed)) {+ fence = !fence;+ continue;+ }+ if (fence || !trimmed || HEADING.test(line) || /^(\||---|<!--)/.test(trimmed)) continue;+ return clean(trimmed.replace(/^[>\-*+ ]+/, "").replace(/\*\*|`/g, ""), 280);+ }+ return "";+}diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/skillVisuals.tsx b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/skillVisuals.tsxnew file mode 100644index 0000000000..6cb66a61e7--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/skillVisuals.tsx@@ -0,0 +1,156 @@+import type { CSSProperties } from "react";+import {+ BookOpen,+ Brain,+ Bug,+ Code2,+ FlaskConical,+ GitBranch,+ ListChecks,+ Palette,+ Rocket,+ ShieldCheck,+ Sparkles,+ SquareTerminal,+ WandSparkles,+ type LucideIcon,+} from "lucide-react";+import { cn } from "@/lib/utils";+import { SKILL_HUES, type SkillHue, type SkillIcon } from "@/lib/ideSkillsApi";++/**+ * How a skill looks: its hue and its glyph.+ *+ * A hue is a NAME the backend stores; here each name points at an existing+ * theme token, never a literal colour, so a skill reads in light and dark mode+ * alike and follows any later palette change. Everything that paints with the+ * hue reads it through one custom property, `--skill`, set by `skillStyle`.+ */+const HUE_TOKEN: Record<SkillHue, string> = {+ blue: "--accent",+ violet: "--viz-reasoning",+ teal: "--viz-terminal",+ amber: "--viz-file",+ rose: "--viz-agent",+ green: "--viz-result",+ magenta: "--viz-integration",+ slate: "--viz-tool",+};++export function isSkillHue(value: string): value is SkillHue {+ return (SKILL_HUES as readonly string[]).includes(value);+}++/** Sets `--skill` for everything inside to paint with this hue. */+export function skillStyle(hue: string): CSSProperties {+ const token = HUE_TOKEN[isSkillHue(hue) ? hue : "blue"];+ return { "--skill": `var(${token})` } as CSSProperties;+}++export const SKILL_ICON: Record<Exclude<SkillIcon, "auto">, LucideIcon> = {+ sparkles: Sparkles,+ code: Code2,+ bug: Bug,+ book: BookOpen,+ shield: ShieldCheck,+ rocket: Rocket,+ wand: WandSparkles,+ brain: Brain,+ flask: FlaskConical,+ palette: Palette,+ terminal: SquareTerminal,+ git: GitBranch,+ list: ListChecks,+};++/** Keywords that pick a glyph for a skill left on "auto", first match wins. */+const AUTO_RULES: readonly [RegExp, Exclude<SkillIcon, "auto">][] = [+ [/\b(bug|fix|debug|error|crash|trace)/i, "bug"],+ [/\b(test|spec|qa|tdd|coverage)/i, "flask"],+ [/\b(review|audit|secur|check|lint|verify)/i, "shield"],+ [/\b(git|commit|branch|merge|pull request|pr)\b/i, "git"],+ [/\b(design|ui|ux|style|css|colou?r|layout|visual)/i, "palette"],+ [/\b(deploy|release|ship|launch|publish)/i, "rocket"],+ [/\b(refactor|clean|simplif|tidy|rename)/i, "wand"],+ [/\b(plan|think|architect|brainstorm|idea|strategy)/i, "brain"],+ [/\b(shell|cli|terminal|bash|command|script)/i, "terminal"],+ [/\b(todo|checklist|steps|list|workflow)/i, "list"],+ [/\b(doc|readme|write|explain|blog|guide|prompt)/i, "book"],+ [/\b(code|function|api|implement|typescript|python)/i, "code"],+];++/** The glyph a skill wears: its own choice, else one its words suggest. */+export function skillIconFor(icon: string, title: string, description = ""): LucideIcon {+ if (icon !== "auto" && icon in SKILL_ICON) return SKILL_ICON[icon as Exclude<SkillIcon, "auto">];+ const words = `${title} ${description}`;+ const match = AUTO_RULES.find(([pattern]) => pattern.test(words));+ return SKILL_ICON[match ? match[1] : "sparkles"];+}++/**+ * The skill's seal: its glyph on a lit tile of its hue.+ *+ * Two soft layers of the hue (a wash and a brighter corner) with a hairline+ * rim of the same hue, so the tile reads as made of the colour rather than+ * painted on — and stays legible at 4 % dark and on white.+ */+export function SkillSeal({ hue, icon, title, description, size = "md", className }: {+ hue: string;+ icon: string;+ title: string;+ description?: string;+ size?: "sm" | "md" | "lg";+ className?: string;+}) {+ const Icon = skillIconFor(icon, title, description);+ const box = size === "lg" ? "h-12 w-12 rounded-xl" : size === "sm" ? "h-7 w-7 rounded-lg" : "h-9 w-9 rounded-[10px]";+ const glyph = size === "lg" ? "h-6 w-6" : size === "sm" ? "h-3.5 w-3.5" : "h-[18px] w-[18px]";+ return (+ <span+ aria-hidden+ style={skillStyle(hue)}+ className={cn(+ "relative inline-flex shrink-0 items-center justify-center overflow-hidden text-[hsl(var(--skill))]",+ "bg-[linear-gradient(135deg,hsl(var(--skill)/0.26),hsl(var(--skill)/0.08))]",+ "shadow-[inset_0_0_0_1px_hsl(var(--skill)/0.32),inset_0_1px_0_0_hsl(var(--skill)/0.25)]",+ box,+ className,+ )}+ >+ <span className="pointer-events-none absolute -right-2 -top-2 h-2/3 w-2/3 rounded-full bg-[hsl(var(--skill)/0.28)] blur-md" />+ <Icon className={cn("relative", glyph)} strokeWidth={1.9} />+ </span>+ );+}++/** Rough token count for a text: about four characters per token. */+export function approxTokens(text: string): number {+ return Math.max(1, Math.round(text.length / 4));+}++export function lineCount(text: string): number {+ return text ? text.split("\n").length : 0;+}++/** "1.2k" for anything past a thousand, so the meta row keeps its width. */+export function compactCount(value: number): string {+ if (value < 1000) return String(value);+ const thousands = value / 1000;+ return `${thousands >= 10 ? Math.round(thousands) : thousands.toFixed(1).replace(/\.0$/, "")}k`;+}++/** The body of a Markdown text without its YAML frontmatter, and the frontmatter's fields. */+export function splitSkillFrontmatter(content: string): { fields: [string, string][]; body: string } {+ // A byte-order mark in front of the block (a file saved by Notepad) is not text.+ const text = content.charCodeAt(0) === 0xfeff ? content.slice(1) : content;+ const match = /^---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/.exec(text);+ if (!match) return { fields: [], body: text };+ const fields: [string, string][] = [];+ for (const line of match[1].split(/\r?\n/)) {+ const field = /^([A-Za-z][\w-]*)\s*:\s*(.*)$/.exec(line);+ if (field && field[2].trim() && !/^[>|]-?$/.test(field[2].trim())) {+ fields.push([field[1], field[2].trim().replace(/^["']|["']$/g, "")]);+ }+ }+ return { fields, body: text.slice(match[0].length) };+}diff --git a/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/starterSkills.ts b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/starterSkills.tsnew file mode 100644index 0000000000..01de989393--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/agentic/sidePanel/skills/starterSkills.ts@@ -0,0 +1,59 @@+import type { IdeSkillDraft } from "@/lib/ideSkillsApi";++/**+ * Three example skills an empty library offers to add in one click, so the+ * first drag onto a terminal can happen before the user has written anything.+ * Plain, general-purpose instructions that work with any coding agent.+ */+export const STARTER_SKILLS: readonly IdeSkillDraft[] = [+ {+ title: "Plan before coding",+ hue: "violet",+ icon: "brain",+ content: `# Plan before coding++Before you change any file:++1. Restate the goal in one sentence.+2. List the files you expect to touch and why.+3. Name the riskiest part of the change and how you will check it.+4. Wait for my go-ahead, then implement in small steps.++Keep the plan short — ten lines at most.+`,+ },+ {+ title: "Test-first bug fix",+ hue: "rose",+ icon: "bug",+ content: `# Test-first bug fix++Fix the bug described below with this order of work:++- Write a failing test that reproduces the bug. Run it and show me it fails.+- Find the root cause. Explain it in two or three sentences.+- Make the smallest change that turns the test green.+- Run the surrounding tests and report anything that broke.++Do not refactor unrelated code in the same change.++Bug:+`,+ },+ {+ title: "Code review checklist",+ hue: "amber",+ icon: "shield",+ content: `# Code review checklist++Review the current diff. For each finding give file:line, what is wrong and a concrete fix.++- **Correctness:** edge cases, error paths, off-by-one, null handling.+- **Security:** untrusted input, secrets in code, injection, unsafe paths.+- **Clarity:** names, dead code, comments that no longer match the code.+- **Tests:** is the new behaviour covered, and would the tests catch a regression?++Rank findings by severity. Skip style nits unless they hide a bug.+`,+ },+];diff --git a/jarvis/ui/web/frontend/src/components/agentic/skillDrag.test.ts b/jarvis/ui/web/frontend/src/components/agentic/skillDrag.test.tsnew file mode 100644index 0000000000..759839d76a--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/agentic/skillDrag.test.ts@@ -0,0 +1,122 @@+import { act, renderHook } from "@testing-library/react";+import { afterEach, describe, expect, it, vi } from "vitest";+import type { DragEvent as ReactDragEvent } from "react";+import { usePaneFileDrag } from "./paneFileDrag";+import { resetDragSessionForTests } from "./dragSessionEnd";+import { SKILL_DRAG_TYPE, dragCarriesSkill, loadSkillDrag, pasteSkillText, readSkillDrag } from "./skillDrag";++afterEach(() => resetDragSessionForTests());++/** A DataTransfer good enough for loading and reading a drag. */+function transfer(initial: Record<string, string> = {}): DataTransfer {+ const data = new Map(Object.entries(initial));+ return {+ get types() {+ return [...data.keys()];+ },+ effectAllowed: "all",+ dropEffect: "",+ files: [] as unknown as FileList,+ setData: (type: string, value: string) => void data.set(type, value),+ getData: (type: string) => data.get(type) ?? "",+ } as unknown as DataTransfer;+}++function dragEvent(dataTransfer: DataTransfer) {+ return { dataTransfer, preventDefault: vi.fn() } as unknown as ReactDragEvent;+}++const SKILL = { id: "s1", title: "Review", content: "# Review\n\nCheck it.", hue: "amber" };++describe("carrying a skill", () => {+ it("loads its own type and the text, and reads back what was loaded", () => {+ const dt = transfer();+ loadSkillDrag(dt, SKILL);++ expect(dt.types).toEqual([SKILL_DRAG_TYPE, "text/plain"]);+ expect(dt.getData("text/plain")).toBe(SKILL.content);+ expect(dragCarriesSkill(dt)).toBe(true);+ expect(readSkillDrag(dt)).toEqual(SKILL);+ });++ it("reads junk under the skill type as no skill", () => {+ expect(readSkillDrag(transfer({ [SKILL_DRAG_TYPE]: "{not json" }))).toBeNull();+ expect(readSkillDrag(transfer({ [SKILL_DRAG_TYPE]: JSON.stringify({ id: 1 }) }))).toBeNull();+ });+});++describe("a terminal pane taking a skill", () => {+ it("arms for a skill drag and says what it carries", () => {+ const { result } = renderHook(() => usePaneFileDrag(vi.fn(), vi.fn()));+ const dt = transfer();+ loadSkillDrag(dt, SKILL);++ act(() => result.current.handlers.onDragEnter(dragEvent(dt)));++ expect(result.current.dragging).toBe(true);+ expect(result.current.carrying).toBe("skill");+ });++ it("stays quiet for a skill drag when it takes no skills", () => {+ const { result } = renderHook(() => usePaneFileDrag(vi.fn()));+ const dt = transfer();+ loadSkillDrag(dt, SKILL);++ act(() => result.current.handlers.onDragEnter(dragEvent(dt)));++ expect(result.current.dragging).toBe(false);+ });++ it("hands the dropped skill over instead of treating it as files", () => {+ const onFiles = vi.fn();+ const onSkill = vi.fn();+ const { result } = renderHook(() => usePaneFileDrag(onFiles, onSkill));+ const dt = transfer();+ loadSkillDrag(dt, SKILL);++ act(() => {+ result.current.handlers.onDragEnter(dragEvent(dt));+ result.current.handlers.onDrop(dragEvent(dt));+ });++ expect(onSkill).toHaveBeenCalledWith(SKILL);+ expect(onFiles).not.toHaveBeenCalled();+ expect(result.current.dragging).toBe(false);+ expect(result.current.carrying).toBeNull();+ });++ it("still takes files when it also takes skills", () => {+ const onFiles = vi.fn();+ const { result } = renderHook(() => usePaneFileDrag(onFiles, vi.fn()));+ const dt = transfer({ Files: "" });++ act(() => {+ result.current.handlers.onDragEnter(dragEvent(dt));+ });+ expect(result.current.carrying).toBe("files");+ act(() => result.current.handlers.onDrop(dragEvent(dt)));++ expect(onFiles).toHaveBeenCalledTimes(1);+ });+});++describe("pasting a skill's text", () => {+ const terminal = (bracketedPasteMode: boolean) => ({ paste: vi.fn(), focus: vi.fn(), modes: { bracketedPasteMode } });++ it("pastes into a terminal in bracketed-paste mode, lines and all", () => {+ const term = terminal(true);+ expect(pasteSkillText(term, "one\ntwo")).toBe(true);+ expect(term.paste).toHaveBeenCalledWith("one\ntwo");+ });++ it("refuses a multi-line text where every line would run as a command", () => {+ const term = terminal(false);+ expect(pasteSkillText(term, "one\ntwo")).toBe(false);+ expect(term.paste).not.toHaveBeenCalled();+ });++ it("pastes a single line anywhere: paste never adds the Enter", () => {+ const term = terminal(false);+ expect(pasteSkillText(term, "one line")).toBe(true);+ });+});diff --git a/jarvis/ui/web/frontend/src/components/agentic/skillDrag.ts b/jarvis/ui/web/frontend/src/components/agentic/skillDrag.tsnew file mode 100644index 0000000000..808f7178fb--- /dev/null+++ b/jarvis/ui/web/frontend/src/components/agentic/skillDrag.ts@@ -0,0 +1,107 @@+/**+ * Carrying a skill from the side panel's Skills tab to a terminal pane.+ *+ * A skill travels under its own drag type, the way an explorer row does+ * (`WORKSPACE_PATH_TYPE` in ./paneDrop): the pane recognises it during the+ * drag from `DataTransfer.types` alone, and only on the drop reads the+ * payload — browsers seal a drag's data until then. The text also rides along+ * as `text/plain`, so dropping a skill into any ordinary text field (or out of+ * the app) still hands over the Markdown.+ *+ * `text/plain` alone never arms a pane: that is what an accidental text drag+ * looks like (BUG-110), so the pane keys on the skill type, never on text.+ */++import { fill, translate } from "@/i18n";+import { useEventStore } from "@/store/events";++/** The drag type a skill card loads. */+export const SKILL_DRAG_TYPE = "application/x-jarvis-skill";++/**+ * The window event that pastes a skill into one named pane without a drag —+ * the card's "Paste into …" button, and the keyboard route to the same thing.+ */+export const PANE_PASTE_EVENT = "jarvis:ide-pane-paste";++export interface PanePasteDetail {+ workspaceId: string;+ pane: string;+ skill: SkillDragPayload;+}++/** What a dropped or pasted skill carries: enough to paste and to say what landed. */+export interface SkillDragPayload {+ id: string;+ title: string;+ content: string;+ hue: string;+}++/** Load a drag with one skill. */+export function loadSkillDrag(dt: DataTransfer, skill: SkillDragPayload): void {+ dt.effectAllowed = "copy";+ dt.setData(SKILL_DRAG_TYPE, JSON.stringify(skill));+ dt.setData("text/plain", skill.content);+}++/** Is a skill in this drag? Answerable mid-drag (types only). */+export function dragCarriesSkill(dt: DataTransfer | null): boolean {+ if (!dt) return false;+ return Array.from(dt.types ?? []).includes(SKILL_DRAG_TYPE);+}++/** The skill a drop carried, or null for anything else. Read synchronously. */+export function readSkillDrag(dt: DataTransfer | null): SkillDragPayload | null {+ if (!dt) return null;+ const raw = dt.getData(SKILL_DRAG_TYPE);+ if (!raw) return null;+ try {+ const value = JSON.parse(raw) as Partial<SkillDragPayload>;+ if (typeof value?.id !== "string" || typeof value.content !== "string") return null;+ return {+ id: value.id,+ title: typeof value.title === "string" ? value.title : "",+ content: value.content,+ hue: typeof value.hue === "string" ? value.hue : "blue",+ };+ } catch {+ // A foreign page faking the type with junk: not a skill, nothing to paste.+ return null;+ }+}++/** The slice of an xterm terminal a skill paste needs. */+export interface SkillPasteTerminal {+ paste(text: string): void;+ focus(): void;+ readonly modes: { readonly bracketedPasteMode: boolean };+}++/**+ * Paste a skill's text into a terminal — only where it cannot run by itself.+ *+ * A coding agent (Claude Code, Codex) turns on bracketed paste, so a+ * multi-line text arrives in its prompt as ONE block and waits there. A plain+ * shell that never turned it on reads every newline as Enter and would run+ * each Markdown line as a command. So a multi-line skill goes only into a+ * terminal in bracketed-paste mode; a single line is safe anywhere, since+ * `paste` never adds the final Enter. Returns whether the text was pasted.+ */+export function pasteSkillText(term: SkillPasteTerminal, text: string): boolean {+ if (!text) return false;+ if (text.includes("\n") && !term.modes.bracketedPasteMode) return false;+ term.paste(text);+ term.focus();+ return true;+}++/** Say why a skill did not land: the pane would have run it line by line. */+export function announceSkillRefused(pane: string): void {+ useEventStore.getState().pushToast("warning", fill(translate("ide_side_panel.skills.paste_refused"), { pane }));+}++/** Ask one pane to paste a skill, as a drop on it would. */+export function pasteSkillIntoPane(detail: PanePasteDetail): void {+ window.dispatchEvent(new CustomEvent<PanePasteDetail>(PANE_PASTE_EVENT, { detail }));+}diff --git a/jarvis/ui/web/frontend/src/components/workspace/WorkspaceTerminal.tsx b/jarvis/ui/web/frontend/src/components/workspace/WorkspaceTerminal.tsxindex 7c4dd75aef..d6821d1590 100644--- a/jarvis/ui/web/frontend/src/components/workspace/WorkspaceTerminal.tsx+++ b/jarvis/ui/web/frontend/src/components/workspace/WorkspaceTerminal.tsx@@ -7,13 +7,17 @@* Conventions copied from PtyTerminal: xterm instance in a ref (never state, or* it rerenders per chunk), dispose() on unmount (WebGL context cap).*/-import { useEffect, useRef, useState } from "react";+import { useCallback, useEffect, useRef, useState } from "react";import { Terminal } from "@xterm/xterm";import { FitAddon } from "@xterm/addon-fit";import { WebLinksAddon } from "@xterm/addon-web-links";import "@xterm/xterm/css/xterm.css";import { Terminal as TerminalIcon, AlertCircle } from "lucide-react";import { installNewlineBridge } from "../agentic/terminalNewline";+import { usePaneFileDrag } from "../agentic/paneFileDrag";+import { announceSkillRefused, pasteSkillText, type SkillDragPayload } from "../agentic/skillDrag";+import { SkillDropCard } from "../agentic/sidePanel/skills/SkillDropCard";+import { useIdeSkillsStore } from "@/store/ideSkills";import { requestConnect } from "@/lib/connectBudget";import { FONT_DEFAULT } from "../agentic/paneFont";import {@@ -269,8 +273,26 @@ export function WorkspaceTerminal({if (term) term.options.theme = themeFor(appearance);}, [appearance]);+ // A skill from the Skills tab, dropped here: one bracketed paste, not sent+ // (a plain shell without bracketed paste refuses a multi-line one).+ // Files have no route into a plain shell; the drop is only claimed so it+ // cannot navigate the IDE away.+ const pasteSkill = useCallback((skill: SkillDragPayload) => {+ const term = termRef.current;+ if (!term || !skill.content) return;+ if (!pasteSkillText(term, skill.content)) {+ announceSkillRefused(title);+ return;+ }+ useIdeSkillsStore.getState().recordUse(skill.id, title);+ }, [title]);+ const ignoreFiles = useCallback(() => {}, []);+ const { dragging, carrying, handlers: dragHandlers } = usePaneFileDrag(ignoreFiles, pasteSkill);+ const skillInFlight = useIdeSkillsStore((state) => (carrying === "skill" ? state.dragging : null));+return (<div+ {...dragHandlers}className="relative flex h-full w-full flex-col overflow-hidden rounded-lg border border-border"style={{ background: PANE_CHROME[appearance].shell }}>@@ -295,6 +317,8 @@ export function WorkspaceTerminal({</span></header><div ref={containerRef} className="flex-1 overflow-hidden p-1" />+ {dragging && carrying === "skill" && <SkillDropCard skill={skillInFlight} target={title}+ blocked={Boolean(skillInFlight?.multiline) && !termRef.current?.modes.bracketedPasteMode} />}{error && (<div className="border-t border-border bg-destructive/10 px-3 py-1.5 text-xs text-destructive">{error}diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.jsonindex 8794df1e6a..60e71730f1 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json@@ -6098,6 +6098,7 @@},"tabs": {"git": "Git",+ "skills": "Skills","agents": "Agents","files": "Ordner","changes": "Änderungen",@@ -6170,6 +6171,124 @@"seconds_ago": "vor {n} s","minutes_ago": "vor {n} min"},+ "skills": {+ "subtitle": "Auf ein Terminal ziehen, um ihn einzufügen",+ "new": "Neuer Skill",+ "new_short": "Neu",+ "paste_short": "Text einfügen",+ "import_short": ".md importieren",+ "add_examples": "Drei Beispiel-Skills hinzufügen",+ "drop_files_hint": "Oder Markdown-Dateien einfach hier ablegen.",+ "empty_title": "Deine Prompts, einen Zug entfernt",+ "empty_body": "Ein Skill ist ein Markdown-Text mit Titel. Zieh ihn auf ein Terminal, und er landet im Prompt des Agenten — eingefügt, nicht abgeschickt.",+ "search_placeholder": "Skills durchsuchen…",+ "search_label": "Skills durchsuchen",+ "search_clear": "Suche leeren",+ "sort_menu": "Skills sortieren",+ "sort_label": "Reihenfolge: {order}",+ "sort_manual": "Eigene Reihenfolge",+ "sort_used": "Meistgenutzt",+ "sort_recent": "Zuletzt genutzt",+ "sort_name": "A bis Z",+ "loading": "Skills werden geladen",+ "load_failed": "Skills konnten nicht geladen werden ({error}).",+ "retry": "Erneut versuchen",+ "no_match": "Kein Skill passt zu „{query}“.",+ "list_label": "Skills",+ "hint_dragging": "Auf ein Terminal ablegen — der Text wird eingefügt, nicht abgeschickt.",+ "hint_target": "⏎ fügt in {pane} ein",+ "hint_no_target": "Klick ein Terminal an, um festzulegen, wohin ⏎ einfügt.",+ "drop_files_title": "Ablegen zum Importieren",+ "drop_files_body": "Eine Datei öffnet sich im Editor, mehrere werden direkt gespeichert.",+ "drop_file_editor": "Ablegen, um den Text durch diese Datei zu ersetzen",+ "drop_eyebrow": "Skill einfügen",+ "drop_unknown": "Skill",+ "drop_into": "in {pane} · nicht abgeschickt",+ "drop_blocked": "{pane} würde jede Zeile als Befehl ausführen — öffne dort einen Coding-Agent",+ "paste_refused": "Nicht eingefügt: {pane} würde jede Zeile als Befehl ausführen. Leg den Skill stattdessen auf einen Coding-Agent.",+ "card_aria": "Skill {title}. Auf ein Terminal ziehen, Enter fügt ein, Leertaste öffnet.",+ "no_description": "Keine Beschreibung",+ "landed": "In {pane} eingefügt",+ "meta_lines": "Zeilen",+ "meta_tokens": "Ungefähre Tokens",+ "meta_used": "So oft eingefügt",+ "tokens_short": "~{n} Tok.",+ "used_short": "{n}×",+ "ghost_meta": "{lines} Zeilen · auf ein Terminal ziehen",+ "paste_into": "In {pane} einfügen",+ "paste_no_target": "Wähle zuerst ein Terminal aus",+ "more": "Weitere Aktionen für {title}",+ "more_short": "Mehr",+ "key_space": "Leertaste",+ "action_preview": "Öffnen",+ "action_edit": "Bearbeiten",+ "action_duplicate": "Duplizieren",+ "action_copy": "Text kopieren",+ "action_export": "Als .md-Datei speichern",+ "action_delete": "Löschen",+ "action_delete_confirm": "Zum Löschen erneut klicken",+ "copy_title": "{title} (Kopie)",+ "deleted": "„{title}“ gelöscht.",+ "copied": "„{title}“ kopiert.",+ "copy_failed": "Der Text konnte nicht kopiert werden.",+ "import_not_markdown": "Nur Markdown- oder Textdateien können Skills werden.",+ "imported": "{n} Skills importiert.",+ "clipboard_empty": "In der Zwischenablage ist kein Text.",+ "editor_new_aria": "Neuer Skill",+ "editor_edit_aria": "Skill {title} bearbeiten",+ "editor_eyebrow_new": "Neuer Skill",+ "editor_eyebrow_edit": "Skill",+ "title_placeholder": "Gib ihm einen Titel",+ "description_label": "Kurzbeschreibung",+ "description_placeholder": "Eine Zeile dazu, was er tut (optional)",+ "close": "Schließen",+ "colour_label": "Farbe",+ "icon_label": "Symbol",+ "view_label": "Ansicht",+ "view_write": "Schreiben",+ "view_preview": "Vorschau",+ "view_split": "Nebeneinander",+ "paste_clipboard": "Aus Zwischenablage einfügen",+ "import_file": "Markdown-Datei importieren",+ "content_placeholder": "Markdown hier einfügen oder schreiben — eine Checkliste, ein Hausstil, eine SKILL.md…",+ "preview_empty": "Noch nichts für die Vorschau.",+ "stat_lines": "{n} Zeilen",+ "stat_words": "{n} Wörter",+ "stat_tokens": "~{n} Tokens",+ "discard_question": "Änderungen verwerfen?",+ "discard_yes": "Verwerfen",+ "discard_keep": "Weiter bearbeiten",+ "cancel": "Abbrechen",+ "save_new": "Skill speichern",+ "save_changes": "Änderungen speichern",+ "save_and_paste": "Speichern und in {pane} einfügen",+ "hue": {+ "blue": "Blau",+ "violet": "Violett",+ "teal": "Petrol",+ "amber": "Bernstein",+ "rose": "Rosé",+ "green": "Grün",+ "magenta": "Magenta",+ "slate": "Schiefer"+ },+ "icon": {+ "auto": "Automatisch (aus dem Titel)",+ "sparkles": "Funkeln",+ "code": "Code",+ "bug": "Bug",+ "book": "Buch",+ "shield": "Schild",+ "rocket": "Rakete",+ "wand": "Zauberstab",+ "brain": "Gehirn",+ "flask": "Kolben",+ "palette": "Palette",+ "terminal": "Terminal",+ "git": "Git",+ "list": "Checkliste"+ }+ },"office": {"failed": "Das Jarvis Verse konnte nicht laden.","retry": "Erneut versuchen"diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.jsonindex a171d0654a..858f06e91b 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json@@ -6131,6 +6131,7 @@},"tabs": {"git": "Git",+ "skills": "Skills","agents": "Agents","files": "Folder","changes": "Changes",@@ -6203,6 +6204,124 @@"seconds_ago": "{n} s ago","minutes_ago": "{n} min ago"},+ "skills": {+ "subtitle": "Drag one onto a terminal to paste it",+ "new": "New skill",+ "new_short": "New",+ "paste_short": "Paste text",+ "import_short": "Import .md",+ "add_examples": "Add three example skills",+ "drop_files_hint": "Or drop Markdown files anywhere here.",+ "empty_title": "Your prompts, one drag away",+ "empty_body": "A skill is a Markdown text with a title. Drag it onto any terminal and it lands in the agent's prompt — pasted, not sent.",+ "search_placeholder": "Search skills…",+ "search_label": "Search skills",+ "search_clear": "Clear search",+ "sort_menu": "Sort skills",+ "sort_label": "Order: {order}",+ "sort_manual": "Your order",+ "sort_used": "Most used",+ "sort_recent": "Recently used",+ "sort_name": "A to Z",+ "loading": "Loading skills",+ "load_failed": "Skills could not be loaded ({error}).",+ "retry": "Try again",+ "no_match": "No skill matches “{query}”.",+ "list_label": "Skills",+ "hint_dragging": "Drop on any terminal — the text is pasted, not sent.",+ "hint_target": "⏎ pastes into {pane}",+ "hint_no_target": "Click a terminal to choose where ⏎ pastes.",+ "drop_files_title": "Drop to import",+ "drop_files_body": "One file opens in the editor; several are saved at once.",+ "drop_file_editor": "Drop to replace the text with this file",+ "drop_eyebrow": "Paste skill",+ "drop_unknown": "Skill",+ "drop_into": "into {pane} · not sent",+ "drop_blocked": "{pane} would run each line as a command — open a coding agent there",+ "paste_refused": "Not pasted: {pane} would run each line as a command. Drop the skill on a coding agent instead.",+ "card_aria": "Skill {title}. Drag onto a terminal, Enter pastes, Space opens.",+ "no_description": "No description",+ "landed": "Pasted into {pane}",+ "meta_lines": "Lines",+ "meta_tokens": "Approximate tokens",+ "meta_used": "Times pasted",+ "tokens_short": "~{n} tok",+ "used_short": "{n}×",+ "ghost_meta": "{lines} lines · drop on a terminal",+ "paste_into": "Paste into {pane}",+ "paste_no_target": "Select a terminal first",+ "more": "More actions for {title}",+ "more_short": "More",+ "key_space": "Space",+ "action_preview": "Open",+ "action_edit": "Edit",+ "action_duplicate": "Duplicate",+ "action_copy": "Copy text",+ "action_export": "Save as .md file",+ "action_delete": "Delete",+ "action_delete_confirm": "Click again to delete",+ "copy_title": "{title} (copy)",+ "deleted": "Deleted “{title}”.",+ "copied": "Copied “{title}”.",+ "copy_failed": "The text could not be copied.",+ "import_not_markdown": "Only Markdown or text files can become skills.",+ "imported": "Imported {n} skills.",+ "clipboard_empty": "The clipboard holds no text.",+ "editor_new_aria": "New skill",+ "editor_edit_aria": "Edit skill {title}",+ "editor_eyebrow_new": "New skill",+ "editor_eyebrow_edit": "Skill",+ "title_placeholder": "Give it a title",+ "description_label": "Short description",+ "description_placeholder": "One line on what it does (optional)",+ "close": "Close",+ "colour_label": "Colour",+ "icon_label": "Icon",+ "view_label": "View",+ "view_write": "Write",+ "view_preview": "Preview",+ "view_split": "Side by side",+ "paste_clipboard": "Paste from clipboard",+ "import_file": "Import Markdown file",+ "content_placeholder": "Paste or write Markdown here — a checklist, a house style, a SKILL.md…",+ "preview_empty": "Nothing to preview yet.",+ "stat_lines": "{n} lines",+ "stat_words": "{n} words",+ "stat_tokens": "~{n} tokens",+ "discard_question": "Discard your changes?",+ "discard_yes": "Discard",+ "discard_keep": "Keep editing",+ "cancel": "Cancel",+ "save_new": "Save skill",+ "save_changes": "Save changes",+ "save_and_paste": "Save and paste into {pane}",+ "hue": {+ "blue": "Blue",+ "violet": "Violet",+ "teal": "Teal",+ "amber": "Amber",+ "rose": "Rose",+ "green": "Green",+ "magenta": "Magenta",+ "slate": "Slate"+ },+ "icon": {+ "auto": "Automatic (from the title)",+ "sparkles": "Sparkles",+ "code": "Code",+ "bug": "Bug",+ "book": "Book",+ "shield": "Shield",+ "rocket": "Rocket",+ "wand": "Wand",+ "brain": "Brain",+ "flask": "Flask",+ "palette": "Palette",+ "terminal": "Terminal",+ "git": "Git",+ "list": "Checklist"+ }+ },"office": {"failed": "The Jarvis Verse could not load.","retry": "Try again"diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.jsonindex 5703b99427..b0431533fc 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json@@ -6098,6 +6098,7 @@},"tabs": {"git": "Git",+ "skills": "Skills","agents": "Agentes","files": "Carpeta","changes": "Cambios",@@ -6170,6 +6171,124 @@"seconds_ago": "hace {n} s","minutes_ago": "hace {n} min"},+ "skills": {+ "subtitle": "Arrástralo a un terminal para pegarlo",+ "new": "Nuevo skill",+ "new_short": "Nuevo",+ "paste_short": "Pegar texto",+ "import_short": "Importar .md",+ "add_examples": "Añadir tres skills de ejemplo",+ "drop_files_hint": "O suelta archivos Markdown aquí.",+ "empty_title": "Tus prompts, a un arrastre",+ "empty_body": "Un skill es un texto Markdown con título. Arrástralo a cualquier terminal y llega al prompt del agente — pegado, no enviado.",+ "search_placeholder": "Buscar skills…",+ "search_label": "Buscar skills",+ "search_clear": "Borrar búsqueda",+ "sort_menu": "Ordenar skills",+ "sort_label": "Orden: {order}",+ "sort_manual": "Tu orden",+ "sort_used": "Más usados",+ "sort_recent": "Usados recientemente",+ "sort_name": "De la A a la Z",+ "loading": "Cargando skills",+ "load_failed": "No se pudieron cargar los skills ({error}).",+ "retry": "Reintentar",+ "no_match": "Ningún skill coincide con “{query}”.",+ "list_label": "Skills",+ "hint_dragging": "Suéltalo en cualquier terminal — el texto se pega, no se envía.",+ "hint_target": "⏎ pega en {pane}",+ "hint_no_target": "Haz clic en un terminal para elegir dónde pega ⏎.",+ "drop_files_title": "Suelta para importar",+ "drop_files_body": "Un archivo se abre en el editor; varios se guardan de una vez.",+ "drop_file_editor": "Suelta para reemplazar el texto con este archivo",+ "drop_eyebrow": "Pegar skill",+ "drop_unknown": "Skill",+ "drop_into": "en {pane} · sin enviar",+ "drop_blocked": "{pane} ejecutaría cada línea como un comando — abre ahí un agente de código",+ "paste_refused": "No se pegó: {pane} ejecutaría cada línea como un comando. Suelta el skill en un agente de código.",+ "card_aria": "Skill {title}. Arrástralo a un terminal, Intro pega, Espacio abre.",+ "no_description": "Sin descripción",+ "landed": "Pegado en {pane}",+ "meta_lines": "Líneas",+ "meta_tokens": "Tokens aproximados",+ "meta_used": "Veces pegado",+ "tokens_short": "~{n} tok",+ "used_short": "{n}×",+ "ghost_meta": "{lines} líneas · suéltalo en un terminal",+ "paste_into": "Pegar en {pane}",+ "paste_no_target": "Selecciona primero un terminal",+ "more": "Más acciones para {title}",+ "more_short": "Más",+ "key_space": "Espacio",+ "action_preview": "Abrir",+ "action_edit": "Editar",+ "action_duplicate": "Duplicar",+ "action_copy": "Copiar texto",+ "action_export": "Guardar como archivo .md",+ "action_delete": "Eliminar",+ "action_delete_confirm": "Haz clic de nuevo para eliminar",+ "copy_title": "{title} (copia)",+ "deleted": "Se eliminó “{title}”.",+ "copied": "Se copió “{title}”.",+ "copy_failed": "No se pudo copiar el texto.",+ "import_not_markdown": "Solo los archivos Markdown o de texto pueden ser skills.",+ "imported": "Se importaron {n} skills.",+ "clipboard_empty": "El portapapeles no contiene texto.",+ "editor_new_aria": "Nuevo skill",+ "editor_edit_aria": "Editar el skill {title}",+ "editor_eyebrow_new": "Nuevo skill",+ "editor_eyebrow_edit": "Skill",+ "title_placeholder": "Ponle un título",+ "description_label": "Descripción breve",+ "description_placeholder": "Una línea sobre lo que hace (opcional)",+ "close": "Cerrar",+ "colour_label": "Color",+ "icon_label": "Icono",+ "view_label": "Vista",+ "view_write": "Escribir",+ "view_preview": "Vista previa",+ "view_split": "Lado a lado",+ "paste_clipboard": "Pegar del portapapeles",+ "import_file": "Importar archivo Markdown",+ "content_placeholder": "Pega o escribe Markdown aquí — una lista de control, una guía de estilo, un SKILL.md…",+ "preview_empty": "Todavía no hay nada que previsualizar.",+ "stat_lines": "{n} líneas",+ "stat_words": "{n} palabras",+ "stat_tokens": "~{n} tokens",+ "discard_question": "¿Descartar los cambios?",+ "discard_yes": "Descartar",+ "discard_keep": "Seguir editando",+ "cancel": "Cancelar",+ "save_new": "Guardar skill",+ "save_changes": "Guardar cambios",+ "save_and_paste": "Guardar y pegar en {pane}",+ "hue": {+ "blue": "Azul",+ "violet": "Violeta",+ "teal": "Verde azulado",+ "amber": "Ámbar",+ "rose": "Rosa",+ "green": "Verde",+ "magenta": "Magenta",+ "slate": "Pizarra"+ },+ "icon": {+ "auto": "Automático (según el título)",+ "sparkles": "Destellos",+ "code": "Código",+ "bug": "Error",+ "book": "Libro",+ "shield": "Escudo",+ "rocket": "Cohete",+ "wand": "Varita",+ "brain": "Cerebro",+ "flask": "Matraz",+ "palette": "Paleta",+ "terminal": "Terminal",+ "git": "Git",+ "list": "Lista de control"+ }+ },"office": {"failed": "No se pudo cargar el Jarvis Verse.","retry": "Reintentar"diff --git a/jarvis/ui/web/frontend/src/lib/ideSkillsApi.ts b/jarvis/ui/web/frontend/src/lib/ideSkillsApi.tsnew file mode 100644index 0000000000..9bedbe85da--- /dev/null+++ b/jarvis/ui/web/frontend/src/lib/ideSkillsApi.ts@@ -0,0 +1,86 @@+// REST client for the Agentic IDE's skill library (`/api/agentic-ide/skills`).+// Plain same-origin fetch with `no-store`, like the rest of the IDE's clients:+// WebView2 would otherwise serve a stale list after an edit.++/** The palette slots a skill can wear; the UI maps each onto theme tokens. */+export const SKILL_HUES = ["blue", "violet", "teal", "amber", "rose", "green", "magenta", "slate"] as const;+export type SkillHue = (typeof SKILL_HUES)[number];++/** The glyphs a skill can wear; "auto" picks one from the title. */+export const SKILL_ICONS = [+ "auto", "sparkles", "code", "bug", "book", "shield", "rocket", "wand", "brain", "flask", "palette", "terminal", "git", "list",+] as const;+export type SkillIcon = (typeof SKILL_ICONS)[number];++export interface IdeSkill {+ id: string;+ title: string;+ /** The Markdown pasted into a terminal, verbatim. */+ content: string;+ /** One line: the frontmatter description or the first prose line. */+ description: string;+ hue: SkillHue;+ icon: SkillIcon;+ created_at: string;+ updated_at: string;+ use_count: number;+ last_used_at: string | null;+}++export interface IdeSkillDraft {+ title: string;+ content: string;+ description?: string;+ hue?: SkillHue;+ icon?: SkillIcon;+}++const BASE = "/api/agentic-ide/skills";++async function detail(res: Response): Promise<string> {+ try {+ const body = (await res.json()) as { detail?: unknown };+ if (typeof body?.detail === "string" && body.detail) return body.detail;+ } catch {+ /* not JSON: the status line below is the best there is */+ }+ return `${res.status} ${res.statusText}`.trim();+}++async function call<T>(path: string, init?: RequestInit): Promise<T> {+ const res = await fetch(`${BASE}${path}`, {+ cache: "no-store",+ ...init,+ headers: init?.body ? { "Content-Type": "application/json", ...init.headers } : init?.headers,+ });+ if (!res.ok) throw new Error(await detail(res));+ return (await res.json()) as T;+}++export async function listIdeSkills(): Promise<IdeSkill[]> {+ return (await call<{ skills: IdeSkill[] }>("")).skills;+}++export function createIdeSkill(draft: IdeSkillDraft): Promise<IdeSkill> {+ return call<IdeSkill>("", { method: "POST", body: JSON.stringify(draft) });+}++export function updateIdeSkill(id: string, patch: Partial<IdeSkillDraft>): Promise<IdeSkill> {+ return call<IdeSkill>(`/${encodeURIComponent(id)}`, { method: "PATCH", body: JSON.stringify(patch) });+}++export async function deleteIdeSkill(id: string): Promise<void> {+ await call<{ removed: boolean }>(`/${encodeURIComponent(id)}`, { method: "DELETE" });+}++export function markIdeSkillUsed(id: string): Promise<IdeSkill> {+ return call<IdeSkill>(`/${encodeURIComponent(id)}/used`, { method: "POST" });+}++export async function reorderIdeSkills(ids: string[]): Promise<IdeSkill[]> {+ return (await call<{ skills: IdeSkill[] }>("/order", { method: "PUT", body: JSON.stringify({ ids }) })).skills;+}++export function deriveIdeSkillFields(content: string, filename = ""): Promise<{ title: string; description: string }> {+ return call("/derive", { method: "POST", body: JSON.stringify({ content, filename }) });+}diff --git a/jarvis/ui/web/frontend/src/store/ideSidePanel.ts b/jarvis/ui/web/frontend/src/store/ideSidePanel.tsindex c8809f077c..6d6ddf011e 100644--- a/jarvis/ui/web/frontend/src/store/ideSidePanel.ts+++ b/jarvis/ui/web/frontend/src/store/ideSidePanel.ts@@ -11,7 +11,7 @@ import { create } from "zustand";*//** Every function the panel can show. A new one is a new id plus a registry entry. */-export type SidePanelTabId = "agents" | "changes" | "files" | "git" | "office" | `terminal:${string}`;+export type SidePanelTabId = "agents" | "changes" | "files" | "git" | "skills" | "office" | `terminal:${string}`;export interface SidePanelTerminal {id: `terminal:${string}`;@@ -22,7 +22,7 @@ export interface SidePanelTerminal {export const MAX_TERMINAL_TABS = 16;-export const SIDE_PANEL_TAB_IDS: readonly SidePanelTabId[] = ["agents", "changes", "files", "git", "office"];+export const SIDE_PANEL_TAB_IDS: readonly SidePanelTabId[] = ["agents", "changes", "files", "git", "skills", "office"];const OPEN_KEY = "jarvis.agenticIde.sidePanelOpen";// v4: the panel starts with Agents alone and the other tabs are added fromdiff --git a/jarvis/ui/web/frontend/src/store/ideSkills.ts b/jarvis/ui/web/frontend/src/store/ideSkills.tsnew file mode 100644index 0000000000..357f3729c1--- /dev/null+++ b/jarvis/ui/web/frontend/src/store/ideSkills.ts@@ -0,0 +1,140 @@+import { create } from "zustand";+import {+ createIdeSkill,+ deleteIdeSkill,+ listIdeSkills,+ markIdeSkillUsed,+ reorderIdeSkills,+ updateIdeSkill,+ type IdeSkill,+ type IdeSkillDraft,+} from "@/lib/ideSkillsApi";++/**+ * The Agentic IDE's skill library, shared by the Skills tab and the panes.+ *+ * The tab lists and edits the skills; a pane that receives one (dropped or+ * sent with "Paste into …") reports the landing here, so the card that was+ * carried can say where it went and the use count moves at once. The pane a+ * button press pastes into is the grid's selected pane, which only the IDE+ * view knows — it publishes it as `target`.+ */++export interface SkillLanding {+ skillId: string;+ pane: string;+ at: number;+}++/** The skill being carried right now, for the overlays that cannot read the drag yet. */+export interface SkillInFlight {+ id: string;+ title: string;+ hue: string;+ icon: string;+ /** Spans lines: only a terminal in bracketed-paste mode may take it. */+ multiline: boolean;+}++export interface SkillPasteTarget {+ workspaceId: string;+ pane: string;+}++type LoadState = "idle" | "loading" | "ready" | "error";++interface IdeSkillsState {+ skills: IdeSkill[];+ status: LoadState;+ error: string | null;+ load: (force?: boolean) => Promise<void>;+ create: (draft: IdeSkillDraft) => Promise<IdeSkill>;+ update: (id: string, patch: Partial<IdeSkillDraft>) => Promise<IdeSkill>;+ remove: (id: string) => Promise<void>;+ /** Put the skill with `id` where `beforeId` stands (null = at the end). */+ move: (id: string, beforeId: string | null) => Promise<void>;+ landing: SkillLanding | null;+ /** A pane took a skill: count it and remember where it went. */+ recordUse: (skillId: string, pane: string) => void;+ dragging: SkillInFlight | null;+ setDragging: (skill: SkillInFlight | null) => void;+ target: SkillPasteTarget | null;+ setTarget: (target: SkillPasteTarget | null) => void;+}++let inflight: Promise<void> | null = null;++export const useIdeSkillsStore = create<IdeSkillsState>((set, get) => ({+ skills: [],+ status: "idle",+ error: null,+ load: async (force = false) => {+ if (inflight) return inflight;+ if (!force && get().status === "ready") return;+ set((state) => ({ status: state.status === "ready" ? "ready" : "loading", error: null }));+ inflight = listIdeSkills()+ .then((skills) => set({ skills, status: "ready", error: null }))+ .catch((error: unknown) => set({ status: "error", error: error instanceof Error ? error.message : String(error) }))+ .finally(() => { inflight = null; });+ return inflight;+ },+ create: async (draft) => {+ const skill = await createIdeSkill(draft);+ set((state) => ({ skills: [skill, ...state.skills.filter((entry) => entry.id !== skill.id)] }));+ return skill;+ },+ update: async (id, patch) => {+ const skill = await updateIdeSkill(id, patch);+ set((state) => ({ skills: state.skills.map((entry) => (entry.id === id ? skill : entry)) }));+ return skill;+ },+ remove: async (id) => {+ const before = get().skills;+ set({ skills: before.filter((entry) => entry.id !== id) });+ try {+ await deleteIdeSkill(id);+ } catch (error) {+ set({ skills: before });+ throw error;+ }+ },+ move: async (id, beforeId) => {+ const before = get().skills;+ const moving = before.find((entry) => entry.id === id);+ if (!moving || id === beforeId) return;+ const rest = before.filter((entry) => entry.id !== id);+ const at = beforeId ? rest.findIndex((entry) => entry.id === beforeId) : rest.length;+ const next = [...rest.slice(0, at < 0 ? rest.length : at), moving, ...rest.slice(at < 0 ? rest.length : at)];+ set({ skills: next });+ try {+ set({ skills: await reorderIdeSkills(next.map((entry) => entry.id)) });+ } catch (error) {+ set({ skills: before });+ throw error;+ }+ },+ landing: null,+ recordUse: (skillId, pane) => {+ const now = new Date().toISOString();+ set((state) => ({+ landing: { skillId, pane, at: Date.now() },+ skills: state.skills.map((entry) =>+ entry.id === skillId ? { ...entry, use_count: entry.use_count + 1, last_used_at: now } : entry,+ ),+ }));+ markIdeSkillUsed(skillId)+ .then((skill) => set((state) => ({ skills: state.skills.map((entry) => (entry.id === skillId ? skill : entry)) })))+ .catch((error: unknown) => {+ // The paste itself already happened; only the counter is behind.+ console.warn("Could not count a skill paste", error);+ });+ },+ dragging: null,+ setDragging: (dragging) => set({ dragging }),+ target: null,+ setTarget: (target) => {+ const current = get().target;+ if (current?.pane === target?.pane && current?.workspaceId === target?.workspaceId) return;+ set({ target });+ },+}));diff --git a/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx b/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsxindex 68c1f8dfe1..db10c458a8 100644--- a/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx+++ b/jarvis/ui/web/frontend/src/views/AgenticIdeView.tsx@@ -23,6 +23,7 @@ import { cn } from "@/lib/utils";import { useEventStore } from "@/store/events";import { useIdeChatStore } from "@/store/ideChat";import { useIdeProjectsStore } from "@/store/ideProjects";+import { useIdeSkillsStore } from "@/store/ideSkills";import { openProject } from "@/lib/chatLibraryApi";import {activateWorkspace, addTerminal, closeTerminal, closeWorkspace, fetchIdeAgents, fetchIdeProjects, fetchIdeState, renameWorkspace,@@ -215,6 +216,11 @@ export function AgenticIdeView({ onScreen = true }: AgenticIdeViewProps) {// Report the selected pane: it is the voice/prompt target, and the backend// saves it with the workspace so a reopened app restores the focus.const sessionId = session?.id ?? "";+ // The Skills tab pastes into the selected pane when a card's button is used.+ useEffect(() => {+ useIdeSkillsStore.getState().setTarget(sessionId && selected ? { workspaceId: sessionId, pane: selected } : null);+ }, [sessionId, selected]);+ useEffect(() => () => useIdeSkillsStore.getState().setTarget(null), []);useEffect(() => {if (!sessionId || !selected) return;void syncAgenticIdeSurface({ workspaceId: sessionId, view: "grid", onScreen, terminal: null, promptTarget: selected })