From d79a12fa768fa68baca61503684c518e18aaffa1 Mon Sep 17 00:00:00 2001 From: Taylor Ho Date: Tue, 25 Aug 2026 12:16:37 -0700 Subject: [PATCH] Finish shared instruction picker rename Co-authored-by: Rizz <302abe414ca6e3134763d2539bfcf145aea2a63fe5f8455204ed602fd40cf381@buzz.block.builderlab.xyz> Signed-off-by: Taylor Ho --- .../agents/ui/AgentInstructionsField.tsx | 2 +- .../agents/ui/SharedInstructionPicker.tsx | 104 ++++++++++-------- .../ui/SharedInstructionPreviewButton.tsx | 16 +-- 3 files changed, 69 insertions(+), 53 deletions(-) diff --git a/desktop/src/features/agents/ui/AgentInstructionsField.tsx b/desktop/src/features/agents/ui/AgentInstructionsField.tsx index bbf63157f6..69592908fd 100644 --- a/desktop/src/features/agents/ui/AgentInstructionsField.tsx +++ b/desktop/src/features/agents/ui/AgentInstructionsField.tsx @@ -56,7 +56,7 @@ export function AgentInstructionsField({ labelFor="persona-system-prompt" onChange={onAssignedSharedInstructionsChange} onEdit={onEditSharedInstruction} - publishedSkills={publishedSharedInstructions} + publishedInstructions={publishedSharedInstructions} selected={assignedSharedInstructions} > {textarea( diff --git a/desktop/src/features/agents/ui/SharedInstructionPicker.tsx b/desktop/src/features/agents/ui/SharedInstructionPicker.tsx index 87718d7dec..d2649c9a8e 100644 --- a/desktop/src/features/agents/ui/SharedInstructionPicker.tsx +++ b/desktop/src/features/agents/ui/SharedInstructionPicker.tsx @@ -27,7 +27,7 @@ type SharedInstructionPickerProps = { selected: readonly string[]; onChange: (coordinates: string[]) => void; onEdit: (detail: ResolvedSharedInstruction | null) => void; - publishedSkills: readonly SharedInstructionCover[]; + publishedInstructions: readonly SharedInstructionCover[]; }; type LoadState = "loading" | "ready" | "error"; @@ -40,16 +40,18 @@ export function SharedInstructionPicker({ selected, onChange, onEdit, - publishedSkills, + publishedInstructions, }: SharedInstructionPickerProps) { - const [skills, setSkills] = React.useState([]); + const [instructions, setInstructions] = React.useState< + SharedInstructionCover[] + >([]); const [loadState, setLoadState] = React.useState("loading"); const [pickerOpen, setPickerOpen] = React.useState(false); - const loadSkills = React.useCallback(async () => { + const loadInstructions = React.useCallback(async () => { setLoadState("loading"); try { - setSkills(await listMySharedInstructions()); + setInstructions(await listMySharedInstructions()); setLoadState("ready"); } catch { setLoadState("error"); @@ -57,40 +59,46 @@ export function SharedInstructionPicker({ }, []); React.useEffect(() => { - void loadSkills(); - }, [loadSkills]); + void loadInstructions(); + }, [loadInstructions]); - const visibleSkills = React.useMemo( + const visibleInstructions = React.useMemo( () => [ - ...publishedSkills, - ...skills.filter( - (skill) => - !publishedSkills.some( - (published) => published.coordinate === skill.coordinate, + ...publishedInstructions, + ...instructions.filter( + (instruction) => + !publishedInstructions.some( + (published) => published.coordinate === instruction.coordinate, ), ), ], - [publishedSkills, skills], + [publishedInstructions, instructions], ); const knownCoordinates = React.useMemo( - () => new Set(visibleSkills.map((skill) => skill.coordinate)), - [visibleSkills], + () => + new Set(visibleInstructions.map((instruction) => instruction.coordinate)), + [visibleInstructions], ); const unknownSelected = loadState === "ready" ? selected.filter((coordinate) => !knownCoordinates.has(coordinate)) : []; - const selectedSkills = selected + const selectedInstructions = selected .map((coordinate) => - visibleSkills.find((skill) => skill.coordinate === coordinate), + visibleInstructions.find( + (instruction) => instruction.coordinate === coordinate, + ), ) - .filter((skill): skill is SharedInstructionCover => skill !== undefined); - const hasSelectedSkills = - selectedSkills.length > 0 || unknownSelected.length > 0; + .filter( + (instruction): instruction is SharedInstructionCover => + instruction !== undefined, + ); + const hasSelectedInstructions = + selectedInstructions.length > 0 || unknownSelected.length > 0; - function toggleSkill(skill: SharedInstructionCover) { + function toggleInstruction(instruction: SharedInstructionCover) { if (disabled) return; - const next = toggleSharedInstructionCoordinate(selected, skill); + const next = toggleSharedInstructionCoordinate(selected, instruction); if ( next.length !== selected.length || next.some((coordinate, index) => coordinate !== selected[index]) @@ -112,7 +120,7 @@ export function SharedInstructionPicker({ function renderPickerIngress() { if (loadState !== "ready") return null; - if (visibleSkills.length === 0) { + if (visibleInstructions.length === 0) { return ( diff --git a/desktop/src/features/agents/ui/SharedInstructionPreviewButton.tsx b/desktop/src/features/agents/ui/SharedInstructionPreviewButton.tsx index 388ebdc4b4..5df0efa516 100644 --- a/desktop/src/features/agents/ui/SharedInstructionPreviewButton.tsx +++ b/desktop/src/features/agents/ui/SharedInstructionPreviewButton.tsx @@ -37,7 +37,7 @@ type SharedInstructionPreviewButtonProps = Omit< previewAlign?: React.ComponentProps["align"]; previewOnFocus?: boolean; previewSide?: React.ComponentProps["side"]; - skill: SharedInstructionCover; + instruction: SharedInstructionCover; }; type PreviewState = "idle" | "loading" | "ready" | "error"; @@ -54,7 +54,7 @@ export function SharedInstructionPreviewButton({ previewAlign = "center", previewOnFocus = true, previewSide = "top", - skill, + instruction, ...buttonProps }: SharedInstructionPreviewButtonProps) { const [open, setOpen] = React.useState(false); @@ -63,7 +63,8 @@ export function SharedInstructionPreviewButton({ null, ); const currentDetail = - detail?.coordinate === skill.coordinate && detail.eventId === skill.eventId + detail?.coordinate === instruction.coordinate && + detail.eventId === instruction.eventId ? detail : null; const contentRef = React.useRef(null); @@ -152,7 +153,7 @@ export function SharedInstructionPreviewButton({ let active = true; setPreviewState("loading"); - void resolveSharedInstructions([skill.coordinate]) + void resolveSharedInstructions([instruction.coordinate]) .then(([resolved]) => { if (!active) return; setDetail(resolved ?? null); @@ -167,10 +168,11 @@ export function SharedInstructionPreviewButton({ return () => { active = false; }; - }, [currentDetail, open, skill.coordinate]); + }, [currentDetail, open, instruction.coordinate]); - const displayTitle = currentDetail?.title || skill.title || skill.slug; - const displaySummary = currentDetail?.summary || skill.summary; + const displayTitle = + currentDetail?.title || instruction.title || instruction.slug; + const displaySummary = currentDetail?.summary || instruction.summary; const focusPreviewOnTab = (event: React.KeyboardEvent) => { if (event.key !== "Tab" || event.shiftKey || !open) return; event.preventDefault();