Skip to content

Bug fixes : stabilize auth, privacy lock, and insight reports#49

Merged
aryansoni-dev merged 2 commits into
mainfrom
dev
Jul 4, 2026
Merged

Bug fixes : stabilize auth, privacy lock, and insight reports#49
aryansoni-dev merged 2 commits into
mainfrom
dev

Conversation

@aryansoni-dev

@aryansoni-dev aryansoni-dev commented Jul 4, 2026

Copy link
Copy Markdown
Owner
- prevent repeated splash screens after authentication
- fix Clerk sign-out crashes and upgrade Clerk Expo
- show privacy cover only in background or recents
- fix report freshness detection and source synchronization
- improve AI report regeneration and retry handling
- bump app version and refine privacy policy content

Summary by CodeRabbit

  • New Features

    • Improved report retry handling, making error recovery more reliable.
    • Auth callback screens now skip the launch splash for faster sign-in and return flows.
  • Bug Fixes

    • Fixed logout behavior across app lock and profile screens.
    • Updated report error actions so retry runs the correct recovery step.
    • Improved app locking to respond only to real app state changes.
  • Chores

    • Updated app version and Clerk dependency.
    • Privacy policy wording was lightly refined.

    - prevent repeated splash screens after authentication
    - fix Clerk sign-out crashes and upgrade Clerk Expo
    - show privacy cover only in background or recents
    - fix report freshness detection and source synchronization
    - improve AI report regeneration and retry handling
    - bump app version and refine privacy policy content
@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@aryansoni-dev, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 9 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 430f661b-c61b-4548-965d-53713e76afa6

📥 Commits

Reviewing files that changed from the base of the PR and between d4fa6e8 and cfb7fc1.

📒 Files selected for processing (3)
  • app.json
  • hooks/useAIInsightReport.ts
  • supabase/functions/generate-insight-report/index.ts
📝 Walkthrough

Walkthrough

This PR migrates sign-out logic to Clerk's useClerk hook, adds a retry() operation and shared source-snapshot normalization to the AI insight report feature (client and Supabase edge function), refines app-lock AppState handling, gates the launch splash on auth callback routes, edits privacy policy text, and applies minor config/sync fixes.

Changes

Clerk Authentication Updates

Layer / File(s) Summary
Sign-out via useClerk
package.json, components/app-lock/AppLockScreen.tsx, components/profile/profile-screen.tsx
@clerk/expo bumped to 3.6.5; AppLockScreen and ProfileScreen now obtain signOut from useClerk() instead of useAuth().
Auth screen redirect removal
components/auth/auth-screen.tsx
useAuth() now only tracks isLoaded; the isSignedIn-based redirect useEffect is removed.

AI Insight Report Retry and Snapshot Sync

Layer / File(s) Summary
Shared snapshot builder utilities
lib/insights/reportSourceSnapshot.ts, supabase/functions/_shared/buildReportSourceSnapshot.ts
New client/server utilities normalize timestamps and build sorted, pipe-delimited snapshot strings; server variant also computes a SHA-256 hash and latest updated timestamp.
Client hook retry logic and snapshot integration
hooks/useAIInsightReport.ts
Adds retry(), tracks last failed operation, reworks period-source sync, generalizes getEntriesInPeriod with includeDeleted, and uses the shared snapshot builder plus refined error messaging.
Report screen retry wiring
app/insights/report/[periodType].tsx
ErrorBanner's onRetry now calls reportState.retry() instead of refresh().
Server narrative generation and snapshot usage
supabase/functions/generate-insight-report/index.ts
Adopts the shared snapshot builder, tightens narrative prompt constraints, retries on truncated provider responses, and raises max_tokens via maxNarrativeTokens.
Snapshot normalization tests
tests/report-source-snapshot.test.mjs
New test verifies client/server snapshot normalization and deterministic sort order match.

App Lock Lifecycle AppState Handling

Layer / File(s) Summary
AppState change-only listener
hooks/useAppLockLifecycle.ts
Removes blur/focus handling and appStateRef, retaining only the "change" event listener with clarifying comments and simplified cleanup.

App Launch Gate Splash Routing

