Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions apps/dashboard/src/components/theme-toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ export default function ThemeToggle() {
return;
}

if (typeof document.startViewTransition !== "function") {
setTheme(nextTheme);
return;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Redundant startViewTransition check duplicates existing guard

Low Severity

The new typeof document.startViewTransition !== "function" check on lines 25-28 is redundant dead code. The existing supportsViewTransitions() function (line 8-10) already checks "startViewTransition" in document, and the early return on line 20 ensures execution only reaches line 25 when that property exists. In all real browser implementations, when "startViewTransition" in document is true, the property is always a function, making this second guard unreachable.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b5232a1. Configure here.

Comment on lines +25 to +28
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Redundant guard — already covered by supportsViewTransitions()

The new typeof document.startViewTransition !== "function" check is unreachable in practice. The existing supportsViewTransitions() call on line 20 uses "startViewTransition" in document, which already returns false whenever the API is absent, causing an early return before this block is ever evaluated. The only case where this new guard would fire is if startViewTransition is present on document but isn't a function — a scenario that doesn't exist in any real browser. Consider either updating supportsViewTransitions() to use typeof document.startViewTransition === "function" and removing this guard, or simply removing this redundant block.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/dashboard/src/components/theme-toggle.tsx
Line: 25-28

Comment:
**Redundant guard — already covered by `supportsViewTransitions()`**

The new `typeof document.startViewTransition !== "function"` check is unreachable in practice. The existing `supportsViewTransitions()` call on line 20 uses `"startViewTransition" in document`, which already returns `false` whenever the API is absent, causing an early return before this block is ever evaluated. The only case where this new guard would fire is if `startViewTransition` is present on `document` but isn't a function — a scenario that doesn't exist in any real browser. Consider either updating `supportsViewTransitions()` to use `typeof document.startViewTransition === "function"` and removing this guard, or simply removing this redundant block.

How can I resolve this? If you propose a fix, please make it concise.


document.documentElement.classList.add("vt-disable-transitions");

const transition = document.startViewTransition(() => {
Expand Down
9 changes: 7 additions & 2 deletions apps/dashboard/src/hooks/use-wait-for-idle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ export function useWaitForIdle(min = 0, max = 5000) {
useEffect(() => {
let cancelled = false;
setTimeout(() => {
requestIdleCallback(() => {
const cb = () => {
if (cancelled) return;
setHasWaited(true);
}, { timeout: max - min });
};
if (typeof requestIdleCallback === "function") {
requestIdleCallback(cb, { timeout: max - min });
} else {
setTimeout(cb, max - min);
}
Comment on lines +12 to +16
}, min);
return () => {
cancelled = true;
Comment on lines 5 to 19
Expand Down
Loading