Repository: rails/rails
File: railties/lib/rails/commands/console/irb_console.rb (Ruby)

Code before:
    IRB::HelperMethod.register(:app, AppInstance)
    IRB::HelperMethod.register(:reload!, ReloadHelper)

    class IRBConsole
      def initialize(app)
        @app = app

        require "irb"
        require "irb/completion"
      end

      def name
        "IRB"
      end

      def start
        IRB.setup(nil)

        if !Rails.env.local? && !ENV.key?("IRB_USE_AUTOCOMPLETE")
          IRB.conf[:USE_AUTOCOMPLETE] = false
        end

        env = colorized_env
        prompt_prefix = "%N(#{env})"
        IRB.conf[:IRB_NAME] = @app.name

        IRB.conf[:PROMPT][:RAILS_PROMPT] = {
          PROMPT_I: "#{prompt_prefix}:%03n> ",
          PROMPT_S: "#{prompt_prefix}:%03n%l ",
          PROMPT_C: "#{prompt_prefix}:%03n* ",
          RETURN: "=> %s\n"
        }

        if current_filter = IRB.conf[:BACKTRACE_FILTER]
          IRB.conf[:BACKTRACE_FILTER] = -> (backtrace) do
            backtrace = current_filter.call(backtrace)
            Rails.backtrace_cleaner.filter(backtrace)
          end
        else
          IRB.conf[:BACKTRACE_FILTER] = -> (backtrace) do
            Rails.backtrace_cleaner.filter(backtrace)
          end
        end

        # Respect user's choice of prompt mode.
        IRB.conf[:PROMPT_MODE] = :RAILS_PROMPT if IRB.conf[:PROMPT_MODE] == :DEFAULT
        IRB::Irb.new.run(IRB.conf)
      end

      def colorized_env
        case Rails.env

Review comment (suggestion):
This seems likely to break if irb ever changes the default name.

I'm not sure we need to respect their setting here either, as the goal seems to be to put the Application name front and center to avoid confusion.

While this change could re-introduce that ambiguity.

Code after:
    IRB::HelperMethod.register(:app, AppInstance)
    IRB::HelperMethod.register(:reload!, ReloadHelper)

    class IRBConsole
      def initialize(app)
        @app = app

        require "irb"
        require "irb/completion"
      end

      def name
        "IRB"
      end

      def start
        IRB.setup(nil)

        if !Rails.env.local? && !ENV.key?("IRB_USE_AUTOCOMPLETE")
          IRB.conf[:USE_AUTOCOMPLETE] = false
        end

        env = colorized_env
        prompt_prefix = "%N(#{env})"
        # Respect user's configured irb name.
        IRB.conf[:IRB_NAME] = @app.name if IRB.conf[:IRB_NAME] == "irb"

        IRB.conf[:PROMPT][:RAILS_PROMPT] = {
          PROMPT_I: "#{prompt_prefix}:%03n> ",
          PROMPT_S: "#{prompt_prefix}:%03n%l ",
          PROMPT_C: "#{prompt_prefix}:%03n* ",
          RETURN: "=> %s\n"
        }

        if current_filter = IRB.conf[:BACKTRACE_FILTER]
          IRB.conf[:BACKTRACE_FILTER] = -> (backtrace) do
            backtrace = current_filter.call(backtrace)
            Rails.backtrace_cleaner.filter(backtrace)
          end
        else
          IRB.conf[:BACKTRACE_FILTER] = -> (backtrace) do
            Rails.backtrace_cleaner.filter(backtrace)
          end
        end

        # Respect user's choice of prompt mode.
        IRB.conf[:PROMPT_MODE] = :RAILS_PROMPT if IRB.conf[:PROMPT_MODE] == :DEFAULT
        IRB::Irb.new.run(IRB.conf)
      end

      def colorized_env