Layer / File(s) Summary
Auth callback splash bypass
components/onboarding/app-launch-gate.tsx
Uses usePathname and a module-level flag to skip the splash screen on auth callback routes.

Privacy Policy Text Updates

Layer / File(s) Summary
Policy section text edits
content/legal/privacyPolicy.ts
Splits the Operator/Website line into two entries and adds a dash before the support email in the Contact section.

Misc Config and Sync Guard Fix

Layer / File(s) Summary
Gitignore and version bump
.gitignore, app.json
Removes the UI/ ignore rule and bumps app version to 1.0.2.
Auto-sync guard narrowing
hooks/useAutoSync.ts
runAutoSync no longer blocks on an in-progress sync, only on offline connectivity.

Estimated code review effort: 4 (Complex) | ~55 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ReportScreen
  participant useAIInsightReport
  participant SupabaseFunction

  ReportScreen->>useAIInsightReport: onRetry() calls retry()
  useAIInsightReport->>useAIInsightReport: check lastFailedOperationRef
  alt last failure was regenerate
    useAIInsightReport->>SupabaseFunction: requestGeneration(true)
  else last failure was generate
    useAIInsightReport->>SupabaseFunction: requestGeneration(false)
  else no recorded failure
    useAIInsightReport->>SupabaseFunction: refresh()
  end
  SupabaseFunction-->>useAIInsightReport: report result
  useAIInsightReport-->>ReportScreen: updated report state
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is clear, concise, and matches the main themes of the changes: auth, privacy lock, and insight report fixes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app.json`:
- Line 5: The app version was bumped in app.json, but the native build
identifiers were not updated. Update the android.versionCode and set
ios.buildNumber in the app configuration alongside the version change, keeping
them in sync with the new 1.0.2 release since AppVersionSource is local and
auto-increment is disabled. Locate the version fields in app.json and bump the
native numbers manually before the next store build.

In `@hooks/useAIInsightReport.ts`:
- Around line 182-183: Move the lastFailedOperationRef.current assignment out of
the top of refresh() and requestGeneration() in useAIInsightReport so
guard-clause early exits do not overwrite the previously failed action. Keep the
enabled/hydration/connectivity/in-flight checks first, then set
lastFailedOperationRef.current only immediately before the try block for the
operation being attempted. Make sure both refresh and generation paths preserve
the exact failed action for retry().

In `@supabase/functions/generate-insight-report/index.ts`:
- Around line 727-746: The retry path in generate-insight-report is reusing
buildNarrativeRetryPrompt(prompt) for provider_response_truncated, which keeps
pushing for fuller output instead of reducing size. Update the narrative retry
logic in the callAIProvider loop to distinguish truncation from invalid JSON
(for example with a wasTruncated flag) and use a dedicated truncation retry
prompt that asks for shorter, more concise output while preserving the original
field caps from buildNarrativePrompt. Keep the existing JSON-repair retry prompt
only for parse failures, and route retries based on the branch hit in the
previous attempt rather than inferring it from error across iterations.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ef5a71d2-cc22-41fd-b680-500f37ec58fd

📥 Commits

Reviewing files that changed from the base of the PR and between c1e7489 and d4fa6e8.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (16)
  • .gitignore
  • app.json
  • app/insights/report/[periodType].tsx
  • components/app-lock/AppLockScreen.tsx
  • components/auth/auth-screen.tsx
  • components/onboarding/app-launch-gate.tsx
  • components/profile/profile-screen.tsx
  • content/legal/privacyPolicy.ts
  • hooks/useAIInsightReport.ts
  • hooks/useAppLockLifecycle.ts
  • hooks/useAutoSync.ts
  • lib/insights/reportSourceSnapshot.ts
  • package.json
  • supabase/functions/_shared/buildReportSourceSnapshot.ts
  • supabase/functions/generate-insight-report/index.ts
  • tests/report-source-snapshot.test.mjs
💤 Files with no reviewable changes (1)
  • .gitignore

Comment thread app.json
Comment thread hooks/useAIInsightReport.ts Outdated
Comment thread supabase/functions/generate-insight-report/index.ts
@aryansoni-dev aryansoni-dev merged commit 58267d6 into main Jul 4, 2026
1 check passed
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