fix(swift-ios): keep composer above software keyboard - #6145
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| @State private var isManuallyExpanded = false | ||
| @State private var isAttachmentFlowActive = false | ||
| @State private var dockedSoftwareKeyboardOccupiesScreen = false | ||
| @State private var composerWindow: UIWindow? |
There was a problem hiding this comment.
🟡 Medium Chat/FeatureComposerView.swift:9
composerWindow is stored as a strong @State reference to UIWindow. The window retains its root view controller and view hierarchy, which includes this composer and its SwiftUI state, so dismissing the hierarchy can leave the entire window/composer graph retained — a memory leak. Consider wrapping the window in a weak reference holder rather than storing it directly in @State.
| @State private var composerWindow: UIWindow? | |
| +@State private var composerWindow: FeatureComposerWindowBox? |
🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/swift-ios/Features/Chat/FeatureComposerView.swift around line 9:
`composerWindow` is stored as a strong `@State` reference to `UIWindow`. The window retains its root view controller and view hierarchy, which includes this composer and its SwiftUI state, so dismissing the hierarchy can leave the entire window/composer graph retained — a memory leak. Consider wrapping the window in a weak reference holder rather than storing it directly in `@State`.
What
Keeps the composer input and footer controls clear of a docked software keyboard, including New Task autofocus and accessibility text sizes.
Scope
Two focused commits: the keyboard geometry/notification foundation and the New Task follow-up. Only FeatureComposerView and FeatureComposerPowerTests change.
Verification
Dependencies and gate
Note
Keep the chat composer above the software keyboard on iOS
FeatureComposerKeyboardLayoutenum in FeatureComposerView.swift to centralize keyboard detection logic: determines when a local, docked, sufficiently tall keyboard occupies the screen and adjusts the composer's line limit and bottom clearance accordingly.TextFieldline limit collapses to a single line and the footer padding reduces to avoid content being clipped.FeatureComposerWindowReader(UIViewRepresentable) to expose the composer'sUIWindowso keyboard frames can be converted to view coordinates and the keyboard layout guide can be read.dockedSoftwareKeyboardOccupiesScreenstate current.📊 Macroscope summarized 54cf050. 1 file reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted
🗂️ Filtered Issues
No issues evaluated.