Skip to content

Conversation

@swrobel
Copy link
Contributor

@swrobel swrobel commented Sep 16, 2025

Fixes #2696. Reverts #2628.

Summary

A change was made in #2628 to work around a bug in Ghostty by forcing a new process to open in the default terminal app by adding the following option to the macOS open command:

-n Open a new instance of the application(s) even if one is already running.

This means that, in iTerm at least (and likely others), an entirely new dock icon will appear, which prevents switching between existing iTerm windows and this new one using the typical cmd+~ keyboard shortcut.

Furthermore, iTerm has overrides that allow you to open in a tab instead of a window when the command is open -a, but it can't do anything to override open open -na because of the fact that it launches an entirely separate process, not just window. (Side note: I would love to understand the rationale behind the fact that metro insists on launching in a new window instead of letting the terminal app in use decide how to handle it per the user's preferences, but I digress).

This removes the -n flag as the Ghostty bug that it added to work around has been verified fixed and released in Ghostty 1.2.0, out today

Test Plan

This reverts to longtime behavior for the CLI when launching the metro server process in a terminal. However, I have tested it with the following, and all seems to behave as expected:

  1. REACT_TERMINAL=iTerm yarn ios
  2. REACT_TERMINAL=Ghostty yarn ios (using Ghostty 1.2.0)
  3. REACT_TERMINAL=Terminal yarn ios

cc @Kamefrede for additional testing

Checklist

  • Documentation is up to date.
  • Follows commit message convention described in CONTRIBUTING.md.
  • For functional changes, my test plan has linked these CLI changes into a local react-native checkout (instructions).

Copy link
Collaborator

@szymonrybczak szymonrybczak left a comment

Choose a reason for hiding this comment

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

Nice! Thank you 🙏 Really appreciate really well described description

@thymikee thymikee merged commit ddbba6c into react-native-community:main Sep 16, 2025
4 of 8 checks passed
@swrobel swrobel deleted the patch-1 branch September 16, 2025 19:26
@robhogan
Copy link
Collaborator

robhogan commented Oct 7, 2025

I would love to understand the rationale behind the fact that metro insists on launching in a new window

Metro has no opinion on this, FWIW. For example, Expo doesn't launch Metro in a separate window - it's purely a community CLI choice. Possibly to do with displaying native build progress in the main terminal instead?

(Thanks for this improvement btw)

@andidev
Copy link

andidev commented Oct 10, 2025

@thymikee any chance to get this released soon? its really messing up the windows/tabs on iterm2 so you cannot switch tabs and work correctly, going crazy here 😂

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.

Metro open in new window instead of tab

5 participants