| @@ -1,4 +1,5 @@ | ||
| 1 | +import { useCanvasOpen } from '@agent/components/Canvas'; | |
| 1 | 2 | import { useDraggable } from '@agent/hooks/useDraggable'; |
| 2 | 3 | import { usePortal } from '@agent/hooks/usePortal'; |
| 3 | 4 | import { useResizable } from '@agent/hooks/useResizable'; |
| 4 | 5 | import { useGlobalStore } from '@agent/state/global'; |
| @@ -33,8 +34,10 @@ | ||
| 33 | 34 | open, |
| 34 | 35 | initialPosition: usePositionStore.getState(), |
| 35 | 36 | onDragEnd: (x, y) => { |
| 36 | 37 | usePositionStore.getState().setPosition(x, y); |
| 38 | + // External contract: no in-repo listener by design — emitted for | |
| 39 | + // host-page/analytics consumers (mirrors the consumed :resize-end below). | |
| 37 | 40 | window.dispatchEvent( |
| 38 | 41 | new CustomEvent('extendify-agent:drag-end', { detail: { x, y } }), |
| 39 | 42 | ); |
| 40 | 43 | }, |
| @@ -62,10 +65,14 @@ | ||
| 62 | 65 | observer.observe(el); |
| 63 | 66 | return () => observer.disconnect(); |
| 64 | 67 | }, [el, open, setOpen]); |
| 65 | 68 | |
| 69 | + const canvasOpen = useCanvasOpen(); | |
| 70 | + | |
| 66 | 71 | const closeAgent = () => { |
| 67 | 72 | setOpen(false); |
| 73 | + // External contract: no in-repo listener by design — notifies | |
| 74 | + // host-page/analytics consumers the user dismissed the agent. | |
| 68 | 75 | window.dispatchEvent(new CustomEvent('extendify-agent:closed-button')); |
| 69 | 76 | }; |
| 70 | 77 | |
| 71 | 78 | if (!mountNode || !open) return null; |
| @@ -98,11 +105,12 @@ | ||
| 98 | 105 | <div className="opacity-0 transition-opacity duration-300 group-hover:opacity-100"> |
| 99 | 106 | <DragButton /> |
| 100 | 107 | </div> |
| 101 | 108 | </div> |
| 109 | + {/* Only hidden: removing it shifts the drag handle to the edge. */} | |
| 102 | 110 | <button |
| 103 | 111 | type="button" |
| 104 | - className="relative z-10 flex h-full items-center rounded-none border-0 bg-banner-main py-3 pe-4 ps-2 text-banner-text outline-hidden ring-design-main focus:shadow-none focus:outline-hidden focus-visible:outline-design-main" | |
| 112 | + className={`relative z-10 flex h-full items-center rounded-none border-0 bg-banner-main py-3 pe-4 ps-2 text-banner-text outline-hidden ring-design-main focus:shadow-none focus:outline-hidden focus-visible:outline-design-main ${canvasOpen ? 'invisible' : ''}`} | |
| 105 | 113 | onClick={closeAgent} |
| 106 | 114 | > |
| 107 | 115 | <Icon |
| 108 | 116 | className="pointer-events-none fill-current leading-none" |