Skip to content

feat: ピルシート終了時の課金転換ダイアログ(A/B)を追加#1809

Open
bannzai wants to merge 24 commits into
mainfrom
issue-385
Open

feat: ピルシート終了時の課金転換ダイアログ(A/B)を追加#1809
bannzai wants to merge 24 commits into
mainfrom
issue-385

Conversation

@bannzai

@bannzai bannzai commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Abstract

ピルシートが終了した free ユーザーに、価値ティーザー型の課金転換ダイアログを表示する A/B 機能を追加します(PilllBackend issue #385 の Flutter 側実装)。

  • Variant A history_blur: 最新の服用履歴3件を「先頭1件は鮮明・残り2件は blur」で見せて課金を訴求
  • Variant B summary_stats: 服用記録できた日数・記録漏れ日数の集計メッセージを見せる

既存のピルシート終了バーは残し、ダイアログを 追加 します(置換しない)。表示は free ユーザー限定で、終了グループにつき1回です。

Why

PR #383 のリリース後分析で、ペイウォール起動経路別の購入転換に大きな差が判明しました。

経路 view→押下 view→購入
ended_pill_sheet_bar(終了バー) 1.7% 0.6%
pill_sheet_modified_history_card(ぼかし履歴カード) 26% 13.6%

差はファネル最上流(paywall を開いた瞬間の意図)で生まれています。終了バーは「機能タスクの予告」文言で意図ミスマッチ、ぼかし履歴カードは「価値ティーザー+プレミアム明示+本人のオプトイン」で意図一致するため高転換です。この勝ち筋を終了タイミングに移植し、どの提示形式が効くかを A/B 検証します。

変更内容

計測

  • PaywallSourceendedPillSheetDialogHistory / endedPillSheetDialogSummary を追加(value: ended_pill_sheet_dialog_history / ended_pill_sheet_dialog_summary
  • ダイアログのライフサイクルイベントを variant 付きで送出: ended_sheet_dialog_shown / ended_sheet_dialog_cta_tapped / ended_sheet_dialog_dismissed
  • CTA → showPremiumIntroductionSheet(source: 各バリアントの source) で既存 paywall ファネル(paywall_viewedpressed_*_purchase_buttonpurchase_succeeded)に接続

A/B 割り当て

  • Firebase Remote Config / A/B Testing 方式。RCキー endedPillSheetDialogVariant(default 空文字=非表示)を追加し、history_blur / summary_stats を配信して 50:50 で振り分ける

集計(Variant B の x/y)

  • 既存の服用遵守ロジック missedPillDays の集合構築部分を pillTakenDateSets として公開し、服用記録日の集合を流用
  • 服用予定日は各シートの実薬分(dosingPeriod)のみを対象とし、偽薬・休薬期間は記録漏れに含めない。y(記録漏れ日数)= 服用予定日 − 服用記録日、x(服用記録日数)= 服用予定日数 − y

既存挙動の変更(missedPillDays)と波及

集計の流用にあたり、共有ロジック missedPillDays の既存バグ修正・挙動変更を行いました。

  • 日付正規化: 従来は最古履歴が時刻付き(服用記録は通常時刻付き)だと、集計期間の日付集合が時刻を引き継ぎ服用記録日(0時に正規化済み)と一致せず、飲み忘れ日数が実態より過大にカウントされていた。全日付を日付のみ(午前0時)に正規化して修正
  • 取り消し(revertTakenPill)の反映: 従来は取り消し履歴が無視され、取り消した日も服用済み扱いだった。取り消された日 =(取り消し後の最終服用日, 取り消し前の最終服用日] を服用記録から除外するよう修正。before/after グループが null の取り消し履歴は従来どおり無視される
  • まとめ記録の反映: 従来は履歴の操作日だけを服用記録日としていたため、複数日分をまとめて記録すると1日に潰れて集計されていた。記録対象日 =(記録前の最終服用日, 記録後の最終服用日] を展開して集計するよう修正(初回記録はシート開始日から展開。同じピル日への2回目の記録はその日。服用日時を編集した履歴は編集後の日時を記録日とし、取り消し時は編集後の日付も除外。グループ情報の無い旧履歴は従来どおり)

この変更は利用側のホーム飲み忘れバー(SpecialOfferingAnnouncementBar2、表示条件 missedDays >= 1)にも波及します:

  • 日付正規化・まとめ記録の反映により、これまで過大カウントでバーがほぼ常に表示され得たのが、正確な値に減って表示されにくくなる
  • 取り消し反映により、服用記録を取り消したままのユーザーは飲み忘れ日数が増えてバーが表示されやすくなる

いずれも修正後の値が本来意図された「飲み忘れ日数」であるため、この波及は許容とする(挙動変更のテスト監査とあわせて確認済み)。

表示トリガー / 頻度制御

  • home/page.dart の起動時 useEffect に「終了グループ(activePillSheet == null かつ deletedAt == null)+ free(!premiumOrTrial)+ 未表示」分岐を追加(既存の月次 paywall と排他)
  • pillSheetGroupID を key に SharedPreferences で表示済みフラグを保持し、終了グループにつき1回だけ表示
  • ティーザー内容を提示できない場合(summaryStats: 履歴TTL切れ・対象グループの履歴なし / historyBlur: 表示できる服用記録なし)は表示自体を抑止し、impression と表示済みフラグを消費しない
  • 起動時自動モーダル(起動時ペイウォール・買い切りオファー)と同一起動で重ならないよう shownPaywallOnThisAppLaunchProvider を共有排他フラグとして参照・更新

動作確認

iOS Simulator で初期設定 → ピルシート登録 → 服用記録の上、ダイアログを表示して確認しました。

Variant A history_blur Variant B summary_stats
  • Variant A: 「先頭1件は鮮明・残り2件は blur」の履歴ティーザーが要件どおり表示される
  • Variant B: 「服用記録 x 件・記録漏れ y 件でした」の集計メッセージが表示される

補足: 動作確認のためダイアログを起動時に強制表示しています(この強制表示コードはコミットに含めていません)。Variant B の集計値は、終了していないグループ(未来日が記録漏れにカウントされる)かつ初期設定直後(過去の服用が createdPillSheet 扱いで takenPill 履歴が少ない)のため暫定値です。実トリガー(free+終了グループ+日々の服用履歴)では適切な値になります。集計ロジック自体はユニットテストで検証済みです。

テスト

  • flutter test 全件パス(1524 件)
  • 集計の境界値(空 / 全日服用 / 1日服用 / 休薬期間 / 実薬のみ対象 / まとめ記録 / 集計可否のTTL境界): ended_pill_sheet_taken_summary_test.dart
  • variant 解決 / value / paywallSource: ended_pill_sheet_dialog_variant_test.dart
  • ダイアログの variant 分岐描画・ティーザーのグループ絞り込み / 取り消し反映 / ローディング / TTL抑止: ended_pill_sheet_dialog_test.dart
  • 起動時モーダル排他フラグの発行: show_lifetime_offer_on_app_launch_test.dart
  • missedPillDays の挙動変更を直接検証するユニットテスト: pill_sheet_modified_history_test.dart#missedPillDays(取り消してそのまま / 同日再記録 / まとめて取り消し / 全件取り消し / null グループの取り消しは無視 / 最古履歴が深夜時刻付き / 時刻付き最古履歴+服用お休み継続中 / 同日複数履歴の正規化 / まとめ記録 / 初回まとめ記録)

残作業(本PR対象外)

  • PilllBackend 側: paywall_source_conversion.sqlknown_sources に新2値追加、paywall_source_ended_dialog_ab.sql(A/B集計)を追加(イベント着弾後)
  • Firebase Console で A/B Testing experiment を設定(endedPillSheetDialogVariant を 50:50 配信)
  • 多言語 arb の翻訳(現在 ja / en のみ。他言語は ja フォールバック)

Links

Checked

  • Analyticsのログを入れたか
  • 境界値に対してのUnitTestを書いた
  • パターン分岐が発生するWidgetに対してWidgetTestを書いた

Summary by CodeRabbit

  • New Features
    • ピルシート終了時に案内ダイアログを表示し、履歴(ぼかし表示)/振り返り(集計サマリー)をバリアントで切り替えます。
    • 表示文言に加え、記録日数/飲み忘れ日数の集計メッセージを追加しました。
    • 表示・CTA・閉じる操作の計測と、詳細導線への連携に対応しました(表示は各ピルシート単位で制御)。
  • Bug Fixes
    • 服用予定日・飲み忘れ日数の集計を、日付単位で正規化し休薬期間を除外して算出するよう改善しました。
  • Tests
    • ダイアログ表示・バリアント解決・集計ロジックのテストを追加/更新しました。

bannzai added 6 commits June 25, 2026 18:14
ended_pill_sheet_dialog_history / ended_pill_sheet_dialog_summary を追加し、A/B 各バリアントの paywall 経路を計測できるようにする
A/B バリアント割り当てを Firebase Remote Config / A/B Testing で行う。
default は空文字(実験未参加=非表示)で、history_blur / summary_stats を配信する。
String 取得用の getStringOrDefault 拡張も追加
服用予定日と服用記録日の集合構築を内部ヘルパーに切り出し(missedPillDays の戻り値は不変)、
服用予定日数を返す scheduledPillDays を追加する。
ダイアログ Variant B の x(服用記録日数) = scheduledPillDays - missedPillDays に利用する
endedPillSheetDialogShown(pillSheetGroupID) で終了グループごとに表示済みを保持し、
1つの終了ピルシートグループにつき1回だけダイアログを出す
ピルシート終了時に free ユーザーへ価値ティーザー型ダイアログを表示する。
- Variant A(history_blur): 最新の服用履歴3件を先頭1件は鮮明・残り2件は blur で見せる
- Variant B(summary_stats): 服用記録できた日数・記録漏れ日数の集計メッセージを表示
- shown / cta_tapped / dismissed を variant 付きで送出し、CTA から各 source で paywall を開く
- 集計の境界値・variant 解決・ダイアログの分岐描画をテスト
HomePageBody の起動時 useEffect に「終了グループ + free + 未表示」分岐を追加し、
Remote Config の variant に応じてダイアログを表示する。既存の月次 paywall とは排他。
バーは残し、ダイアログを追加する(置換しない)
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

終了ピルシート向けに、服用集計、Remote Config の variant、ダイアログ UI、ホーム画面からの表示導線を追加しました。履歴ぼかし/集計の2種ティーザーと、表示済み判定付きの起動処理も含まれます。

Changes

終了ピルシートダイアログ

Layer / File(s) Summary
服用集計の共通化
lib/entity/pill_sheet_modified_history.codegen.dart, lib/features/ended_pill_sheet_dialog/ended_pill_sheet_taken_summary.dart, test/entity/pill_sheet_modified_history_test.dart, test/features/ended_pill_sheet_dialog/ended_pill_sheet_taken_summary_test.dart
服用予定日と服用記録日の集合計算を共通化し、終了ピルシート用の集計関数と検証テストを追加しています。
終了ダイアログ用 Remote Config
lib/entity/remote_config_parameter.codegen.dart, lib/entity/remote_config_parameter.codegen.freezed.dart, lib/entity/remote_config_parameter.codegen.g.dart, lib/provider/remote_config_parameter.dart, lib/provider/remote_config_parameter.g.dart, lib/utils/remote_config.dart
endedPillSheetDialogVariant を Remote Config のモデル、JSON、取得処理、既定値設定に通しています。
終了ダイアログの variant
lib/features/ended_pill_sheet_dialog/ended_pill_sheet_dialog_variant.dart, lib/features/premium_introduction/paywall_source.dart, test/features/ended_pill_sheet_dialog/ended_pill_sheet_dialog_variant_test.dart, test/features/premium_introduction/paywall_source_test.dart
historyBlur / summaryStats の variant と文字列変換、Remote Config 解決、paywall source 対応を追加しています。
終了ダイアログの UI
lib/features/ended_pill_sheet_dialog/components/*, lib/features/ended_pill_sheet_dialog/ended_pill_sheet_dialog.dart, lib/l10n/app_*.arb, test/features/ended_pill_sheet_dialog/ended_pill_sheet_dialog_test.dart
履歴ぼかしティーザー、集計ティーザー、終了ダイアログ本体、文言キー、表示分岐テストを追加しています。
ホーム画面の起動導線
lib/features/home/page.dart, lib/utils/shared_preference/keys.dart
HomePageBody が Remote Config で variant を解決し、終了ピルシートで一度だけダイアログを表示して表示済みフラグを保存しています。

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

Possibly related PRs

  • bannzai/Pilll#1797: PaywallSource を付与して paywall 呼び出しへ流す経路を整えており、今回の終了ピルシートダイアログからの遷移追加と接続しています。
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed ピルシート終了時のA/B課金転換ダイアログ追加という変更内容を的確に要約できています。
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-385

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.

❤️ Share

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

@gemini-code-assist gemini-code-assist 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.

Code Review

このプルリクエストでは、ピルシートが終了した無料ユーザー向けに、Firebase Remote Configのバリアント設定(履歴のぼかし表示または服用記録の集計メッセージ)に応じた課金転換ダイアログを表示する機能が追加されました。これに伴い、服用予定日数や記録漏れ日数を集計するロジックの共通化や、関連するUIコンポーネントおよびテストコードが実装されています。レビュー指摘として、endedPillSheetTakenSummary 内で _buildPillTakenDateSets が重複して実行される非効率な実装に対して、1回の呼び出しに最適化する具体的なコード提案が行われています。

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9ab08dc4d3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/features/home/page.dart Outdated
Comment thread lib/features/ended_pill_sheet_dialog/components/summary_stats_teaser.dart Outdated
Comment thread lib/features/ended_pill_sheet_dialog/ended_pill_sheet_taken_summary.dart Outdated
Comment thread lib/features/ended_pill_sheet_dialog/ended_pill_sheet_taken_summary.dart Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
lib/l10n/app_en.arb (1)

2805-2809: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

新規ローカライズキーの @ メタデータ description が欠落・空です。

endedPillSheetDialogHistoryTitleendedPillSheetDialogSummaryTitle には @ メタデータ(description)が無く、endedPillSheetDialogSummaryMessage の description は空文字です。このファイルの他キーと同様に翻訳意図が伝わる説明を付与しておくと、翻訳品質・保守性が向上します。

🤖 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 `@lib/l10n/app_en.arb` around lines 2805 - 2809, The new localization keys in
app_en.arb are missing proper @ metadata descriptions, and
endedPillSheetDialogSummaryMessage currently has an empty description. Update
the corresponding metadata entries for endedPillSheetDialogHistoryTitle,
endedPillSheetDialogSummaryTitle, and endedPillSheetDialogSummaryMessage so each
has a clear, non-empty description consistent with the other ARB entries, using
the same key names to locate them.
🤖 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 `@lib/features/home/page.dart`:
- Around line 174-175: The ended pill sheet “shown” flag is written without
waiting for the result, so failures can be missed and the dialog may reappear
for the same group. Update the flow in the home page logic around
showEndedPillSheetDialog and sharedPreferences.setBool to await the write, check
the returned success value, and handle the failure case explicitly so the saved
state is reliable.

In `@test/features/ended_pill_sheet_dialog/ended_pill_sheet_dialog_test.dart`:
- Line 30: The EndedPillSheetDialog widget test group name should follow the
Widget Test naming convention and start with a # prefix. Update the group
declaration in EndedPillSheetDialog tests to use the widget class name with a
leading # so it matches the path instructions and is easy to identify alongside
other widget test groups.

---

Nitpick comments:
In `@lib/l10n/app_en.arb`:
- Around line 2805-2809: The new localization keys in app_en.arb are missing
proper @ metadata descriptions, and endedPillSheetDialogSummaryMessage currently
has an empty description. Update the corresponding metadata entries for
endedPillSheetDialogHistoryTitle, endedPillSheetDialogSummaryTitle, and
endedPillSheetDialogSummaryMessage so each has a clear, non-empty description
consistent with the other ARB entries, using the same key names to locate them.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1301f059-a4bd-45dc-95f7-c5b54131e18a

📥 Commits

Reviewing files that changed from the base of the PR and between ef78332 and 9ab08dc.

📒 Files selected for processing (22)
  • lib/entity/pill_sheet_modified_history.codegen.dart
  • lib/entity/remote_config_parameter.codegen.dart
  • lib/entity/remote_config_parameter.codegen.freezed.dart
  • lib/entity/remote_config_parameter.codegen.g.dart
  • lib/features/ended_pill_sheet_dialog/components/history_blur_teaser.dart
  • lib/features/ended_pill_sheet_dialog/components/summary_stats_teaser.dart
  • lib/features/ended_pill_sheet_dialog/ended_pill_sheet_dialog.dart
  • lib/features/ended_pill_sheet_dialog/ended_pill_sheet_dialog_variant.dart
  • lib/features/ended_pill_sheet_dialog/ended_pill_sheet_taken_summary.dart
  • lib/features/home/page.dart
  • lib/features/premium_introduction/paywall_source.dart
  • lib/l10n/app_en.arb
  • lib/l10n/app_ja.arb
  • lib/provider/remote_config_parameter.dart
  • lib/provider/remote_config_parameter.g.dart
  • lib/utils/remote_config.dart
  • lib/utils/shared_preference/keys.dart
  • test/entity/pill_sheet_modified_history_test.dart
  • test/features/ended_pill_sheet_dialog/ended_pill_sheet_dialog_test.dart
  • test/features/ended_pill_sheet_dialog/ended_pill_sheet_dialog_variant_test.dart
  • test/features/ended_pill_sheet_dialog/ended_pill_sheet_taken_summary_test.dart
  • test/features/premium_introduction/paywall_source_test.dart

Comment thread lib/features/home/page.dart Outdated
Comment thread test/features/ended_pill_sheet_dialog/ended_pill_sheet_dialog_test.dart Outdated
bannzai added 3 commits July 2, 2026 10:45
- 日付集合をすべて日付のみに正規化(時刻付き履歴で服用日が一致せず recordedDays=0 になる不具合を修正)
- 集計期間をシート開始日(beginDate)〜終了日(endDate・両端含む)にし、開始日〜初回記録前の未記録日も記録漏れに含める
- endedPillSheetTakenSummary は pillTakenDateSets を1回だけ呼び出す(服用予定日数・記録漏れ日数の二重計算を解消)
- scheduledPillDays を削除し、_buildPillTakenDateSets を pillTakenDateSets として公開
CodeRabbit レビュー対応: setBool の結果を待たずにいたため、保存失敗時に同じ終了グループでダイアログが再表示される可能性があった。await して失敗時は debugPrint する。
CodeRabbit レビュー対応: Widget Test のグループは Widget クラス名を # 始まりで命名する規約に合わせる。

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
lib/features/ended_pill_sheet_dialog/ended_pill_sheet_taken_summary.dart (1)

18-20: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

到達不能な null 分岐

beginDate は必須パラメータのため、pillTakenDateSets が null を返す条件(beginDate == null かつ履歴が空)には到達しません。この分岐は実質デッドコードです。

♻️ 提案
-  if (sets == null) {
-    return (recordedDays: 0, missedDays: 0);
-  }
-  final missedDays = sets.scheduledDates.difference(sets.takenDates).length;
+  final missedDays = sets!.scheduledDates.difference(sets.takenDates).length;

または、戻り値の型を non-nullable にできないか pillTakenDateSets 側の実装を確認した上で、呼び出し側のnullチェックの要否を再検討してください。

🤖 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 `@lib/features/ended_pill_sheet_dialog/ended_pill_sheet_taken_summary.dart`
around lines 18 - 20, The null guard in pillTakenDateSummary is unreachable
because beginDate is required, so the sets == null branch is dead code. Remove
that branch from ended_pill_sheet_taken_summary.dart and then verify
pillTakenDateSets and any callers of pillTakenDateSummary so the return type can
be kept consistently non-nullable if possible, or adjust the API only if a real
null case exists.
🤖 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 `@lib/features/ended_pill_sheet_dialog/ended_pill_sheet_taken_summary.dart`:
- Around line 18-20: The null guard in pillTakenDateSummary is unreachable
because beginDate is required, so the sets == null branch is dead code. Remove
that branch from ended_pill_sheet_taken_summary.dart and then verify
pillTakenDateSets and any callers of pillTakenDateSummary so the return type can
be kept consistently non-nullable if possible, or adjust the API only if a real
null case exists.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: aefe2cf1-9674-4ab2-91e5-0d3e8831e586

📥 Commits

Reviewing files that changed from the base of the PR and between 9ab08dc and 723748e.

📒 Files selected for processing (7)
  • lib/entity/pill_sheet_modified_history.codegen.dart
  • lib/features/ended_pill_sheet_dialog/components/summary_stats_teaser.dart
  • lib/features/ended_pill_sheet_dialog/ended_pill_sheet_taken_summary.dart
  • lib/features/home/page.dart
  • test/entity/pill_sheet_modified_history_test.dart
  • test/features/ended_pill_sheet_dialog/ended_pill_sheet_dialog_test.dart
  • test/features/ended_pill_sheet_dialog/ended_pill_sheet_taken_summary_test.dart
✅ Files skipped from review due to trivial changes (1)
  • lib/entity/pill_sheet_modified_history.codegen.dart
🚧 Files skipped from review as they are similar to previous changes (3)
  • test/features/ended_pill_sheet_dialog/ended_pill_sheet_dialog_test.dart
  • lib/features/home/page.dart
  • lib/features/ended_pill_sheet_dialog/components/summary_stats_teaser.dart

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 723748ec86

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/features/ended_pill_sheet_dialog/components/summary_stats_teaser.dart Outdated
Comment thread lib/features/ended_pill_sheet_dialog/components/summary_stats_teaser.dart Outdated
Comment thread lib/features/ended_pill_sheet_dialog/ended_pill_sheet_taken_summary.dart Outdated
bannzai added 2 commits July 10, 2026 05:21
コンフリクト解消:
- remote_config / paywall_source: main の lifetimeOffer* と本ブランチの endedPillSheetDialogVariant / endedPillSheetDialog* を両方残す
- home/page.dart: main で削除された月次 paywall (homeMonthly) 分岐は削除し、ピルシート終了ダイアログ分岐のみ残す
- 生成ファイル (freezed/g.dart) は build_runner で再生成

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5ab5553bc5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/features/ended_pill_sheet_dialog/components/history_blur_teaser.dart Outdated
Comment thread lib/features/home/page.dart
Comment thread lib/features/ended_pill_sheet_dialog/components/summary_stats_teaser.dart Outdated
Comment thread lib/entity/pill_sheet_modified_history.codegen.dart Outdated
bannzai added 4 commits July 10, 2026 06:19
- 日付正規化を DateTime(y,m,d) の手書きから .date() extension に置き換え
- revertTakenPill 履歴の before/after グループの lastTakenDate 差分から取り消された日を takenDates から除外する。取り消し後に再記録された日は時系列処理で再度加算される
服用予定日を begin〜end の全日から「各シートの錠剤日付のうち実薬分(dosingPeriod)」に変更。
pillsheet_21 等の休薬・偽薬期間が記録漏れにカウントされる問題を修正する。
服用お休みによる日付シフトは PillSheet.buildDates が織り込む
- AsyncValue を when で分岐し、ロード中は Indicator・エラーはメッセージをそのまま表示(空履歴での誤集計を防ぐ)
- afterPillSheetGroup.id でフィルタし、同じ日付範囲を含む別グループの履歴が混ざらないようにする
視覚的に隠している履歴がスクリーンリーダーで読み上げられないようにする
@bannzai

bannzai commented Jul 9, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@lib/features/ended_pill_sheet_dialog/components/summary_stats_teaser.dart`:
- Around line 54-62: The error branch in the `summary_stats_teaser.dart` widget
is exposing internal details by rendering `error.toString()` directly. Update
the `error:` callback in the teaser’s builder to avoid showing raw exception
text; instead, display a user-friendly fallback message or reuse the same
`Indicator` loading-style UI. Keep the change localized to the error handling
for this summary stats teaser so the widget no longer leaks implementation
details.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1765aad7-706b-42b9-bc47-9d3951b9d485

📥 Commits

Reviewing files that changed from the base of the PR and between 871b319 and 3edc953.

📒 Files selected for processing (14)
  • lib/entity/pill_sheet_modified_history.codegen.dart
  • lib/entity/remote_config_parameter.codegen.dart
  • lib/entity/remote_config_parameter.codegen.freezed.dart
  • lib/entity/remote_config_parameter.codegen.g.dart
  • lib/features/ended_pill_sheet_dialog/components/history_blur_teaser.dart
  • lib/features/ended_pill_sheet_dialog/components/summary_stats_teaser.dart
  • lib/features/ended_pill_sheet_dialog/ended_pill_sheet_taken_summary.dart
  • lib/features/home/page.dart
  • lib/features/premium_introduction/paywall_source.dart
  • lib/provider/remote_config_parameter.dart
  • lib/provider/remote_config_parameter.g.dart
  • lib/utils/remote_config.dart
  • lib/utils/shared_preference/keys.dart
  • test/features/ended_pill_sheet_dialog/ended_pill_sheet_taken_summary_test.dart
💤 Files with no reviewable changes (1)
  • lib/features/home/page.dart
✅ Files skipped from review due to trivial changes (4)
  • lib/entity/remote_config_parameter.codegen.g.dart
  • lib/utils/remote_config.dart
  • lib/provider/remote_config_parameter.g.dart
  • lib/entity/remote_config_parameter.codegen.freezed.dart
🚧 Files skipped from review as they are similar to previous changes (6)
  • lib/features/ended_pill_sheet_dialog/components/history_blur_teaser.dart
  • lib/utils/shared_preference/keys.dart
  • lib/features/premium_introduction/paywall_source.dart
  • lib/provider/remote_config_parameter.dart
  • lib/entity/remote_config_parameter.codegen.dart
  • lib/entity/pill_sheet_modified_history.codegen.dart

@bannzai

bannzai commented Jul 9, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3edc953186

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/features/home/page.dart
Comment thread lib/l10n/app_ja.arb
Comment thread lib/features/home/page.dart Outdated
bannzai added 2 commits July 10, 2026 06:39
履歴は180日のTTLで削除されるため、終了から長期間経過したグループでは取得結果が空になり
「服用記録0件・記録漏れ全日」の誤った集計が表示されていた。対象グループの履歴が空の場合は
集計メッセージを出さず、見出し・プレミアム訴求・CTAのみ表示する
- 取り消してそのままの日は飲み忘れとしてカウントされる
- 取り消して同じ日に再記録した場合は飲み忘れにならない
- 複数日分まとめて取り消した場合は全日が飲み忘れになる

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 07fd6408d0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/features/ended_pill_sheet_dialog/components/summary_stats_teaser.dart Outdated
Comment thread lib/features/home/page.dart Outdated
PR #1809 の既存挙動変更の監査で不足していた直接テストを追加:
- 全件取り消し(取り消し後の最終服用日が null)で全日が飲み忘れになる
- before/after グループが null の revert は従来どおり無視される
- 最古履歴が深夜(23:59)の時刻付きでも日付単位で集計される
- 時刻付き最古履歴 + 服用お休み継続中で休薬期間が除外される

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 07a7cec6d4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/features/ended_pill_sheet_dialog/components/history_blur_teaser.dart Outdated
Comment thread lib/features/ended_pill_sheet_dialog/components/history_blur_teaser.dart Outdated
- HistoryBlurTeaser を対象グループの履歴に絞り、取り消し(revertTakenPill)されたままの服用記録を表示しない
- SummaryStatsTeaser は集計開始日が履歴TTL(180日)の窓外の場合、部分的な履歴欠落による誤集計を防ぐため集計メッセージを表示しない
- 削除済み(deletedAt != null)グループを終了ダイアログの表示対象から除外
- 上記の widget テストを追加
@bannzai

bannzai commented Jul 11, 2026

Copy link
Copy Markdown
Owner Author

/gemini review

@bannzai

bannzai commented Jul 11, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5ab0993388

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/features/home/page.dart
Comment thread lib/features/ended_pill_sheet_dialog/components/summary_stats_teaser.dart Outdated
集計メッセージの無いダイアログで impression と表示済みフラグを消費しないよう、
表示トリガー側で endedPillSheetTakenSummaryAvailable(履歴TTL窓内かつ対象グループの
履歴あり)を事前判定する。ティーザー側の同条件チェックは表示中のデータ更新に対する
防御として共通関数で残す

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: feee1cacae

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/entity/pill_sheet_modified_history.codegen.dart Outdated
Comment thread lib/features/home/page.dart
Comment thread lib/features/ended_pill_sheet_dialog/components/history_blur_teaser.dart Outdated
- pillTakenDateSets: まとめ記録では操作日ではなく記録対象日 (記録前の最終服用日, 記録後の最終服用日] を展開して集計する。グループ情報の無い旧履歴は従来どおり
- 起動時自動モーダルの排他: shownPaywallOnThisAppLaunchProvider を共有フラグとして、終了ダイアログと買い切りオファーが同一起動で重ならないようにする
- HistoryBlurTeaser: AsyncValue.when でローディング中は Indicator を表示し、表示トリガー側でも履歴取得後に表示可否を判定する(内容の無いダイアログで impression と表示済みフラグを消費しない)
@bannzai

bannzai commented Jul 11, 2026

Copy link
Copy Markdown
Owner Author

/gemini review

@bannzai

bannzai commented Jul 11, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5dc4a449bd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/entity/pill_sheet_modified_history.codegen.dart Outdated
Comment thread lib/features/home/page.dart
Comment thread lib/features/home/page.dart
Comment thread lib/features/ended_pill_sheet_dialog/components/history_blur_teaser.dart Outdated
- takenPillHistoryTargetDates を切り出し、服用日時が編集された履歴は編集後の日時を記録日とする(before/after の lastTakenDate は編集前のままのため)
- 履歴ティーザーの照合を操作日ではなく記録対象日で行い、過去日のピルを後から記録した履歴が落ちないようにする
- 終了ダイアログ表示直前に起動時モーダルの共有排他フラグを再確認する(履歴取得 await 中の競合対策)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 97cceb77f4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/features/ended_pill_sheet_dialog/components/history_blur_teaser.dart Outdated
Comment thread lib/features/root/resolver/show_lifetime_offer_on_app_launch.dart
Comment thread lib/entity/pill_sheet_modified_history.codegen.dart Outdated
Comment thread lib/entity/pill_sheet_modified_history.codegen.dart
- 同じピル日に2回目を記録した履歴(lastTakenDate 不変)も記録対象日としてその日を返す
- 服用日時を編集した記録が取り消された場合、編集後の日付も服用済みから除外する(元のピル日付→編集後日付の対応を保持)
- 一部だけ取り消されたまとめ記録の行はティーザーに表示しない(行表示が afterPillSheetGroup ベースで実態とずれるため)
- 買い切りオファー側も表示直前に起動時モーダルの共有排他フラグを再確認する
@bannzai

bannzai commented Jul 11, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: a2369566d3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

# Conflicts:
#	lib/entity/remote_config_parameter.codegen.dart
#	lib/entity/remote_config_parameter.codegen.freezed.dart
#	lib/entity/remote_config_parameter.codegen.g.dart
#	lib/provider/remote_config_parameter.dart
#	lib/provider/remote_config_parameter.g.dart
#	lib/utils/remote_config.dart

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7a06139dd0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

return false;
}
final targetDates = takenPillHistoryTargetDates(history);
return targetDates.isNotEmpty && targetDates.every(takenDates.contains);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 再記録後も取り消し済み行を表示しないでください

同じ日を takenPill → revertTakenPill → takenPill で再記録した場合、takenDates には最終的な日付だけが残るため、後続の再記録だけでなく取り消された元の takenPill 行もこの条件を通過します。履歴ティーザーは revertTakenPill 行を表示しないので、直近3件に元行が入ると、最終状態では1件の服用記録しかない日に取り消し済みの服用行まで課金ティーザーとして見えてしまいます。日付集合だけでなく、時系列処理で生き残った taken 履歴を特定して表示対象を絞ってください。

Useful? React with 👍 / 👎.

Comment on lines +336 to +337
if (history.value.takenPill?.edited != null) {
return [history.estimatedEventCausingDate.date()];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 編集履歴の操作順で取り消しを反映してください

新たな根拠は、現在のコードが編集後の服用日時を estimatedEventCausingDate にして日付順処理するため、編集後日時が取り消し操作より後だと revert が先に処理される点です。服用日時を翌日などへ編集してからすぐ取り消すと、revert 時点では editedTakenDatesByOriginalDate が未登録で編集後日付を消せず、その後この分岐で取り消し済みの日付が takenDates に追加され、summary/history teaser に服用済みとして残ります。操作順(createdAt など)で取り消しを処理するか、revert 後にも編集済み対応を除去してください。

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant