Repository navigation
LineBoard(東日本・JR九州・埼京線・都営)に到着予想分数のオーバーレイ表示を追加 - #6321
Conversation
📝 WalkthroughWalkthroughLineDotコンポーネントに到着予想分数を表示するオーバーレイ機能を追加し、LineBoardEast・LineBoardJRKyushu・LineBoardSaikyo・LineBoardToeiの各コンポーネントでuseEstimateArrivalTimesフックを用いてstationGroupIdごとのestimatedMinutesを算出しLineDotへ渡すよう変更。対応するテストファイルのモックも更新。 Changes到着予想時間表示機能
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)をオーバーレイ表示
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (3)
src/components/LineBoard/shared/components/LineDot.tsx (1)
103-118: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win3桁以上の到着予想分数でテキストがはみ出す可能性があります。
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 winMap構築ロジックが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
📒 Files selected for processing (9)
src/components/LineBoard/shared/components/LineDot.tsxsrc/components/LineBoardEast.test.tsxsrc/components/LineBoardEast.tsxsrc/components/LineBoardJRKyushu.test.tsxsrc/components/LineBoardJRKyushu.tsxsrc/components/LineBoardSaikyo.test.tsxsrc/components/LineBoardSaikyo.tsxsrc/components/LineBoardToei.test.tsxsrc/components/LineBoardToei.tsx
概要
LineBoard の東日本・JR九州・埼京線・都営の4テーマに、到着予想分数をドットに重ねて表示する機能を追加します。全テーマへの反映は段階的に進めており、本PRはその一部です。分数表示に対応していないテーマもまだ残っています。
変更の種類
変更内容
LineDotに到着予想分数を丸の上に重ねて表示するestimatedMinutesprop とオーバーレイ表示を追加LineBoardEast/LineBoardJRKyushu/LineBoardSaikyo/LineBoardToeiにてuseEstimateArrivalTimesから取得したルート情報を駅グループIDごとの分数マップに変換し、各駅のLineDotに受け渡しuseEstimateArrivalTimesのモックを追加テスト
npm run lintが通ることnpm testが通ることnpm run typecheckが通ること関連Issue
スクリーンショット(任意)
Summary by CodeRabbit
新機能
テスト