Skip to content

プリセット機能の改善 - #4954

Merged
TinyKitten merged 1 commit into
devfrom
fix/presets
Jan 6, 2026
Merged

TinyKitten merged 1 commit into
devfrom
fix/presets

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Jan 6, 2026 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

リリースノート

  • スタイル

    • プリセットカードのタイトルフォントサイズおよび間隔を調整し、視認性を向上させました。
  • 改善

    • 「保存済み経路」の用語を「プリセット」に統一し、英語および日本語の UI テキストを更新しました。
    • プリセット保存時の命名ロジックを簡素化しました。
  • テスト

    • 駅情報ユーティリティの包括的なテストスイートを追加しました。

✏️ Tip: You can customize this high-level summary in your review settings.

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

coderabbitai Bot commented Jan 6, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

保存済みルート関連の用語をプリセットに統一するための変更です。翻訳ファイルの更新、ルート名の動的生成を簡略化した SelectBoundModal の修正、PresetCard のレイアウト調整、および station ユーティリティ関数の署名変更が含まれています。

Changes

Cohort / File(s) 変更概要
翻訳ファイル
assets/translations/en.json, assets/translations/ja.json
"保存済みルート" から "プリセット" への用語統一。削除確認テキストからルート名参照を削除し、保存・削除完了メッセージをプリセット表現に更新。新しい preset キーを追加。
プリセット保存ロジック
src/components/SelectBoundModal.tsx
ルート名の動的生成コード(lineName、edgeStationNames、destinationName、trainTypeName)を削除。ルート保存時に翻訳されたプリセット文字列を固定値として使用するように簡略化。wantedDestination と stations の依存関係を削除。
プリセット UI コンポーネント
src/components/PresetCard.tsx
タイトルフォントサイズ縮小(21→16)、マージン調整(8→16)。getStationPrimaryCode の呼び出しでパラメータを入れ替え(左右のコードの取得順序を逆転)。EllipsizeMode プロパティを削除し、コード表示を無条件レンダリング。
駅ユーティリティ関数
src/utils/station.ts, src/utils/station.test.ts
getStationPrimaryCode の署名を変更(単一引数から 2 引数へ、string | null から string へ)。getIsLocal 使用条件を追加。getStationName の実装を修正(複数の定義が混在)。station.test.ts に包括的なテストスイートを追加。

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

react

Poem

🐰 プリセットへと名は変わりて
ルートの保存も、シンプルに
パラメータ入れ替え、スタイル調整
テストで守られし、変わりゆく景色
選択肢は増えて、動作も軽くなり 🎉

Pre-merge checks and finishing touches

✅ 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.
✨ Finishing touches
  • 📝 Generate docstrings

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

@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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/components/SelectBoundModal.tsx (1)

397-427: プリセット削除時のコンテキスト不足が問題です。

すべてのプリセットが同じ名前("プリセット")で保存されるため、削除時の確認ダイアログで、どのプリセットを削除するのかが不明確になります。PresetCard では経由駅が表示されているため、カルーセルでの区別は可能ですが、削除確認ダイアログ(line 370)には削除対象のルート情報がなく、confirmDeleteRouteText に routeName="プリセット" が渡されるだけです。

route の識別情報(路線名、始発駅、終着駅など)をプリセット名に含めるか、削除ダイアログにルート情報を追加することで、より明確な操作フローになります。

🧹 Nitpick comments (2)
src/components/PresetCard.tsx (1)

245-247: 駅コードが空の場合の扱いについて。

leftCodeとrightCodeが空文字列でも常にTypographyコンポーネントをレンダリングしています。これはレイアウトの一貫性のための意図的な設計だと思われますが、空の要素が不要なスペースを作成する可能性があります。

現在の実装で問題ない場合はそのままで構いません。

Also applies to: 270-272

src/utils/station.ts (1)

16-16: 可読性向上のためのリファクタリング提案

この行の複雑な文字列補間は、可読性を向上させるために分割を検討してください。

🔎 提案されるリファクタリング
-  return `${from?.stationNumbers?.[0]?.stationNumber ?? ''} ${isJapanese ? (from?.trainType?.name ?? '') : (from?.trainType?.nameRoman ?? '')}`.trim();
+  const stationNumber = from?.stationNumbers?.[0]?.stationNumber ?? '';
+  const trainTypeName = isJapanese
+    ? (from?.trainType?.name ?? '')
+    : (from?.trainType?.nameRoman ?? '');
+  return `${stationNumber} ${trainTypeName}`.trim();
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 57a4c20 and 7294944.

📒 Files selected for processing (6)
  • assets/translations/en.json
  • assets/translations/ja.json
  • src/components/PresetCard.tsx
  • src/components/SelectBoundModal.tsx
  • src/utils/station.test.ts
  • src/utils/station.ts
🧰 Additional context used
📓 Path-based instructions (11)
**/*.{ts,tsx,js,jsx,json}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use Biome as the formatter for all code files

Files:

  • src/utils/station.test.ts
  • src/components/SelectBoundModal.tsx
  • assets/translations/en.json
  • src/components/PresetCard.tsx
  • assets/translations/ja.json
  • src/utils/station.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx,js,jsx}: Use Biome as the linter for all code files
Use // biome-ignore only for true compatibility issues and include an inline reason

Files:

  • src/utils/station.test.ts
  • src/components/SelectBoundModal.tsx
  • src/components/PresetCard.tsx
  • src/utils/station.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.test.{ts,tsx}: Place test files in the same hierarchy as the target module with .test.ts or .test.tsx extension
Mock network and Firebase layers using jest.mock
Call jest.clearAllMocks() in afterEach hook
Include TODO comments with reason and assignee for skipped tests

**/*.test.{ts,tsx}: Co-locate unit tests as .test.ts or .test.tsx siblings to the module.
Reuse helper utilities from src/utils/test/ to avoid duplicate setup code in tests.
Mock network and Firebase layers with jest.mock, and call jest.clearAllMocks() in afterEach.
When modifying behavior, update or add tests in the same change set; document skipped tests with TODOs and owner rationale.
Update or add tests relevant to code changes before submitting.

Files:

  • src/utils/station.test.ts
**/*.{ts,tsx,js,jsx,py,java,go,cs}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,js,jsx,py,java,go,cs}: Use descriptive names for agents that clearly indicate their purpose and domain
Implement agents with well-defined input/output contracts to ensure clear communication
Document agent responsibilities and expected behaviors in comments or docstrings
Use composition and dependency injection for agent collaboration rather than tight coupling
Implement error handling and graceful degradation in agents to improve system resilience

Files:

  • src/utils/station.test.ts
  • src/components/SelectBoundModal.tsx
  • src/components/PresetCard.tsx
  • src/utils/station.ts
**/*.{test,spec}.{ts,tsx,js,jsx,py,java,go,cs}

📄 CodeRabbit inference engine (CLAUDE.md)

Test agents in isolation and with integration tests to ensure correctness and compatibility

Files:

  • src/utils/station.test.ts
**/*

📄 CodeRabbit inference engine (AGENTS.md)

Use UTF-8 encoding, two-space indentation, single quotes, and ES5 trailing commas as enforced by .editorconfig.

Files:

  • src/utils/station.test.ts
  • src/components/SelectBoundModal.tsx
  • assets/translations/en.json
  • src/components/PresetCard.tsx
  • assets/translations/ja.json
  • src/utils/station.ts
**/*.{js,ts,tsx,jsx,json}

📄 CodeRabbit inference engine (AGENTS.md)

Biome is authoritative for linting; avoid // biome-ignore unless a rule is truly incompatible and document the rationale inline.

Files:

  • src/utils/station.test.ts
  • src/components/SelectBoundModal.tsx
  • assets/translations/en.json
  • src/components/PresetCard.tsx
  • assets/translations/ja.json
  • src/utils/station.ts
