Repository navigation
THQ新仕様対応&テレメトリトグル対応 - #4700
THQ新仕様対応&テレメトリトグル対応#4700
Conversation
|
Note
|
| コホート / ファイル(s) | 変更の概要 |
|---|---|
環境設定とトークン型定義 \.env, src/@types/react-native-dotenv.d.ts |
新環境変数 EXPERIMENTAL_TELEMETRY_TOKEN を .env に追加、型定義に export const EXPERIMENTAL_TELEMETRY_TOKEN: string; を追加。 |
翻訳ファイル assets/translations/en.json, assets/translations/ja.json |
翻訳キー optInTelemetryTitle と telemetrySettingWillPersist を追加。 |
iOS プロジェクト設定 ios/TrainLCD.xcodeproj/project.pbxproj, ios/TrainLCD.xcodeproj/xcshareddata/xcschemes/CanaryTrainLCD.xcscheme |
PBXFileSystemSynchronized* エントリ名/構造を説明的に再構成、CURRENT_PROJECT_VERSION = 2315 と MARKETING_VERSION = 10.0.22 を追加、Canary scheme の LaunchAction を Debug→Release に変更。 |
AsyncStorage キー src/constants/asyncStorage.ts |
ASYNC_STORAGE_KEYS に TELEMETRY_ENABLED: '@TrainLCD:telemetryEnabled' を追加(型に反映)。 |
正規表現定数 src/constants/regexp.ts |
webSocketUrlRegexp をより厳密なホスト/ポート/パス許容パターンに置換。 |
ビルド時フラグ設定 src/utils/telemetryConfig.ts |
isTelemetryEnabled を isTelemetryEnabledByBuild にリネームし、__DEV__ ゲーティングを削除して判定ロジックを単純化。 |
テレメトリ送信フック src/hooks/useTelemetrySender.ts |
プロトコルにトークン使用、useCurrentStation/useCurrentLine の導入、ペイロード簡素化(GNSS/radio 削除、lineId/stationId/error 追加)、ビルド時/ユーザー時フラグの複合ゲーティング、送信キュー/フラッシュ・WebSocketライフサイクル強化を実装。 |
テスト更新(テレメトリ) src/hooks/useTelemetrySender.disabled.test.ts, src/hooks/useTelemetrySender.enabled.test.tsx, src/components/DevOverlay.test.tsx |
モックで isTelemetryEnabled → isTelemetryEnabledByBuild に差し替え、useCurrentStation/useCurrentLine モック追加、atom モックに telemetryEnabled を含める等のテスト調整とコンソールスパイを追加。 |
Jotai チューニング状態 src/store/atoms/tuning.ts |
TuningState と tuningState atom に telemetryEnabled: boolean フィールド(初期 false)を追加。 |
UI 表示(DevOverlay) src/components/DevOverlay.tsx, src/components/DevOverlay.test.tsx |
useAtomValue でユーザー有効フラグを取得し、isTelemetryEnabledByBuild && telemetryEnabledByUser の複合評価で表示を制御。テスト側で atom をモック。 |
初期化/永続化 src/components/Permitted.tsx |
起動時に AsyncStorage から TELEMETRY_ENABLED を読み込み tuning.telemetryEnabled に適用(setTuning を使用)し、Effect の依存に setTuning を追加。 |
設定画面(TuningSettings) src/components/TuningSettings.tsx |
テレメトリ永続化処理を追加(AsyncStorage、ASYNC_STORAGE_KEYS)、有効化確認ダイアログ、LED/通常スイッチの UI トグル(optInTelemetryTitle ラベル)とハンドラを実装。 |
Sequence Diagram(s)
sequenceDiagram
participant User as ユーザー
participant UI as TuningSettings / DevOverlay
participant Storage as AsyncStorage
participant Atom as tuningState (Jotai)
participant Sender as useTelemetrySender
participant WS as Telemetry WebSocket
User->>UI: テレメトリをオン/オフ操作
UI->>UI: 必要なら確認ダイアログ表示
UI->>Storage: TELEMETRY_ENABLED を保存/削除
UI->>Atom: tuning.telemetryEnabled を更新
Atom->>UI: 表示を更新
UI->>Sender: 現在のビルドフラグとユーザーフラグを評価
alt 双方有効
Sender->>WS: プロトコル(トークン)で接続/キュー送信
else いずれか無効
Sender->>Sender: 送信停止・キューを保持
end
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 分
- 注目ポイント:
- src/hooks/useTelemetrySender.ts:ペイロード変更・ゲーティング(ビルド×ユーザー)・WebSocketキュー/プロトコル周りの複雑なロジック
- src/components/TuningSettings.tsx / src/components/Permitted.tsx:AsyncStorage 永続化と UI 確認ダイアログの組合せ、初期化順序の検証
- src/utils/telemetryConfig.ts と型定義のリネームに伴うインポート/モック箇所の全置換確認
- ios/TrainLCD.xcodeproj/project.pbxproj:手動でのpbxproj整合性確認(ID→説明変更・バージョン番号差分)
Possibly related PRs
- thqの新仕様に対応 #4466 — useTelemetrySender.ts に関するペイロード・ログ・タイプ変更を扱っており、送信ロジックの重複改修があるため関連性高。
- テレメトリのログ送信キュー処理実装 #4243 — useTelemetrySender.ts にメッセージキューイング・フラッシュ挙動を追加する変更と重複する点が多いため関連。
- WSローカルテレメトリ実装 #4211 — telemetryConfig、環境変数、useTelemetrySender 周辺の基礎実装を扱っており、ビルドフラグ名変更や挙動整合に関連。
ポエム
🐰 ぽこぽこ走る小さなログ、
ユーザーの合図でそっと永続化。
ビルドと心(ユーザー)の二重の承認で、
WebSocket の糸がふわり繋がるよ。
🥕 今日はいいデータの日だね。
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 | プルリクエストのタイトルは「THQ新仕様対応&テレメトリトグル対応」で、変更セットの主要な内容(テレメトリ機能の追加とトグル対応)を明確に示しており、開発者の観点から重要な変更を適切に要約しています。 |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
✨ Finishing touches
- 📝 Generate docstrings
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
- Commit unit tests in branch
feature/thq
Comment @coderabbitai help to get the list of available commands and usage tips.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/hooks/useTelemetrySender.ts (1)
127-158:sendLogペイロードに必須のlineIdが欠落しています。
TelemetryPayloadスキーマではlineIdが必須フィールド(z.number())として定義されていますが、sendLog関数のペイロードには含まれていません。safeParseで検証エラーになる可能性があります。const payload = TelemetryPayload.safeParse({ type: 'log', log: { type: 'app', level, message, }, device: Device.modelName ?? 'unknown', timestamp: now, + lineId: line?.id ?? 0, });または、ログタイプのペイロードでは
lineIdをオプショナルにするか、型の分岐を検討してください。
🧹 Nitpick comments (5)
assets/translations/en.json (1)
198-200: テレメトリ用キー追加OKだが文言の自然さは少しだけ検討の余地ありそうです
setBoundForSelectedStationを残したまま、optInTelemetryTitle/telemetrySettingWillPersistが追加されているだけなので構造的には問題なさそうです。英語としては"Enabling telemetry will be persisted."よりも"This setting will be saved."や"Your telemetry preference will be saved."などの方が自然かもしれません(必須ではありません)。Based on learnings, backgroundPermissionDenied などと同様に「キー追加のみ」であることを確認しました。assets/translations/ja.json (1)
199-201: テレメトリ用の日本語翻訳キー追加は問題なさそうです英語側と同じキー構成で
optInTelemetryTitle/telemetrySettingWillPersistが追加されており、既存のsetBoundForSelectedStationは維持されているので整合性は取れています。文言も意図は十分伝わる内容だと思います(より自然にするなら「テレメトリの有効化設定は永続的に保存されます。」程度の調整はありえますが必須ではありません)。Based on learnings, キーが削除されていないことも確認しました。.env (1)
12-13: テレメトリ用環境変数の追加は妥当ですが dotenv-linter 的なスタイルだけ調整余地がありますキー自体は空値で追加されているのでテンプレートとしては問題ありませんが、dotenv-linter の指摘どおり
EXPERIMENTAL_TELEMETRY_ENDPOINT_URL/EXPERIMENTAL_TELEMETRY_TOKENを他のキーと同じ順序(先頭側)に移動し、ファイル末尾に改行を入れておくと警告を避けられそうです。また.env.example側にも同じキーが追加されているか一度確認しておくと良さそうです。As per coding guidelines,.envをテンプレートとして扱う前提でコメントしています。src/hooks/useTelemetrySender.disabled.test.ts (1)
72-75:afterEachにjest.clearAllMocks()を追加してください。コーディングガイドラインでは、
afterEachフックでjest.clearAllMocks()を呼び出すことが推奨されています。afterEach(() => { + jest.clearAllMocks(); consoleErrorSpy.mockRestore(); consoleWarnSpy.mockRestore(); });src/hooks/useTelemetrySender.ts (1)
170-182: ペイロードに未使用のフィールドが含まれています。
gnssとradioフィールドがペイロードに渡されていますが、TelemetryPayloadスキーマにはこれらのフィールドが定義されていません。zodのsafeParseによりストリップされますが、不要なコードは削除することを推奨します。const payload = TelemetryPayload.safeParse({ type: 'location_update', coords, device: Device.modelName ?? 'unknown', state, - gnss: gnssRef.current ?? null, - radio: { - isWifiConnected, - }, lineId: line.id, stationId: station?.id, timestamp: now, });
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
ios/Podfile.lockis excluded by!**/*.lock
📒 Files selected for processing (17)
.env(1 hunks)assets/translations/en.json(1 hunks)assets/translations/ja.json(1 hunks)ios/TrainLCD.xcodeproj/project.pbxproj(10 hunks)ios/TrainLCD.xcodeproj/xcshareddata/xcschemes/CanaryTrainLCD.xcscheme(1 hunks)src/@types/react-native-dotenv.d.ts(1 hunks)src/components/DevOverlay.test.tsx(4 hunks)src/components/DevOverlay.tsx(2 hunks)src/components/Permitted.tsx(4 hunks)src/components/TuningSettings.tsx(4 hunks)src/constants/asyncStorage.ts(1 hunks)src/constants/regexp.ts(1 hunks)src/hooks/useTelemetrySender.disabled.test.ts(4 hunks)src/hooks/useTelemetrySender.enabled.test.tsx(1 hunks)src/hooks/useTelemetrySender.ts(11 hunks)src/store/atoms/tuning.ts(2 hunks)src/utils/telemetryConfig.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{ts,tsx,js,jsx,json}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use Biome as the formatter for all code files
Files:
src/store/atoms/tuning.tssrc/@types/react-native-dotenv.d.tssrc/components/TuningSettings.tsxsrc/components/Permitted.tsxsrc/components/DevOverlay.tsxsrc/constants/regexp.tssrc/components/DevOverlay.test.tsxsrc/hooks/useTelemetrySender.enabled.test.tsxassets/translations/ja.jsonsrc/hooks/useTelemetrySender.tssrc/constants/asyncStorage.tssrc/utils/telemetryConfig.tsassets/translations/en.jsonsrc/hooks/useTelemetrySender.disabled.test.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-ignoreonly for true compatibility issues and include an inline reasonUse
.editorconfigstandards: UTF-8 encoding, two-space indentation, single quotes, and ES5 trailing commas
Files:
src/store/atoms/tuning.tssrc/@types/react-native-dotenv.d.tssrc/components/TuningSettings.tsxsrc/components/Permitted.tsxsrc/components/DevOverlay.tsxsrc/constants/regexp.tssrc/components/DevOverlay.test.tsxsrc/hooks/useTelemetrySender.enabled.test.tsxsrc/hooks/useTelemetrySender.tssrc/constants/asyncStorage.tssrc/utils/telemetryConfig.tssrc/hooks/useTelemetrySender.disabled.test.ts
src/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Biome is authoritative for linting; avoid
// biome-ignoreunless a rule is truly incompatible and document the rationale inline
Files:
src/store/atoms/tuning.tssrc/@types/react-native-dotenv.d.tssrc/components/TuningSettings.tsxsrc/components/Permitted.tsxsrc/components/DevOverlay.tsxsrc/constants/regexp.tssrc/components/DevOverlay.test.tsxsrc/hooks/useTelemetrySender.enabled.test.tsxsrc/hooks/useTelemetrySender.tssrc/constants/asyncStorage.tssrc/utils/telemetryConfig.tssrc/hooks/useTelemetrySender.disabled.test.ts
src/{components,screens}/**/*.tsx
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Component files should use PascalCase naming (e.g.,
StationBanner.tsx)Use PascalCase for component file names (e.g.,
StationBanner.tsx)
Files:
src/components/TuningSettings.tsxsrc/components/Permitted.tsxsrc/components/DevOverlay.tsxsrc/components/DevOverlay.test.tsx
{.env,.env.example}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Treat
.envas a template and keep.env.examplein sync for onboarding
Files:
.env
.env*
📄 CodeRabbit inference engine (AGENTS.md)
Store secrets in
.env.local; keep.envas the template and.env.examplesynchronized for onboarding
Files:
.env
**/*.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.tsor.test.tsxextension
Mock network and Firebase layers usingjest.mock
Calljest.clearAllMocks()inafterEachhook
Include TODO comments with reason and assignee for skipped tests
**/*.test.{ts,tsx}: Co-locate unit tests as.test.tsor.test.tsxsiblings to the module being tested
Mock network and Firebase layers withjest.mock, and calljest.clearAllMocks()inafterEach
Files:
src/components/DevOverlay.test.tsxsrc/hooks/useTelemetrySender.enabled.test.tsxsrc/hooks/useTelemetrySender.disabled.test.ts
src/hooks/**/*.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Custom hooks should use
useprefix (e.g.,useStationFeed.ts)Use
use*naming convention for custom hooks
Files:
src/hooks/useTelemetrySender.tssrc/hooks/useTelemetrySender.disabled.test.ts
🧠 Learnings (18)
📓 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.
Learnt from: TinyKitten
Repo: TrainLCD/MobileApp PR: 4249
File: __tests__/hooks/useTelemetrySender.enabled.test.tsx:54-68
Timestamp: 2025-05-07T23:04:31.413Z
Learning: TinyKitten is working on implementing a queue for movement logs in the TrainLCD mobile app, but realized the implementation differed from their original intention.
📚 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/components/DevOverlay.tsxsrc/components/DevOverlay.test.tsxsrc/hooks/useTelemetrySender.tssrc/hooks/useTelemetrySender.disabled.test.ts
📚 Learning: 2025-11-25T03:10:44.293Z
Learnt from: CR
Repo: TrainLCD/MobileApp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T03:10:44.293Z
Learning: Applies to **/*.test.{ts,tsx} : Mock network and Firebase layers with `jest.mock`, and call `jest.clearAllMocks()` in `afterEach`
Applied to files:
src/components/DevOverlay.test.tsxsrc/hooks/useTelemetrySender.enabled.test.tsxsrc/hooks/useTelemetrySender.disabled.test.ts
📚 Learning: 2025-06-18T17:29:46.085Z
Learnt from: TinyKitten
Repo: TrainLCD/MobileApp PR: 4359
File: src/components/TrainTypeList.tsx:1-1
Timestamp: 2025-06-18T17:29:46.085Z
Learning: When analyzing React import changes in TypeScript/JavaScript files, carefully verify that React.Fragment, React.createElement, or other React namespace usages actually exist in the code before flagging them as issues. Don't assume React.Fragment is used just because the default React import was removed.
Applied to files:
src/components/DevOverlay.test.tsxsrc/hooks/useTelemetrySender.enabled.test.tsx
📚 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 **/*.test.{ts,tsx} : Mock network and Firebase layers using `jest.mock`
Applied to files:
src/components/DevOverlay.test.tsxsrc/hooks/useTelemetrySender.enabled.test.tsxsrc/hooks/useTelemetrySender.disabled.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: Applies to {jest.setup.js,src/setupTests.ts} : Jest global setup is managed in `jest.setup.js` and `src/setupTests.ts`
Applied to files:
src/components/DevOverlay.test.tsxsrc/hooks/useTelemetrySender.enabled.test.tsxsrc/hooks/useTelemetrySender.disabled.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: Applies to **/*.test.{ts,tsx} : Call `jest.clearAllMocks()` in `afterEach` hook
Applied to files:
src/components/DevOverlay.test.tsxsrc/hooks/useTelemetrySender.enabled.test.tsxsrc/hooks/useTelemetrySender.disabled.test.ts
📚 Learning: 2025-05-06T18:50:57.931Z
Learnt from: TinyKitten
Repo: TrainLCD/MobileApp PR: 4243
File: __tests__/hooks/useTelemetrySender.enabled.test.tsx:0-0
Timestamp: 2025-05-06T18:50:57.931Z
Learning: In Jest tests that mock WebSocket objects, it's important to define the global WebSocket mock object and its constants (like WebSocket.OPEN) before using them in other mock objects to prevent "WebSocket is not defined" reference errors.
Applied to files:
src/components/DevOverlay.test.tsxsrc/hooks/useTelemetrySender.enabled.test.tsxsrc/hooks/useTelemetrySender.tssrc/hooks/useTelemetrySender.disabled.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: Reuse test helpers from `src/utils/test/`
Applied to files:
src/components/DevOverlay.test.tsxsrc/hooks/useTelemetrySender.enabled.test.tsxsrc/hooks/useTelemetrySender.disabled.test.ts
📚 Learning: 2025-05-06T18:50:57.931Z
Learnt from: TinyKitten
Repo: TrainLCD/MobileApp PR: 4243
File: __tests__/hooks/useTelemetrySender.enabled.test.tsx:0-0
Timestamp: 2025-05-06T18:50:57.931Z
Learning: In the test files for WebSocket mocks, the global WebSocket object and its constants must be defined before using them in mock objects (e.g., setting readyState to WebSocket.OPEN) to prevent ReferenceError, especially in CI environments.
Applied to files:
src/components/DevOverlay.test.tsxsrc/hooks/useTelemetrySender.enabled.test.tsxsrc/hooks/useTelemetrySender.tssrc/hooks/useTelemetrySender.disabled.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/components/DevOverlay.test.tsxsrc/hooks/useTelemetrySender.disabled.test.ts
📚 Learning: 2025-11-25T03:10:44.293Z
Learnt from: CR
Repo: TrainLCD/MobileApp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T03:10:44.293Z
Learning: Applies to src/hooks/**/*.ts : Use `use*` naming convention for custom hooks
Applied to files:
src/components/DevOverlay.test.tsx
📚 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/hooks/**/*.ts : Custom hooks should use `use` prefix (e.g., `useStationFeed.ts`)
Applied to files:
src/components/DevOverlay.test.tsxsrc/hooks/useTelemetrySender.disabled.test.ts
📚 Learning: 2025-09-22T09:30:14.592Z
Learnt from: TinyKitten
Repo: TrainLCD/MobileApp PR: 4511
File: package.json:43-66
Timestamp: 2025-09-22T09:30:14.592Z
Learning: TrainLCDのApp Clipは15MB制限を超えるため、iOS 17以上(50MB制限)をdeployment targetとして設定する必要がある。IPHONEOS_DEPLOYMENT_TARGET = 17.6の設定は技術的要件に基づく適切な判断。
Applied to files:
ios/TrainLCD.xcodeproj/project.pbxproj
📚 Learning: 2025-09-22T09:21:21.741Z
Learnt from: TinyKitten
Repo: TrainLCD/MobileApp PR: 4511
File: package.json:43-66
Timestamp: 2025-09-22T09:21:21.741Z
Learning: TinyKittenはExpo SDK 54アップグレードにおいて、babel.config.js、RCTNewArchEnabled設定、Podfile設定を適切に処理している。App ClipのiOS deployment targetの調整のみが必要な状況。
Applied to files:
ios/TrainLCD.xcodeproj/project.pbxproj
📚 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/ja.jsonassets/translations/en.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: Write commit messages in Japanese (e.g., `テレメトリー送信機をリファクタリングしてnull状態を回避`)
Applied to files:
assets/translations/ja.json
📚 Learning: 2025-08-04T12:17:03.430Z
Learnt from: TinyKitten
Repo: TrainLCD/MobileApp PR: 4429
File: src/components/CustomErrorBoundary.tsx:25-25
Timestamp: 2025-08-04T12:17:03.430Z
Learning: In the TrainLCD mobile app, __DEV__ and isDevApp serve different purposes: __DEV__ is only true during debug/development time, while isDevApp is true for both debug time and release-built canary versions. This distinction is intentional - __DEV__ is used to prevent sending crash reports to Sentry during development, while isDevApp is used to enable stack trace display for both developers and canary testers.
Applied to files:
src/utils/telemetryConfig.ts
🧬 Code graph analysis (5)
src/components/TuningSettings.tsx (2)
src/constants/asyncStorage.ts (1)
ASYNC_STORAGE_KEYS(1-20)src/translation.ts (1)
translate(7-12)
src/components/Permitted.tsx (1)
src/constants/asyncStorage.ts (1)
ASYNC_STORAGE_KEYS(1-20)
src/components/DevOverlay.tsx (1)
src/utils/telemetryConfig.ts (1)
isTelemetryEnabledByBuild(5-6)
src/hooks/useTelemetrySender.ts (2)
src/@types/react-native-dotenv.d.ts (1)
EXPERIMENTAL_TELEMETRY_TOKEN(15-15)src/utils/telemetryConfig.ts (1)
isTelemetryEnabledByBuild(5-6)
src/utils/telemetryConfig.ts (2)
src/utils/isDevApp.ts (1)
isDevApp(7-10)src/@types/react-native-dotenv.d.ts (1)
ENABLE_EXPERIMENTAL_TELEMETRY(13-13)
🪛 dotenv-linter (4.0.0)
.env
[warning] 12-12: [UnorderedKey] The EXPERIMENTAL_TELEMETRY_ENDPOINT_URL key should go before the NEARBY_STATIONS_LIMIT key
(UnorderedKey)
[warning] 13-13: [EndingBlankLine] No blank line at the end of the file
(EndingBlankLine)
[warning] 13-13: [UnorderedKey] The EXPERIMENTAL_TELEMETRY_TOKEN key should go before the NEARBY_STATIONS_LIMIT key
(UnorderedKey)
🔇 Additional comments (16)
ios/TrainLCD.xcodeproj/xcshareddata/xcschemes/CanaryTrainLCD.xcscheme (1)
71-97: CanaryスキームをRelease起動にした影響について
LaunchActionのbuildConfigurationをReleaseにしたことで、Xcode からの Canary 実行も本番相当の最適化・ビルドフラグで起動されるようになります。本番同等条件で THQ 新仕様やテレメトリ挙動を確認したい意図なら妥当そうですが、日常開発のデバッグにもこのスキームを使っている場合は、スタックトレースの読みにくさなどでデバッグしづらくなる可能性があります。「本番相当確認用: Canary(Release)」と「開発用: Debug スキーム」を分けて運用する前提であれば、この変更で問題ないと思います。意図した運用になっているかだけ確認しておいてください。
src/constants/regexp.ts (1)
4-5:localhostや IP アドレスを使う WebSocket URL を想定していないか確認したいですこの正規表現だと
ws://example.comのような FQDN だけが許可され、ws://localhost:8080やws://127.0.0.1:8080などはマッチしなくなります。THQ 向けは FQDN 固定かもしれませんが、開発・検証環境でこれらを使っていないか一度確認しておくと安全そうです。ios/TrainLCD.xcodeproj/project.pbxproj (1)
2518-2518: Add CURRENT_PROJECT_VERSION and MARKETING_VERSION to ProdAppClip target settings for consistency.
ProdAppClip(lines 3496–3595) lacks explicit version settings, relying on project-level inheritance forCURRENT_PROJECT_VERSION = 2315. However,CanaryAppClip(lines 3596–3703) explicitly defines bothCURRENT_PROJECT_VERSION = 2315andMARKETING_VERSION = 10.0.22. For clarity and to ensure both app variants maintain version parity, add these settings toProdAppClip's Debug and Release configurations.src/@types/react-native-dotenv.d.ts (1)
15-15: EXPERIMENTAL_TELEMETRY_TOKEN の型定義追加は既存パターンに沿っていて問題なさそうです既存の環境変数定義と同じ形で string 型が追加されており、型レベルの不整合はなさそうです。あとは
.env/.env.exampleの両方にEXPERIMENTAL_TELEMETRY_TOKENが定義されているかだけ念のため確認しておくと安心です。src/store/atoms/tuning.ts (1)
14-24: tuning の telemetryEnabled 追加は型/初期値ともに整合していて良さそうです
TuningStateにtelemetryEnabled: booleanを追加し、atom<TuningState>の初期値にもtelemetryEnabled: falseを入れていて形がそろっているので、この PR 内の利用(DevOverlay, Permitted など)と整合していそうです。型チェックでエラーが出ていないかだけ CI 側で確認いただければ十分だと思います。src/components/DevOverlay.tsx (1)
2-2: ビルドフラグ+ユーザー設定のANDでテレメトリ状態を決める実装で妥当に見えます
tuningStateからtelemetryEnabledをuseAtomValueで参照し、isTelemetryEnabledByBuild && telemetryEnabledByUserで最終的な Telemetry ON/OFF を決めているので、ビルド時有効かつユーザーが明示的に有効化した場合にだけ ON になる挙動になっていて意図どおりに見えます。フラグ組み合わせごとの表示(OFF/ON)がテストでカバーされているかだけ確認いただければ十分そうです。Also applies to: 10-10, 44-48, 100-101
src/components/Permitted.tsx (1)
50-50: AsyncStorage から telemetryEnabled を復元して tuningState に反映する実装で整合していそうです
ASYNC_STORAGE_KEYS.TELEMETRY_ENABLEDを他のキーと同様にEffect.allで取得し、telemetryEnabledStr === 'true'で boolean に変換してsetTuningに渡しているので、既存のspeechEnabledやBG_TTS_ENABLEDなどと同じパターンで実装されています。キーが存在しない場合は初期値falseのままになるので、既存ユーザーに対しても「明示的に有効化されるまでは OFF」という挙動になっていて問題なさそうです。念のため、AsyncStorage に@TrainLCD:telemetryEnabledが既に入っているケース('true' / 'false' / null)の動作だけテストで確認しておくと安心です。Also applies to: 304-320, 349-354, 359-359
src/utils/telemetryConfig.ts (1)
5-6: isTelemetryEnabledByBuild へのリネームとロジックの切り出しは妥当で、isDevApp の使い方も意図に合っていそうです
isTelemetryEnabledByBuild = isDevApp && ENABLE_EXPERIMENTAL_TELEMETRY === 'true'とすることで、「開発/カナリア系バンドルかつ env フラグが true のときだけビルドとしてテレメトリ有効」という意味が明示されていて分かりやすいです。isDevApp側に__DEV__も含まれているので、以前の__DEV__チェックを外しても開発時を含めた挙動は保ちつつ、必要に応じてカナリア版でもテレメトリを有効にできる構造になっていそうです。この挙動が THQ 側の新仕様どおりかだけ、テストや実機ビルドで確認いただければ十分だと思います。Based on learnings, DEV と isDevApp の意図的な使い分けを踏まえたコメントです。src/constants/asyncStorage.ts (1)
19-19: LGTM!新しいテレメトリ設定用のAsyncStorageキーが既存の命名規則に従って追加されています。
src/hooks/useTelemetrySender.disabled.test.ts (1)
26-32: LGTM!
useCurrentStationとuseCurrentLineのモック追加は、実装の変更に適切に対応しています。src/components/DevOverlay.test.tsx (2)
7-13: LGTM!
jotaiのモックがrequireActualパターンを使用して適切に設定されており、useAtomValueのみをモック化しています。
78-80: LGTM!
telemetryEnabledの状態がbeforeEachで正しく設定されており、新しいテレメトリフラグのロジックに対応しています。src/components/TuningSettings.tsx (1)
142-168: LGTM!テレメトリ有効化時にユーザー確認を求める実装は適切です。無効化は即座に反映され、有効化はOKボタン押下後にのみ永続化されるフローは良い設計です。
src/hooks/useTelemetrySender.enabled.test.tsx (1)
15-17: LGTM!テレメトリ設定のモックが
isTelemetryEnabledByBuildに更新され、実装の変更に適切に対応しています。src/hooks/useTelemetrySender.ts (2)
76-81: 認証トークンがWebSocketプロトコルに含まれています。
EXPERIMENTAL_TELEMETRY_TOKENがWebSocketサブプロトコルとして渡されています。これは一般的なパターンですが、トークンがログや開発者ツールで露出しないことを確認してください。
213-215: LGTM!ビルド時フラグ(
isTelemetryEnabledByBuild)とユーザー設定(isTelemetryEnabledByUser)の両方を組み合わせたテレメトリゲーティングは適切な設計です。
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/components/TuningSettings.tsx (1)
142-168: AsyncStorage 呼び出しを明示的な fire-and-forget にするとより安全です機能としてはこれで問題ないですが、Promise を待たずに投げる意図を明示するために
voidを付けておくと、no-floating-promises 系の Lint にも引っかかりにくくなると思います。- if (settings.telemetryEnabled) { - AsyncStorage.setItem(ASYNC_STORAGE_KEYS.TELEMETRY_ENABLED, 'false'); + if (settings.telemetryEnabled) { + void AsyncStorage.setItem(ASYNC_STORAGE_KEYS.TELEMETRY_ENABLED, 'false'); @@ - onPress: () => { - AsyncStorage.setItem(ASYNC_STORAGE_KEYS.TELEMETRY_ENABLED, 'true'); + onPress: () => { + void AsyncStorage.setItem(ASYNC_STORAGE_KEYS.TELEMETRY_ENABLED, 'true'); setSettings((prev) => ({また、必要であれば Alert の
"OK"もtranslateに寄せると i18n 的に一貫しそうです(既存キーがあればで十分だと思います)。
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/components/TuningSettings.tsx(4 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
src/{components,screens}/**/*.tsx
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Component files should use PascalCase naming (e.g.,
StationBanner.tsx)Use PascalCase for component file names (e.g.,
StationBanner.tsx)
Files:
src/components/TuningSettings.tsx
**/*.{ts,tsx,js,jsx,json}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use Biome as the formatter for all code files
Files:
src/components/TuningSettings.tsx
**/*.{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-ignoreonly for true compatibility issues and include an inline reasonUse
.editorconfigstandards: UTF-8 encoding, two-space indentation, single quotes, and ES5 trailing commas
Files:
src/components/TuningSettings.tsx
src/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Biome is authoritative for linting; avoid
// biome-ignoreunless a rule is truly incompatible and document the rationale inline
Files:
src/components/TuningSettings.tsx
🧠 Learnings (1)
📓 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.
Learnt from: TinyKitten
Repo: TrainLCD/MobileApp PR: 4249
File: __tests__/hooks/useTelemetrySender.enabled.test.tsx:54-68
Timestamp: 2025-05-07T23:04:31.413Z
Learning: TinyKitten is working on implementing a queue for movement logs in the TrainLCD mobile app, but realized the implementation differed from their original intention.
Learnt from: TinyKitten
Repo: TrainLCD/MobileApp PR: 4511
File: package.json:43-66
Timestamp: 2025-09-22T09:21:21.741Z
Learning: TinyKittenはExpo SDK 54アップグレードにおいて、babel.config.js、RCTNewArchEnabled設定、Podfile設定を適切に処理している。App ClipのiOS deployment targetの調整のみが必要な状況。
🧬 Code graph analysis (1)
src/components/TuningSettings.tsx (2)
src/constants/asyncStorage.ts (1)
ASYNC_STORAGE_KEYS(1-20)src/translation.ts (1)
translate(7-12)
🔇 Additional comments (2)
src/components/TuningSettings.tsx (2)
1-1: インポート追加は目的と整合しており問題ありませんテレメトリ設定の永続化のための AsyncStorage / ASYNC_STORAGE_KEYS の追加として妥当で、副作用もなさそうです。
Also applies to: 16-16
299-322: テレメトリトグル UI の配線は正しく一貫していますLEDThemeSwitch / Switch の両方が
settings.telemetryEnabledとtoggleTelemetryEnabledに正しくバインドされており、ラベルのonPressも同じハンドラになっていて UX・アクセシビリティ的にも問題ないと思います。
fixes #4599
Summary by CodeRabbit
リリースノート
新機能
バグ修正
その他
✏️ Tip: You can customize this high-level summary in your review settings.