Skip to content

thqの新仕様に対応 - #4466

Merged
TinyKitten merged 1 commit into
devfrom
fix/for-telemetry
Aug 16, 2025
Merged

TinyKitten merged 1 commit into
devfrom
fix/for-telemetry

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Aug 16, 2025 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • 新機能
    • なし
  • リファクタリング
    • テレメトリのペイロード設計を整理し、ログと位置情報更新の区別を明確化。整合性と拡張性を向上しつつ、送信条件やキュー/スロットリングなどの挙動は従来どおり。
  • テスト
    • テレメトリ送信の期待値を新仕様に合わせて更新。

@TinyKitten TinyKitten self-assigned this Aug 16, 2025
@github-actions github-actions Bot added the react label Aug 16, 2025
@coderabbitai

coderabbitai Bot commented Aug 16, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

朕、報ず。テレメトリ送信の型を判別可能に改め、payload に top-level の type を導入('log' | 'location_update')。log は内部に log.type: 'app' を持つ。テストは WebSocket 期待値とメッセージ文言を更新。シリアライズ時は top-level type を含めぬ方針に整えたり。

Changes

Cohort / File(s) Summary
Hook 実装
src/hooks/useTelemetrySender.ts
TelemetryPayload を判別共用体化(type: 'log'
テスト
src/hooks/useTelemetrySender.enabled.test.tsx
期待 payload の type を 'app' に、ログ文言を 'Test log from the app' に更新。sendLog 入力も同文言へ変更。

Sequence Diagram(s)

sequenceDiagram
  participant UI as UI/Caller
  participant Hook as useTelemetrySender
  participant Q as Queue
  participant WS as WebSocket

  UI->>Hook: sendLog(level, "Test log from the app")
  Hook->>Hook: 構築 {type:'log', schemaVersion:2, log:{type:'app', level, message}}
  Hook->>Q: エンキュー(必要時)
  alt WS 準備完了
    Q->>WS: シリアライズ送信(top-level type 無し)
  else 未接続/バックプレッシャ
    Q->>Q: 待機
  end
Loading
sequenceDiagram
  participant Device as Device State
  participant Hook as useTelemetrySender
  participant Q as Queue
  participant WS as WebSocket

  Device->>Hook: location_update(coords, gnss, radio, ...)
  Hook->>Hook: 構築 {type:'location_update', schemaVersion:2, ...}
  Hook->>Q: エンキュー(スロットリング適用)
  alt WS 準備完了
    Q->>WS: シリアライズ送信(top-level type 無し)
  else 未接続
    Q->>Q: 待機
  end
Loading

Estimated code review effort

🎯 3 (中程度) | ⏱️ ~20 分

Possibly related PRs

Poem

朕の令、電の馬に載りて走る
型は二つに割れ、道は明らか
「app」と名乗る声、雲を抜け
位置もまた告ぐ、静かなる符
列を保ち、時を待て
一度つながらば、万里を渡る 🛰️


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 746b239 and 5e5b078.

📒 Files selected for processing (2)
  • src/hooks/useTelemetrySender.enabled.test.tsx (1 hunks)
  • src/hooks/useTelemetrySender.ts (4 hunks)
🔇 Additional comments (8)
src/hooks/useTelemetrySender.enabled.test.tsx (2)

67-67: 朕、テスト入力の更新を評価す。

新仕様に合わせ、ログメッセージを 'Test log from the app' に変更せしこと、適切なり。


75-76: 朕、期待値の変更を確認せり。

WebSocketペイロードの検証において、message.type が 'app' を期待し、message.log.message が 'Test log from the app' を期待するよう更新されたり。新たな discriminated payload 構造に合致す。

src/hooks/useTelemetrySender.ts (6)

24-26: 朕、discriminated union の導入を賞賛す。

スキーマバージョンを2に更新し、top-level の type フィールドにて 'log' | 'location_update' を判別可能とした設計、優れたり。型安全性が向上せん。


38-44: 朕、ログ構造の再設計を評価す。

log.type: 'app' の literal 型を導入し、内部構造を明確化せり。階層的な設計にて可読性向上せん。


126-136: 朕、ログ送信時のペイロード構築を査閲す。

新仕様に従い、top-level に type: 'log' を設定し、log.type: 'app' を内包する構造に変更されたり。適切な実装なり。


165-176: 朕、位置情報更新のペイロード構築を査閲す。

type: 'location_update' を top-level に設定し、座標情報、デバイス情報、状態等を含む構造に変更されたり。新仕様に合致す。


183-185: 朕、位置情報のシリアライゼーション処理にも同様の疑念あり。

ここでも payload.data 全体をシリアライズしており、top-level の type フィールドが含まれるなり。ログ送信と同様の問題が存在するやもしれん。


143-146: 汝、TelemetryPayload の型定義を自ら点検せよ
余が検索の限り、TelemetryPayload の定義ファイルが見当たらず、payload.data に本来除外すべき top-level の type フィールドが含まれているか判別できぬ。
速やかに以下を確認せよ:

  • src/hooks/useTelemetrySender.ts における
    const strigifiedMessage = JSON.stringify({ ...payload.data });
    この箇所で payload.data が持つ type フィールドが不要に含まれていないか
  • プロジェクト内の TelemetryPayload (または相当する型)定義ファイルの所在地を特定し、data 部分に type が含まれないようになっているか

❶ 型定義のファイルパスを開示のうえ、top-level type フィールドの排除方針に齟齬なきことを自証せよ。
❷ 必要に応じてロジックを修正し、明示的に除外するか、シリアライズ対象から外すこと。

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/for-telemetry

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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