Skip to content

fix: allow backward navigation in setup wizard (#38801)#38925

Open
Subhooo5 wants to merge 8 commits intoRocketChat:developfrom
Subhooo5:fix/setup-wizard-back-navigation
Open

fix: allow backward navigation in setup wizard (#38801)#38925
Subhooo5 wants to merge 8 commits intoRocketChat:developfrom
Subhooo5:fix/setup-wizard-back-navigation

Conversation

@Subhooo5
Copy link
Copy Markdown

@Subhooo5 Subhooo5 commented Feb 23, 2026

Proposed changes

This PR fixes the backward navigation issue in the Organization / Workspace Registration Setup Wizard where users were unable to return to previous steps either through:

🔙 Browser back button
🔗 Manual URL navigation

The issue occurred because the useRedirectToSetupWizard hook was enforcing a redirect to /setup-wizard even when the user was already inside a setup wizard route. This resulted in users being automatically pushed forward to the required step, thereby preventing backward navigation between onboarding steps.

Changeset

Adjusts the setup wizard redirection logic to prevent forced navigation to /setup-wizard when the user is already inside a setup wizard route to allow backward navigation between onboarding steps.

Issue(s)

Closes: ➡️ #38801

Steps to test or reproduce

🔁 Reproduce the Issue (Before Fix)

1️⃣ Stop the running Rocket.Chat server: Ctrl + C

2️⃣ Clear the local Meteor database: rm -rf .meteor/local

3️⃣ Start the application again: yarn dev(more than or equal to 16GB memory), otherwise : yarn dsv

4️⃣ In a new terminal, navigate to the Meteor app directory:
cd apps/meteor
meteor shell

5️⃣ Force reset the Setup Wizard state:
_MongoInternals.defaultRemoteCollectionDriver().mongo.db.collection("rocketchat_settings").updateOne({ id: "Show_Setup_Wizard" }, { $set: { value: "pending" } });

6️⃣ Exit the Meteor shell: .exit

7️⃣ Restart the server:
cd ../..
yarn dev

8️⃣ Open the Setup Wizard manually: http://localhost:3000/setup-wizard

Behaviour Before Fix

Navigate forward to any setup wizard step
Try to manually go back via URL: /setup-wizard/server → /setup-wizard/organization

The application automatically redirects the user back to the next required step, preventing backward navigation.

Behaviour After Fix

-Forward navigation skipping is still restricted
-Backward navigation between steps is now allowed
-Manual URL change to previous setup steps works correctly
-Browser back button works as expected

Summary by CodeRabbit

  • New Features

    • Added a back button on the username registration screen for easier navigation.
  • Bug Fixes

    • Refined setup-wizard redirect behavior to avoid forcing navigation when already in the setup flow, preventing navigation loops and allowing users to navigate backward between onboarding steps.
  • Documentation

    • Added a changelog entry explaining the setup-wizard redirect adjustment.

@Subhooo5 Subhooo5 requested a review from a team as a code owner February 23, 2026 10:41
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot bot commented Feb 23, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 23, 2026

🦋 Changeset detected

Latest commit: 0bb3767

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 41 packages
Name Type
@rocket.chat/meteor Major
@rocket.chat/core-typings Major
@rocket.chat/rest-typings Major
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/fuselage-ui-kit Major
@rocket.chat/gazzodown Major
@rocket.chat/http-router Patch
@rocket.chat/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/ui-avatar Major
@rocket.chat/ui-client Major
@rocket.chat/ui-contexts Major
@rocket.chat/ui-voip Major
@rocket.chat/web-ui-registration Major
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/abac Patch
@rocket.chat/federation-matrix Patch
@rocket.chat/license Patch
@rocket.chat/media-calls Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/models Patch
@rocket.chat/network-broker Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/mock-providers Patch
@rocket.chat/ui-video-conf Major
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch
@rocket.chat/server-fetch Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Feb 23, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 23, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

RegisterUsername adds a Back button that uses the router to navigate back. useRedirectToSetupWizard now reads the current pathname and only navigates to /setup-wizard when redirect is required and the user is not already on a setup-wizard route. (27 words)

Changes

Cohort / File(s) Summary
Navigation UI Enhancement
apps/meteor/client/views/root/MainLayout/RegisterUsername.tsx
Imported useRouter, instantiated router in the component, and added a Back button to the form footer that calls router.navigate(-1) on click.
Redirect Guard Logic
apps/meteor/client/views/root/hooks/useRedirectToSetupWizard.ts
Now reads current pathname via router.getLocationPathname and only redirects to /setup-wizard when mustRedirect is true and the current path does not start with /setup-wizard.
Changelog
.changeset/tasty-apples-explode.md
Adds a changelog entry describing the setup-wizard redirect guard and the added back-navigation behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Poem

🐇 I hopped a route and left a mark,
A back button glowing in the dark,
I checked the wizard's winding way,
And only nudged when off the stray,
Small paws, steady paths—hooray!

🚥 Pre-merge checks | ✅ 3
✅ 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 'fix: allow backward navigation in setup wizard' directly and clearly describes the main change in the changeset - enabling backward navigation in the setup wizard by preventing forced redirection when already on setup wizard routes.
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.


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.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

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: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/meteor/client/views/root/hooks/useRedirectToSetupWizard.ts`:
- Line 16: Remove the inline comment "//DO NOT Redirect if already inside setup
wizard (Fixes navigation)" from the useRedirectToSetupWizard hook
implementation; locate the comment inside the useRedirectToSetupWizard function
(or the surrounding hook file) and delete that line so the logic remains
unchanged but the file complies with the "no code comments" guideline.

In `@apps/meteor/client/views/root/MainLayout/RegisterUsername.tsx`:
- Line 131: Replace the hardcoded "Back" label in the RegisterUsername
component's JSX with the i18n translation call used elsewhere (e.g., change the
literal "Back" to {t('Back')} or the appropriate translation key) so it uses the
same t(...) function already present in this file; locate the button/link
element in RegisterUsername.tsx and update its label to use t('Back') to
maintain consistency with other user-facing strings.
- Line 14: Remove the inline debug/authoring comments in RegisterUsername.tsx:
delete the trailing comment after the useRouter import (the "// ✅ ADDED" next to
useRouter), remove the similar inline comment at the other import/line
referenced (line with the second "// ✅ ADDED"), and remove the JSX comment
around the back button ("{/* ✅ BACK BUTTON ADDED */}") in the RegisterUsername
component; keep the imports and JSX structure unchanged, only delete those
comment tokens so no inline comments remain.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 133da0b and fff11fe.

📒 Files selected for processing (2)
  • apps/meteor/client/views/root/MainLayout/RegisterUsername.tsx
  • apps/meteor/client/views/root/hooks/useRedirectToSetupWizard.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/client/views/root/hooks/useRedirectToSetupWizard.ts
  • apps/meteor/client/views/root/MainLayout/RegisterUsername.tsx
🧠 Learnings (1)
📚 Learning: 2026-02-10T16:32:42.586Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38528
File: apps/meteor/client/startup/roles.ts:14-14
Timestamp: 2026-02-10T16:32:42.586Z
Learning: In Rocket.Chat's Meteor client code, DDP streams use EJSON and Date fields arrive as Date objects; do not manually construct new Date() in stream handlers (for example, in sdk.stream()). Only REST API responses return plain JSON where dates are strings, so implement explicit conversion there if needed. Apply this guidance to all TypeScript files under apps/meteor/client to ensure consistent date handling in DDP streams and REST responses.

Applied to files:

  • apps/meteor/client/views/root/hooks/useRedirectToSetupWizard.ts
🧬 Code graph analysis (2)
apps/meteor/client/views/root/hooks/useRedirectToSetupWizard.ts (1)
packages/ui-contexts/src/index.ts (1)
  • useRole (59-59)
apps/meteor/client/views/root/MainLayout/RegisterUsername.tsx (1)
packages/ui-contexts/src/index.ts (1)
  • useRouter (63-63)
🔇 Additional comments (1)
apps/meteor/client/views/root/MainLayout/RegisterUsername.tsx (1)

130-130: No action required – router.navigate(-1) is correctly typed.

The RouterContextValue type in @rocket.chat/ui-contexts (packages/ui-contexts/src/RouterContext.ts) includes the numeric delta overload: navigate(delta: number): void. This allows router.navigate(-1) to work as intended for back navigation. No type errors or runtime issues.

@Subhooo5 Subhooo5 force-pushed the fix/setup-wizard-back-navigation branch from fff11fe to 5d2fce3 Compare February 23, 2026 10:56
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.

♻️ Duplicate comments (1)
apps/meteor/client/views/root/hooks/useRedirectToSetupWizard.ts (1)

16-16: Inline comment still present — violates the "no code comments" guideline.

As per coding guidelines, avoid code comments in the implementation for *.ts files.

♻️ Proposed fix
-		//DO NOT Redirect if already inside setup wizard (Fixes navigation)
 		if (mustRedirect && !currentPath?.startsWith('/setup-wizard')) {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/client/views/root/hooks/useRedirectToSetupWizard.ts` at line 16,
Remove the inline code comment "//DO NOT Redirect if already inside setup wizard
(Fixes navigation)" from the useRedirectToSetupWizard hook implementation;
locate the comment in the function useRedirectToSetupWizard in the file and
delete it (do not replace with another inline comment)—if a note is required for
future readers, add a short descriptive identifier or extract logic into a
well-named helper function instead (e.g., isInSetupWizard) so the code is
self-documenting.
🧹 Nitpick comments (1)
apps/meteor/client/views/root/hooks/useRedirectToSetupWizard.ts (1)

15-17: Remove optional chaining on currentPath.

router.getLocationPathname() returns LocationPathname, a non-nullable string type. The optional chaining in currentPath?.startsWith(...) is unnecessary. Change to currentPath.startsWith(...).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/client/views/root/hooks/useRedirectToSetupWizard.ts` around lines
15 - 17, In useRedirectToSetupWizard, remove the unnecessary optional chaining
on currentPath: change the conditional that uses
currentPath?.startsWith('/setup-wizard') to use
currentPath.startsWith('/setup-wizard') instead, since
router.getLocationPathname() returns a non-nullable LocationPathname; update the
if statement that checks mustRedirect and currentPath to reference
currentPath.startsWith(...) so the logic remains identical but without the
redundant `?.`.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@apps/meteor/client/views/root/hooks/useRedirectToSetupWizard.ts`:
- Line 16: Remove the inline code comment "//DO NOT Redirect if already inside
setup wizard (Fixes navigation)" from the useRedirectToSetupWizard hook
implementation; locate the comment in the function useRedirectToSetupWizard in
the file and delete it (do not replace with another inline comment)—if a note is
required for future readers, add a short descriptive identifier or extract logic
into a well-named helper function instead (e.g., isInSetupWizard) so the code is
self-documenting.

---

Nitpick comments:
In `@apps/meteor/client/views/root/hooks/useRedirectToSetupWizard.ts`:
- Around line 15-17: In useRedirectToSetupWizard, remove the unnecessary
optional chaining on currentPath: change the conditional that uses
currentPath?.startsWith('/setup-wizard') to use
currentPath.startsWith('/setup-wizard') instead, since
router.getLocationPathname() returns a non-nullable LocationPathname; update the
if statement that checks mustRedirect and currentPath to reference
currentPath.startsWith(...) so the logic remains identical but without the
redundant `?.`.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fff11fe and 5d2fce3.

📒 Files selected for processing (2)
  • apps/meteor/client/views/root/MainLayout/RegisterUsername.tsx
  • apps/meteor/client/views/root/hooks/useRedirectToSetupWizard.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/meteor/client/views/root/MainLayout/RegisterUsername.tsx
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/client/views/root/hooks/useRedirectToSetupWizard.ts
🧠 Learnings (2)
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to **/*.{ts,tsx,js} : Avoid code comments in the implementation

Applied to files:

  • apps/meteor/client/views/root/hooks/useRedirectToSetupWizard.ts
📚 Learning: 2026-02-10T16:32:42.586Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38528
File: apps/meteor/client/startup/roles.ts:14-14
Timestamp: 2026-02-10T16:32:42.586Z
Learning: In Rocket.Chat's Meteor client code, DDP streams use EJSON and Date fields arrive as Date objects; do not manually construct new Date() in stream handlers (for example, in sdk.stream()). Only REST API responses return plain JSON where dates are strings, so implement explicit conversion there if needed. Apply this guidance to all TypeScript files under apps/meteor/client to ensure consistent date handling in DDP streams and REST responses.

Applied to files:

  • apps/meteor/client/views/root/hooks/useRedirectToSetupWizard.ts
🧬 Code graph analysis (1)
apps/meteor/client/views/root/hooks/useRedirectToSetupWizard.ts (1)
packages/ui-contexts/src/index.ts (1)
  • useRole (59-59)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants