Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/utils/deviceDetect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Device detection utilities
export function isMobileDevice(): boolean {
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
}

export function isIOSDevice(): boolean {
return /iPad|iPhone|iPod/.test(navigator.userAgent);
}

export function isTouchDevice(): boolean {
return 'ontouchstart' in window || navigator.maxTouchPoints > 0;
}

export function getDeviceType(): 'mobile' | 'tablet' | 'desktop' {
const width = window.innerWidth;
if (width < 768) return 'mobile';
if (width < 1024) return 'tablet';
return 'desktop';
}

export function getBrowserName(): string {
const ua = navigator.userAgent;
if (ua.includes('Firefox')) return 'Firefox';
if (ua.includes('Chrome')) return 'Chrome';
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: getBrowserName misclassifies Microsoft Edge as Chrome because the Chrome check runs first and Edge is matched with Edge instead of modern Edg/.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/utils/deviceDetect.ts, line 24:

<comment>`getBrowserName` misclassifies Microsoft Edge as Chrome because the Chrome check runs first and Edge is matched with `Edge` instead of modern `Edg/`.</comment>

<file context>
@@ -0,0 +1,28 @@
+export function getBrowserName(): string {
+  const ua = navigator.userAgent;
+  if (ua.includes('Firefox')) return 'Firefox';
+  if (ua.includes('Chrome')) return 'Chrome';
+  if (ua.includes('Safari')) return 'Safari';
+  if (ua.includes('Edge')) return 'Edge';
</file context>
Fix with Cubic

if (ua.includes('Safari')) return 'Safari';
if (ua.includes('Edge')) return 'Edge';
return 'Unknown';
}
Loading