diff --git a/internal/server/handler_install.go b/internal/server/handler_install.go index d865ddc2b..5bc94a668 100644 --- a/internal/server/handler_install.go +++ b/internal/server/handler_install.go @@ -87,6 +87,7 @@ func (s *Server) handleInstallBatch(w http.ResponseWriter, r *http.Request) { Force bool `json:"force"` SkipAudit bool `json:"skipAudit"` Into string `json:"into"` + Name string `json:"name"` } if err := json.NewDecoder(r.Body).Decode(&body); err != nil { writeError(w, http.StatusBadRequest, "invalid JSON body") @@ -130,13 +131,8 @@ func (s *Server) handleInstallBatch(w http.ResponseWriter, r *http.Request) { } } - // Cross-path duplicate detection - if !body.Force && source.CloneURL != "" { - if err := install.CheckCrossPathDuplicate(s.cfg.Source, source.CloneURL, body.Into); err != nil { - writeError(w, http.StatusConflict, err.Error()) - return - } - } + // Note: no cross-path duplicate check for batch — user explicitly selected + // specific skills from discovery, so installing to a different path is intentional. results := make([]batchResultItem, 0, len(body.Skills)) installOpts := install.InstallOptions{ @@ -148,20 +144,24 @@ func (s *Server) handleInstallBatch(w http.ResponseWriter, r *http.Request) { installOpts.AuditProjectRoot = s.projectRoot } for _, sel := range body.Skills { - destPath := filepath.Join(s.cfg.Source, body.Into, sel.Name) + skillName := sel.Name + if body.Name != "" && len(body.Skills) == 1 { + skillName = body.Name + } + destPath := filepath.Join(s.cfg.Source, body.Into, skillName) res, err := install.InstallFromDiscovery(discovery, install.SkillInfo{ Name: sel.Name, Path: sel.Path, }, destPath, installOpts) if err != nil { results = append(results, batchResultItem{ - Name: sel.Name, + Name: skillName, Error: err.Error(), }) continue } results = append(results, batchResultItem{ - Name: sel.Name, + Name: skillName, Action: res.Action, Warnings: res.Warnings, }) diff --git a/ui/src/api/client.ts b/ui/src/api/client.ts index 3834468e2..ffdc07029 100644 --- a/ui/src/api/client.ts +++ b/ui/src/api/client.ts @@ -244,7 +244,7 @@ export const api = { method: 'POST', body: JSON.stringify(opts), }), - installBatch: (opts: { source: string; skills: DiscoveredSkill[]; force?: boolean; skipAudit?: boolean; into?: string }) => + installBatch: (opts: { source: string; skills: DiscoveredSkill[]; force?: boolean; skipAudit?: boolean; into?: string; name?: string }) => apiFetch('/install/batch', { method: 'POST', body: JSON.stringify(opts), diff --git a/ui/src/components/InstallForm.tsx b/ui/src/components/InstallForm.tsx index d519c7773..86c1f7bfb 100644 --- a/ui/src/components/InstallForm.tsx +++ b/ui/src/components/InstallForm.tsx @@ -122,7 +122,6 @@ export default function InstallForm({ const [severityFilter, setSeverityFilter] = useState(null); const resetForm = () => { - setSource(''); setName(''); setInto(''); setTrack(false); @@ -264,6 +263,7 @@ export default function InstallForm({ const allWarnings: string[] = []; const auditFindings: string[] = []; const auditBlockedSkills: DiscoveredSkill[] = []; + let installed = 0; for (const item of res.results) { if (item.error) { if (isAuditBlock(item.error)) { @@ -273,14 +273,19 @@ export default function InstallForm({ } else { toast(`${item.name}: ${item.error}`, 'error'); } + } else { + installed++; } if (item.warnings?.length) allWarnings.push(...item.warnings.map((w) => `${item.name}: ${w}`)); } - toast(res.summary, auditBlockedSkills.length > 0 ? 'warning' : 'success'); - if (allWarnings.length > 0) setWarningDialog(allWarnings); - resetForm(); - invalidateAfterInstall(); - onSuccess?.({ action: 'installed', warnings: [], skillName: res.summary }); + if (installed > 0) { + const variant = auditBlockedSkills.length > 0 ? 'warning' : 'success'; + toast(res.summary, variant as 'success' | 'warning'); + if (allWarnings.length > 0) setWarningDialog(allWarnings); + resetForm(); + invalidateAfterInstall(); + onSuccess?.({ action: 'installed', warnings: [], skillName: res.summary }); + } if (auditBlockedSkills.length > 0) { setAuditDialog({ findings: auditFindings, @@ -314,10 +319,12 @@ export default function InstallForm({ into: into.trim() || undefined, force, skipAudit, + name: selected.length === 1 && name.trim() ? name.trim() : undefined, }); const allWarnings: string[] = []; const auditFindings: string[] = []; const auditBlockedSkills: DiscoveredSkill[] = []; + let installed = 0; for (const item of res.results) { if (item.error) { if (isAuditBlock(item.error)) { @@ -327,16 +334,22 @@ export default function InstallForm({ } else { toast(`${item.name}: ${item.error}`, 'error'); } + } else { + installed++; } if (item.warnings?.length) allWarnings.push(...item.warnings.map((w) => `${item.name}: ${w}`)); } - // Always show summary toast - toast(res.summary, auditBlockedSkills.length > 0 ? 'warning' : 'success'); - if (allWarnings.length > 0) setWarningDialog(allWarnings); - setShowPicker(false); - resetForm(); - invalidateAfterInstall(); - onSuccess?.({ action: 'installed', warnings: [], skillName: res.summary }); + + // Only show summary + close picker when at least one skill installed + if (installed > 0) { + const variant = auditBlockedSkills.length > 0 ? 'warning' : 'success'; + toast(res.summary, variant as 'success' | 'warning'); + if (allWarnings.length > 0) setWarningDialog(allWarnings); + setShowPicker(false); + resetForm(); + invalidateAfterInstall(); + onSuccess?.({ action: 'installed', warnings: [], skillName: res.summary }); + } // Show audit dialog for blocked items only (force-retry targets just those) if (auditBlockedSkills.length > 0) { setAuditDialog({ @@ -395,13 +408,16 @@ export default function InstallForm({ {/* Optional overrides */}
- setName(e.target.value)} - /> +
+ setName(e.target.value)} + /> +

