Skip to content

駅通過時にヘッダーが通過駅ではなく次の停車駅を表示するように修正#5515

Merged
TinyKitten merged 2 commits intodevfrom
claude/fix-station-header-display-CV6hr
Mar 2, 2026
Merged

駅通過時にヘッダーが通過駅ではなく次の停車駅を表示するように修正#5515
TinyKitten merged 2 commits intodevfrom
claude/fix-station-header-display-CV6hr

Conversation

@TinyKitten
Copy link
Member

@TinyKitten TinyKitten commented Mar 2, 2026

Summary

  • 駅通過中にヘッダーに通過している駅名が表示されていた不具合を修正
  • showNextExpression の条件順序を変更し、通過駅チェック (getIsPass) を arrived チェックの前に移動
  • これにより通過駅到着時でも showNextExpression = true となり、ヘッダーが「次は」状態で次の停車駅名を正しく表示する

原因

showNextExpression!nextStation || arrived を一括で早期リターンしていたため、通過駅に到着した際(arrived = true)に getIsPass チェックに到達せず、ヘッダーが CURRENT 状態のまま通過駅名を表示していた。

変更内容

src/hooks/useTransitionHeaderState.ts:

  1. !nextStationarrived の条件を分離
  2. 通過駅チェック (getIsPass) を arrived チェックの前に配置

Test plan

  • npm run lint — passed
  • npm run typecheck — passed
  • npm test — 136 suites, 1257 tests all passed
  • 通過駅のある路線(例: 急行運転路線)でヘッダー表示を実機確認

https://claude.ai/code/session_019vrAoQbcYcG1WcG41D2qe5

Summary by CodeRabbit

リリースノート

  • Bug Fixes
    • ヘッダーの状態遷移ロジックを改善し、到着状況の処理をより柔軟に対応するよう修正しました。駅情報の更新時における画面表示の切り替わりがより正確になります。

showNextExpressionで`arrived`チェックが`getIsPass`チェックより前にあったため、
通過駅に到着した際にshowNextExpressionがfalseを返し、ヘッダーが通過駅名を
表示していた。通過駅チェックを到着チェックの前に移動することで修正。

https://claude.ai/code/session_019vrAoQbcYcG1WcG41D2qe5
@github-actions github-actions bot added the react label Mar 2, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1c37188 and 6e2f352.

📒 Files selected for processing (1)
  • src/hooks/useTransitionHeaderState.ts

📝 Walkthrough

Walkthrough

useTransitionHeaderStateフック内のshowNextExpressionで到着(arrived)フラグの評価順と早期リターン条件が見直され、nextStationの存在確認と到着判定が分離されて後続条件の評価が可能になるよう制御フローが変更されました。

Changes

Cohort / File(s) Summary
Header State Transition Logic
src/hooks/useTransitionHeaderState.ts
showNextExpressionの早期終了条件をif (!nextStation)に変更し、arrived判定を別ブランチで扱うように修正。stationForHeader比較と次ヘッダー遷移条件からarrivedガードを除去し、最終フォールバックは到着に依存しない形へ変更。到着・接近フラグを用いる条件順序に注意が必要。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 ぴょんと跳ねて次へ行く、
到着の扉はそっと分けて、
条件整えば道は開く、
小さな変化で景色かわる、
🥕ヘッダーも喜ぶ春の日。

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed プルリクエストのタイトルは、駅通過時にヘッダーが表示する駅情報の修正内容を明確に説明しており、変更セットの主要な目的と一致しています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch claude/fix-station-header-display-CV6hr

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/hooks/useTransitionHeaderState.ts (1)

140-163: ロジック変更は正しく、PRの目的に沿っています。

通過駅では到着中でも次の停車駅を表示するようになり、意図した動作です。

ただし、リファクタリングの余地があります: Line 150-152でarrivedがtrueの場合は既にreturnしているため、Line 154の&& !arrivedとLine 162の!arrived &&は冗長になっています。

♻️ 冗長な条件の削除
     // 急行停車駅発車直後trueにする
-    if (stationForHeader?.id === station?.id && !arrived) {
+    if (stationForHeader?.id === station?.id) {
       return true;
     }
     // 地理的な最寄り駅と次の停車駅が違う場合場合 かつ 次の停車駅に近づいていなければtrue
     if (stationForHeader?.id !== station?.id && !approaching) {
       return true;
     }
     // 地理的な最寄り駅と次の停車駅が同じ場合に到着していない かつ 接近もしていない場合true
-    return !arrived && !approaching;
+    return !approaching;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/hooks/useTransitionHeaderState.ts` around lines 140 - 163, The computed
showNextExpression in useTransitionHeaderState.ts contains redundant arrived
checks; remove the unnecessary "&& !arrived" in the branch that checks
"stationForHeader?.id === station?.id && !arrived" and remove the "!arrived &&"
in the final return since earlier branches already return when arrived is
true—leave the initial arrived check (if (arrived) return false) intact and
update the memo dependencies as-is so the remaining conditions
(stationForHeader?.id === station?.id, stationForHeader?.id !== station?.id &&
!approaching, and final return !approaching) reflect the same logic without
duplicated arrived guards.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/hooks/useTransitionHeaderState.ts`:
- Around line 140-163: The computed showNextExpression in
useTransitionHeaderState.ts contains redundant arrived checks; remove the
unnecessary "&& !arrived" in the branch that checks "stationForHeader?.id ===
station?.id && !arrived" and remove the "!arrived &&" in the final return since
earlier branches already return when arrived is true—leave the initial arrived
check (if (arrived) return false) intact and update the memo dependencies as-is
so the remaining conditions (stationForHeader?.id === station?.id,
stationForHeader?.id !== station?.id && !approaching, and final return
!approaching) reflect the same logic without duplicated arrived guards.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b50b5a0 and 1c37188.

📒 Files selected for processing (1)
  • src/hooks/useTransitionHeaderState.ts

早期リターン`if (arrived) return false`の後では`arrived`は常にfalseのため、
後続の`&& !arrived`および`!arrived &&`ガードは不要。

https://claude.ai/code/session_019vrAoQbcYcG1WcG41D2qe5
@TinyKitten TinyKitten merged commit 6440c65 into dev Mar 2, 2026
6 checks passed
@TinyKitten TinyKitten deleted the claude/fix-station-header-display-CV6hr branch March 2, 2026 05:58
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