Repository navigation
試験的機能としてポートレートモードを追加 - #6204
試験的機能としてポートレートモードを追加#6204
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughポートレートモード表示を試験的機能として実装した PR。Jotai 状態管理、実験設定画面、AsyncStorage 永続化、ポートレイト専用 UI、メイン画面の条件分岐、多言語対応、および AppSettings への項目追加を含む。 ChangesPortrait Mode Experimental Feature
Sequence Diagram(s)sequenceDiagram
participant UI as ExperimentalSettings UI
participant Handler as handleToggleChange
participant Atom as portraitModeEnabledAtom
participant AsyncStorage
UI->>Handler: トグル操作
Handler->>Atom: set(newBoolean)
Handler->>AsyncStorage: setItem(PORTRAIT_MODE_ENABLED, 'true'/'false')
AsyncStorage-->>Handler: 成功/失敗
Handler-->>UI: 更新完了 / エラー表示
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/components/PortraitMain.tsx (1)
1-393: ⚡ Quick winテストファイルを追加することを推奨します。
ポートレート UI の新規追加に伴い、ユニットテストまたは統合テストを同階層に
.test.tsxとして配置することで、停車駅リストのレンダリング、通過駅判定、駅番号表示の条件分岐、乗り換え線ドット表示などの重要なロジックの正確性を保証できます。コーディングガイドラインに基づき、テストファイルは対象モジュールと同じ階層に配置してください。
🤖 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/PortraitMain.tsx` around lines 1 - 393, Add a new test file PortraitMain.test.tsx alongside PortraitMain.tsx that mounts the PortraitMain component (and/or renders the StopRow via PortraitMain) and covers: rendering the stop list from leftStations, pass/train-stop branching using getIsPass, station numbering display via NumberingIcon when useStationNumberIndexFunc yields a station number, and transfer dot rendering using useTransferLinesFromStation (including limiting to 8). Mock hooks useHeaderCommonData, useCurrentLine, useCurrentTrainType, useStationNumberIndexFunc, useTransferLinesFromStation and the leftStationsAtom to control scenarios for current/first/last stops, pass vs stop, with/without stationNumber and transfer lines; assert DOM/text presence, conditional elements (passLabel, stopNameCurrent, stopNumbering, transferDots), and that line/train colors are applied.Source: Coding guidelines
🤖 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 `@src/screens/ExperimentalSettings.tsx`:
- Around line 97-109: The optimistic update in handleTogglePortraitMode
currently sets the atom via setPortraitModeEnabled(flag) before awaiting
AsyncStorage.setItem but doesn't revert the atom on failure; fix this by
capturing the previous state (e.g., const prev = portraitModeEnabled) before
calling setPortraitModeEnabled(flag), then try to save with AsyncStorage.setItem
and on catch call setPortraitModeEnabled(prev) to rollback and still show the
Alert; reference handleTogglePortraitMode, setPortraitModeEnabled, and
AsyncStorage.setItem when making the change.
In `@src/screens/Main.tsx`:
- Around line 697-706: The portrait-mode branch currently returns only
<PortraitMain /> (plus DevOverlay) so SelectBoundModal and the
bottomState-driven TypeChangeNotify never render; either (A) render
<SelectBoundModal ... /> and the TypeChangeNotify conditional (driven by
bottomState === 'TYPE_CHANGE') alongside <PortraitMain /> in the portrait-mode
return so the existing modal/notify flow is preserved, or (B) move the
modal/notify rendering into PortraitMain and wire up the same props/handlers
(state getters/setters, e.g. bottomState, onSelectBound/onTypeChange) so
portrait has equivalent interaction; locate usage points by searching for
SelectBoundModal, TypeChangeNotify, bottomState, portraitModeEnabled,
windowHeight/windowWidth and ensure required props/state/handlers are passed
through or lifted into PortraitMain.
---
Nitpick comments:
In `@src/components/PortraitMain.tsx`:
- Around line 1-393: Add a new test file PortraitMain.test.tsx alongside
PortraitMain.tsx that mounts the PortraitMain component (and/or renders the
StopRow via PortraitMain) and covers: rendering the stop list from leftStations,
pass/train-stop branching using getIsPass, station numbering display via
NumberingIcon when useStationNumberIndexFunc yields a station number, and
transfer dot rendering using useTransferLinesFromStation (including limiting to
8). Mock hooks useHeaderCommonData, useCurrentLine, useCurrentTrainType,
useStationNumberIndexFunc, useTransferLinesFromStation and the leftStationsAtom
to control scenarios for current/first/last stops, pass vs stop, with/without
stationNumber and transfer lines; assert DOM/text presence, conditional elements
(passLabel, stopNameCurrent, stopNumbering, transferDots), and that line/train
colors are applied.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: dd7eea95-3816-4f4a-b52e-a654abe01dad
📒 Files selected for processing (11)
assets/translations/en.jsonassets/translations/ja.jsonsrc/components/Permitted.tsxsrc/components/PortraitMain.tsxsrc/constants/asyncStorage.tssrc/screens/AppSettings.tsxsrc/screens/ExperimentalSettings.test.tsxsrc/screens/ExperimentalSettings.tsxsrc/screens/Main.tsxsrc/stacks/MainStack.tsxsrc/store/atoms/experimental.ts
There was a problem hiding this comment.
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 `@src/screens/ExperimentalSettings.test.tsx`:
- Around line 65-86: Mock Alert.alert in the test setup and assert it and
console.error are called when AsyncStorage.setItem rejects: add a mock for
Alert.alert (and restore it after) before running the test (or in the file-level
mocks), ensure the test case that simulates AsyncStorage.setItem rejecting still
spies on console.error and then assert both Alert.alert and console.error were
invoked after the rollback, referencing the existing AsyncStorage.setItem mock,
the renderWithStore/getByLabelText interaction, and the portraitModeEnabledAtom
state check to locate where to add the assertions and mock restore calls.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6d4acdba-11bd-41d7-b3f5-7817e23ab69c
📒 Files selected for processing (3)
src/components/PortraitMain.test.tsxsrc/screens/ExperimentalSettings.test.tsxsrc/screens/ExperimentalSettings.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- src/screens/ExperimentalSettings.tsx
概要
変更の種類
変更内容
AppSettings.tsx。カナリアリリース(isDevApp)限定で表示。項目挿入に強いよう、パーソナライズ節のレンダリングをmapベースに整理)ExperimentalSettings.tsxを追加(portraitModeEnabledAtom+ AsyncStorage@TrainLCD:portraitModeEnabledで永続化し、起動時にPermitted.tsxで読み込み。保存失敗時はatom状態をロールバック)PortraitMain.tsxに切り替え(路線カード/状態テキスト+駅名+ナンバリング/停車駅の縦リスト。横向きに戻すと従来表示。閲覧専用の簡易表示とし、路線・種別変更の導線は対象外)ExperimentalSettings.test.tsx: トグル永続化・保存失敗時ロールバック、PortraitMain.test.tsx: 表示要素・通過駅ラベル・データ未取得時の分岐)テスト
npm run lintが通ることnpm testが通ることnpm run typecheckが通ること関連Issue
スクリーンショット(任意)
https://claude.ai/code/session_01Nv3odSWJubXwE8s4jewpQw
Summary by CodeRabbit
新機能
多言語対応
改善
テスト