Only applies to single skill install

+
setShowPicker(false)} installing={batchInstalling} + singleSelect={!!name.trim()} /> ); @@ -492,13 +509,13 @@ export default function InstallForm({ style={{ borderRadius: radius.md }} > {f.skillName &&
{f.skillName}
} -
+
{f.severity} - {f.description} + {f.description}
{f.snippets.length > 0 && (
@@ -555,13 +572,13 @@ export default function InstallForm({ style={{ borderRadius: radius.md }} > {f.skillName &&
{f.skillName}
} -
+
{f.severity} - {f.description} + {f.description}
{f.snippets.length > 0 && (
diff --git a/ui/src/components/SkillPickerModal.tsx b/ui/src/components/SkillPickerModal.tsx index 25f896d3d..30ed8654c 100644 --- a/ui/src/components/SkillPickerModal.tsx +++ b/ui/src/components/SkillPickerModal.tsx @@ -13,6 +13,7 @@ interface SkillPickerModalProps { onInstall: (selected: DiscoveredSkill[]) => void; onCancel: () => void; installing: boolean; + singleSelect?: boolean; } export default function SkillPickerModal({ @@ -22,6 +23,7 @@ export default function SkillPickerModal({ onInstall, onCancel, installing, + singleSelect, }: SkillPickerModalProps) { const [selected, setSelected] = useState>(new Set()); const [filter, setFilter] = useState(''); @@ -37,13 +39,13 @@ export default function SkillPickerModal({ ); }, [skills, filter]); - // Select all by default when modal opens; reset filter + // Reset selection when modal opens useEffect(() => { if (open) { - setSelected(new Set(skills.map((s) => s.path))); + setSelected(singleSelect ? new Set() : new Set(skills.map((s) => s.path))); setFilter(''); } - }, [open, skills]); + }, [open, skills, singleSelect]); if (!open) return null; @@ -61,6 +63,11 @@ export default function SkillPickerModal({ }; const toggle = (path: string) => { + if (singleSelect) { + // Radio behavior: only one selected at a time + setSelected(selected.has(path) ? new Set() : new Set([path])); + return; + } const next = new Set(selected); if (next.has(path)) { next.delete(path); @@ -76,9 +83,9 @@ export default function SkillPickerModal({ }; return ( - +

- Select Skills to Install + {singleSelect ? 'Select a Skill to Install' : 'Select Skills to Install'}

{source} @@ -102,51 +109,76 @@ export default function SkillPickerModal({

)} - {/* Select All */} -
- - {filter && ( + {/* Select All (multi-select only) */} + {!singleSelect && ( +
+ + {filter && ( + + {filtered.length} of {skills.length} skills + + )} +
+ )} + + {/* Single-select hint */} + {singleSelect && ( +
- {filtered.length} of {skills.length} skills + Custom name is set — select one skill + {filter && ` (${filtered.length} of ${skills.length})`} - )} -
+
+ )} {/* Skill list */}
- {filtered.map((skill) => ( - + ); + })}
{/* Footer */} @@ -167,7 +199,7 @@ export default function SkillPickerModal({ loading={installing} > - Install Selected ({selected.size}) + {singleSelect ? 'Install' : `Install Selected (${selected.size})`}
diff --git a/ui/src/components/Toast.tsx b/ui/src/components/Toast.tsx index 9847e4c71..32826fbd8 100644 --- a/ui/src/components/Toast.tsx +++ b/ui/src/components/Toast.tsx @@ -135,7 +135,7 @@ export function ToastProvider({ children }: { children: ReactNode }) { {children} {/* Toast container */} -
+
{toasts.map((t) => ( ))} diff --git a/ui/src/components/Tooltip.tsx b/ui/src/components/Tooltip.tsx index 7ab701850..bb4b056cf 100644 --- a/ui/src/components/Tooltip.tsx +++ b/ui/src/components/Tooltip.tsx @@ -1,44 +1,85 @@ -import { useState, useRef, useCallback, type ReactNode } from 'react'; +import { useState, useRef, useCallback, useLayoutEffect, type ReactNode } from 'react'; import { createPortal } from 'react-dom'; interface TooltipProps { children: ReactNode; content: string; side?: 'top' | 'bottom'; + followCursor?: boolean; } -export default function Tooltip({ children, content, side = 'bottom' }: TooltipProps) { +const OFFSET = 12; +const MARGIN = 8; + +export default function Tooltip({ children, content, side = 'bottom', followCursor }: TooltipProps) { const [pos, setPos] = useState<{ x: number; y: number } | null>(null); const timerRef = useRef>(undefined); + const visibleRef = useRef(false); + const tooltipRef = useRef(null); + + // Render at (0,0) hidden → measure natural size → clamp → show + useLayoutEffect(() => { + const el = tooltipRef.current; + if (!el || !pos) return; + + const w = el.offsetWidth; + const h = el.offsetHeight; + const vw = window.innerWidth; + const vh = window.innerHeight; + + let x = pos.x; + let y = pos.y; + if (x + w > vw - MARGIN) x = pos.x - w - OFFSET * 2; + if (x < MARGIN) x = MARGIN; + if (y + h > vh - MARGIN) y = pos.y - h - OFFSET * 2; + if (y < MARGIN) y = MARGIN; + + el.style.left = `${x}px`; + el.style.top = `${y}px`; + el.style.visibility = 'visible'; + }, [pos]); const show = useCallback((e: React.MouseEvent) => { - const rect = (e.currentTarget as HTMLElement).getBoundingClientRect(); - timerRef.current = setTimeout(() => { - setPos({ - x: rect.left, - y: side === 'top' ? rect.top - 4 : rect.bottom + 4, - }); - }, 200); - }, [side]); + if (followCursor) { + const x = e.clientX + OFFSET; + const y = e.clientY + OFFSET; + timerRef.current = setTimeout(() => { + visibleRef.current = true; + setPos({ x, y }); + }, 200); + } else { + const rect = (e.currentTarget as HTMLElement).getBoundingClientRect(); + timerRef.current = setTimeout(() => { + setPos({ + x: rect.left, + y: side === 'top' ? rect.top - 4 : rect.bottom + 4, + }); + }, 200); + } + }, [side, followCursor]); + + const move = useCallback((e: React.MouseEvent) => { + if (visibleRef.current) { + setPos({ x: e.clientX + OFFSET, y: e.clientY + OFFSET }); + } + }, []); const hide = useCallback(() => { if (timerRef.current) clearTimeout(timerRef.current); + visibleRef.current = false; setPos(null); }, []); return ( <> - + {children} {pos && createPortal(
{content}
, diff --git a/ui/src/pages/AnalyzePage.tsx b/ui/src/pages/AnalyzePage.tsx index e359b4e8f..74f194dca 100644 --- a/ui/src/pages/AnalyzePage.tsx +++ b/ui/src/pages/AnalyzePage.tsx @@ -359,18 +359,18 @@ function TopHeaviestChart({ skills }: { skills: AnalyzeSkill[] }) {
{sorted.map((skill, idx) => { const pct = maxTokens > 0 ? (skill.description_tokens / maxTokens) * 100 : 0; - const tooltipText = `Description: ${formatTokens(skill.description_tokens)} tokens\nBody: ${formatTokens(skill.body_tokens)} tokens\nTotal: ${formatTokens(skill.description_tokens + skill.body_tokens)} tokens`; + const tooltipText = `${skill.path}\n---\nDescription: ${formatTokens(skill.description_tokens)} tokens\nBody: ${formatTokens(skill.body_tokens)} tokens\nTotal: ${formatTokens(skill.description_tokens + skill.body_tokens)} tokens`; return ( - -
+ +
{idx + 1} - {skill.name} + {skill.path}
- {skill.name} + {skill.path} {skill.is_tracked && tracked}
@@ -777,7 +777,7 @@ function SkillDetailDialog({
-

{skill.name}

+

{skill.path}

{skill.is_tracked && tracked}