Skip to content

共通ダイアログモーダルを追加してAlert表示を移行 - #6550

Merged
TinyKitten merged 3 commits into
devfrom
feature/common-dialog-modal
Aug 5, 2026
Merged

TinyKitten merged 3 commits into
devfrom
feature/common-dialog-modal

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Aug 5, 2026 •

Copy link
Copy Markdown
Member

概要

アプリ内で使用していたネイティブのダイアログ表示を、統一されたデザインの CommonDialogModal へ移行します。
ThemeConfirmModal と CommonDialogModal はそれぞれ独立した公開コンポーネントとして維持し、共通するレイアウトだけを内部コンポーネントへ切り出しました。

変更の種類

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

変更内容

  • CustomModal を基盤とする CommonDialogModal を追加
  • ThemeConfirmModal と共通するレイアウトを DialogModalLayout に集約
  • アプリ全体でダイアログを提示する CommonDialogPresenter と表示APIを追加
  • 表示中に届いたダイアログのキューイングと、StrictModeにおける自動表示の重複防止を実装
  • キャンセル、破壊的操作、背景タップ、Androidの戻るキーに対応
  • 既存のネイティブダイアログ呼び出しを共通ダイアログへ移行
  • 左上の絵文字にOS標準フォント、サイズ上限、行高を適用して見切れを修正
  • 表示基盤の状態遷移が分かる日本語コメントを追加
  • StrictModeのダイアログ表示に関する開発ドキュメントを更新
  • ダイアログのボタンを「確定1個+任意のキャンセル1個」に制限し、不正な要求を明示的にエラー化
  • 完了コールバックから新しい要求が追加されても、待機中のダイアログをFIFO順で表示
  • 権限拒否ダイアログをキャンセル不可にし、必要な画面遷移を必ず実行
  • 画面側テストで要求内容に加えて表示状態も検証

回帰リスクとして、ダイアログの表示順、閉じるアニメーション後のコールバック実行、キャンセル操作が変わる可能性があります。表示キューと入力制約の単体テスト、既存画面の関連テスト、Android実機確認で軽減しています。

テスト

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

実行結果:

  • npm run lint: 613ファイル成功
  • npm test -- --runInBand --silent: 207スイート、2187テスト成功
  • npm run typecheck: 成功
  • git diff --check: 成功

関連Issue

なし

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

  • T12_ROW(Android 13)で CommonDialogModal の表示、絵文字の見切れがないこと、Android戻るキーによる閉じる動作を確認

Summary by CodeRabbit

  • 新機能

    • アプリ全体で利用できる共通確認ダイアログを追加しました。
    • 絵文字、テーマ、破壊的操作に対応した統一レイアウトを提供します。
    • ダイアログの重複表示を防ぎ、複数の通知を順番に表示します。
  • 改善

    • エラー通知や確認操作を、従来のアラートから共通ダイアログへ統一しました。
    • ダイアログ表示中の画面操作や戻るボタンへの対応を改善しました。
  • テスト

    • 表示内容、ボタン操作、重複防止、表示順序に関するテストを追加・更新しました。

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

coderabbitai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

React Native の Alert を共通ダイアログ基盤へ移行しました。表示状態、重複抑止、キュー処理、共通モーダル、アプリ全体の表示経路、関連テストを追加・更新しました。

Changes

共通ダイアログ基盤

