Skip to content

AIチャットの入力をエンターキーで即送信するよう変更 - #6504

Merged
TinyKitten merged 2 commits into
devfrom
claude/ai-chat-enter-send-wn444p
Aug 1, 2026
Merged

TinyKitten merged 2 commits into
devfrom
claude/ai-chat-enter-send-wn444p

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Aug 1, 2026 •

Copy link
Copy Markdown
Member

概要

AIチャット(目的地エージェント)の入力欄で、Enter キーを押した時点で即座にメッセージを送信するようにしました。日本語入力の変換確定に使う Enter では送信されません。

変更の種類

  • バグ修正
  • 新機能
  • リファクタリング
  • ドキュメント
  • CI/CD
  • その他

変更内容

  • AgentInputBar の TextInput に submitBehavior="submit" を指定し、multiline を維持したまま Enter を改行ではなく送信イベントへ振り替え。blurAndSubmit ではなく submit にすることで送信後もキーボードが開いたままになり、続けて質問できる
  • returnKeyType="send" を指定し、Enter が改行ではなく送信であることをキーラベルでも示す
  • onSubmitEditing は送信ボタンと同じ canSend 判定(空文字・送信中・429 到達)を通してから onSend を呼ぶ。入力バー単体で空送信と二重送信を弾く
  • AgentInputBar.test.tsx を新規追加(Enter 送信 / submitBehavior の振り替え / 空白のみ・送信中・429 時の送信抑止 / 送信ボタン経路)

日本語入力(IME)の確定について

変換確定の Enter は IME 側が消費するため、未確定文字列のまま送信されることはありません。React Native 0.83 の実装を読んで確認しています。

  • iOS: multiline の送信は RCTBackedTextInputDelegateAdapter.mm の textView:shouldChangeTextInRange:replacementText: で text == "\n" のときだけ発火する。未確定文字列(marked text)がある状態の Return は UIKit の入力メソッドが先に確定処理として消費するため、"\n" としては届かない
  • Android: 送信は ReactTextInputManager.kt の OnEditorActionListener 経由。変換中の Enter は IME が確定として処理し、エディタアクションを発行しない

onKeyPress による JS 側のコンポジション判定は意図的に足していません。Android では onKeyPress を渡すと ReactEditText.onCreateInputConnection が ReactEditTextInputConnectionWrapper を挿し込み、変換中の 1 打鍵ごとに JS へイベントが飛ぶため、ネイティブ側で既に解決している問題に対してホットパスのコストだけが増えます。

回帰リスクと緩和策

  • ソフトキーボードから改行を入力できなくなる: submitBehavior="submit" は Enter を送信へ振り替えるため、改行の入力手段が失われます。Enter 即送信という要件上は意図した挙動ですが、長文で改行を入れたいケースには影響します
  • react-native-web では従来どおり改行のまま: react-native-web は submitBehavior を解釈せず blurOnSubmit を見るため、web では Enter は改行のままです。app.config.ts に web 設定が無く src/ にも web 分岐が無いため、対象外と判断しました
  • 緩和策: 送信ボタンは従来どおり残しており、Enter 経路とボタン経路は同じ canSend 判定を共有します。双方の挙動をユニットテストで固定しました

テスト

ローカルで以下を実行し、すべて成功しています。

  • npm run lint: 604 files checked / no fixes applied
  • npm test: 201 suites / 2166 tests passed
  • npm run typecheck: エラーなし

実機・シミュレータでの日本語 IME 実動作の確認は未実施です。

  • npm run lint が通ること
  • npm test が通ること
  • npm run typecheck が通ること

関連Issue

スクリーンショット(任意)


Generated by Claude Code

Summary by CodeRabbit

  • 新機能

    • 入力欄でEnterキーを押してメッセージを送信できるようになりました。
    • 送信後もキーボードを表示したまま入力を続けられます。
  • バグ修正

    • 空の入力、送信中、送信上限到達時に誤送信されないよう改善しました。

@TinyKitten TinyKitten self-assigned this Aug 1, 2026
@github-actions github-actions Bot added the react label Aug 1, 2026
@coderabbitai

coderabbitai Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ee0138e7-83d4-4caa-bd93-1ede734fb961

📥 Commits

Reviewing files that changed from the base of the PR and between 7d442c8 and 8116752.

📒 Files selected for processing (1)
  • src/screens/DestinationAgent/AgentInputBar.test.tsx

📝 Walkthrough

Walkthrough

AgentInputBarにEnterキー送信を追加しました。canSend が偽の場合は送信しません。Enterキー、複数行入力、送信抑止条件、送信ボタンをテストします。

Changes

Destination Agent入力送信

Layer / File(s) Summary
Enterキー送信の実装
src/screens/DestinationAgent/AgentInputBar.tsx
canSend が真の場合だけ onSend を呼び出します。TextInput のEnterキーを送信に設定します。
送信動作のテスト
src/screens/DestinationAgent/AgentInputBar.test.tsx
Enterキー送信、複数行入力、空白入力・送信中・日次上限時の送信抑止、送信ボタンの動作を検証します。

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • TrainLCD/MobileApp#6479: AgentInputBarの導入元です。今回の実装とテストが直接関連します。
  • TrainLCD/MobileApp#6493: Destination Agentの入力操作を変更します。今回の変更は別の入力コンポーネントを対象にします。

Poem

Poem

うさぎがEnterをぴょんと押す
入力は送信へ進む
空白と上限は送信を止める
ボタンも同じ条件で待つ
テストが軽やかに跳ねる

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed タイトルはEnterキーによる即時送信という主変更を具体的かつ簡潔に示しています。
Description check ✅ Passed 概要、変更内容、テスト結果、関連Issue、任意項目を含み、変更目的と検証内容を十分に説明しています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/ai-chat-enter-send-wn444p

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/screens/DestinationAgent/AgentInputBar.test.tsx`:
- Around line 55-101: Update the AgentInputBar tests to assert
input.returnKeyType is "send" alongside submitBehavior, and add send-button
assertions that disabled is true for whitespace-only value, sending, and
rateLimited states. Use the existing renderBar or rendered button query and
preserve the enabled-button submission test to verify both paths share the same
canSend conditions.
- Around line 10-13: Apply Biome ES5-style trailing commas to the multiline
object literals in the jest.mock setup and the additional object around the
referenced lines, including their final properties, while preserving the
existing mock behavior.
🪄 Autofix (Beta)

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: 6fb36194-c157-4091-b99f-1633e3bad541

📥 Commits

Reviewing files that changed from the base of the PR and between 572b56a and 7d442c8.

📒 Files selected for processing (2)
  • src/screens/DestinationAgent/AgentInputBar.test.tsx
  • src/screens/DestinationAgent/AgentInputBar.tsx

@TinyKitten
TinyKitten merged commit 9e5fa24 into dev Aug 1, 2026
5 checks passed
@TinyKitten
TinyKitten deleted the claude/ai-chat-enter-send-wn444p branch August 1, 2026 03:52
@TinyKitten TinyKitten mentioned this pull request Aug 1, 2026
6 of 9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants