-
Notifications
You must be signed in to change notification settings - Fork 0
connection recovery feature #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
🧹 Nitpick comments (3)
UWBViewerSystem/Domain/Usecase/ConnectionManagementUsecase.swift (1)
189-201: 自動接続の動作を確認してくださいデバイス発見時に自動的に接続リクエストを送信していますが、この動作はユーザーの意図しない接続を引き起こす可能性があります。特に複数のデバイスが検出される環境では問題となる可能性があります。ユーザーが明示的に接続を開始するフローを検討してください。
また、デバッグ用のprint文(lines 191, 195, 197, 199)が多数残されています。コーディングガイドラインに従い、不要なデバッグコードは削除してください。
Based on coding guidelines
UWBViewerSystem/Presentation/Components/ConnectionRecoveryView.swift (2)
173-232: 再接続ロジックの改善を検討してください自動再接続時に
resetAll()を呼び出していますが、これは全ての既存接続を切断してしまいます。複数デバイスが接続されている環境では、切断されていないデバイスまで影響を受ける可能性があります。特定の切断されたデバイスのみを対象とした再接続ロジックを検討してください。
lastDisconnectedDeviceの情報を活用して、そのデバイスのみを再接続対象とすることができます。
114-135: アクセシビリティの改善を検討してください(任意)自動再接続ボタンの状態変化がアクセシビリティツールに適切に伝わるよう、
.accessibilityLabelや.accessibilityHintの追加を検討してください。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
UWBViewerSystem/Domain/Entity/DeviceConnectionState.swift(1 hunks)UWBViewerSystem/Domain/Usecase/ConnectionManagementUsecase.swift(5 hunks)UWBViewerSystem/Presentation/Components/ConnectionRecoveryView.swift(1 hunks)UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationView.swift(1 hunks)UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationViewModel.swift(2 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.swift
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.swift: SwiftFormat(swift-format)ルールに従い、make formatでコード整形を行う
デバッグ用コードやコメントアウトされた古いコードなどの不要なコードは削除する
不要なimport文は削除する
デッドコードは削除し、コメントは必要最小限に留める(自己文書化を優先)
Files:
UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationView.swiftUWBViewerSystem/Presentation/Components/ConnectionRecoveryView.swiftUWBViewerSystem/Domain/Usecase/ConnectionManagementUsecase.swiftUWBViewerSystem/Domain/Entity/DeviceConnectionState.swiftUWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationViewModel.swift
**/*View.swift
📄 CodeRabbit inference engine (CLAUDE.md)
Viewのファイル名は「〜View.swift」とする
Files:
UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationView.swiftUWBViewerSystem/Presentation/Components/ConnectionRecoveryView.swift
**/*Usecase.swift
📄 CodeRabbit inference engine (CLAUDE.md)
Usecaseのファイル名は「〜Usecase.swift」とする
Files:
UWBViewerSystem/Domain/Usecase/ConnectionManagementUsecase.swift
**/*ViewModel.swift
📄 CodeRabbit inference engine (CLAUDE.md)
ViewModelのファイル名は「〜ViewModel.swift」とする
Files:
UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationViewModel.swift
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
Repo: kajiLabTeam/UWBViewerSystem PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-23T15:18:09.790Z
Learning: Applies to Devices/**/*.swift : UWBデバイス関連の通信・制御ロジックはDevices/配下に配置する
📚 Learning: 2025-09-23T15:18:09.790Z
Learnt from: CR
Repo: kajiLabTeam/UWBViewerSystem PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-23T15:18:09.790Z
Learning: ViewModelはPublished/StateObjectでViewと双方向バインディングする
Applied to files:
UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationView.swiftUWBViewerSystem/Presentation/Components/ConnectionRecoveryView.swift
📚 Learning: 2025-09-23T15:18:09.790Z
Learnt from: CR
Repo: kajiLabTeam/UWBViewerSystem PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-23T15:18:09.790Z
Learning: Applies to Devices/**/*.swift : UWBデバイス関連の通信・制御ロジックはDevices/配下に配置する
Applied to files:
UWBViewerSystem/Domain/Entity/DeviceConnectionState.swift
🧬 Code graph analysis (2)
UWBViewerSystem/Presentation/Components/ConnectionRecoveryView.swift (1)
UWBViewerSystem/Domain/Usecase/ConnectionManagementUsecase.swift (6)
getConnectedDeviceCount(161-163)resetAll(113-141)startAdvertising(72-79)startDiscovery(86-92)hasConnectedDevices(157-159)stopDiscovery(94-96)
UWBViewerSystem/Domain/Usecase/ConnectionManagementUsecase.swift (2)
UWBViewerSystem/Devices/NearByConnection/NearByConnectionApi.swift (1)
requestConnection(194-216)UWBViewerSystem/Domain/Usecase/RealtimeDataUsecase.swift (1)
removeDisconnectedDevice(102-107)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Run Swift Tests
🔇 Additional comments (6)
UWBViewerSystem/Domain/Usecase/ConnectionManagementUsecase.swift (1)
237-242: LGTM: 接続時の状態管理が適切ですendpointIdとdeviceNameのマッピング保存と、エラーフラグのクリアが適切に実装されています。
UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationView.swift (1)
52-60: LGTM: 接続復旧UIの統合が適切ですConnectionRecoveryViewのモーダル表示が適切に実装されています。iOS向けのpresentationDetentsの使用も適切です。
UWBViewerSystem/Domain/Entity/DeviceConnectionState.swift (2)
4-67: LGTM: 接続状態モデルの設計が適切ですDeviceConnectionStateの設計は明確で、各状態が適切にモデル化されています。computed propertiesも読みやすく実装されています。
70-81: LGTM: 切断理由の列挙型が適切ですDisconnectionReasonの定義は明確で、一般的な切断シナリオを適切にカバーしています。
UWBViewerSystem/Presentation/Components/ConnectionRecoveryView.swift (1)
7-36: LGTM: ビューの構造が適切ですプロパティラッパーの使用とビュー構造が適切に実装されています。
UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationViewModel.swift (1)
50-51: LGTM: プロパティの定義が適切です接続復旧画面の表示制御用プロパティが適切に定義されています。
| print("📥 [ConnectionManagement] 接続リクエスト受信: \(deviceName) (\(endpointId))") | ||
| // 自動的に接続を承認 | ||
| accept(true) | ||
| print("✅ [ConnectionManagement] 接続リクエストを承認しました") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
デバッグ用のprint文を削除してください
コーディングガイドラインに従い、デバッグ用のprint文は削除してください。
Based on coding guidelines
🤖 Prompt for AI Agents
In UWBViewerSystem/Domain/Usecase/ConnectionManagementUsecase.swift around lines
214 to 217, remove the two debug print statements ("📥 [ConnectionManagement]
接続リクエスト受信..." and "✅ [ConnectionManagement] 接続リクエストを承認しました") to comply with the
coding guidelines; if runtime visibility is required replace them with the
project's standard logging API (e.g., logger.info/debug) or remove entirely,
keeping the accept(true) call unchanged.
| // endpointIdからdeviceNameを取得 | ||
| let deviceName = self.endpointToDeviceNameMap[endpointId] | ||
|
|
||
| self.connectedEndpoints.remove(endpointId) | ||
| self.connectState = "端末切断: \(endpointId)" | ||
| self.connectState = "端末切断: \(deviceName ?? endpointId)" | ||
|
|
||
| // 接続エラーフラグを設定 | ||
| self.hasConnectionError = true | ||
| self.lastDisconnectedDevice = deviceName | ||
|
|
||
| // RealtimeDataUsecaseに端末切断を通知 | ||
| // endpointIdではなくdeviceNameが必要だが、ここではendpointIdしかないので | ||
| // 接続中のdeviceNamesから削除する | ||
| if let deviceName = self.connectedDeviceNames.first(where: { _ in true }) { | ||
| if let deviceName { | ||
| self.connectedDeviceNames.remove(deviceName) | ||
| self.realtimeDataUsecase?.removeDisconnectedDevice(deviceName) | ||
| print("📱 RealtimeDataUsecaseに端末切断を通知: \(deviceName)") | ||
|
|
||
| // マッピングから削除 | ||
| self.endpointToDeviceNameMap.removeValue(forKey: endpointId) | ||
| } else { | ||
| print("⚠️ endpointId \(endpointId) に対応するdeviceNameが見つかりません") | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
LGTM: 切断時の状態管理が適切です
endpointIdからdeviceNameを取得し、マッピングのクリーンアップも適切に行われています。マッピングが見つからない場合の警告ログも有用です。
ただし、Line 268のデバッグ用print文はコーディングガイドラインに従い削除してください。
Based on coding guidelines
🤖 Prompt for AI Agents
In UWBViewerSystem/Domain/Usecase/ConnectionManagementUsecase.swift around lines
254 to 274, remove the debug print on line 268 ("📱 RealtimeDataUsecaseに端末切断を通知:
\(deviceName)") to comply with coding guidelines; if persistent audit is
required replace it with the project's standard logging mechanism (e.g., use the
shared logger or a configurable logger call) otherwise simply delete the print
statement so no debug prints remain in production code.
| private func restartDiscovery() { | ||
| print("🔍 手動で再度検索を開始") | ||
|
|
||
| // エラーフラグをクリア | ||
| self.connectionUsecase.hasConnectionError = false | ||
| self.connectionUsecase.lastDisconnectedDevice = nil | ||
|
|
||
| // 検索と広告を再開 | ||
| self.connectionUsecase.stopDiscovery() | ||
| self.connectionUsecase.startDiscovery() | ||
| self.connectionUsecase.startAdvertising() | ||
|
|
||
| // 画面を閉じる | ||
| self.isPresented = false | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
デバッグ用のprint文を削除してください
Line 236のデバッグ用print文はコーディングガイドラインに従い削除してください。
Based on coding guidelines
🤖 Prompt for AI Agents
In UWBViewerSystem/Presentation/Components/ConnectionRecoveryView.swift around
lines 235 to 249, remove the debug print statement on line 236 ("🔍 手動で再度検索を開始")
so the method no longer outputs debug text; keep the remaining logic (clearing
error flags, stopping/starting discovery and advertising, and dismissing the
view) unchanged to preserve behavior and coding-guideline compliance.
| /// 接続監視を設定 | ||
| private func setupConnectionMonitoring() { | ||
| // hasConnectionErrorの変更を監視 | ||
| ConnectionManagementUsecase.shared.$hasConnectionError | ||
| .sink { [weak self] hasError in | ||
| guard let self else { return } | ||
| if hasError { | ||
| print("⚠️ 接続断検出: 接続復旧画面を表示します") | ||
| self.handleConnectionError() | ||
| } | ||
| } | ||
| .store(in: &self.cancellables) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
接続監視の実装が適切です
Combineを使った接続エラーの監視が適切に実装されています。weak selfの使用によりメモリリークも防止されています。
ただし、Line 232のデバッグ用print文はコーディングガイドラインに従い削除してください。
Based on coding guidelines
🤖 Prompt for AI Agents
UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationViewModel.swift
around lines 225 to 237: the debug print at line 232 must be removed per coding
guidelines; replace the print with a proper logging call (e.g., use the app's
logger or OSLog) or simply remove it if no runtime log is required, keeping the
existing ConnectionManagementUsecase sink and self.handleConnectionError()
behavior unchanged and preserve the weak self capture and cancellable storage.
| /// 接続エラーハンドリング | ||
| private func handleConnectionError() { | ||
| // データ収集中・キャリブレーション中の場合は停止 | ||
| if self.isCollecting || self.isCalibrating { | ||
| print("⚠️ データ収集/キャリブレーションを中断します") | ||
| self.isCollecting = false | ||
| self.isCalibrating = false | ||
| } | ||
|
|
||
| // エラーメッセージを設定 | ||
| if let deviceName = ConnectionManagementUsecase.shared.lastDisconnectedDevice { | ||
| self.errorMessage = "デバイス「\(deviceName)」との接続が切断されました" | ||
| } else { | ||
| self.errorMessage = "接続が切断されました" | ||
| } | ||
|
|
||
| // 接続復旧画面を表示 | ||
| self.showConnectionRecovery = true | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
エラーハンドリングが適切です
接続エラー発生時に実行中の処理を適切に停止し、ユーザーにわかりやすいエラーメッセージを提供しています。
ただし、Lines 243と256のデバッグ用print文はコーディングガイドラインに従い削除してください。
Based on coding guidelines
🤖 Prompt for AI Agents
UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationViewModel.swift
around lines 239 to 257: remove debug print statements per coding guidelines;
specifically delete the print("⚠️ データ収集/キャリブレーションを中断します") on line ~243 and any
other stray debug prints in this block (e.g., at ~256) so that logging follows
production standards, leaving only the state updates, errorMessage assignment,
and showConnectionRecovery toggle.
…etween tag positions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (1)
UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationViewModel.swift (1)
235-264: デバッグprintを削除してください
setupConnectionMonitoringとhandleConnectionErrorに追加された
提案diff:ConnectionManagementUsecase.shared.$hasConnectionError .sink { [weak self] hasError in guard let self else { return } if hasError { - print("⚠️ 接続断検出: 接続復旧画面を表示します") self.handleConnectionError() } } .store(in: &self.cancellables) @@ // データ収集中・キャリブレーション中の場合は停止 if self.isCollecting || self.isCalibrating { - print("⚠️ データ収集/キャリブレーションを中断します") self.isCollecting = false self.isCalibrating = false }As per coding guidelines
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
UWBViewerSystem/Domain/Usecase/AutoAntennaCalibrationUsecase.swift(1 hunks)UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationView.swift(2 hunks)UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationViewModel.swift(4 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.swift
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.swift: SwiftFormat(swift-format)ルールに従い、make formatでコード整形を行う
デバッグ用コードやコメントアウトされた古いコードなどの不要なコードは削除する
不要なimport文は削除する
デッドコードは削除し、コメントは必要最小限に留める(自己文書化を優先)
Files:
UWBViewerSystem/Domain/Usecase/AutoAntennaCalibrationUsecase.swiftUWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationView.swiftUWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationViewModel.swift
**/*Usecase.swift
📄 CodeRabbit inference engine (CLAUDE.md)
Usecaseのファイル名は「〜Usecase.swift」とする
Files:
UWBViewerSystem/Domain/Usecase/AutoAntennaCalibrationUsecase.swift
**/*View.swift
📄 CodeRabbit inference engine (CLAUDE.md)
Viewのファイル名は「〜View.swift」とする
Files:
UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationView.swift
**/*ViewModel.swift
📄 CodeRabbit inference engine (CLAUDE.md)
ViewModelのファイル名は「〜ViewModel.swift」とする
Files:
UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationViewModel.swift
🧠 Learnings (1)
📚 Learning: 2025-09-23T15:18:09.790Z
Learnt from: CR
Repo: kajiLabTeam/UWBViewerSystem PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-23T15:18:09.790Z
Learning: ViewModelはPublished/StateObjectでViewと双方向バインディングする
Applied to files:
UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationView.swift
🧬 Code graph analysis (2)
UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationView.swift (1)
UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationViewModel.swift (2)
goToPreviousTagPosition(354-384)proceedToNextTagPosition(347-351)
UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationViewModel.swift (1)
UWBViewerSystem/Domain/Usecase/AutoAntennaCalibrationUsecase.swift (3)
clearData(311-315)clearData(318-324)clearData(331-336)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Run Swift Tests
| print("⬅️ 現在のタグ(\(currentTag.tagId))を取り消して前のタグ位置に戻る: \(self.trueTagPositions[self.currentTagPositionIndex].tagId)") | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
デバッグprintの削除をお願いします
goToPreviousTagPosition 内の print("⬅️ ...") もデバッグログのまま残っています。ガイドラインに従い削除するか、必要な場合は正式なロギング手段へ置換してください。
提案diff:
- print("⬅️ 現在のタグ(\(currentTag.tagId))を取り消して前のタグ位置に戻る: \(self.trueTagPositions[self.currentTagPositionIndex].tagId)")As per coding guidelines
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| print("⬅️ 現在のタグ(\(currentTag.tagId))を取り消して前のタグ位置に戻る: \(self.trueTagPositions[self.currentTagPositionIndex].tagId)") |
🤖 Prompt for AI Agents
UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationViewModel.swift
around lines 379-380: the debug print call print("⬅️
現在のタグ(\(currentTag.tagId))を取り消して前のタグ位置に戻る:
\(self.trueTagPositions[self.currentTagPositionIndex].tagId)") should be removed
or replaced with the app's formal logging mechanism; delete the print statement,
or replace it with a structured logger/OSLog/Swift.Log call at the appropriate
level (e.g., debug) and include the same contextual message and variables,
ensuring no stray debug prints remain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
UWBViewerSystem/Domain/Usecase/ConnectionManagementUsecase.swift(6 hunks)UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationView.swift(4 hunks)UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationViewModel.swift(7 hunks)UWBViewerSystem/Presentation/Scenes/FloorMapTab/PairingSettingPage/PairingSettingView.swift(1 hunks)UWBViewerSystem/Presentation/Scenes/FloorMapTab/PairingSettingPage/PairingSettingViewModel.swift(7 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.swift
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.swift: SwiftFormat(swift-format)ルールに従い、make formatでコード整形を行う
デバッグ用コードやコメントアウトされた古いコードなどの不要なコードは削除する
不要なimport文は削除する
デッドコードは削除し、コメントは必要最小限に留める(自己文書化を優先)
Files:
UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationView.swiftUWBViewerSystem/Domain/Usecase/ConnectionManagementUsecase.swiftUWBViewerSystem/Presentation/Scenes/FloorMapTab/PairingSettingPage/PairingSettingView.swiftUWBViewerSystem/Presentation/Scenes/FloorMapTab/PairingSettingPage/PairingSettingViewModel.swiftUWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationViewModel.swift
**/*View.swift
📄 CodeRabbit inference engine (CLAUDE.md)
Viewのファイル名は「〜View.swift」とする
Files:
UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationView.swiftUWBViewerSystem/Presentation/Scenes/FloorMapTab/PairingSettingPage/PairingSettingView.swift
**/*Usecase.swift
📄 CodeRabbit inference engine (CLAUDE.md)
Usecaseのファイル名は「〜Usecase.swift」とする
Files:
UWBViewerSystem/Domain/Usecase/ConnectionManagementUsecase.swift
**/*ViewModel.swift
📄 CodeRabbit inference engine (CLAUDE.md)
ViewModelのファイル名は「〜ViewModel.swift」とする
Files:
UWBViewerSystem/Presentation/Scenes/FloorMapTab/PairingSettingPage/PairingSettingViewModel.swiftUWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationViewModel.swift
🧠 Learnings (8)
📚 Learning: 2025-09-23T15:18:09.790Z
Learnt from: CR
Repo: kajiLabTeam/UWBViewerSystem PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-23T15:18:09.790Z
Learning: ViewModelはPublished/StateObjectでViewと双方向バインディングする
Applied to files:
UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationView.swiftUWBViewerSystem/Domain/Usecase/ConnectionManagementUsecase.swift
📚 Learning: 2025-09-23T15:18:09.790Z
Learnt from: CR
Repo: kajiLabTeam/UWBViewerSystem PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-23T15:18:09.790Z
Learning: Clean Architecture + MVVMを採用する(データフロー: View→ViewModel→Usecase→Repository)
Applied to files:
UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationView.swift
📚 Learning: 2025-09-23T15:18:09.790Z
Learnt from: CR
Repo: kajiLabTeam/UWBViewerSystem PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-23T15:18:09.790Z
Learning: Applies to **/*.swift : デッドコードは削除し、コメントは必要最小限に留める(自己文書化を優先)
Applied to files:
UWBViewerSystem/Domain/Usecase/ConnectionManagementUsecase.swiftUWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationViewModel.swift
📚 Learning: 2025-09-23T15:18:09.790Z
Learnt from: CR
Repo: kajiLabTeam/UWBViewerSystem PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-23T15:18:09.790Z
Learning: Applies to **/*.swift : デバッグ用コードやコメントアウトされた古いコードなどの不要なコードは削除する
Applied to files:
UWBViewerSystem/Domain/Usecase/ConnectionManagementUsecase.swiftUWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationViewModel.swift
📚 Learning: 2025-09-23T15:18:09.790Z
Learnt from: CR
Repo: kajiLabTeam/UWBViewerSystem PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-23T15:18:09.790Z
Learning: Applies to Devices/**/*.swift : UWBデバイス関連の通信・制御ロジックはDevices/配下に配置する
Applied to files:
UWBViewerSystem/Domain/Usecase/ConnectionManagementUsecase.swiftUWBViewerSystem/Presentation/Scenes/FloorMapTab/PairingSettingPage/PairingSettingViewModel.swift
📚 Learning: 2025-09-23T15:18:09.790Z
Learnt from: CR
Repo: kajiLabTeam/UWBViewerSystem PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-23T15:18:09.790Z
Learning: Applies to **/*Usecase.swift : Usecaseのファイル名は「〜Usecase.swift」とする
Applied to files:
UWBViewerSystem/Domain/Usecase/ConnectionManagementUsecase.swift
📚 Learning: 2025-09-23T15:18:09.790Z
Learnt from: CR
Repo: kajiLabTeam/UWBViewerSystem PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-09-23T15:18:09.790Z
Learning: Applies to **/*ViewModel.swift : ViewModelのファイル名は「〜ViewModel.swift」とする
Applied to files:
UWBViewerSystem/Presentation/Scenes/FloorMapTab/PairingSettingPage/PairingSettingView.swift
📚 Learning: 2025-09-23T14:37:07.451Z
Learnt from: harutiro
Repo: kajiLabTeam/UWBViewerSystem PR: 0
File: :0-0
Timestamp: 2025-09-23T14:37:07.451Z
Learning: UWBViewerSystemでUserDefaults変更通知のテストを行う際は、NotificationCenterの非同期処理完了を確実に待機するため、1.5秒程度の待機時間とポーリング方式の検証を使用する。これにより競合状態やタイミング問題を回避できる。
Applied to files:
UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationViewModel.swift
🧬 Code graph analysis (5)
UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationView.swift (2)
UWBViewerSystem/Presentation/Router/SensingFlowNavigator.swift (1)
setRouter(32-34)UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationViewModel.swift (3)
setFlowNavigator(235-237)goToPreviousTagPosition(372-408)proceedToNextTagPosition(365-369)
UWBViewerSystem/Domain/Usecase/ConnectionManagementUsecase.swift (3)
UWBViewerSystem/Presentation/Scenes/FloorMapTab/PairingSettingPage/PairingSettingViewModel.swift (1)
pairAntennaWithDevice(205-276)UWBViewerSystem/Devices/NearByConnection/NearByConnectionApi.swift (1)
requestConnection(194-216)UWBViewerSystem/Domain/Usecase/RealtimeDataUsecase.swift (1)
removeDisconnectedDevice(102-107)
UWBViewerSystem/Presentation/Scenes/FloorMapTab/PairingSettingPage/PairingSettingView.swift (1)
UWBViewerSystem/Presentation/Scenes/FloorMapTab/PairingSettingPage/PairingSettingViewModel.swift (1)
saveAndProceedToNextStep(344-355)
UWBViewerSystem/Presentation/Scenes/FloorMapTab/PairingSettingPage/PairingSettingViewModel.swift (3)
UWBViewerSystem/Domain/Usecase/ConnectionManagementUsecase.swift (3)
pairAntennaWithDevice(178-181)unpairAntenna(184-187)clearAllPairings(190-193)UWBViewerSystem/Presentation/Router/NavigationRouterModel.swift (1)
push(25-31)UWBViewerSystem/Presentation/Router/SensingFlowNavigator.swift (1)
proceedToNextStep(44-78)
UWBViewerSystem/Presentation/Scenes/FloorMapTab/AutoAntennaCalibrationPage/AutoAntennaCalibrationViewModel.swift (1)
UWBViewerSystem/Domain/Usecase/AutoAntennaCalibrationUsecase.swift (3)
clearData(311-315)clearData(318-324)clearData(331-336)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Run Swift Tests
| self.antennaPairings.removeAll { $0.device.id == endpointId } | ||
| self.isConnected = !self.antennaPairings.isEmpty | ||
| self.savePairingData() | ||
|
|
||
| // ConnectionManagementUsecaseからも削除 | ||
| if let pairing = self.antennaPairings.first(where: { $0.device.id == endpointId }) { | ||
| self.connectionUsecase.unpairAntenna(antennaId: pairing.antenna.id) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ペアリング解除が ConnectionManagementUsecase に反映されません
self.antennaPairings.removeAll { … } を実行した直後に first(where:) でペアリングを探しているため、常に nil になり connectionUsecase.unpairAntenna(...) が呼ばれなくなっています。その結果、接続が切れた端末のペアリング情報が ConnectionManagementUsecase 側に残り続け、後続処理や復旧フローで不整合が発生します。
- self.antennaPairings.removeAll { $0.device.id == endpointId }
- self.isConnected = !self.antennaPairings.isEmpty
-
- // ConnectionManagementUsecaseからも削除
- if let pairing = self.antennaPairings.first(where: { $0.device.id == endpointId }) {
- self.connectionUsecase.unpairAntenna(antennaId: pairing.antenna.id)
- }
+ if let pairing = self.antennaPairings.first(where: { $0.device.id == endpointId }) {
+ self.connectionUsecase.unpairAntenna(antennaId: pairing.antenna.id)
+ }
+
+ self.antennaPairings.removeAll { $0.device.id == endpointId }
+ self.isConnected = !self.antennaPairings.isEmpty📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| self.antennaPairings.removeAll { $0.device.id == endpointId } | |
| self.isConnected = !self.antennaPairings.isEmpty | |
| self.savePairingData() | |
| // ConnectionManagementUsecaseからも削除 | |
| if let pairing = self.antennaPairings.first(where: { $0.device.id == endpointId }) { | |
| self.connectionUsecase.unpairAntenna(antennaId: pairing.antenna.id) | |
| } | |
| if let pairing = self.antennaPairings.first(where: { $0.device.id == endpointId }) { | |
| self.connectionUsecase.unpairAntenna(antennaId: pairing.antenna.id) | |
| } | |
| self.antennaPairings.removeAll { $0.device.id == endpointId } | |
| self.isConnected = !self.antennaPairings.isEmpty |
🤖 Prompt for AI Agents
In
UWBViewerSystem/Presentation/Scenes/FloorMapTab/PairingSettingPage/PairingSettingViewModel.swift
around lines 525 to 531, the code removes antennaPairings then tries to find the
same pairing with first(where:), which will always be nil so
connectionUsecase.unpairAntenna(...) is never called; to fix this, first locate
(or filter) the pairing(s) matching endpointId and call
connectionUsecase.unpairAntenna(antennaId:) for each found pairing before
removing them from self.antennaPairings, then update self.isConnected
accordingly so ConnectionManagementUsecase stays in sync.
Summary by CodeRabbit
新機能
改善