import { Meta, Source } from '@storybook/addon-docs/blocks'

<Meta title='@dxtmisha/en/figma-code/Functions/setupFrameSelection - Setup bidirectional selection'/>

# `setupFrameSelection`

Sets up bidirectional frame selection management between the Figma backend and the plugin UI. This single function handles both automatic tracking of what the user is currently looking at and programmatic selection from the interface.

1.  **Selection Tracking** — Automatically calls `makeFigmaFrameSelection()`, which starts observing user selection changes in Figma and sends detailed data (names, IDs, screenshots) to the UI.
2.  **Remote Control** — Registers a listener for the `UI_FIGMA_FRAME_SET_SELECTION` message. When the UI sends this message with an ID, the backend finds the object, selects it, and zooms the viewport to focus on it.

**Returns:**
`void`

## Examples

```typescript
import { setupFrameSelection } from '@dxtmisha/figma-code'

// Call this during plugin backend initialization
setupFrameSelection()
```