**/*.{tsx,ts}

📄 CodeRabbit inference engine (AGENTS.md)

Name components with PascalCase (e.g., StationBanner.tsx).

Files:

  • src/utils/station.test.ts
  • src/components/SelectBoundModal.tsx
  • src/components/PresetCard.tsx
  • src/utils/station.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Name hooks with use* prefix (e.g., useStationFeed.ts).

Files:

  • src/utils/station.test.ts
  • src/components/SelectBoundModal.tsx
  • src/components/PresetCard.tsx
  • src/utils/station.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Keep comments purposeful: explain intent or non-obvious constraints, not obvious mechanics.

Files:

  • src/utils/station.test.ts
  • src/components/SelectBoundModal.tsx
  • src/components/PresetCard.tsx
  • src/utils/station.ts
src/{components,screens}/**/*.tsx

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Component files should use PascalCase naming (e.g., StationBanner.tsx)

Files:

  • src/components/SelectBoundModal.tsx
  • src/components/PresetCard.tsx
🧠 Learnings (17)
📓 Common learnings
Learnt from: TinyKitten
Repo: TrainLCD/MobileApp PR: 0
File: :0-0
Timestamp: 2025-08-11T21:13:39.083Z
Learning: TinyKitten prefers concise code reviews for the TrainLCD/MobileApp repository. Keep review comments brief and to the point.
Learnt from: TinyKitten
Repo: TrainLCD/MobileApp PR: 4448
File: functions/src/funcs/tts.ts:214-232
Timestamp: 2025-08-11T20:23:23.071Z
Learning: PR #4448 in TrainLCD/MobileApp is specifically about AI feedback summarization and labeling functionality, not about TTS (Text-to-Speech) improvements. The TTS code changes appear to be part of a modularization refactoring but are not the focus of this PR.
📚 Learning: 2025-12-31T12:21:36.200Z
Learnt from: CR
Repo: TrainLCD/MobileApp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-31T12:21:36.200Z
Learning: Applies to **/*.test.{ts,tsx} : Update or add tests relevant to code changes before submitting.

Applied to files:

  • src/utils/station.test.ts
📚 Learning: 2025-12-27T22:48:28.461Z
Learnt from: CR
Repo: TrainLCD/MobileApp PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-27T22:48:28.461Z
Learning: Applies to **/*.{test,spec}.{ts,tsx,js,jsx,py,java,go,cs} : Test agents in isolation and with integration tests to ensure correctness and compatibility

Applied to files:

  • src/utils/station.test.ts
📚 Learning: 2025-05-19T10:59:37.813Z
Learnt from: TinyKitten
Repo: TrainLCD/MobileApp PR: 4286
File: src/components/HeaderLED.tsx:5-10
Timestamp: 2025-05-19T10:59:37.813Z
Learning: The hooks useCurrentStation, useNextStation, useIsNextLastStop, and useNumbering are properly exported in src/hooks/index.ts, allowing them to be imported from '../hooks' in src/components/HeaderLED.tsx as implemented in PR #4286.

Applied to files:

  • src/utils/station.test.ts
  • src/components/SelectBoundModal.tsx
  • src/components/PresetCard.tsx
  • src/utils/station.ts
📚 Learning: 2025-12-31T12:21:36.200Z
Learnt from: CR
Repo: TrainLCD/MobileApp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-31T12:21:36.200Z
Learning: Applies to **/*.test.{ts,tsx} : When modifying behavior, update or add tests in the same change set; document skipped tests with TODOs and owner rationale.

Applied to files:

  • src/utils/station.test.ts
📚 Learning: 2025-12-31T12:21:36.200Z
Learnt from: CR
Repo: TrainLCD/MobileApp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-31T12:21:36.200Z
Learning: Applies to **/*.test.{ts,tsx} : Reuse helper utilities from `src/utils/test/` to avoid duplicate setup code in tests.

Applied to files:

  • src/utils/station.test.ts
📚 Learning: 2025-11-25T03:10:26.328Z
Learnt from: CR
Repo: TrainLCD/MobileApp PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-25T03:10:26.328Z
Learning: Extend `src/test/e2e.ts` for integration flow tests