Layer / File(s) Summary
ダイアログ状態管理
src/utils/dialogPresentation.ts, src/utils/dialogPresentation.test.ts
ダイアログ要求、キーによる重複抑止、表示待ちキュー、終了後コールバックを実装し、動作を検証しました。
共通ダイアログUI
src/components/DialogModalLayout.tsx, src/components/CommonDialogModal.tsx, src/components/CommonDialogPresenter.tsx, src/components/ThemeConfirmModal.tsx
テーマ対応レイアウト、絵文字付きモーダル、状態購読型プレゼンターを追加しました。テーマ確認モーダルを共通レイアウトへ移行しました。
アプリルートと表示経路の接続
src/index.tsx, src/components/*, src/hooks/*, src/providers/*, src/screens/*
アプリルートに CommonDialogPresenter を配置しました。通知と確認表示を showDialog または showDialogWhilePresenting に変更しました。
テストと利用指針
src/components/*.test.tsx, src/hooks/useInitialNearbyStation.test.tsx, src/screens/*test.tsx, AGENTS.md, docs/spec/ai-agent/ui.md
表示内容、操作コールバック、遅延実行、状態スナップショットを検証するテストへ変更しました。自動表示の利用指針とUI仕様を更新しました。

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Screen
  participant dialogPresentation
  participant CommonDialogPresenter
  participant CommonDialogModal
  Screen->>dialogPresentation: showDialogWhilePresenting(key, title, message, buttons)
  dialogPresentation->>CommonDialogPresenter: publish dialog snapshot
  CommonDialogPresenter->>CommonDialogModal: render common modal
  CommonDialogModal->>dialogPresentation: dismissPresentedDialog(buttonIndex)
  dialogPresentation->>dialogPresentation: completePresentedDialogDismissal()
  dialogPresentation->>Screen: execute selected callback
Loading

Possibly related PRs

Poem

うさぎがキーを、ぴょんと押す
ダイアログは列を守る
閉じるまで処理を待ち
次の窓を静かに開く
Alert は共通窓へ移る 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed タイトルは、共通ダイアログモーダルの追加とAlert表示の移行という主要変更を簡潔かつ明確に示しています。
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 feature/common-dialog-modal

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: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/screens/Privacy.tsx (1)

88-99: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

権限拒否時のダイアログをキャンセル不可にしてください。

showDialog は既定で背景タップとAndroidの戻るキーによる終了を許可します。この経路では handleStartWithoutPermissionPress が実行されず、ユーザーはPrivacy画面に残ります。

既存のOK操作と同じ遷移を必須にするため、{ cancelable: false } を渡してください。

修正例
       [
         {
           text: 'OK',
           onPress: handleStartWithoutPermissionPress,
         },
-      ]
+      ],
+      { cancelable: false }
     );
🤖 Prompt for 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.

In `@src/screens/Privacy.tsx` around lines 88 - 99, Update the permission-denied
dialog invocation in Privacy.tsx to pass the showDialog option { cancelable:
false }, while preserving the existing OK button and
handleStartWithoutPermissionPress transition.
🧹 Nitpick comments (1)
src/hooks/useInitialNearbyStation.test.tsx (1)

141-145: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

ダイアログの表示状態も検証してください。

現在のテストは request の内容だけを確認します。visible を確認しないため、要求が作成されても表示されていない状態を検出できません。getDialogPresentationSnapshot() 全体を検証し、visible: true と request の title / message を確認してください。

  • src/hooks/useInitialNearbyStation.test.tsx#L141-L145: visible: true と初回起動ダイアログの request を同時に検証してください。
  • src/screens/ExperimentalSettings.test.tsx#L88-L90: visible: true を追加して保存失敗ダイアログの表示を検証してください。
  • src/screens/ExperimentalSettings.test.tsx#L138-L144: visible: true を追加してテレメトリ保存失敗ダイアログの表示を検証してください。
  • src/screens/TTSSettings.test.tsx#L174-L177: visible: true を追加してリンク失敗ダイアログの表示を検証してください。
🤖 Prompt for 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.

In `@src/hooks/useInitialNearbyStation.test.tsx` around lines 141 - 145, Update
the dialog presentation assertions to verify visibility as well as request
content: in src/hooks/useInitialNearbyStation.test.tsx:141-145 assert visible:
true alongside the initial-launch request fields; add visible: true in the
save-failure assertion at src/screens/ExperimentalSettings.test.tsx:88-90 and
the telemetry-save-failure assertion at
src/screens/ExperimentalSettings.test.tsx:138-144; and add visible: true to the
link-failure assertion at src/screens/TTSSettings.test.tsx:174-177.
🤖 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/components/CommonDialogModal.test.tsx`:
- Around line 14-41: Clear Jest mock call history after each test: add an
afterEach calling jest.clearAllMocks() in CommonDialogModal.test.tsx (lines
14-41), and update the existing afterEach in CommonDialogPresenter.test.tsx
(lines 24-30) to call jest.clearAllMocks().

In `@src/components/CommonDialogPresenter.tsx`:
- Around line 42-53: The CommonDialogPresenter currently drops additional
non-cancel buttons because DialogModalLayout supports only two button slots.
Enforce and document the DialogButton[] constraint at the request boundary so at
most one cancel and one non-cancel button are accepted, and make the invalid
multiple-confirm-button case fail explicitly rather than silently discarding
buttons. Add or update tests covering two non-cancel buttons and the resulting
behavior.

In `@src/utils/dialogPresentation.test.ts`:
- Around line 11-13: Update the afterEach cleanup in the dialog presentation
tests to call jest.clearAllMocks() both before and after
resetDialogPresentationForTests(), while preserving the existing reset behavior.

In `@src/utils/dialogPresentation.ts`:
- Around line 154-169: Update the completion flow around
completedRequest.buttons[buttonIndex]?.onPress and
completedRequest.options.onDismiss so queued requests retain FIFO order when a
callback invokes showDialog. Activate the existing queued request before
processing callback-created requests, or otherwise append those new requests
after the current queue; ensure the resulting order is A → B → C and add a test
covering that sequence.

---

Outside diff comments:
In `@src/screens/Privacy.tsx`:
- Around line 88-99: Update the permission-denied dialog invocation in
Privacy.tsx to pass the showDialog option { cancelable: false }, while
preserving the existing OK button and handleStartWithoutPermissionPress
transition.

---

Nitpick comments:
In `@src/hooks/useInitialNearbyStation.test.tsx`:
- Around line 141-145: Update the dialog presentation assertions to verify
visibility as well as request content: in
src/hooks/useInitialNearbyStation.test.tsx:141-145 assert visible: true
alongside the initial-launch request fields; add visible: true in the
save-failure assertion at src/screens/ExperimentalSettings.test.tsx:88-90 and
the telemetry-save-failure assertion at
src/screens/ExperimentalSettings.test.tsx:138-144; and add visible: true to the
link-failure assertion at src/screens/TTSSettings.test.tsx:174-177.
🪄 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: 8e731216-0f0c-4ee3-94a6-50908e73c3a0

📥 Commits

Reviewing files that changed from the base of the PR and between 8e303a4 and 1448600.

📒 Files selected for processing (38)
  • AGENTS.md
  • docs/spec/ai-agent/ui.md
  • src/components/CommonDialogModal.test.tsx
  • src/components/CommonDialogModal.tsx
  • src/components/CommonDialogPresenter.test.tsx
  • src/components/CommonDialogPresenter.tsx
  • src/components/DialogModalLayout.tsx
  • src/components/FatalErrorScreen.tsx
  • src/components/NewReportModal.tsx
  • src/components/Permitted.tsx
  • src/components/SelectBoundModal.tsx
  • src/components/StationSearchModal.tsx
  • src/components/ThemeConfirmModal.tsx
  • src/components/TuningSettings.tsx
  • src/components/WalkthroughOverlay.tsx
  • src/hooks/useCheckStoreVersion.ts
  • src/hooks/useInitialNearbyStation.test.tsx
  • src/hooks/useInitialNearbyStation.ts
  • src/index.tsx
  • src/providers/DeepLinkProvider.tsx
  • src/screens/AndroidSettings.tsx
  • src/screens/BatterySettings.test.tsx
  • src/screens/BatterySettings.tsx
  • src/screens/DestinationAgent/index.tsx
  • src/screens/EnabledLanguagesSettings.tsx
  • src/screens/ExperimentalSettings.test.tsx
  • src/screens/ExperimentalSettings.tsx
  • src/screens/Main.tsx
  • src/screens/NotificationSettings.tsx
  • src/screens/Privacy.tsx
  • src/screens/RouteSearchScreen.tsx
  • src/screens/TTSSettings.test.tsx
  • src/screens/TTSSettings.tsx
  • src/screens/ThemeSettings.tsx
  • src/utils/alertPresentation.test.ts
  • src/utils/alertPresentation.ts
  • src/utils/dialogPresentation.test.ts
  • src/utils/dialogPresentation.ts
💤 Files with no reviewable changes (2)
  • src/utils/alertPresentation.test.ts
  • src/utils/alertPresentation.ts

Comment thread src/utils/dialogPresentation.test.ts Resolved
Comment thread src/utils/dialogPresentation.ts Resolved
@TinyKitten

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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.

🧹 Nitpick comments (1)
src/utils/dialogPresentation.test.ts (1)

58-65: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

無効要求がキューに残らないことも検証してください。

getDialogPresentationSnapshot().request は表示中の要求だけを確認します。queuedRequests の残留は確認しません。src/utils/dialogPresentation.ts の enqueueDialog が検証前にキューを変更する場合、このテストは成功しても後続の有効な要求に影響します。

例外後に有効な要求を追加し、最初にその要求が表示されることを確認してください。

検証例
     expect(getDialogPresentationSnapshot().request).toBeNull();
+    showDialog('valid');
+    expect(getDialogPresentationSnapshot().request?.title).toBe('valid');
🤖 Prompt for 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.

In `@src/utils/dialogPresentation.test.ts` around lines 58 - 65, Extend the test
for multiple confirm buttons in the dialog presentation flow to enqueue a valid
request after the invalid showDialog call, then verify that the valid request is
displayed first. Use getDialogPresentationSnapshot and the existing dialog
request symbols to confirm the invalid request did not remain in queuedRequests,
while preserving the current exception and null-request assertions.
🤖 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.

Nitpick comments:
In `@src/utils/dialogPresentation.test.ts`:
- Around line 58-65: Extend the test for multiple confirm buttons in the dialog
presentation flow to enqueue a valid request after the invalid showDialog call,
then verify that the valid request is displayed first. Use
getDialogPresentationSnapshot and the existing dialog request symbols to confirm
the invalid request did not remain in queuedRequests, while preserving the
current exception and null-request assertions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 59854d31-bcee-4930-b523-3bd54adab40b

📥 Commits

Reviewing files that changed from the base of the PR and between 1448600 and 94847da.

📒 Files selected for processing (9)
  • src/components/CommonDialogModal.test.tsx
  • src/components/CommonDialogPresenter.test.tsx
  • src/components/CommonDialogPresenter.tsx
  • src/hooks/useInitialNearbyStation.test.tsx
  • src/screens/ExperimentalSettings.test.tsx
  • src/screens/Privacy.tsx
  • src/screens/TTSSettings.test.tsx
  • src/utils/dialogPresentation.test.ts
  • src/utils/dialogPresentation.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • src/components/CommonDialogPresenter.test.tsx
  • src/components/CommonDialogModal.test.tsx
  • src/screens/Privacy.tsx
  • src/components/CommonDialogPresenter.tsx
  • src/utils/dialogPresentation.ts
  • src/screens/TTSSettings.test.tsx
  • src/hooks/useInitialNearbyStation.test.tsx

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.

1 participant