Skip to content

refactor(deeplink): migrate deepLinking saga to TypeScript#7438

Open
Shevilll wants to merge 5 commits into
RocketChat:developfrom
Shevilll:fix/deeplinking-saga-typescript
Open

refactor(deeplink): migrate deepLinking saga to TypeScript#7438
Shevilll wants to merge 5 commits into
RocketChat:developfrom
Shevilll:fix/deeplinking-saga-typescript

Conversation

@Shevilll

@Shevilll Shevilll commented Jun 25, 2026

Copy link
Copy Markdown

Description

This PR migrates the deepLinking saga to TypeScript, addressing Issue #7090.

Key Changes

  1. Strict TypeScript Typing: Migrated app/sagas/deepLinking.js to app/sagas/deepLinking.ts, introducing strict TypeScript typing across the entire file.
  2. Interface Definitions: Added clean interface definitions for navigation actions and payload parameters (e.g., IParams).
  3. Full Compatibility: Maintained 100% functional compatibility with existing deep linking behaviors, ensuring all routing and handling flows work exactly as before.

Summary by CodeRabbit

  • New Features

    • Added localized feedback for invalid usernames.
    • Profile editing now validates usernames against the server’s allowed-character rules.
    • Improved deep-link navigation coverage across room, invite, sharing, OAuth, and call links.
  • Bug Fixes

    • Prevents saving profile changes when a username format is invalid.
  • Tests

    • Added/updated ProfileView tests to verify invalid/valid username submission behavior and localized messaging.

Shevilll and others added 4 commits June 22, 2026 16:21
Validate the username field against the server's UTF8_User_Names_Validation
setting (with the default pattern as a fallback) before submitting the profile.
This prevents invalid characters such as spaces from reaching the server, which
previously surfaced only as a generic save error, and shows an inline message
explaining the allowed characters.

Closes RocketChat#1682
Drop the stale isMasterDetail destructured from useAppSelector (the
selector no longer returns it) so only the useMasterDetail() hook
declares it, fixing the no-redeclare lint/build failure introduced by
merging develop. Also annotate isValidUsername with an explicit boolean
return type per the TS guideline.
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 31caf204-3578-4bb2-a3f3-198432e85885

📥 Commits

Reviewing files that changed from the base of the PR and between 8b3883d and 1a3c6f5.

📒 Files selected for processing (5)
  • app/actions/deepLinking.ts
  • app/i18n/locales/en.json
  • app/sagas/deepLinking.ts
  • app/views/ProfileView/index.test.tsx
  • app/views/ProfileView/index.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
  • app/views/ProfileView/index.test.tsx
  • app/views/ProfileView/index.tsx
  • app/sagas/deepLinking.ts
📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{js,jsx,ts,tsx,json}

📄 CodeRabbit inference engine (CLAUDE.md)

Use Prettier formatting with tabs, single quotes, 130 character line width, no trailing commas, and avoid arrow function parentheses

Files:

  • app/i18n/locales/en.json
  • app/actions/deepLinking.ts
app/i18n/**/*.{ts,tsx,json}

📄 CodeRabbit inference engine (CLAUDE.md)

Place internationalization (i18n) configuration in 'app/i18n/' directory with support for 40+ locales and RTL

Files:

  • app/i18n/locales/en.json
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,ts,jsx,tsx}: Use descriptive names for functions, variables, and classes that clearly convey their purpose
Write comments that explain the 'why' behind code decisions, not the 'what'
Keep functions small and focused on a single responsibility
Use const by default, let when reassignment is needed, and avoid var
Prefer async/await over .then() chains for handling asynchronous operations
Use explicit error handling with try/catch blocks for async operations
Avoid deeply nested code; refactor complex logic into helper functions

Files:

  • app/actions/deepLinking.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript for type safety; add explicit type annotations to function parameters and return types
Prefer interfaces over type aliases for defining object shapes in TypeScript
Use enums for sets of related constants rather than magic strings or numbers

Use TypeScript with strict mode enabled

