Skip to content

Androidホーム画面ウィジェットが更新されず未乗車表示のままになる問題を修正 - #6577

Merged
TinyKitten merged 3 commits into
devfrom
claude/android-widget-implementation-jc2yaf
Aug 6, 2026
Merged

TinyKitten merged 3 commits into
devfrom
claude/android-widget-implementation-jc2yaf

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Aug 6, 2026 •

Copy link
Copy Markdown
Member

概要

Android のホーム画面ウィジェットが、乗車中でも常に未乗車表示(dev 版ではアプリ名の TrainLCD Canary)のままになる問題を修正します。

原因は、ウィジェットへの同期を呼んでいた useUpdateLiveActivities が iOS でしかマウントされていないことでした(src/screens/Main.tsx の FxUpdateLiveActivities が Platform.OS === 'ios' でゲートされている。#6422 の再レンダー最適化で導入)。そのため Android では updateWidget が一度も呼ばれず、ウィジェットは初期状態のままでした。

加えて、未乗車時の 1 行レイアウトが @string/app_name を表示していたため、TrainLCD Canary という文字列だけが見える状態になっていました。ウィジェット選択画面のプレビューも、レイアウトに既定文言がなく空欄でした。

Note

同じゲートにより Android 16 のライブアップデート通知(startLiveUpdate / updateLiveUpdate)も現状呼ばれていません。ウィジェットとは独立した挙動変更になるため本 PR では触れていません。復活させるべきかは別途ご判断ください。

変更の種類

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

変更内容

データ経路の修正

  • useUpdateWidget を新設。ウィジェットが必要とする低頻度の項目(路線名・路線色・路線記号・方面)だけを購読し、到着・通過など毎秒変化する状態は購読しないため、高頻度atom購読の隔離で位置更新ごとの全画面再レンダーを解消 #6422 で避けた位置更新ごとの派生計算コストは持ち込まない
  • MainScreenEffects に FxUpdateWidget を追加し、Android でのみマウント(レンダーレス副作用ホスト 1 つにつき 1 フックの規約に従う)
  • iOS 専用の useUpdateLiveActivities から、呼ばれることのなかった updateWidget / clearWidget の呼び出しを削除
  • useUpdateWidget の単体テストを追加(行先選択時に送信する / 未選択では送らない / アンマウント(降車)で消去する)

表示の修正

テスト

npm run lint / npm test(209 suites・2198 tests passed)/ npm run typecheck をローカルで実行し、いずれも成功しています。あわせて Android SDK 36 + JDK 17 で ./gradlew :app:compileDevDebugKotlin を実行し BUILD SUCCESSFUL を確認しました(processDevDebugResources を通過しているため、追加・変更したレイアウトとリソースも検証済みです)。

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

関連Issue

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

作業環境にエミュレータ/実機がないため未取得です。canary ビルドで、乗車後にウィジェットへ路線名・方面・路線記号が反映されること、および未乗車時にプレースホルダーが表示されることの確認をお願いします。


Generated by Claude Code

Summary by CodeRabbit

  • 新機能

    • Androidホーム画面ウィジェットが、極小・小型・横長・正方形の4サイズに対応しました。
    • 路線名、行き先、路線記号をサイズに応じて見やすく表示します。
    • 選択中の乗車情報を自動反映し、乗車情報が解除されるとウィジェットもリセットされます。
  • 改善

    • 路線記号や行き先が未設定の場合に、適切なプレースホルダーを表示します。
    • ウィジェットの初期表示とプレビューを小型レイアウトに更新しました。

claude added 2 commits August 6, 2026 14:06
ライブアクティビティ更新フックはiOSでのみマウントされるため、その中から呼んでいた
ウィジェット同期がAndroidでは一度も実行されていなかった。ウィジェットが必要とする
低頻度の項目だけを購読する専用フックへ切り出し、Androidで別ホストとしてマウントする。

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XHQB1iKjHbZLmPDKysVpnt
未乗車時の1行表示がアプリ名(dev版では「TrainLCD Canary」)になっていたため、
路線未設定のプレースホルダーへ差し替える。あわせてiOSのHomeScreenWidgetに合わせた
正方形レイアウトの追加とナンバリングサークルの線幅調整、ウィジェット選択画面の
プレビューが空にならないよう各レイアウトへ既定文言を設定する。

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XHQB1iKjHbZLmPDKysVpnt
@TinyKitten TinyKitten self-assigned this Aug 6, 2026
@TinyKitten TinyKitten mentioned this pull request Aug 6, 2026
4 of 9 tasks
@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 2 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c1a5228b-b23d-4733-96f5-28e1851c893e

📥 Commits

Reviewing files that changed from the base of the PR and between 560c0fe and fee72a6.

📒 Files selected for processing (3)
  • android/app/src/main/java/me/tinykitten/trainlcd/RideWidgetProvider.kt
  • src/hooks/useUpdateWidget.test.tsx
  • src/hooks/useUpdateWidget.ts
📝 Walkthrough

Walkthrough

Androidウィジェットを4種類のサイズに対応させました。路線情報の表示を更新しました。useUpdateWidget を追加し、Android環境で乗車情報を同期します。ライブアクティビティ処理からウィジェット更新を分離しました。

Changes

Androidウィジェット表示

Layer / File(s) Summary
サイズ別レイアウトと表示内容
android/app/src/main/java/.../RideWidgetProvider.kt, android/app/src/main/res/layout/*, android/app/src/main/res/drawable/*, android/app/src/main/res/values/strings.xml, android/app/src/main/res/xml/ride_widget_info.xml
高さに基づく4種類のレイアウト判定を追加しました。smallレイアウトを新設しました。路線記号、路線名、行き先、プレースホルダーの表示を更新しました。
乗車情報同期フック
src/hooks/useUpdateWidget.ts, src/hooks/useUpdateWidget.test.tsx, src/hooks/index.ts, src/hooks/useUpdateLiveActivities.ts
useUpdateWidget を追加しました。選択中の乗車方向がある場合にウィジェットを更新します。アンマウント時にウィジェットをクリアします。関連テストを追加し、ライブアクティビティ処理からウィジェット更新を削除しました。
Android限定の副作用組み込み
src/screens/Main.tsx
FxUpdateWidget を追加しました。Android環境でのみ useUpdateWidget を実行します。

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • TrainLCD/MobileApp#6569: RideWidgetProvider、ウィジェットレイアウト、useUpdateLiveActivities の連携を導入したPRです。

Poem

うさぎが路線をぴょんと追い
小さな画面にも記号が咲く
路線と行き先を届ければ
ウィジェットは今日も更新
乗車が終われば、そっとクリア

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed タイトルは、Androidホーム画面ウィジェットが更新されず未乗車表示のままになる問題の修正という主な変更内容を正確に示しています。
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/android-widget-implementation-jc2yaf

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 `@android/app/src/main/java/me/tinykitten/trainlcd/RideWidgetProvider.kt`:
- Around line 108-110: Update the view-selection logic in RideWidgetProvider so
smallViews requires both the small height threshold and a width/aspect-ratio
condition; route wide 4x2 widgets to rectangularViews while keeping 2x2 widgets
on smallViews. Add regression coverage for both widget sizes using the existing
test structure.

In `@src/hooks/useUpdateWidget.ts`:
- Around line 48-54: Update the useEffect in useUpdateWidget so its
!selectedBound branch calls clearWidget() before returning, clearing stale
widget data when selectedBound changes to null. Add a test that rerenders from a
populated selectedBound to null and verifies clearWidget is invoked.
🪄 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: f3ead137-5a4c-4e36-8c94-d00f0f1dca45

📥 Commits

Reviewing files that changed from the base of the PR and between 3fce328 and 560c0fe.

📒 Files selected for processing (13)
  • android/app/src/main/java/me/tinykitten/trainlcd/RideWidgetProvider.kt
  • android/app/src/main/res/drawable/widget_numbering_circle.xml
  • android/app/src/main/res/layout/widget_ride_circular.xml
  • android/app/src/main/res/layout/widget_ride_inline.xml
  • android/app/src/main/res/layout/widget_ride_rectangular.xml
  • android/app/src/main/res/layout/widget_ride_small.xml
  • android/app/src/main/res/values/strings.xml
  • android/app/src/main/res/xml/ride_widget_info.xml
  • src/hooks/index.ts
  • src/hooks/useUpdateLiveActivities.ts
  • src/hooks/useUpdateWidget.test.tsx
  • src/hooks/useUpdateWidget.ts
  • src/screens/Main.tsx
💤 Files with no reviewable changes (1)
  • src/hooks/useUpdateLiveActivities.ts

Comment thread src/hooks/useUpdateWidget.ts Resolved
@TinyKitten

Copy link
Copy Markdown
Member Author

@coderabbitai review

@TinyKitten
TinyKitten merged commit d10a866 into dev Aug 6, 2026
5 checks passed
@TinyKitten
TinyKitten deleted the claude/android-widget-implementation-jc2yaf branch August 6, 2026 16:07
@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.

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.

@TinyKitten TinyKitten mentioned this pull request Aug 8, 2026
5 of 9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants