Skip to content

refactor: split useRoomNavigation and drop InteractionManager from initial jump params - #7682

Merged
diegolmello merged 3 commits into
native-34-roomview-hooksfrom
diegolmello/pr7482-useroomnavigation-split
Sep 14, 2026
Merged

diegolmello merged 3 commits into
native-34-roomview-hooksfrom
diegolmello/pr7482-useroomnavigation-split

Conversation

@diegolmello

@diegolmello diegolmello commented Sep 11, 2026

Copy link
Copy Markdown
Member

Proposed changes

Two follow-ups to the RoomView hooks migration, both scoped to how RoomView reaches a target Message or Thread.

Split useRoomNavigation into useJumpToMessage and plain services. The hook is renamed to match the Positional State row in CONTEXT.md. Opening a Thread or another Room moves into openThread and openRoom, async services with explicit dependencies. Consumption of the initial route params (jumpToMessageId, jumpToThreadId) lives in a non-exported helper so the jump generation counter has one owner. Public surface (onThreadMessagesLoaded, onThreadPress, jumpToMessageByUrl) is unchanged.

Consume initial route params in a mount effect instead of InteractionManager.runAfterInteractions. The gate never waited for the navigation transition: react-navigation registers no interaction handles, and on this React Native version InteractionManager is the stub whose runAfterInteractions is setImmediate. The API is deprecated and starts warning at runtime in 0.84. The helper now reads the initial Message target first and the once-only Thread target second in a single mount effect, keeping the message-before-thread guard. The jump starts one tick earlier than before. In-flight jumps still settle after unmount, as before; the generation counter is not bumped on unmount. useRoomInit, useRoomSubscription and JoinCode keep their own InteractionManager usage and are not touched here.

Issue(s)

https://rocketchat.atlassian.net/browse/NATIVE-1550
https://rocketchat.atlassian.net/browse/NATIVE-1551

How to test or reproduce

Each step starts from a Room that is not currently open.

  • Tap a message notification: the Room opens with the target message highlighted.
  • Tap a message search result: the Room jumps to that message.
  • Open Pinned Messages and tap one: the Room jumps to it.
  • Open a Thread deep link that carries both a message and a thread param: the message target is consumed first, then exactly one Thread screen opens.
  • Open a Thread whose messages are still loading with a pending message target: the jump waits for the Thread to load.
  • With the Room already open, receive updated route params: they are consumed immediately as before.

Screens: RoomView, Thread view.

Screenshots

Device runs on iPhone 16 Pro simulator and Pixel API 34 emulator, both against mobile.qa. Each recording starts with the target Room not mounted.

iOS, message target into a not-mounted Room. A permalink to a message in another Room is tapped; the Room mounts with the target highlighted.

ios-checkA-messagelink.mp4

iOS, message target that is a Thread reply. The Room mounts, the reply is resolved, and exactly one Thread screen opens; back returns to the Room.

ios-checkBC-threadreply.mp4

Search result into the current Room, both platforms. Same highlight as before the change.

iOS search result highlighted
Android search result highlighted

Not covered on device: the jumpToThreadId route param. It is only produced by the rocketchat://room deep link, which does not navigate on this Android emulator (the intent reaches the activity, the JS side never navigates; the auth deep link behaves the same). The Android not-mounted-Room run was also blocked by the test environment's login. Thread-param ordering is pinned by the lifecycle and composed suites instead.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves a current function)
  • New feature (non-breaking change which adds functionality)
  • Documentation update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if applicable)
  • I have added necessary documentation (if applicable)
  • Any dependent changes have been merged and published in downstream modules

Further comments

The lifecycle and composed suites no longer spy on InteractionManager. Tests that only passed because a mocked scheduler was never released were removed rather than rewritten, since after this change there is no deferred task to cancel and an "after unmount" assertion would only have exercised its own never-resolving mocks. The contract that pending asynchronous work keeps settling after unmount is still pinned by its existing test.

Summary by CodeRabbit

  • New Features

    • Improved navigation from messages and links to the relevant room, thread, or specific message.
    • Added more reliable handling for opening threads, including encrypted or unavailable thread names.
    • Room and thread destinations now open immediately when jump targets are provided.
  • Bug Fixes

    • Improved thread and message navigation behavior when required room or thread details are missing.
    • Added safer handling for cancelled or unsuccessful thread-loading requests.

… openThread/openRoom services

Rename the hook to useJumpToMessage to match the CONTEXT.md Positional State row.
Move Thread and Room opening into plain async services with explicit deps.
Isolate route-param consumption in a non-exported helper hook so the
generation counter has a single owner. Behavior and public surface unchanged;
the three existing suites pass with only import renames.

NATIVE-1550
@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: b47d4570-9e49-4d4b-9e48-39c0a338e6c5

📥 Commits

Reviewing files that changed from the base of the PR and between 9938297 and e2fdfa7.

📒 Files selected for processing (10)
  • app/views/RoomView/__tests__/roomAndThreadScreens.test.tsx
  • app/views/RoomView/definitions.ts
  • app/views/RoomView/hooks/__tests__/useJumpToMessage.composed.test.tsx
  • app/views/RoomView/hooks/__tests__/useJumpToMessage.lifecycle.test.tsx
  • app/views/RoomView/hooks/__tests__/useJumpToMessage.test.ts
  • app/views/RoomView/hooks/__tests__/useRoomMessaging.test.tsx
  • app/views/RoomView/hooks/useJumpToMessage.ts
  • app/views/RoomView/hooks/useRoomMessaging.ts
  • app/views/RoomView/services/openRoom.ts
  • app/views/RoomView/services/openThread.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (3)
