@@ -143,24 +143,31 @@ function collectKeyboardChrome(nodes: SnapshotNode[]): SettleChrome {
143143 }
144144 // Preserve app-owned accessory controls hosted above the keyboard: they were
145145 // swept in by the whole-window pass but are not keyboard chrome.
146- for ( const index of collectKeyboardAccessoryIndexes (
146+ const accessoryExemptIndexes = collectKeyboardAccessoryIndexes (
147147 nodes ,
148148 byIndex ,
149149 windowIndexes ,
150150 containerIndexes ,
151151 containerSubtreeIndexes ,
152- ) ) {
152+ ) ;
153+ for ( const index of accessoryExemptIndexes ) {
153154 chromeIndexes . delete ( index ) ;
154155 }
155156 // Keyboard-owned classes the projection flattened out of every reachable subtree are chrome
156- // by their own declaration, so the app-accessory guard above never exempts them. An editable
157- // text node inside one of them is the same inputAccessoryView guard in disguise: an app that
158- // hosts a text field in its own input view keeps it, as it does under the window pass.
157+ // by their own declaration — but the walk may NOT outrank the app-accessory exemption above:
158+ // an app's `UITextField.inputAssistantItem` bar buttons render UNDER the system assistant
159+ // view, above the keys, and the window pass just exempted them; re-claiming them through the
160+ // assistant's subtree would hide real app controls from the settle diff. An exempted node
161+ // only re-joins chrome when IT declares a keyboard-owned role (a prediction cell is
162+ // system-owned wherever it sits); an app node under an owned host stays exempt. In the
163+ // flattened interactive shape there is no window anchor, the exemption is empty, and the
164+ // walk claims the key plane exactly as the container-descendant walk always did.
159165 for ( const index of collectOwnedKeyboardChromeIndexes (
160166 nodes ,
161167 byIndex ,
162168 ownedSubtreeRootIndexes ,
163169 containerSubtreeIndexes ,
170+ accessoryExemptIndexes ,
164171 ) ) {
165172 chromeIndexes . add ( index ) ;
166173 }
@@ -179,39 +186,69 @@ function collectKeyboardChrome(nodes: SnapshotNode[]): SettleChrome {
179186}
180187
181188/**
182- * The subtree under each keyboard-owned-class root, minus editable text the app hosts inside it
183- * outside the keyboard container. A keyboard's own `Key` nodes never trip that guard — the walk
184- * claims them with their own subtree roots even when a stripped field re-parented them — and an
185- * app that hosts its whole composer inside its input view still loses every key, exactly as the
186- * container-descendant walk always did.
189+ * The subtree under each keyboard-owned-class root, minus two app-content guards: indexes the
190+ * app-accessory exemption already granted (an app's `inputAssistantItem` bar buttons ride the
191+ * system assistant view above the keys), and editable text the app hosts inside an owned root
192+ * outside the keyboard container, with its subtree. A keyboard's own `Key` nodes trip neither —
193+ * they sit inside the container subtree, which the accessory pass never exempts — and the
194+ * flattened interactive shape carries no window anchor, so the exemption is empty there and the
195+ * walk claims the whole key plane exactly as the container-descendant walk always did.
187196 */
188197function collectOwnedKeyboardChromeIndexes (
189198 nodes : SnapshotNode [ ] ,
190199 byIndex : Map < number , SnapshotNode > ,
191200 ownedSubtreeRootIndexes : ReadonlySet < number > ,
192201 containerSubtreeIndexes : ReadonlySet < number > ,
202+ accessoryExemptIndexes : ReadonlySet < number > ,
193203) : Set < number > {
194204 const chromeIndexes = collectSubtreeIndexes ( nodes , byIndex , ownedSubtreeRootIndexes ) ;
195- for ( const node of nodes ) {
196- if (
197- chromeIndexes . has ( node . index ) &&
198- EDITABLE_TEXT_TYPES . has ( normalizeType ( node . type ?? '' ) ) &&
199- ! containerSubtreeIndexes . has ( node . index )
200- ) {
201- chromeIndexes . delete ( node . index ) ;
202- for ( const descendant of nodes ) {
203- if (
204- chromeIndexes . has ( descendant . index ) &&
205- hasAncestorIn ( descendant , byIndex , new Set ( [ node . index ] ) )
206- ) {
207- chromeIndexes . delete ( descendant . index ) ;
208- }
209- }
210- }
205+ // An exempted node re-joins chrome only when IT declares a keyboard-owned role: a system
206+ // prediction cell is chrome wherever it sits, while an app's `inputAssistantItem` bar button
207+ // under the assistant view declares no owned role and keeps its exemption.
208+ for ( const index of accessoryExemptIndexes ) {
209+ if ( ! ownedSubtreeRootIndexes . has ( index ) ) chromeIndexes . delete ( index ) ;
210+ }
211+ for ( const index of collectHostedEditableTextIndexes (
212+ nodes ,
213+ byIndex ,
214+ chromeIndexes ,
215+ containerSubtreeIndexes ,
216+ ) ) {
217+ chromeIndexes . delete ( index ) ;
211218 }
212219 return chromeIndexes ;
213220}
214221
222+ /**
223+ * Editable text the app hosts under an owned root outside the keyboard container, and the
224+ * chrome claimed beneath it — the inputAccessoryView guard in disguise: an app that rides its
225+ * own composer on the assistant host keeps the field it is typing into.
226+ */
227+ function collectHostedEditableTextIndexes (
228+ nodes : SnapshotNode [ ] ,
229+ byIndex : Map < number , SnapshotNode > ,
230+ chromeIndexes : ReadonlySet < number > ,
231+ containerSubtreeIndexes : ReadonlySet < number > ,
232+ ) : Set < number > {
233+ const dropped = new Set < number > ( ) ;
234+ const hostedTextIndexes = new Set (
235+ nodes
236+ . filter (
237+ ( node ) =>
238+ chromeIndexes . has ( node . index ) &&
239+ EDITABLE_TEXT_TYPES . has ( normalizeType ( node . type ?? '' ) ) &&
240+ ! containerSubtreeIndexes . has ( node . index ) ,
241+ )
242+ . map ( ( node ) => node . index ) ,
243+ ) ;
244+ for ( const node of nodes ) {
245+ if ( ! chromeIndexes . has ( node . index ) ) continue ;
246+ if ( hasAncestorIn ( node , byIndex , hostedTextIndexes ) ) dropped . add ( node . index ) ;
247+ }
248+ for ( const index of hostedTextIndexes ) dropped . add ( index ) ;
249+ return dropped ;
250+ }
251+
215252/**
216253 * Indexes of app-owned accessory content in a keyboard window: non-keyboard
217254 * nodes whose center sits ABOVE the keyboard container's top edge (an
0 commit comments