Skip to content

regression: go back instead of closing app on rooms search#6750

Merged
diegolmello merged 3 commits intodevelopfrom
room-search-fix
Dec 3, 2025
Merged

regression: go back instead of closing app on rooms search#6750
diegolmello merged 3 commits intodevelopfrom
room-search-fix

Conversation

@Rohit3523
Copy link
Copy Markdown
Contributor

@Rohit3523 Rohit3523 commented Oct 29, 2025

Proposed changes

Currently when we go to room search and press back button 2 times, on the first press it hides the keyboard but on the second click it exit the app where we have to open the app again, so with this PR users will go back to room list.

Issue(s)

https://rocketchat.atlassian.net/browse/COMM-71

How to test or reproduce

Screenshots

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

Summary by CodeRabbit

  • New Features

    • Back button now exits active search mode and returns to the previous screen, improving navigation during searches while preserving default behavior otherwise.
  • Tests

    • Added an automated Android UI test for the search flow and back-button behavior to validate search focus, navigation, and dismissal.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Oct 29, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds a BackHandler listener in RoomsListView to intercept Android hardware back presses: when search is active it clears search and navigates back (consuming the event); otherwise it allows default back behavior. Also adds a Maestro Android test exercising the search/back flow.

Changes

Cohort / File(s) Summary
Back-button interception in search mode
app/views/RoomsListView/index.tsx
Adds useEffect and BackHandler imports and registers a hardware back-press listener. When searchEnabled is true, the handler clears/stops search and navigates back (returns true); otherwise returns false to allow default behavior.
Android UI test for search flow
.maestro/tests/room/search.yaml
Adds a Maestro test configuration that runs the Android Search flow: setup, login via deeplink, focus search, wait for room list states, type into search, press back, and verify the search input is gone. Uses extended timeouts and environment-provided credentials.
sequenceDiagram
    actor User
    participant Android as BackHandler
    participant Rooms as RoomsListView
    participant Nav as Navigation

    User->>Android: press hardware Back
    Android->>Rooms: invoke back-press listener

    alt searchEnabled == true
        Rooms->>Rooms: clear/stop search state
        Rooms->>Nav: navigate back
        Rooms-->>Android: return true (consume)
    else searchEnabled == false
        Rooms-->>Android: return false (allow default)
        Android->>Nav: perform default back navigation
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review attention items:
    • BackHandler subscription/unsubscription lifecycle in index.tsx.
    • Ensure search state cleared and navigation doesn't double-navigate.
    • Validate Maestro test selectors, timeouts, and credential handling.

🐰
I nibble keys at break of dawn,
When search is loud I hush and yawn,
One back-press stops the frantic quest,
We hop back home and take a rest,
Tiny paws, a tidy test.

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'regression: go back instead of closing app on rooms search' clearly summarizes the main change: modifying back-button behavior during room search to navigate back instead of closing the app, which aligns with the PR objectives and code changes.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0693f7d and be3bf10.

📒 Files selected for processing (2)
  • .maestro/tests/room/search.yaml (1 hunks)
  • app/views/RoomsListView/index.tsx (2 hunks)

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.

@Rohit3523 Rohit3523 marked this pull request as ready for review October 29, 2025 22:31
@Rohit3523
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Oct 29, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 55e7db3 and c3293e9.

📒 Files selected for processing (1)
  • app/views/RoomsListView/index.tsx (2 hunks)
🔇 Additional comments (2)
app/views/RoomsListView/index.tsx (2)

2-3: LGTM!

The new imports are necessary for the back button handling functionality.


54-64: Note: Hardware back button behavior is Android-only.

The BackHandler API only affects Android's hardware back button and will have no effect on iOS. This is typically expected behavior, but as noted in the PR comments, iOS testing hasn't been completed yet. Ensure that the iOS back navigation works as expected through the native navigation gestures.