Applied to files:

  • src/utils/station.test.ts
📚 Learning: 2025-12-31T12:21:36.200Z
Learnt from: CR
Repo: TrainLCD/MobileApp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-31T12:21:36.200Z
Learning: Applies to src/test/**/*.{ts,tsx} : For integration flows, extend `src/test/e2e.ts` and prefer fixtures from `src/__fixtures__/`.

Applied to files:

  • src/utils/station.test.ts
📚 Learning: 2026-01-02T09:13:15.829Z
Learnt from: TinyKitten
Repo: TrainLCD/MobileApp PR: 4890
File: src/components/LineBoard.tsx:41-50
Timestamp: 2026-01-02T09:13:15.829Z
Learning: In LineBoard.tsx for bus lines (TransportType.Bus), only the `nameRoman` field requires parentheses removal via `parenthesisRegexp.replace()`. Other language fields (name, nameKatakana, nameChinese, nameKorean) should remain unchanged in the slicedLeftStations mapping.

Applied to files:

  • src/utils/station.test.ts
  • src/components/SelectBoundModal.tsx
  • src/components/PresetCard.tsx
  • src/utils/station.ts
📚 Learning: 2025-07-18T11:04:45.459Z
Learnt from: TinyKitten
Repo: TrainLCD/MobileApp PR: 4396
File: src/components/TrainTypeBoxJRKyushu.tsx:176-183
Timestamp: 2025-07-18T11:04:45.459Z
Learning: TrainTypeBoxJRKyushuコンポーネントでは、trainTypeNameとprevTrainTypeNameは常に文字列となるため、.split()メソッドを使用する際のnull安全性チェックは不要である。これらの変数はuseMemoとuseLazyPreviousを通じて管理され、translate()関数からのフォールバック値により常に文字列が保証される。

Applied to files:

  • src/components/SelectBoundModal.tsx
  • src/utils/station.ts
📚 Learning: 2024-12-18T00:29:05.817Z
Learnt from: TinyKitten
Repo: TrainLCD/MobileApp PR: 0
File: :0-0
Timestamp: 2024-12-18T00:29:05.817Z
Learning: 翻訳ファイル(`assets/translations/en.json` と `assets/translations/ja.json`)の変更を要約する際、`backgroundPermissionDenied` のようなキーが追加されているのか削除されているのかを正確に確認する。

Applied to files:

  • assets/translations/en.json
  • assets/translations/ja.json
📚 Learning: 2025-12-14T10:03:53.498Z
Learnt from: TinyKitten
Repo: TrainLCD/MobileApp PR: 4741
File: assets/translations/en.json:203-203
Timestamp: 2025-12-14T10:03:53.498Z
Learning: Ensure developer-facing translation keys (e.g., forDevelopers) are not exposed in production/public builds. Audit all translation files under assets/translations (e.g., en.json and other locales) and remove or guard such keys before releasing.

Applied to files:

  • assets/translations/en.json
  • assets/translations/ja.json
📚 Learning: 2025-11-25T03:10:26.328Z
Learnt from: CR
Repo: TrainLCD/MobileApp PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-25T03:10:26.328Z
Learning: Applies to src/{components,screens}/**/*.tsx : Component files should use PascalCase naming (e.g., `StationBanner.tsx`)

Applied to files:

  • src/components/PresetCard.tsx
📚 Learning: 2025-12-20T09:29:40.164Z
Learnt from: TinyKitten
Repo: TrainLCD/MobileApp PR: 4758
File: src/components/TypeChangeNotify.tsx:663-672
Timestamp: 2025-12-20T09:29:40.164Z
Learning: In TrainLCD/MobileApp TypeChangeNotify component (src/components/TypeChangeNotify.tsx), the centerCircle size differences across themes (MetroBars, SaikyoBars, JOBars) are intentional design decisions. JOBars uses larger non-tablet dimensions (32x32, borderRadius 16) compared to the base style (24x24, borderRadius 15) to maintain theme-specific visual identity.

Applied to files:

  • src/components/PresetCard.tsx
