Skip to content

feat(mcp): 録画中の座標ログ蓄積機能#1

Open
sinano1107 wants to merge 8 commits intofeat/mcp-coordinate-logging-basefrom
feat/mcp-coordinate-logging
Open

feat(mcp): 録画中の座標ログ蓄積機能#1
sinano1107 wants to merge 8 commits intofeat/mcp-coordinate-logging-basefrom
feat/mcp-coordinate-logging

Conversation

@sinano1107
Copy link
Copy Markdown
Owner

概要

録画中のtap/swipe座標を自動蓄積し、stop_recording時にffprobeで動画内タイムスタンプに補正してcoordinate_logとして返却する。

依存

変更内容

RecordingManager

  • InteractionEvent/CoordinateLogEntryデータクラス追加
  • appendTapEvent()/appendSwipeEvent(): 録画中のみイベントを蓄積(録画なしならno-op)
  • captureTimestamp(): テスタビリティのためのclock wrapper
  • stopRecording()にffprobeによるduration取得とタイムスタンプ補正を追加
    • actual_start = stop_time - duration
    • offset = (event.wallClock - actual_start) / 1000.0
  • stopWallClockMsstopScreenRecording()の後に記録(録画停止処理分のズレ防止)
  • clock/videoDurationProviderをコンストラクタ注入(テスト用)

TapOnTool

  • runFlow()の前後でタイムスタンプを記録し、中間値を使用
  • タップ成功時にrecordingManager.appendTapEvent()を呼び出し

RunFlowTool

  • 同様の中間値タイムスタンプ
  • CommandResultにstart_point/end_pointがある場合のみswipeとして蓄積

StopRecordingTool

  • レスポンスにdurationcoordinate_logを追加
  • tap: center配列、swipe: start_point/end_point配列

タイムスタンプ精度

方式 問題
runFlow後に記録 settle待ち分だけ遅い(少しだけ)
runFlow前に記録 要素解決分だけ早い(1秒以上)
前後の中間値 両方の誤差を半分に分割(採用)

テスト

  • ユニットテスト: fake clock/duration providerでタイムスタンプ補正、クランプ、tap/swipe混在、startup delay等をカバー
  • 手動テスト: Simulator上でstart_recordingtap_onswipetap_onstop_recordingのフローを確認済み

sinano1107 and others added 6 commits April 4, 2026 16:39
RecordingManager now accumulates tap/swipe coordinates with wall-clock
timestamps during recording. On stop, ffprobe reads the video duration
and timestamps are corrected to video-relative time. stop_recording
returns coordinate_log alongside video_path and duration.

TapOnTool appends tap coordinates when a recording is active (no-op
otherwise). RunFlowTool appends swipe coordinates when CommandResult
contains start_point/end_point.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Record wall-clock timestamp before orchestra.runFlow() instead of
after, so the coordinate log reflects when the command was dispatched
rather than when it completed (which includes settle wait time).
appendTapEvent/appendSwipeEvent now accept an explicit timestampMs
parameter. captureTimestamp() is exposed for callers to record time
before executing commands.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Capture wall-clock time both before and after orchestra.runFlow(),
then use the midpoint as the event timestamp. This splits the error
between element resolution (before tap) and settle wait (after tap),
giving better accuracy than either extreme alone.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move the wall-clock anchor to after the recording process has stopped,
so the timestamp correction is not offset by the stop operation duration.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sinano1107 sinano1107 changed the base branch from feat/mcp-recording-tools-upstream to feat/mcp-coordinate-logging-base April 4, 2026 08:19
@sinano1107
Copy link
Copy Markdown
Owner Author

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

@sinano1107
Copy link
Copy Markdown
Owner Author

詳細レビュー結果

5件の指摘を検出し、スコアリングで評価した。閾値(80)を超える指摘はなし。

1. run_flow内の全swipeが同一タイムスタンプ(スコア: 75)

RunFlowToolmidMs = (beforeMs + afterMs) / 2を1回だけ計算し、全swipeに同じ値を割り当てている。複数swipeを含むフローでは時系列情報が失われる。

判定: run_flowの説明が"preferably one at a time"と明記しており、実用上は単一コマンドで使われる。またOrchestraがper-command timingを提供しないため、現状の構造では修正が困難。

2. run_flow経由のtapが座標ログに記録されない(スコア: 65)

RunFlowToolstartPoint/endPointのみチェックするため、run_flow YAML内のtapOnコマンドはcoordinate_logに記録されない。TapOnTool経由のtapは正常に記録される。

判定: PR説明で「CommandResultにstart_point/end_pointがある場合のみswipeとして蓄積」と意図的設計を明記。tap_onが主要なtapインターフェースであり、実用上の影響は限定的。

3. ffprobe失敗時に動画パスが返らない(スコア: 50)

videoDurationProviderがthrowすると、finallyでactiveRecordingsは削除されるが、動画ファイルのパスは呼び出し元に返らない。フォールバック(coordinate_logなしでvideo_pathだけ返す)がない。

判定: ffprobeは座標ログ機能の必須依存。未インストール時は機能全体が非機能になるため、個別のフォールバックは過剰。tempファイルはシャットダウン時にクリーンアップされる。

4. ::getVideoDurationWithFfprobeのcompanion object参照(スコア: 5)

RecordingManagerコンストラクタのデフォルト値::getVideoDurationWithFfprobeがcompanion object内の関数を正しく参照できるかという懸念。

判定: 偽陽性。Kotlinではcompanion objectの関数はクラススコープから参照可能。実際にコンパイル・全テスト通過済み。

5. クランプテストで時計が逆行する(スコア: 50)

stopRecording clamps timestampsテストでcurrentTimeMsを16000→15000に巻き戻している。実際のSystem.currentTimeMillis()では不可能なシナリオ。

判定: fake clockによるテストなので動作する。midpoint計算により実際にstop時刻後のタイムスタンプが発生しうるため、クランプのテスト自体は妥当。テストシナリオをより現実的にする改善の余地はある。

- start_recording: document that tap_on/run_flow auto-log coordinates
- tap_on: document coordinate logging during active recording
- run_flow: document swipe coordinate logging and limitations (direction/relative swipes not logged)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant