Skip to content

LineBoard(東日本・JR九州・埼京線・都営)に到着予想分数のオーバーレイ表示を追加 - #6321

Merged
TinyKitten merged 1 commit into
devfrom
feature/lineboard-estimated-minutes-overlay
Jul 1, 2026
Merged

TinyKitten merged 1 commit into
devfrom
feature/lineboard-estimated-minutes-overlay

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Jul 1, 2026 •

Copy link
Copy Markdown
Member

概要

LineBoard の東日本・JR九州・埼京線・都営の4テーマに、到着予想分数をドットに重ねて表示する機能を追加します。全テーマへの反映は段階的に進めており、本PRはその一部です。分数表示に対応していないテーマもまだ残っています。

変更の種類

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

変更内容

  • LineDot に到着予想分数を丸の上に重ねて表示する estimatedMinutes prop とオーバーレイ表示を追加
  • LineBoardEast / LineBoardJRKyushu / LineBoardSaikyo / LineBoardToei にて useEstimateArrivalTimes から取得したルート情報を駅グループIDごとの分数マップに変換し、各駅の LineDot に受け渡し
  • 上記4テーマのテストで useEstimateArrivalTimes のモックを追加

テスト

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

関連Issue

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

Summary by CodeRabbit

  • 新機能

    • 駅一覧に到着見込み分数を表示できるようになりました。
    • 路線図の駅アイコン上に、推定分数がある場合は数値バッジが重なって表示されます。
  • テスト

    • 到着見込み情報に関するテスト環境を更新し、表示の安定性を高めました。

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

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

LineDotコンポーネントに到着予想分数を表示するオーバーレイ機能を追加し、LineBoardEast・LineBoardJRKyushu・LineBoardSaikyo・LineBoardToeiの各コンポーネントでuseEstimateArrivalTimesフックを用いてstationGroupIdごとのestimatedMinutesを算出しLineDotへ渡すよう変更。対応するテストファイルのモックも更新。

Changes

到着予想時間表示機能

Layer / File(s) Summary
LineDot: estimatedMinutesオーバーレイ表示
src/components/LineBoard/shared/components/LineDot.tsx
LineDotPropsにestimatedMinutes?: number | nullを追加し、dotSizeStyleを共通化。estimatedMinutesが存在する場合に丸めた分数を表示するオーバーレイViewとTextを追加。
LineBoardEast: 到着予想時間の算出と伝播
src/components/LineBoardEast.tsx, src/components/LineBoardEast.test.tsx
useEstimateArrivalTimesからstationGroupIdごとのcumulativeMinutesをMap化し、StationNameCell経由でLineDotへ渡す。テストモックにuseEstimateArrivalTimesを追加。
LineBoardJRKyushu: 到着予想時間の算出と伝播
src/components/LineBoardJRKyushu.tsx, src/components/LineBoardJRKyushu.test.tsx
同様にestimatedMinutesByGroupIdをuseMemoで構築し、StationNameCellProps/BaseとLineDotに渡す。テストモックを更新。
LineBoardSaikyo: 到着予想時間の算出と伝播
src/components/LineBoardSaikyo.tsx, src/components/LineBoardSaikyo.test.tsx
同様の到着予想時間算出・伝播ロジックを追加。テストモックを更新。
LineBoardToei: 到着予想時間の算出と伝播
src/components/LineBoardToei.tsx, src/components/LineBoardToei.test.tsx
同様の到着予想時間算出・伝播ロジックを追加。テストモックを更新。

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

Sequence Diagram(s)

sequenceDiagram
  participant LineBoard as LineBoard系コンポーネント
  participant Hook as useEstimateArrivalTimes
  participant Cell as StationNameCell
  participant Dot as LineDot

  LineBoard->>Hook: 呼び出し
  Hook-->>LineBoard: estimatedRoute.stops
  LineBoard->>LineBoard: stationGroupId毎にcumulativeMinutesをMap化
  LineBoard->>Cell: estimatedMinutesを渡す
  Cell->>Dot: estimatedMinutesを転送
  Dot->>Dot: Math.round(estimatedMinutes)をオーバーレイ表示
Loading

Poem