Format JavaScript and TypeScript code with Oxfmt using the repository configuration: tabs, single quotes, 130-character width, no trailing commas, omitted arrow-function parentheses where possible, and same-line brackets.

📄 CodeRabbit inference engine (CLAUDE.md)

Files:

  • app/views/RoomView/definitions.ts
  • app/views/RoomView/__tests__/roomAndThreadScreens.test.tsx
  • app/views/RoomView/hooks/__tests__/useRoomMessaging.test.tsx
  • app/views/RoomView/services/openRoom.ts
  • app/views/RoomView/hooks/__tests__/useJumpToMessage.test.ts
  • app/views/RoomView/hooks/useRoomMessaging.ts
  • app/views/RoomView/services/openThread.ts
  • app/views/RoomView/hooks/__tests__/useJumpToMessage.lifecycle.test.tsx
  • app/views/RoomView/hooks/__tests__/useJumpToMessage.composed.test.tsx
  • app/views/RoomView/hooks/useJumpToMessage.ts
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...

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • app/views/RoomView/definitions.ts
  • app/views/RoomView/__tests__/roomAndThreadScreens.test.tsx
  • app/views/RoomView/hooks/__tests__/useRoomMessaging.test.tsx
  • app/views/RoomView/services/openRoom.ts
  • app/views/RoomView/hooks/__tests__/useJumpToMessage.test.ts
  • app/views/RoomView/hooks/useRoomMessaging.ts
  • app/views/RoomView/services/openThread.ts
  • app/views/RoomView/hooks/__tests__/useJumpToMessage.lifecycle.test.tsx
  • app/views/RoomView/hooks/__tests__/useJumpToMessage.composed.test.tsx
  • app/views/RoomView/hooks/useJumpToMessage.ts
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 str...

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • app/views/RoomView/definitions.ts
  • app/views/RoomView/__tests__/roomAndThreadScreens.test.tsx
  • app/views/RoomView/hooks/__tests__/useRoomMessaging.test.tsx
  • app/views/RoomView/services/openRoom.ts
  • app/views/RoomView/hooks/__tests__/useJumpToMessage.test.ts
  • app/views/RoomView/hooks/useRoomMessaging.ts
  • app/views/RoomView/services/openThread.ts
  • app/views/RoomView/hooks/__tests__/useJumpToMessage.lifecycle.test.tsx
  • app/views/RoomView/hooks/__tests__/useJumpToMessage.composed.test.tsx
  • app/views/RoomView/hooks/useJumpToMessage.ts
🔇 Additional comments (8)
app/views/RoomView/definitions.ts (1)

250-250: LGTM!

Also applies to: 259-259

app/views/RoomView/hooks/__tests__/useJumpToMessage.test.ts (1)

8-9: LGTM!

Also applies to: 43-45, 59-59

app/views/RoomView/hooks/__tests__/useJumpToMessage.composed.test.tsx (1)

10-11: LGTM!

Also applies to: 46-49, 68-68

app/views/RoomView/hooks/__tests__/useJumpToMessage.lifecycle.test.tsx (1)

13-14: LGTM!

Also applies to: 57-57, 69-69, 306-306, 313-313, 336-336

app/views/RoomView/services/openThread.ts (1)

1-74: LGTM!

app/views/RoomView/hooks/useRoomMessaging.ts (1)

18-18: LGTM!

Also applies to: 39-39

app/views/RoomView/__tests__/roomAndThreadScreens.test.tsx (1)

85-85: LGTM!

app/views/RoomView/hooks/__tests__/useRoomMessaging.test.tsx (1)

31-32: LGTM!


Walkthrough

The pull request renames useRoomNavigation to useJumpToMessage, extracts room and thread navigation into services, removes interaction scheduling, and updates integrations and tests for immediate route-target handling.

Changes

Room jump navigation

Layer / File(s) Summary
Navigation services and route-target handling
app/views/RoomView/definitions.ts, app/views/RoomView/hooks/useJumpToMessage.ts, app/views/RoomView/services/*
The hook uses renamed interfaces, immediate route-target effects, and openRoom and openThread services.
Hook integration and mocks
app/views/RoomView/hooks/useRoomMessaging.ts, app/views/RoomView/__tests__/roomAndThreadScreens.test.tsx, app/views/RoomView/hooks/__tests__/useRoomMessaging.test.tsx
Room messaging and screen mocks now reference useJumpToMessage.
Immediate route-target validation
app/views/RoomView/hooks/__tests__/useJumpToMessage*.test.*
Tests remove InteractionManager scheduling and validate immediate initial-target consumption.

Priority: ⬇️ Low

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

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  participant useJumpToMessage
  participant openRoom
  participant openThread
  participant RoomView
  useJumpToMessage->>openRoom: Open a room message target
  openRoom->>RoomView: Resolve room and navigate
  useJumpToMessage->>openThread: Open a thread target
  openThread->>RoomView: Fetch thread name and navigate
Loading

Suggested labels: type: chore

Merge Risk: ⚪ Minimal · up to 4d37d

No unresolved merge-blocking risk remains from this navigation refactor.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 10 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main changes: splitting useRoomNavigation and removing InteractionManager scheduling for initial jump parameters.
✨ Finishing Touches 💡 1
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch diegolmello/pr7482-useroomnavigation-split

Warning

Errors were encountered while retrieving linked issues.

Errors (1)
  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

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.

@diegolmello
diegolmello deployed to approve_e2e_testing September 14, 2026 13:49 — with GitHub Actions Active
@diegolmello
diegolmello merged commit 89c087b into native-34-roomview-hooks Sep 14, 2026
25 of 27 checks passed
@diegolmello
diegolmello deleted the diegolmello/pr7482-useroomnavigation-split branch September 14, 2026 17:30
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