Skip to content

refactor(continue-page): simplify useEffect to avoid unnecessary dependencies#641

Merged
steveiliop56 merged 2 commits into
mainfrom
refactor/simplify-useffect
Feb 15, 2026
Merged

refactor(continue-page): simplify useEffect to avoid unnecessary dependencies#641
steveiliop56 merged 2 commits into
mainfrom
refactor/simplify-useffect

Conversation

@nicotsx
Copy link
Copy Markdown
Collaborator

@nicotsx nicotsx commented Feb 11, 2026

This pull request refactors the redirect logic in the ContinuePage component to improve clarity, maintainability, and user experience. The main changes include consolidating redirect condition checks, improving naming for readability, and streamlining the auto-redirect and warning logic.

Summary by CodeRabbit

  • Bug Fixes

    • Improved redirect validation and clearer untrusted/insecure warning handling; added safeguards to prevent repeated redirects.
  • Refactor

    • Consolidated and deferred auto-redirect flow with clearer flags and timed reveal of the manual redirect option.
  • Chores

    • Added ignore rule for Traefik data directory to .gitignore.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 11, 2026

📝 Walkthrough

Walkthrough

Introduces guarded, derived redirect flags and a controlled auto-redirect flow in the continue page: adds redirect guard state, a redirectToTarget callback with repeated-redirect protection, delays auto-redirect and reveal of manual option, and updates conditional rendering and early logout when redirect is invalid.

Changes

Cohort / File(s) Summary
Continue page redirect logic
frontend/src/pages/continue-page.tsx
Adds derived flags (hasValidRedirect, showUntrustedWarning, showInsecureWarning, shouldAutoRedirect), introduces redirectToTarget with a hasRedirected guard, replaces immediate effect with guarded auto-redirect (100ms delay) and delayed manual-button reveal (5s), updates event handlers and early-return logout for invalid redirects.
Ignore rule
/.gitignore
Adds /traefik to .gitignore (commented as "traefik data").

Sequence Diagram

sequenceDiagram
    actor User
    participant ContinuePage
    participant Browser as window.location

    User->>ContinuePage: Load page / continue
    ContinuePage->>ContinuePage: Compute flags (hasValidRedirect, trusted, httpsDowngrade, shouldAutoRedirect)
    alt !hasValidRedirect
        ContinuePage->>Browser: Navigate to logout
    else hasValidRedirect
        alt shouldAutoRedirect (logged in, no warnings)
            ContinuePage->>ContinuePage: start short delay (100ms)
            ContinuePage->>ContinuePage: set timer to reveal manual option (5s)
            ContinuePage->>ContinuePage: check hasRedirected guard
            ContinuePage->>Browser: window.location.assign(url)
        else show warning or require manual action
            ContinuePage->>User: show untrusted/insecure warning + manual button
            User->>ContinuePage: clicks manual redirect
            ContinuePage->>ContinuePage: check hasRedirected guard
            ContinuePage->>Browser: window.location.assign(url)
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 Hopping through flags with a careful bound,
A guarded nudge before the outbound,
A five‑second pause, a button to show,
No double hops — just a steady go! 🥕

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (13 files):

⚔️ .gitignore (content)
⚔️ Dockerfile (content)
⚔️ Dockerfile.distroless (content)
⚔️ Makefile (content)
⚔️ docker-compose.dev.yml (content)
⚔️ frontend/bun.lock (content)
⚔️ frontend/package.json (content)
⚔️ frontend/src/components/domain-warning/domain-warning.tsx (content)
⚔️ frontend/src/lib/hooks/redirect-uri.ts (content)
⚔️ frontend/src/pages/continue-page.tsx (content)
⚔️ frontend/src/pages/logout-page.tsx (content)
⚔️ go.mod (content)
⚔️ go.sum (content)

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the main refactoring objective: simplifying useEffect dependencies in the continue-page component. The changeset confirms this with the new shouldAutoRedirect flag-based logic, guarded auto-redirect flow, and simplified effect cleanup that depend only on shouldAutoRedirect and redirectToTarget.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/simplify-useffect
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch refactor/simplify-useffect
  • Create stacked PR with resolved conflicts
  • Post resolved changes as copyable diffs in a comment

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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 and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 16.35%. Comparing base (22c4c26) to head (ff771c5).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #641   +/-   ##
=======================================
  Coverage   16.35%   16.35%           
=======================================
  Files          45       45           
  Lines        3431     3431           
=======================================
  Hits          561      561           
  Misses       2813     2813           
  Partials       57       57           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@frontend/src/pages/continue-page.tsx`:
- Around line 46-53: The redirect callback is being recreated each render
because useRedirectUri returns a new URL object each time, which causes the
effect that manages the reveal timeout to reset; fix this by stabilizing the url
dependency: either (A) change redirectToTarget and any deps to depend on the
primitive url?.href (use url?.href in the useCallback dependency array and in
the useEffect that sets timeouts) so the ref is stable across renders, or (B)
memoize the URL inside useRedirectUri (wrap the returned URL in useMemo keyed on
redirect_uri and cookieDomain) so consumers like redirectToTarget receive a
stable URL object; update references to hasRedirected, redirectToTarget, the
useEffect that controls showRedirectButton, and any timeout-clearing logic
accordingly.

Comment thread frontend/src/pages/continue-page.tsx Outdated
Comment thread frontend/src/pages/continue-page.tsx Outdated
@steveiliop56 steveiliop56 merged commit a576e91 into main Feb 15, 2026
7 of 8 checks passed
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@frontend/src/pages/continue-page.tsx`:
- Around line 57-60: handleRedirect sets isLoading true unconditionally but
never resets it if redirectToTarget is a no-op; change the logic so we only set
loading when a redirect will occur or we always clear loading when
redirectToTarget bails. Specifically, either (a) make redirectToTarget return a
boolean/promise indicating whether a redirect happened and in handleRedirect
call setIsLoading(true) only if it will redirect (or setIsLoading(false) when it
returns false), or (b) check hasRedirected.current before setting loading in
handleRedirect, or wrap the call in try/finally and call setIsLoading(false)
when no navigation occurred; reference handleRedirect, redirectToTarget,
hasRedirected.current, and setIsLoading when making the change.

Comment on lines +57 to +60
const handleRedirect = useCallback(() => {
setIsLoading(true);
redirectToTarget();
}, [redirectToTarget]);
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.

⚠️ Potential issue | 🟡 Minor

isLoading is never reset if redirectToTarget is a no-op.

If handleRedirect is called but redirectToTarget bails out (e.g., hasRedirected.current is already true), isLoading stays true and the button remains in its loading state permanently. Given the rendering guards this is very unlikely to surface, but worth noting.

🤖 Prompt for AI Agents
In `@frontend/src/pages/continue-page.tsx` around lines 57 - 60, handleRedirect
sets isLoading true unconditionally but never resets it if redirectToTarget is a
no-op; change the logic so we only set loading when a redirect will occur or we
always clear loading when redirectToTarget bails. Specifically, either (a) make
redirectToTarget return a boolean/promise indicating whether a redirect happened
and in handleRedirect call setIsLoading(true) only if it will redirect (or
setIsLoading(false) when it returns false), or (b) check hasRedirected.current
before setting loading in handleRedirect, or wrap the call in try/finally and
call setIsLoading(false) when no navigation occurred; reference handleRedirect,
redirectToTarget, hasRedirected.current, and setIsLoading when making the
change.

@Rycochet Rycochet deleted the refactor/simplify-useffect branch April 1, 2026 16:09
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.

2 participants