Files:

  • app/actions/deepLinking.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Enforce ESLint rules from @rocket.chat/eslint-config with React, React Native, TypeScript, and Jest plugins

Files:

  • app/actions/deepLinking.ts
app/actions/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Place action creators in 'app/actions/' directory

Files:

  • app/actions/deepLinking.ts
🧠 Learnings (1)
📚 Learning: 2026-04-30T17:07:51.020Z
Learnt from: diegolmello
Repo: RocketChat/Rocket.Chat.ReactNative PR: 7274
File: app/lib/services/voip/MediaCallEvents.ts:0-0
Timestamp: 2026-04-30T17:07:51.020Z
Learning: In this Rocket.Chat React Native codebase, the ESLint rule `no-void: error` is enforced. When you see a promise returned from an async call that is not awaited (a “floating promise”), do not silence it with the `void somePromise()` pattern. Instead, handle the promise explicitly by attaching `.catch(...)` (or otherwise awaiting/handling the error) so unhandled-rejection risks are addressed in a way that satisfies the existing ESLint configuration.

Applied to files:

  • app/actions/deepLinking.ts
🔇 Additional comments (2)
app/actions/deepLinking.ts (1)

5-18: LGTM!

app/i18n/locales/en.json (1)

1005-1005: LGTM! The generic wording addresses the earlier feedback about being too specific for server-driven regex patterns.


Walkthrough

The PR reimplements deep-link handling in TypeScript for room, invite, VoIP, share-extension, OAuth, and video-conference flows. It also adds profile username validation against a server-configured pattern, plus a new English validation string and tests.

Changes

Deep-linking saga rewrite

Layer / File(s) Summary
Deep-link params and destination routing
app/actions/deepLinking.ts, app/sagas/deepLinking.ts
IParams is exported with credential fields, and deep-link parsing maps paths into invite, room, thread, and message destinations before navigation.
VoIP failure recovery
app/sagas/deepLinking.ts
The saga resets VoIP state, ends the CallKeep session, replays navigation for the recovered target, and shows the accept-failed toast.
OAuth and share-extension entry paths
app/sagas/deepLinking.ts
The saga handles OAuth login, loads persisted share-extension credentials, authenticates and selects the server, waits for login when needed, and dispatches share parameters.
Host-based open orchestration
app/sagas/deepLinking.ts
The main open handler normalizes hosts, switches servers, fetches server info, resumes sessions with tokens, waits for inside-stack readiness, and falls back when startup stalls.
Video-conference call-push handling
app/sagas/deepLinking.ts
The saga handles call-push deep links by locating the subscription room, notifying users on accept or decline, joining the conference on accept, and wiring the deep-link watchers.

Profile username validation

Layer / File(s) Summary
Username validation rule and coverage
app/views/ProfileView/index.tsx, app/i18n/locales/en.json, app/views/ProfileView/index.test.tsx
The profile view reads UTF8_User_Names_Validation, validates usernames with a regex test and fallback pattern, adds Username_invalid, and tests blocked and successful submits.

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

Possibly related PRs

Suggested labels: type: chore

Suggested reviewers: diegolmello

🚥 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 accurately summarizes the main change: migrating the deepLinking saga from JavaScript to TypeScript.
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.

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
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/actions/deepLinking.ts (1)

5-16: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Include OAuth credential fields in the exported params contract.

handleOAuth consumes credentialToken and credentialSecret, but exported IParams does not allow those fields. Typed callers of deepLinkingOpen({ type: 'oauth', ... }) will either fail excess-property checks or need casts.

Suggested contract update
 export interface IParams {
 	path: string;
 	rid: string;
 	messageId: string;
 	host: string;
 	fullURL: string;
 	type: string;
 	token: string;
+	credentialToken?: string;
+	credentialSecret?: string;
 	callId?: string;
 	username?: string;
 	voipAcceptFailed?: boolean;
 }
🤖 Prompt for 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.

In `@app/actions/deepLinking.ts` around lines 5 - 16, The exported IParams
contract in deepLinking.ts is missing the OAuth-specific fields used by
handleOAuth. Add credentialToken and credentialSecret as optional properties on
IParams so typed callers of deepLinkingOpen with type: 'oauth' can pass them
without casts or excess-property errors, and keep the shape aligned with the
existing OAuth handling logic.
🧹 Nitpick comments (1)
app/views/ProfileView/index.test.tsx (1)

73-74: 📐 Maintainability & Code Quality | 🔵 Trivial

Use a non-default regex in these tests.

Both tests define UTF8_User_Names_Validation as '[0-9a-zA-Z-_.]+', which matches the DEFAULT_USERNAME_VALIDATION constant in app/views/ProfileView/index.tsx. If the component completely ignored the server setting and hardcoded this fallback, the tests would still pass. To verify that the server configuration is actually wired correctly, one test should use a distinct regex pattern (e.g., allowing spaces or different characters).

🤖 Prompt for 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.

In `@app/views/ProfileView/index.test.tsx` around lines 73 - 74, The ProfileView
tests are using the same username validation regex as the component fallback, so
they won’t catch a hardcoded default. Update one of the test setups in
index.test.tsx to use a distinct UTF8_User_Names_Validation value, and verify
the ProfileView behavior through the relevant test cases so the server-provided
setting is actually exercised instead of DEFAULT_USERNAME_VALIDATION.
🤖 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/i18n/locales/en.json`:
- Line 1005: The Username_invalid locale copy is too specific for the
server-driven validation used by UTF8_User_Names_Validation. Update the string
in the en.json locale entry referenced by Username_invalid to a generic message
like “Username format is invalid” so it stays accurate regardless of the
server’s regex pattern.

In `@app/sagas/deepLinking.ts`:
- Line 4: The `deepLinking.ts` saga has an unused `all` import from
`typed-redux-saga`, which will trigger lint failures. Remove `all` from the
import list and keep the remaining saga helpers (`call`, `delay`, `put`, `take`,
`takeLatest`) unchanged so the module stays lint-clean.
- Around line 281-283: The predicate passed to take in deepLinking.ts should be
formatted to stay on a single line under the project’s 130-character limit.
Update the take call’s action filter so the APP.START and RootEnum.ROOT_INSIDE
check remains inline, matching the configured Prettier formatting and the
existing style in this saga.
- Around line 314-319: The accepted-call flow in deepLinking.ts is coupling
joining the conference to notifyUser and caller metadata, which can block joins
when caller is missing or notification fails. In the saga branch that handles
event === 'accept' inside the deepLinking logic, make videoConfJoin run
independently of notifyUser and guard only on the required join inputs such as
uid/callId, using caller._id only if needed for notification. Keep the
notification call separate so a notifyUser error does not prevent the join path
from continuing.
- Around line 303-311: The call-room deep link flow in handleNavigateCallRoom is
navigating too early after appStart(ROOT_INSIDE). Add the same
navigation-readiness wait used by the regular deep-link path before calling
navigateToRoom, so this saga only opens the room once the target stack is
mounted and ready.

In `@app/views/ProfileView/index.tsx`:
- Around line 95-101: The username validation in ProfileView’s validationSchema
is too strict for read-only or unchanged usernames, which can block saving
unrelated profile edits. Update the username field’s test so it only runs when
username is actually editable or has changed, and skip the
UTF8_User_Names_Validation check for legacy values when
Accounts_AllowUsernameChange is false. Use the validationSchema setup and the
username field definition in ProfileView/index.tsx to guard the isValidUsername
test with the same condition that drives the disabled username field.

---

Outside diff comments:
In `@app/actions/deepLinking.ts`:
- Around line 5-16: The exported IParams contract in deepLinking.ts is missing
the OAuth-specific fields used by handleOAuth. Add credentialToken and
credentialSecret as optional properties on IParams so typed callers of
deepLinkingOpen with type: 'oauth' can pass them without casts or
excess-property errors, and keep the shape aligned with the existing OAuth
handling logic.

---

Nitpick comments:
In `@app/views/ProfileView/index.test.tsx`:
- Around line 73-74: The ProfileView tests are using the same username
validation regex as the component fallback, so they won’t catch a hardcoded
default. Update one of the test setups in index.test.tsx to use a distinct
UTF8_User_Names_Validation value, and verify the ProfileView behavior through
the relevant test cases so the server-provided setting is actually exercised
instead of DEFAULT_USERNAME_VALIDATION.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2b4cfd48-c32e-438a-a3a9-556c0c6811fa

📥 Commits

Reviewing files that changed from the base of the PR and between da389be and 8b3883d.

📒 Files selected for processing (6)
  • app/actions/deepLinking.ts
  • app/i18n/locales/en.json
  • app/sagas/deepLinking.js
  • app/sagas/deepLinking.ts
  • app/views/ProfileView/index.test.tsx
  • app/views/ProfileView/index.tsx
💤 Files with no reviewable changes (1)
  • app/sagas/deepLinking.js
📜 Review details
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{js,jsx,ts,tsx,json}

📄 CodeRabbit inference engine (CLAUDE.md)

Use Prettier formatting with tabs, single quotes, 130 character line width, no trailing commas, and avoid arrow function parentheses

Files:

  • app/i18n/locales/en.json
  • app/actions/deepLinking.ts
  • app/views/ProfileView/index.test.tsx
  • app/views/ProfileView/index.tsx
  • app/sagas/deepLinking.ts
app/i18n/**/*.{ts,tsx,json}

📄 CodeRabbit inference engine (CLAUDE.md)

Place internationalization (i18n) configuration in 'app/i18n/' directory with support for 40+ locales and RTL

Files:

  • app/i18n/locales/en.json
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,ts,jsx,tsx}: Use descriptive names for functions, variables, and classes that clearly convey their purpose
Write comments that explain the 'why' behind code decisions, not the 'what'
Keep functions small and focused on a single responsibility
Use const by default, let when reassignment is needed, and avoid var
Prefer async/await over .then() chains for handling asynchronous operations
Use explicit error handling with try/catch blocks for async operations
Avoid deeply nested code; refactor complex logic into helper functions

Files:

  • app/actions/deepLinking.ts
  • app/views/ProfileView/index.test.tsx
  • app/views/ProfileView/index.tsx
  • app/sagas/deepLinking.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript for type safety; add explicit type annotations to function parameters and return types
Prefer interfaces over type aliases for defining object shapes in TypeScript
Use enums for sets of related constants rather than magic strings or numbers

Use TypeScript with strict mode enabled

Files:

  • app/actions/deepLinking.ts
  • app/views/ProfileView/index.test.tsx
  • app/views/ProfileView/index.tsx
  • app/sagas/deepLinking.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Enforce ESLint rules from @rocket.chat/eslint-config with React, React Native, TypeScript, and Jest plugins

Files:

  • app/actions/deepLinking.ts
  • app/views/ProfileView/index.test.tsx
  • app/views/ProfileView/index.tsx
  • app/sagas/deepLinking.ts
app/actions/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Place action creators in 'app/actions/' directory

Files:

  • app/actions/deepLinking.ts
app/views/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Place screen components in 'app/views/' directory

Files:

  • app/views/ProfileView/index.test.tsx
  • app/views/ProfileView/index.tsx
app/sagas/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Place sagas in 'app/sagas/' directory for handling side effects

Files:

  • app/sagas/deepLinking.ts
🧠 Learnings (2)
📚 Learning: 2026-04-30T17:07:51.020Z
Learnt from: diegolmello
Repo: RocketChat/Rocket.Chat.ReactNative PR: 7274
File: app/lib/services/voip/MediaCallEvents.ts:0-0
Timestamp: 2026-04-30T17:07:51.020Z
Learning: In this Rocket.Chat React Native codebase, the ESLint rule `no-void: error` is enforced. When you see a promise returned from an async call that is not awaited (a “floating promise”), do not silence it with the `void somePromise()` pattern. Instead, handle the promise explicitly by attaching `.catch(...)` (or otherwise awaiting/handling the error) so unhandled-rejection risks are addressed in a way that satisfies the existing ESLint configuration.

Applied to files:

  • app/actions/deepLinking.ts
  • app/views/ProfileView/index.test.tsx
  • app/views/ProfileView/index.tsx
  • app/sagas/deepLinking.ts
📚 Learning: 2026-06-24T22:58:43.390Z
Learnt from: Rohit3523
Repo: RocketChat/Rocket.Chat.ReactNative PR: 7157
File: app/views/MessagesView/index.tsx:392-392
Timestamp: 2026-06-24T22:58:43.390Z
Learning: When wrapping a React Native component (e.g., via `withSafeAreaInsets`) ensure `hoistNonReactStatics` is only required if the wrapped component actually defines static properties/methods that consumers rely on. If the component has no statics (as in `app/views/MessagesView/index.tsx`), you can omit `hoistNonReactStatics` for this case.

Applied to files:

  • app/views/ProfileView/index.test.tsx
  • app/views/ProfileView/index.tsx
🪛 ESLint
app/sagas/deepLinking.ts

[error] 4-4: 'all' is defined but never used.

(@typescript-eslint/no-unused-vars)


[error] 281-283: Replace ⏎↹↹↹↹↹(action:·any)·=>·action.type·===·types.APP.START·&&·action.root·===·RootEnum.ROOT_INSIDE⏎↹↹↹↹ with (action:·any)·=>·action.type·===·types.APP.START·&&·action.root·===·RootEnum.ROOT_INSIDE

(prettier/prettier)

Comment thread app/i18n/locales/en.json Outdated
Comment thread app/sagas/deepLinking.ts Outdated
Comment thread app/sagas/deepLinking.ts Outdated
Comment thread app/sagas/deepLinking.ts
Comment on lines +303 to +311
const handleNavigateCallRoom = function* handleNavigateCallRoom({ params }: { params: ICallPushParams }) {
try {
yield* put(appStart({ root: RootEnum.ROOT_INSIDE }));
const db = database.active;
const subsCollection = db.get('subscriptions');
const room = yield* call([subsCollection, 'find'], params.rid);
if (room) {
const isMasterDetail = getIsMasterDetail();
yield* call(navigateToRoom, { item: room as any, isMasterDetail });

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Wait for navigation readiness before opening the call room.

This starts ROOT_INSIDE and immediately calls navigateToRoom; the regular deep-link path already waits before room navigation to avoid dispatching into an unmounted stack.

Suggested fix
 	try {
 		yield* put(appStart({ root: RootEnum.ROOT_INSIDE }));
+		yield* call(waitForNavigationReady);
 		const db = database.active;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const handleNavigateCallRoom = function* handleNavigateCallRoom({ params }: { params: ICallPushParams }) {
try {
yield* put(appStart({ root: RootEnum.ROOT_INSIDE }));
const db = database.active;
const subsCollection = db.get('subscriptions');
const room = yield* call([subsCollection, 'find'], params.rid);
if (room) {
const isMasterDetail = getIsMasterDetail();
yield* call(navigateToRoom, { item: room as any, isMasterDetail });
const handleNavigateCallRoom = function* handleNavigateCallRoom({ params }: { params: ICallPushParams }) {
try {
yield* put(appStart({ root: RootEnum.ROOT_INSIDE }));
yield* call(waitForNavigationReady);
const db = database.active;
const subsCollection = db.get('subscriptions');
const room = yield* call([subsCollection, 'find'], params.rid);
if (room) {
const isMasterDetail = getIsMasterDetail();
yield* call(navigateToRoom, { item: room as any, isMasterDetail });
🤖 Prompt for 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.

In `@app/sagas/deepLinking.ts` around lines 303 - 311, The call-room deep link
flow in handleNavigateCallRoom is navigating too early after
appStart(ROOT_INSIDE). Add the same navigation-readiness wait used by the
regular deep-link path before calling navigateToRoom, so this saga only opens
the room once the target stack is mounted and ready.

Comment thread app/sagas/deepLinking.ts Outdated
Comment thread app/views/ProfileView/index.tsx Outdated
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.

1 participant