Repository navigation
Fix skeleton loading stuck on Desktop/Capacitor - #490
Conversation
…from SWR hooks The isPaused guard on SWR hooks blocked initial fetches under specific timing conditions on Desktop (Electron) and Capacitor, where async Bearer token retrieval in fetchWithAuth introduces delays that don't exist on web. This caused page tree and breadcrumbs to hang in skeleton state until a 12-second timeout triggered retry. Removes isPaused + hasLoadedRef from usePageTree, useBreadcrumbs, usePermissions, useTabMeta, UsageCounter, UserDropdown, and useAiUsage. The invalidateTree() editing guard already prevents Socket.IO-triggered revalidations during editing, making the isPaused double-guard redundant. Adds clearAllSessions() on Layout mount as defense-in-depth against stale editing state from previous app lifecycle. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
📝 WalkthroughWalkthroughRemoves editing/streaming-driven SWR pause logic across multiple hooks/components, adds a startup session cleanup in Layout, and implements cache-driven self-healing retries in useBreadcrumbs and usePageTree; useBreadcrumbs now returns loading and error state. Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Component
participant Hook as useBreadcrumbs/usePageTree
participant SWR
participant Cache as "useSWRConfig Cache"
participant Timer
Client->>Hook: render / request data
Hook->>SWR: useSWR(key, fetcher, { revalidateOnFocus:false, ... })
SWR->>Cache: read(key)
alt cache has data
SWR-->>Hook: return data
else valid key but no data/error and not validating
Hook->>Hook: detect stuck state (no data, no error, !isValidating)
Hook->>Cache: delete(key)
Hook->>Timer: start 3s debounce
Timer-->>Hook: debounce elapsed
Hook->>SWR: mutate(key) — trigger refetch
SWR->>Cache: write(data) / return error
SWR-->>Hook: return updated state
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Replace tests that asserted isPaused existence with tests that verify isPaused is NOT configured, revalidateOnFocus is false, and dedupingInterval is set correctly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
a98c850 to
5a64dae
Compare
useBreadcrumbs now uses useSWRConfig() for the self-healing stuck-retry logic. Add the missing export to the SWR mock so tests pass. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
isPaused+hasLoadedReffrom 7 SWR hooks that were blocking initial fetches on Desktop (Electron) and Capacitor due to async Bearer token retrieval timingrevalidateOnFocus: falsetousePageTreeanduseBreadcrumbsas a lightweight replacement for the over-aggressiveisPausedguardclearAllSessions()onLayoutmount as defense-in-depth against stale editing state from previous app lifecycleContext
Pages get stuck in skeleton loading state on desktop and mobile apps. Network requests for
pagesandbreadcrumbsdon't fire until the user clicks "Retry" after a 12-second timeout. Web browser is unaffected becausefetchWithAuthuses synchronous cookie headers there.The
isPausedpattern was designed to prevent tree revalidation during editing, but theinvalidateTree()function already has its own editing guard at the call site level, makingisPauseda redundant double-guard that introduced timing bugs on non-web platforms.Files changed
usePageTree.tsisPaused,hasLoadedRef; addrevalidateOnFocus: falseuseBreadcrumbs.tsisPaused,hasLoadedRef; addrevalidateOnFocus: falseusePermissions.tsisPaused,hasLoadedRefuseTabMeta.tsisPaused,hasLoadedRef(2 SWR calls)UsageCounter.tsxisPausedUserDropdown.tsxisPaused(2 SWR calls)useAiUsage.tsisPaused(2 hooks)Layout.tsxclearAllSessions()on mountTest plan
invalidateTree()guard)usePageTree.test.ts: 14/14 passingapps/webunit tests: all passing🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Refactor
Chores
Tests