-
-
Notifications
You must be signed in to change notification settings - Fork 143
Claude/issue 405 20250530 094000 #406
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
Conversation
…lity - Create useDraggable hook with mobile detection - Enable mouse dragging for camera and screen sharing modals on desktop only - Add expand icon to toggle background video mode instead of manual setting - Remove useVideoAsBackground setting from advanced settings - Change modal positioning from absolute to fixed for proper drag behavior Co-authored-by: tegnike <tegnike@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Walkthroughこの変更では、 Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Webcam
participant VideoDisplay
User->>Webcam: ページ表示/デバイス選択
Webcam->>VideoDisplay: videoRef, mediaStream, トグルコールバック等を渡す
User->>VideoDisplay: トグルボタン操作
VideoDisplay-->>Webcam: onToggleSource コールバック呼び出し
Possibly related PRs
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
npm error Exit handler never called! 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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: 2
🧹 Nitpick comments (7)
src/hooks/useDraggable.ts (1)
21-22: ユーザーエージェント検出の信頼性について検討してください現在のユーザーエージェント検出パターンは一般的なものですが、将来的により堅牢な検出方法(例:タッチイベントの存在確認など)の採用も検討することをお勧めします。
setIsMobile( window.innerWidth <= 768 || - /Mobi|Android|iPhone|iPad|iPod/i.test(navigator.userAgent) + /Mobi|Android|iPhone|iPad|iPod/i.test(navigator.userAgent) || + ('ontouchstart' in window) )src/hooks/useResizable.ts (1)
15-16: ウィンドウサイズ変更時の最大サイズ更新について検討してくださいデフォルトの最大サイズがウィンドウサイズに基づいて設定されていますが、ウィンドウがリサイズされた場合に更新されません。これにより、小さなウィンドウでページを開いた後に拡張した場合、制約が厳しすぎる可能性があります。
ウィンドウリサイズイベントを監視して最大サイズを動的に更新することを検討してください:
+useEffect(() => { + const handleResize = () => { + setMaxConstraints({ + maxWidth: window.innerWidth * 0.8, + maxHeight: window.innerHeight * 0.8 + }) + } + window.addEventListener('resize', handleResize) + return () => window.removeEventListener('resize', handleResize) +}, [])src/components/common/VideoDisplay.tsx (5)
39-51: 状態管理とhooksの使用方法を改善できます。useDraggableとuseResizableの戻り値の構造化代入は適切ですが、カスタムhooksの初期位置設定に関して改善の余地があります。
const { isMobile, handleMouseDown, resetPosition, style: dragStyle, - } = useDraggable() + } = useDraggable({ x: 0, y: 0 })初期位置を明示的に設定することで、予期しない配置を防げます。
54-64: 背景ビデオの同期ロジックを確認してください。背景ビデオの同期処理は正しく実装されていますが、エラーハンドリングを追加することを推奨します。
useEffect(() => { if (useVideoAsBackground && videoRef.current?.srcObject) { if (backgroundVideoRef.current) { backgroundVideoRef.current.srcObject = videoRef.current.srcObject + backgroundVideoRef.current.play().catch(console.error) } } else if (!useVideoAsBackground) { if (backgroundVideoRef.current) { backgroundVideoRef.current.srcObject = null } } }, [useVideoAsBackground, videoRef])
74-97: キャプチャ機能の実装は適切ですが、エラーハンドリングを強化してください。キャプチャロジックは正常に動作しますが、より堅牢なエラーハンドリングを追加することを推奨します。
const handleCapture = useCallback(() => { if (!videoRef.current) return + try { const canvas = document.createElement('canvas') canvas.width = videoRef.current.videoWidth canvas.height = videoRef.current.videoHeight const ctx = canvas.getContext('2d') if (!ctx) return ctx.drawImage(videoRef.current, 0, 0) const data = canvas.toDataURL('image/png') if (data !== '') { console.log('capture') homeStore.setState({ modalImage: data, triggerShutter: false, }) } else { homeStore.setState({ modalImage: '' }) } onCapture?.() + } catch (error) { + console.error('Capture failed:', error) + homeStore.setState({ modalImage: '' }) + } }, [videoRef, onCapture])
150-187: リサイズハンドルの実装は良好ですが、アクセシビリティを向上できます。リサイズハンドルの配置と機能は適切ですが、視覚的なフィードバックを改善できます。
<div - className="absolute top-0 left-0 w-3 h-3 cursor-nwse-resize" + className="absolute top-0 left-0 w-3 h-3 cursor-nwse-resize bg-transparent hover:bg-blue-500 hover:opacity-50 transition-colors" onMouseDown={(e) => handleResizeStart(e, 'top-left')} />各リサイズハンドルにホバー効果を追加することで、ユーザビリティが向上します。
126-133: 動的スタイル設定でパフォーマンスの問題を確認してください。インラインスタイルオブジェクトがrenderごとに再作成される可能性があります。useMemoを使用してパフォーマンスを改善することを検討してください。
+ const containerStyle = useMemo(() => ({ + ...dragStyle, + width: isExpanded ? 'auto' : `${size.width}px`, + height: isExpanded ? 'auto' : `${size.height}px`, + maxWidth: isExpanded ? '70%' : 'none', + maxHeight: isExpanded ? '40vh' : 'none', + }), [dragStyle, isExpanded, size.width, size.height]) style={{ - ...dragStyle, - width: isExpanded ? 'auto' : `${size.width}px`, - height: isExpanded ? 'auto' : `${size.height}px`, - maxWidth: isExpanded ? '70%' : 'none', - maxHeight: isExpanded ? '40vh' : 'none', + ...containerStyle, }}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/components/capture.tsx(3 hunks)src/components/common/VideoDisplay.tsx(1 hunks)src/components/webcam.tsx(3 hunks)src/hooks/useDraggable.ts(1 hunks)src/hooks/useResizable.ts(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/components/webcam.tsx (1)
src/components/common/VideoDisplay.tsx (1)
VideoDisplay(25-216)
src/components/common/VideoDisplay.tsx (3)
src/hooks/useDraggable.ts (1)
useDraggable(8-92)src/hooks/useResizable.ts (1)
useResizable(11-133)src/components/iconButton.tsx (1)
IconButton(14-51)
🔇 Additional comments (10)
src/hooks/useDraggable.ts (1)
1-92: 実装は全体的に良好ですこのドラッグ機能フックの実装は適切に設計されており、以下の点で優れています:
- 適切なイベントリスナーの管理(useEffectでの追加/削除)
- モバイル端末での無効化
- ドラッグ中のテキスト選択防止
- 適切な依存関係の管理
src/components/webcam.tsx (3)
4-4: VideoDisplayコンポーネントの統合が適切です新しいVideoDisplayコンポーネントの導入により、コードの責任分離が改善されています。
55-55: 依存関係の更新が正しく行われています
useVideoAsBackgroundへの依存関係が削除されたのは正しい変更です。このロジックがVideoDisplayコンポーネントに移動されたためです。
77-84: VideoDisplayとの統合が適切に実装されていますプロパティの渡し方とコールバックの設定が適切で、カメラローテーション機能も正しく統合されています。
src/components/capture.tsx (3)
3-3: VideoDisplayコンポーネントの統合により、アーキテクチャが改善されていますキャプチャコンポーネントの責任が適切に分離され、VideoDisplayに表示ロジックが委譲されています。
17-26: ストリーム設定関数が適切に更新されています新しいアーキテクチャに合わせてストリーム設定ロジックが適切に調整されており、VideoDisplayコンポーネントとの連携が正しく実装されています。
96-103: VideoDisplayとの統合が正しく実装されていますmediaStreamの渡し方、toggleソースの接続、アイコンの設定などが適切に行われており、画面キャプチャ機能が正しく統合されています。
src/components/common/VideoDisplay.tsx (3)
1-12: インポート文の構成は適切です。React hooksとカスタムhooksが適切にインポートされており、モジュール構成も明確で理解しやすいです。
14-23: インターフェース設計が良好です。VideoDisplayPropsの型定義は明確で、オプショナルプロパティも適切に設定されています。各プロパティの意図が理解しやすく、再利用性を考慮した設計になっています。
218-218: displayNameの設定は適切です。forwardRefを使用したコンポーネントにdisplayNameを設定することで、デバッグ時の識別が容易になります。
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: 0
♻️ Duplicate comments (1)
src/components/common/VideoDisplay.tsx (1)
112-116: 過去に指摘された問題が適切に修正されています。handleExpand関数から
useVideoAsBackgroundの状態変更が削除され、展開状態の管理のみに集中するように改善されました。
🧹 Nitpick comments (4)
src/components/common/VideoDisplay.tsx (4)
94-94: 本番環境用にコンソールログを削除することを推奨します。デバッグ用のログが残っているようです。本番環境では削除するか、適切なロガーを使用することを検討してください。
- console.log('capture')
145-150: パフォーマンス最適化のためにuseMemoの使用を検討してください。videoBounds状態の更新で新しいオブジェクトを毎回生成すると、不要な再レンダリングが発生する可能性があります。値が実際に変更された場合のみ更新するようにすることを推奨します。
+import { useMemo } from 'react' + const newVideoBounds = useMemo(() => ({ + x: offsetX, + y: offsetY, + width: actualWidth, + height: actualHeight, + }), [offsetX, offsetY, actualWidth, actualHeight]) + - setVideoBounds({ - x: offsetX, - y: offsetY, - width: actualWidth, - height: actualHeight, - }) + setVideoBounds(prev => { + if (prev.x === offsetX && prev.y === offsetY && + prev.width === actualWidth && prev.height === actualHeight) { + return prev + } + return newVideoBounds + })
217-285: マジックナンバーを定数として定義することを推奨します。リサイズハンドルの位置計算で使用されている数値(12、8など)を定数として定義すると、コードの可読性と保守性が向上します。
コンポーネントの上部に定数を追加:
+const HANDLE_SIZE = 12 +const EDGE_HANDLE_SIZE = 8 +const EDGE_HANDLE_THICKNESS = 2 // 使用例: - left: `${videoBounds.x + videoBounds.width - 12}px`, + left: `${videoBounds.x + videoBounds.width - HANDLE_SIZE}px`,
25-316: コンポーネントの分割を検討することを推奨します。VideoDisplayコンポーネントは複数の責任(ドラッグ、リサイズ、キャプチャ、背景動画管理)を持っています。将来的な保守性向上のため、以下の分割を検討してください:
VideoContainer: 基本的な動画表示ResizableVideo: リサイズ機能VideoControls: コントロールボタン群BackgroundVideoManager: 背景動画管理これにより、各コンポーネントの責任が明確になり、テストやデバッグが容易になります。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/components/common/VideoDisplay.tsx(1 hunks)src/hooks/useResizable.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/hooks/useResizable.ts
🔇 Additional comments (2)
src/components/common/VideoDisplay.tsx (2)
14-23: Props定義が適切に設計されています。型安全性が確保され、オプショナルプロパティも適切に定義されています。
177-185: 背景動画の条件付きレンダリングが適切に実装されています。useVideoAsBackground設定に基づく条件付きレンダリングが正しく実装されており、対応するエフェクトでも適切なnullチェックが行われています。
…_094000 Claude/issue 405 20250530 094000
Summary by CodeRabbit
新機能
リファクタ