## ADDED Requirements ### Requirement: Resolve AI config before chat Study AI surfaces on iPad (and desktop when present) SHALL resolve a usable `AiRuntimeConfig` via the sync rules before sending model requests. Requests MUST go from the client to the configured `baseUrl` (client direct-connect) using the resolved apiKey, not by posting the apiKey to the PC on every question. #### Scenario: Direct connect - **WHEN** the user submits an AI question with a resolved config - **THEN** the client calls the model endpoint at the configured baseUrl without uploading the apiKey to the PC as part of that question ### Requirement: PDF region ask When `features.pdfChat` is enabled, the study UI SHALL allow selecting a rectangular region on a PDF page, capturing that region as image context, combining it with the user question and `prompts.pdfAsk`, and sending it to the model. #### Scenario: PDF rectangle question - **WHEN** the learner selects a rectangle on a PDF page and submits a question - **THEN** the app includes cropped page imagery and the pdfAsk prompt context in the model request ### Requirement: Audio/video clip ask When `features.audioClipAsk` or `features.videoRegionAsk` is enabled, the study UI SHALL allow setting in/out points on audio or video, combining time range metadata with the user question and the matching prompt, and sending it to the model. #### Scenario: Clip in/out question - **WHEN** the learner sets start and end on an audio or video item and submits a question - **THEN** the app includes the time range and the corresponding prompt in the model request ### Requirement: Feature gating AI study affordances MUST be hidden or disabled when the corresponding feature flag is off or when no usable config can be resolved. #### Scenario: Missing config disables AI - **WHEN** no usable AiRuntimeConfig is available - **THEN** the study AI entry points show unavailable messaging instead of sending requests