--- name: context-chips description: Port or rebuild ANA's context chips — the Chip mode toggle that lets the user tap any on-screen item to attach it to the next chat message, the ✎ draw button that lets them circle things on the screen and send an annotated screenshot plus the items under the marks, and the ⟳ rescan button that registers newly added UI elements as chip targets. Use when the user says "컨텍스트 칩", "칩 모드", "그리기 버튼", "화면에 표시해서 보내기", "annotation", "요소 추가", "새로고침 버튼으로 칩 등록", or when ana-update reports context-chips / context-draw missing. --- # context-chips — point at the screen instead of describing it The user shouldn't have to type "the second task on the Tasks tab". They switch on **Chip**, tap the thing, and it rides along with the next message. Or they draw on the screen. ## UX spec ``` [logo] Work Requests Evolve PRD Update ( ◉ Chip ) (✎) (⟳) (A) │ │ └ profile, always right-aligned │ └ rescan: register new on-screen elements as chip targets └ draw: only shown while Chip is on, placed BEFORE ⟳ ``` - **Chip toggle:** a switch. While on, chip-able items get a subtle affordance (outline on hover/tap target). Tapping an item adds a chip above the chat input: `[Task] Book the venue ✕`. Tapping it again removes the chip. Chips are sent as a `Context:` block (`- [Kind] text`), and the chat log view turns them back into chips on the user's bubble. - **Screen chip:** there's always one chip describing the view: tab, scroll position, viewport size. - **✎ Draw (annotation):** covers the page with a canvas. The bar at the bottom has pen colors **red `#FF0000`, magenta `#FF00FF`, blue `#0000FF`**: pure hues the model recognizes reliably. Strokes are 5px color over a 9px white outline so they read on any background. Buttons: **Undo / Cancel / Add to chat**. Mostly used to circle things, like annotating a slide. - **Add to chat:** 1. Captures the page (`modern-screenshot`, served locally at `/vendor/modern-screenshot.mjs`) and composites the strokes on top. The capture is planned first (`shotPlan`): elements outside the visible part of `#main` are not cloned — ones above it stay as empty boxes of the same height so positions hold, ones below or beside are dropped — and only the style properties in `SHOT_PROPS` are copied. A 15,000-element list went from ~50 s to ~1 s. `features.restoreScrollPosition` is on (the library's default is off, which captured the top of a scrolled list), image loads time out at 8 s, and Safari's re-draw loop is capped at 3. **iframes** are captured separately: the library pastes the whole framed document in place of the frame, so its own scroll was lost. The page capture drops each visible `