const subscription = BackHandler.addEventListener('hardwareBackPress', () => {
if (searchEnabled) {
stopSearch();
navigation.goBack();
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 | 🔴 Critical

🧩 Analysis chain

Verify navigation stack to prevent unintended app exit.

The PR aims to prevent the app from exiting, but navigation.goBack() could still exit the app if the RoomsListView is at the bottom of the navigation stack. Consider checking navigation.canGoBack() before calling goBack(), or verify that there's always a screen to navigate back to in your navigation structure.

Alternatively, consider this defensive approach:

 		const subscription = BackHandler.addEventListener('hardwareBackPress', () => {
 			if (searchEnabled) {
 				stopSearch();
-				navigation.goBack();
+				if (navigation.canGoBack()) {
+					navigation.goBack();
+				}
 				return true;
 			}
 			return false;

🏁 Script executed:

#!/bin/bash
# Search for navigation setup and how RoomsListView is mounted in the navigation stack
rg -n -C 5 "RoomsListView" --type=typescript --type=tsx -g "!*.test.*" -g "!*.spec.*"

Length of output: 34



---

🏁 Script executed:

```shell
#!/bin/bash
# Search for RoomsListView with corrected rg syntax
rg -n -C 5 "RoomsListView" --type ts --type tsx -g "!*.test.*" -g "!*.spec.*"

Length of output: 27


🏁 Script executed:

#!/bin/bash
# Search for navigation.goBack() calls in the codebase
rg -n "navigation\.goBack" --type ts --type tsx -g "!*.test.*" -g "!*.spec.*"

Length of output: 27


🏁 Script executed:

#!/bin/bash
# Search for navigation.canGoBack usage
rg -n "canGoBack" --type ts --type tsx -g "!*.test.*" -g "!*.spec.*"

Length of output: 27


🏁 Script executed:

#!/bin/bash
# Look for the specific file to examine the current implementation
fd "RoomsListView" --type f

Length of output: 0



---

🏁 Script executed:

```shell
#!/bin/bash
# Search for RoomsListView without type restrictions
rg -n -C 5 "RoomsListView" -g "!*.test.*" -g "!*.spec.*"

Length of output: 11909


🏁 Script executed:

#!/bin/bash
# Search for navigation.goBack without type restrictions
rg -n "navigation\.goBack" -g "!*.test.*" -g "!*.spec.*"

Length of output: 912


🏁 Script executed:

#!/bin/bash
# Look for any tsx or ts files in app directory
fd -e tsx -e ts "." app/ 2>/dev/null | head -20

Length of output: 792


🏁 Script executed:

#!/bin/bash
# Search for RoomsListView with broader pattern
fd "RoomsListView" . 2>/dev/null

Length of output: 26


🏁 Script executed:

#!/bin/bash
# Check if app/views/RoomsListView/index.tsx exists
cat app/views/RoomsListView/index.tsx 2>/dev/null | head -80

Length of output: 3592


Add canGoBack() check before calling navigation.goBack() to prevent unintended app exit.

The current implementation calls navigation.goBack() without verifying the navigation stack state. Since RoomsListView is positioned as the first screen in the navigation stack, calling goBack() when the user triggers back from search mode could exit the app. Add a defensive check:

 		const subscription = BackHandler.addEventListener('hardwareBackPress', () => {
 			if (searchEnabled) {
 				stopSearch();
-				navigation.goBack();
+				if (navigation.canGoBack()) {
+					navigation.goBack();
+				}
 				return true;
 			}
 			return false;
📝 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
navigation.goBack();
const subscription = BackHandler.addEventListener('hardwareBackPress', () => {
if (searchEnabled) {
stopSearch();
if (navigation.canGoBack()) {
navigation.goBack();
}
return true;
}
return false;
🤖 Prompt for AI Agents
In app/views/RoomsListView/index.tsx around line 58, the code calls
navigation.goBack() unguarded which can exit the app when this view is the root;
wrap the call in a defensive check by calling navigation.canGoBack() first and
only invoking navigation.goBack() when it returns true (otherwise handle the
back action differently, e.g., dismiss search mode or no-op) so the app cannot
unintentionally close.

@Rohit3523 Rohit3523 temporarily deployed to approve_e2e_testing October 30, 2025 15:23 — with GitHub Actions Inactive
@Rohit3523 Rohit3523 had a problem deploying to experimental_android_build October 30, 2025 15:26 — with GitHub Actions Error
@Rohit3523 Rohit3523 had a problem deploying to official_android_build October 30, 2025 15:26 — with GitHub Actions Error
@Rohit3523 Rohit3523 had a problem deploying to experimental_ios_build October 30, 2025 15:26 — with GitHub Actions Error
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: 0

🧹 Nitpick comments (1)
.maestro/tests/room/search.yaml (1)

18-31: Minor observation: Search setup has a potentially redundant wait.

After tapping the search button (line 23), the test waits for rooms-list-view to be visible (lines 24–26). Since the search overlay typically appears on top of the rooms list, the list is likely already visible. Consider removing this redundant wait to tighten the test flow, though the current approach is safe.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between c3293e9 and 0693f7d.

📒 Files selected for processing (1)
  • .maestro/tests/room/search.yaml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: ESLint and Test / run-eslint-and-test
  • GitHub Check: format
🔇 Additional comments (1)
.maestro/tests/room/search.yaml (1)

1-41: Test structure aligns well with the PR fix for back-button navigation.

The test correctly validates the intended behavior: two back presses while in search mode should exit the search (hiding the search input) without closing the app. The use of extendedWaitUntil with 60-second timeouts for each state transition is appropriate for integration testing.

@Rohit3523 Rohit3523 had a problem deploying to official_android_build October 30, 2025 18:18 — with GitHub Actions Failure
@Rohit3523 Rohit3523 had a problem deploying to experimental_android_build October 30, 2025 18:18 — with GitHub Actions Failure
@Rohit3523 Rohit3523 had a problem deploying to experimental_ios_build October 30, 2025 18:18 — with GitHub Actions Failure
@Rohit3523 Rohit3523 requested a review from diegolmello October 30, 2025 21:14
@diegolmello diegolmello changed the title fix: go back instead of closing app in roomlist search regression: go back instead of closing app in roomlist search Nov 5, 2025
@diegolmello diegolmello changed the title regression: go back instead of closing app in roomlist search regression: go back instead of closing app on rooms search Nov 5, 2025
@diegolmello diegolmello merged commit 6c4637a into develop Dec 3, 2025
2 of 3 checks passed
@diegolmello diegolmello deleted the room-search-fix branch December 3, 2025 20:06
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