From 60608f4dc1b0ca49236162f1d8a6d45231ff0232 Mon Sep 17 00:00:00 2001 From: Taylor Ho Date: Tue, 25 Aug 2026 00:51:25 -0700 Subject: [PATCH] fix(agents): refresh edited shared instruction previews Invalidate cached detail when a replaceable note gets a new event ID, and cover the edit-preview-edit path end to end. Co-authored-by: Rizz <302abe414ca6e3134763d2539bfcf145aea2a63fe5f8455204ed602fd40cf381@buzz.block.builderlab.xyz> Signed-off-by: Taylor Ho --- .../agents/ui/RelaySkillPreviewButton.tsx | 20 ++++++++----- desktop/src/testing/e2eBridge.ts | 30 +++++++++++++++++-- desktop/tests/e2e/agents.spec.ts | 24 +++++++++++---- 3 files changed, 58 insertions(+), 16 deletions(-) diff --git a/desktop/src/features/agents/ui/RelaySkillPreviewButton.tsx b/desktop/src/features/agents/ui/RelaySkillPreviewButton.tsx index 66e3798e9f..621edf6416 100644 --- a/desktop/src/features/agents/ui/RelaySkillPreviewButton.tsx +++ b/desktop/src/features/agents/ui/RelaySkillPreviewButton.tsx @@ -60,6 +60,10 @@ export function RelaySkillPreviewButton({ const [open, setOpen] = React.useState(false); const [previewState, setPreviewState] = React.useState("idle"); const [detail, setDetail] = React.useState(null); + const currentDetail = + detail?.coordinate === skill.coordinate && detail.eventId === skill.eventId + ? detail + : null; const contentRef = React.useRef(null); const hoverTimerRef = React.useRef | null>( null, @@ -140,7 +144,7 @@ export function RelaySkillPreviewButton({ }, [clearHoverTimer, closeWithDelay, open]); React.useEffect(() => { - if (!open || detail?.coordinate === skill.coordinate) { + if (!open || currentDetail) { return; } @@ -161,10 +165,10 @@ export function RelaySkillPreviewButton({ return () => { active = false; }; - }, [detail?.coordinate, open, skill.coordinate]); + }, [currentDetail, open, skill.coordinate]); - const displayTitle = detail?.title || skill.title || skill.slug; - const displaySummary = detail?.summary || skill.summary; + const displayTitle = currentDetail?.title || skill.title || skill.slug; + const displaySummary = currentDetail?.summary || skill.summary; const focusPreviewOnTab = (event: React.KeyboardEvent) => { if (event.key !== "Tab" || event.shiftKey || !open) return; event.preventDefault(); @@ -271,14 +275,14 @@ export function RelaySkillPreviewButton({
Shared instruction
- {onEdit && detail?.editable ? ( + {onEdit && currentDetail?.editable ? (