📚 Learning: 2025-12-31T12:21:36.200Z
Learnt from: CR
Repo: TrainLCD/MobileApp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-31T12:21:36.200Z
Learning: Applies to **/*.{tsx,ts} : Name components with PascalCase (e.g., `StationBanner.tsx`).

Applied to files:

  • src/components/PresetCard.tsx
📚 Learning: 2025-11-03T12:13:46.409Z
Learnt from: TinyKitten
Repo: TrainLCD/MobileApp PR: 4595
File: src/components/LineBoardEast.tsx:497-504
Timestamp: 2025-11-03T12:13:46.409Z
Learning: In TrainLCD/MobileApp LineBoard components (LineBoardEast, LineBoardWest, LineBoardSaikyo, LineBoardToei, LineBoardJRKyushu), the correct implementation pattern is to apply the dynamic width (dim.width / 9) to the outer stationNameContainer View, as implemented in LineBoardEast, not to the inner wrapper View.

Applied to files:

  • src/components/PresetCard.tsx
📚 Learning: 2025-08-23T19:22:45.907Z
Learnt from: TinyKitten
Repo: TrainLCD/MobileApp PR: 4483
File: functions/src/funcs/tts.ts:44-45
Timestamp: 2025-08-23T19:22:45.907Z
Learning: TrainLCD MobileAppのTTS機能では1万駅以上に対応しており、実運用での実績がある場合は理論的なエッジケースよりも実用性と安定性を重視する方針である。

Applied to files:

  • assets/translations/ja.json
🧬 Code graph analysis (3)
src/utils/station.test.ts (2)
src/utils/trainTypeString.ts (1)
  • getIsLocal (4-5)
src/utils/station.ts (3)
  • getStationPrimaryCode (5-17)
  • getStationLineId (21-22)
  • isSameStationShallow (24-35)
src/components/PresetCard.tsx (2)
src/utils/rfValue.ts (1)
  • RFValue (3-18)
src/utils/station.ts (1)
  • getStationPrimaryCode (5-17)
src/utils/station.ts (1)
src/utils/trainTypeString.ts (1)
  • getIsLocal (4-5)
🔇 Additional comments (7)
assets/translations/en.json (1)

152-156: LGTM! 翻訳の整合性が取れています。

保存済みルートからプリセットへの用語統一が適切に反映されています。ja.jsonとの一貫性も後ほど確認します。

Also applies to: 187-189

src/utils/station.test.ts (1)

1-397: LGTM! テストカバレッジが充実しています。

station.tsのユーティリティ関数に対する包括的なテストが実装されています。エッジケース(null、空配列、ロケール変更など)も適切にカバーされており、モックの使い方も適切です。

src/components/PresetCard.tsx (1)

132-133: LGTM! 関数シグネチャの変更が正しく反映されています。

getStationPrimaryCodeの更新されたシグネチャ(2パラメータ)に適切に対応しています。nullハンドリングも適切です。

assets/translations/ja.json (1)

153-156: LGTM! 英語版との整合性が取れています。

en.jsonとの翻訳の一貫性が保たれており、日本語としても自然な表現になっています。プリセット用語への統一が適切に反映されています。

Also applies to: 188-190

src/utils/station.ts (3)

3-3: LGTM!

getIsLocalのインポートはgetStationPrimaryCodeで適切に使用されています。


18-19: LGTM!

シンプルで明確な実装です。ロケールに基づいた名前の取得が適切に処理されています。


5-17: 破壊的変更は正しく実装されています。

getStationPrimaryCodeのシグネチャが単一のStationパラメータからfromとtoの2つのStation | nullパラメータに変更されています。すべての呼び出し元が正しく新しいシグネチャに対応しています:

  • テストケース (src/utils/station.test.ts): すべてのテストが2つのパラメータで呼び出している
  • プロダクションコード (src/components/PresetCard.tsx 132-133行目): getStationPrimaryCode(from ?? null, to ?? null)とgetStationPrimaryCode(to ?? null, from ?? null)で正しく実装

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