ぴょんぴょん跳ねて時計を見る
到着まであと何分?と数える
LineDotの上にちょこんと数字
各線区みんな仲良く伝えあう
うさぎもニッコリ、到着案内 🐰⏱️

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PRタイトルは4テーマへの到着予想分数のオーバーレイ追加という主変更を具体的に表しています。
Description check ✅ Passed 主要セクションが揃っており、概要・変更内容・テスト結果が記載されているため十分です。
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/lineboard-estimated-minutes-overlay

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.

🧹 Nitpick comments (3)
src/components/LineBoard/shared/components/LineDot.tsx (1)

103-118: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

3桁以上の到着予想分数でテキストがはみ出す可能性があります。

estimatedMinutesText に numberOfLines や adjustsFontSizeToFit の指定がなく、Math.round(estimatedMinutes) が2桁を超える場合(長距離路線などで到着予想分数が大きくなるケース)、円形ドット(isTablet ? 36/24 : 24/12 相当のサイズ)内でテキストが折り返されたり、はみ出したりする可能性があります。

💡 オーバーフロー対策の提案
             <Text style={localStyles.estimatedMinutesText}>
+              {/* biome-ignore lint: 桁数増加時のはみ出しを防ぐためnumberOfLinesと自動縮小を明示 */}
+              <Text
+                style={localStyles.estimatedMinutesText}
+                numberOfLines={1}
+                adjustsFontSizeToFit
+                minimumFontScale={0.5}
+              >
                 {Math.round(estimatedMinutes)}
               </Text>
🤖 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/components/LineBoard/shared/components/LineDot.tsx` around lines 103 -
118, The estimated minutes label in LineDot.tsx can overflow the circular dot
when Math.round(estimatedMinutes) becomes 3+ digits. Update the Text inside the
estimatedMinutes overlay (estimatedMinutesText) to constrain it to a single line
and shrink/fitting within the dot, and verify the dot sizing logic in LineDot
and dotSizeStyle still centers the label for both tablet and mobile sizes.
src/components/LineBoardEast.tsx (1)

491-501: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Map構築ロジックが4つのLineBoardコンポーネントで重複している

estimatedRoute?.stops から stationGroupId -> cumulativeMinutes の Map を構築するロジックが、LineBoardJRKyushu.tsx・LineBoardSaikyo.tsx・LineBoardToei.tsx にも一字一句同じ形で存在します。共有フック(例: useEstimatedMinutesByGroupId)に切り出すことで、将来の仕様変更時に4箇所を同期して直す必要がなくなり、実装の分岐リスクを避けられます。

♻️ 共有フックへの切り出し例
// src/hooks/useEstimatedMinutesByGroupId.ts
import { useMemo } from 'react';
import { useEstimateArrivalTimes } from '~/hooks';

export const useEstimatedMinutesByGroupId = () => {
  const { route: estimatedRoute } = useEstimateArrivalTimes();
  return useMemo(
    () =>
      new Map(
        estimatedRoute?.stops
          ?.filter((s) => s.stationGroupId != null)
          .map((s) => [s.stationGroupId as number, s.cumulativeMinutes]) ?? []
      ),
    [estimatedRoute]
  );
};
-  const { route: estimatedRoute } = useEstimateArrivalTimes();
-
-  const estimatedMinutesByGroupId = useMemo(
-    () =>
-      new Map(
-        estimatedRoute?.stops
-          ?.filter((s) => s.stationGroupId != null)
-          .map((s) => [s.stationGroupId as number, s.cumulativeMinutes]) ?? []
-      ),
-    [estimatedRoute]
-  );
+  const estimatedMinutesByGroupId = useEstimatedMinutesByGroupId();
🤖 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/components/LineBoardEast.tsx` around lines 491 - 501, The
estimatedMinutesByGroupId Map-building logic is duplicated across LineBoard
components, so extract it into a shared hook such as
useEstimatedMinutesByGroupId and reuse it from LineBoardEast, LineBoardJRKyushu,
LineBoardSaikyo, and LineBoardToei. Move the useEstimateArrivalTimes plus
useMemo transformation that converts estimatedRoute?.stops into stationGroupId
-> cumulativeMinutes into that hook, then replace the local copies with the
shared hook return value.
src/components/LineBoardEast.test.tsx (1)

13-20: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

estimatedMinutes の実際の伝播を検証するテストが不足している

