Repository navigation
エッジトゥエッジのAndroidでAIチャットの入力欄がキーボードに隠れる問題を修正 - #6603
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019chvStvzeVBarptfXAbZY5
Contributor
📝 WalkthroughWalkthrough
Changesキーボード追従フロー
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Keyboard
participant useKeyboardBottomInset
participant DestinationAgentScreen
participant MessageList
Keyboard->>useKeyboardBottomInset: キーボード表示イベント
useKeyboardBottomInset->>DestinationAgentScreen: 下端インセットとアニメーション時間
DestinationAgentScreen->>MessageList: メッセージ末尾へスクロール
DestinationAgentScreen->>DestinationAgentScreen: 入力バーをアニメーション移動
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Contributor
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/hooks/useKeyboardBottomInset.test.ts`:
- Around line 74-87: Extend the iOS keyboardWillShow coverage in the test around
loadHook and emit to pass a keyboard event with duration 0, then assert
result.current.duration uses the 250ms IOS_FALLBACK_ANIMATION_DURATION fallback.
Keep the existing nonzero-duration assertion unchanged.
In `@src/hooks/useKeyboardBottomInset.ts`:
- Around line 39-42: Update resolveDuration in
src/hooks/useKeyboardBottomInset.ts:39-42 to return 0 for Android
keyboardDidShow/keyboardDidHide events while preserving the existing iOS
duration fallback. Add or update the Android duration assertion in
src/hooks/useKeyboardBottomInset.test.ts:121-128 to verify 0. No direct change
is required in src/screens/DestinationAgent/index.tsx:234-240.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 395d9ae8-e662-4ff2-8e75-85a065d63dd3
📒 Files selected for processing (4)
docs/spec/ai-agent/ui.mdsrc/hooks/useKeyboardBottomInset.test.tssrc/hooks/useKeyboardBottomInset.tssrc/screens/DestinationAgent/index.tsx
Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_019chvStvzeVBarptfXAbZY5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
Pixel 9a (Android 17) で AI に行き先を相談する画面のキーボード表示時、入力バーがキーボードに覆われて見えなくなる不具合を修正します。
原因は
KeyboardAvoidingViewの設定ではなく、エッジトゥエッジ環境 (edgeToEdgeEnabled=true) の Android ではKeyboardAvoidingViewそのものが機能しないことでした。android:windowSoftInputMode="adjustResize"を指定してもウィンドウが縮まない。ReactRootView.checkForKeyboardEvents()が送るendCoordinates.screenYは常に画面下端のままになる。KeyboardAvoidingView._relativeKeyboardHeight()はframe.y + frame.height - screenYを押し上げ量とするため、結果が常に 0 になりbehaviorに何を渡しても効かない(Android はundefinedを渡していたため二重に効いていなかった)。endCoordinates.heightはimeInsets.bottom - barInsets.bottomとして正しく届くので、これを起点に下余白を組み立てる方式へ変更しました。変更の種類
変更内容
src/hooks/useKeyboardBottomInset.tsを追加。キーボードイベントから画面下端に確保すべき余白・追従アニメーション時間・表示状態を返す。keyboardDidShow/keyboardDidHideを購読し、endCoordinates.height(ナビゲーションバー分を除いた IME 高さ)にuseSafeAreaInsets().bottomを足してウィンドウ下端からの重なり量へ戻す。did 系イベントは IME の遷移後に届きうるため、追従アニメーションは行わず即座に確定させる(duration: 0)。keyboardWillShow/keyboardWillHideを購読。endCoordinates.heightはホームインジケータ領域を含むため加算せず、イベントのdurationをそのまま使う(0 で届いた場合は 250ms にフォールバック)。useSafeAreaInsets().bottomを返すため、従来の下端余白の挙動は据え置き。src/screens/DestinationAgent/index.tsxからKeyboardAvoidingViewを削除し、入力バーのコンテナをAnimated.ViewにしてwithTimingでpaddingBottomを追従させる。src/hooks/useKeyboardBottomInset.test.tsを追加。iOS / Android 双方の余白計算、購読するイベント名、durationの解決、リスナ解除を検証(9 ケース)。docs/spec/ai-agent/ui.mdの入力バー仕様を実装に合わせて更新し、KeyboardAvoidingViewを使わない理由を記録。回帰リスクと緩和
DestinationAgent) のみ。他画面のキーボード挙動には触れていません。behavior="padding"で入力バーを持ち上げていましたが、入力バーは画面最下部にあるため押し上げ量は「キーボード高さ」と一致し、新実装と等価です。キーボード非表示時の余白も従来どおりinsets.bottom + 8を維持しています。duration: 0は、RN のイベントが IME 遷移の開始時に届く場合でも終了後に届く場合でも「入力欄が隠れている時間が最短」になる選択です。実機で入力バーの先行移動が気になる場合は短い値への調整余地があります。src/components/CustomModal.tsxのavoidKeyboard(SavePresetNameModal/NewReportModal)も Android では効いていないと考えられますが、本 PR のスコープ外としています。必要であれば同じフックを流用して別途対応します。テスト
ローカルで以下を実行し、いずれも成功することを確認しています(
npm test: 213 suites / 2237 tests all pass)。npm run lintが通ることnpm testが通ることnpm run typecheckが通ること関連Issue
スクリーンショット(任意)
実機・エミュレータを操作できない環境で作業したため、スクリーンショット / 録画は未添付です。マージ前に報告端末である Pixel 9a (Android 17) での目視確認をお願いします。