useEstimateArrivalTimes のモックが常に { route: null } を返すため、estimatedMinutesByGroupId の算出や LineDot への estimatedMinutes 伝播ロジックは実質テストされていません。挙動を追加した変更セットとして、経路データがあるケースで LineDot が期待した estimatedMinutes で呼び出されることを検証するテストを追加することを推奨します。

As per path instructions, src/**/*.test.{ts,tsx} guideline states "When modifying behavior, update or add tests in the same change set; document skipped tests with TODOs and owner rationale." Also **/*.{test,spec}.{ts,tsx,...} guideline: "Test agents in isolation and with integration tests to ensure correctness and compatibility."

✅ 追加テスト例
it('estimatedMinutesがLineDotに正しく渡される', () => {
  const { useEstimateArrivalTimes } = require('~/hooks');
  useEstimateArrivalTimes.mockReturnValue({
    route: { stops: [{ stationGroupId: 2, cumulativeMinutes: 5 }] },
  });
  const { LineDot } = require('./LineBoard/shared/components');
  render(
    <LineBoardEast
      stations={mockStations}
      lineColors={['`#9acd32`', '`#9acd32`']}
      hasTerminus={false}
    />
  );
  expect(LineDot).toHaveBeenCalledWith(
    expect.objectContaining({ estimatedMinutes: 5 }),
    undefined
  );
});
🤖 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/components/LineBoardEast.test.tsx` around lines 13 - 20, The current
LineBoardEast test only mocks useEstimateArrivalTimes to return route: null, so
estimatedMinutesByGroupId and the LineDot estimatedMinutes propagation are not
exercised. Update LineBoardEast.test.tsx by adding a case that uses a real route
value from useEstimateArrivalTimes and asserts that LineDot is called with the
expected estimatedMinutes for the matching station group. Use the existing
symbols useEstimateArrivalTimes, estimatedMinutesByGroupId, and LineDot to
locate and verify the behavior.

Source: Path instructions

🤖 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/components/LineBoard/shared/components/LineDot.tsx`:
- Around line 103-118: The estimated minutes label in LineDot.tsx can overflow
the circular dot when Math.round(estimatedMinutes) becomes 3+ digits. Update the
Text inside the estimatedMinutes overlay (estimatedMinutesText) to constrain it
to a single line and shrink/fitting within the dot, and verify the dot sizing
logic in LineDot and dotSizeStyle still centers the label for both tablet and
mobile sizes.

In `@src/components/LineBoardEast.test.tsx`:
- Around line 13-20: The current LineBoardEast test only mocks
useEstimateArrivalTimes to return route: null, so estimatedMinutesByGroupId and
the LineDot estimatedMinutes propagation are not exercised. Update
LineBoardEast.test.tsx by adding a case that uses a real route value from
useEstimateArrivalTimes and asserts that LineDot is called with the expected
estimatedMinutes for the matching station group. Use the existing symbols
useEstimateArrivalTimes, estimatedMinutesByGroupId, and LineDot to locate and
verify the behavior.

In `@src/components/LineBoardEast.tsx`:
- Around line 491-501: The estimatedMinutesByGroupId Map-building logic is
duplicated across LineBoard components, so extract it into a shared hook such as
useEstimatedMinutesByGroupId and reuse it from LineBoardEast, LineBoardJRKyushu,
LineBoardSaikyo, and LineBoardToei. Move the useEstimateArrivalTimes plus
useMemo transformation that converts estimatedRoute?.stops into stationGroupId
-> cumulativeMinutes into that hook, then replace the local copies with the
shared hook return value.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 58e8e585-5331-4471-860e-47d048dc1bcd

📥 Commits

Reviewing files that changed from the base of the PR and between 10643c8 and dc28fc4.

📒 Files selected for processing (9)
  • src/components/LineBoard/shared/components/LineDot.tsx
  • src/components/LineBoardEast.test.tsx
  • src/components/LineBoardEast.tsx
  • src/components/LineBoardJRKyushu.test.tsx
  • src/components/LineBoardJRKyushu.tsx
  • src/components/LineBoardSaikyo.test.tsx
  • src/components/LineBoardSaikyo.tsx
  • src/components/LineBoardToei.test.tsx
  • src/components/LineBoardToei.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