GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — chore[react-devtools]: unify console patching and default to ansi escape symbols by hoxyq · Pull Request #29869 · react/react

Conversation

@hoxyq

@hoxyq hoxyq commented Jun 12, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

Stacked on #29856.

Summary

By default, React DevTools will apply dimming with ANSI escape symbols, so it works for both terminals and browser consoles.

For Firefox, which doesn't support ANSI escape symbols console stylings, we fallback to css properties, like we used to do before.

How did you test this change?

Environment Dark mode Light mode
Terminal Screenshot 2024-06-12 at 19 39 46 Screenshot 2024-06-12 at 19 39 09
Fusebox console Screenshot 2024-06-12 at 21 03 14 Screenshot 2024-06-12 at 21 02 48
Firefox console Screenshot 2024-06-12 at 21 40 29 Screenshot 2024-06-12 at 21 40 42
Chrome console Screenshot 2024-06-12 at 21 43 09 Screenshot 2024-06-12 at 21 43 00

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vercel

vercel Bot commented Jun 12, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 17, 2024 3:17pm
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Jun 12, 2024
@hoxyq hoxyq changed the title chore[react-devtools]: unify console patching and fallback to ansi escape symbols chore[react-devtools]: unify console patching and default to ansi escape symbols Jun 12, 2024
@react-sizebot

react-sizebot commented Jun 12, 2024

Copy link
Copy Markdown

Comparing: f5af92d...88b169f

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.66 kB 6.66 kB +0.05% 1.82 kB 1.82 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 497.44 kB 497.44 kB = 89.16 kB 89.16 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.67 kB 6.67 kB +0.05% 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 502.26 kB 502.26 kB = 89.85 kB 89.85 kB
facebook-www/ReactDOM-prod.classic.js = 596.94 kB 596.94 kB = 105.24 kB 105.24 kB
facebook-www/ReactDOM-prod.modern.js = 571.12 kB 571.12 kB = 101.19 kB 101.19 kB
test_utils/ReactAllWarnings.js Deleted 63.89 kB 0.00 kB Deleted 15.97 kB 0.00 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
test_utils/ReactAllWarnings.js Deleted 63.89 kB 0.00 kB Deleted 15.97 kB 0.00 kB

Generated by 🚫 dangerJS against 88b169f

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vercel
vercel Bot deployed to Preview June 12, 2024 11:08
View deployment
@hoxyq hoxyq mentioned this pull request Jun 12, 2024
chore[react-devtools]: improve console arguments formatting before passing it to original console #29873
Merged
@hoxyq
hoxyq requested review from rickhanlonii, vzaidman and yungsters June 12, 2024 20:04
@hoxyq hoxyq mentioned this pull request Jun 13, 2024
toggle consoleManagedByDevToolsDuringStrictMode flag for native #29887
Closed
vzaidman
vzaidman approved these changes Jun 17, 2024
View reviewed changes
@hoxyq
chore[react-devtools]: unify console patching and default to ansi esc…
9e0d928
…ape symbols
@hoxyq
hoxyq force-pushed the react-devtools/unify-console-patching branch from 88b169f to 9e0d928 Compare June 17, 2024 15:14
@vercel
vercel Bot deployed to Preview June 17, 2024 15:17
View deployment
@hoxyq
hoxyq merged commit ff6e05a into react:main Jun 17, 2024
@hoxyq
hoxyq deleted the react-devtools/unify-console-patching branch June 17, 2024 15:31
hoxyq added a commit that referenced this pull request Jun 17, 2024
@hoxyq
chore[react-devtools]: improve console arguments formatting before pa…
107a2f8
…ssing it to original console (#29873)

Stacked on #29869.

## Summary

When using ANSI escape sequences, we construct a message in the
following way: `console.<method>('\x1b...%s\x1b[0m',
userspaceArgument1?, userspaceArgument2?, userspaceArgument3?, ...)`.

This won't dim all arguments, if user had something like `console.log(1,
2, 3)`, we would only apply it to `1`, since this is the first
arguments, so we need to:
- inline everything whats possible into a single string, while
preserving console substitutions defined by the user
- omit css and object substitutions, since we can't really inline them
and will delegate in to the environment

## How did you test this change?

Added some tests, manually inspected that it works well for web and
native cases.
@hoxyq hoxyq mentioned this pull request Jun 17, 2024
React DevTools 5.2.0 -> 5.3.0 #29918
Merged
hoxyq added a commit that referenced this pull request Jun 18, 2024
@hoxyq
React DevTools 5.2.0 -> 5.3.0 (#29918)
1434af3
Full list of changes:

* chore[react-devtools]: improve console arguments formatting before
passing it to original console ([hoxyq](https://github.com/hoxyq) in
[#29873](#29873))
* chore[react-devtools]: unify console patching and default to ansi
escape symbols ([hoxyq](https://github.com/hoxyq) in
[#29869](#29869))
* chore[react-devtools/backend]: remove
consoleManagedByDevToolsDuringStrictMode
([hoxyq](https://github.com/hoxyq) in
[#29856](#29856))
* chore[react-devtools/extensions]: make source maps url relative
([hoxyq](https://github.com/hoxyq) in
[#29886](#29886))
* fix[react-devtools] divided inspecting elements between inspecting do…
([vzaidman](https://github.com/vzaidman) in
[#29885](#29885))
* [Fiber] Create virtual Fiber when an error occurs during reconcilation
([sebmarkbage](https://github.com/sebmarkbage) in
[#29804](#29804))
* fix[react-devtools] component badge in light mode is now not invisible
([vzaidman](https://github.com/vzaidman) in
[#29852](#29852))
* Remove Warning: prefix and toString on console Arguments
([sebmarkbage](https://github.com/sebmarkbage) in
[#29839](#29839))
* Add jest lint rules ([rickhanlonii](https://github.com/rickhanlonii)
in [#29760](#29760))
* [Fiber] Track the Real Fiber for Key Warnings
([sebmarkbage](https://github.com/sebmarkbage) in
[#29791](#29791))
* fix[react-devtools/store-test]: fork the test to represent current be…
([hoxyq](https://github.com/hoxyq) in
[#29777](#29777))
* Default native inspections config false
([vzaidman](https://github.com/vzaidman) in
[#29784](#29784))
* fix[react-devtools] remove native inspection button when it can't be
used ([vzaidman](https://github.com/vzaidman) in
[#29779](#29779))
* chore[react-devtools]: ip => internal-ip
([hoxyq](https://github.com/hoxyq) in
[#29772](#29772))
* Fix #29724: `ip` dependency update for CVE-2024-29415
([Rekl0w](https://github.com/Rekl0w) in
[#29725](#29725))
* cleanup[react-devtools]: remove unused supportsProfiling flag from
store config ([hoxyq](https://github.com/hoxyq) in
[#29193](#29193))
* [Fiber] Enable Native console.createTask Stacks When Available
([sebmarkbage](https://github.com/sebmarkbage) in
[#29223](#29223))
* Move createElement/JSX Warnings into the Renderer
([sebmarkbage](https://github.com/sebmarkbage) in
[#29088](#29088))
* Set the current fiber to the source of the error during error
reporting ([sebmarkbage](https://github.com/sebmarkbage) in
[#29044](#29044))
* Unify ReactFiberCurrentOwner and ReactCurrentFiber
([sebmarkbage](https://github.com/sebmarkbage) in
[#29038](#29038))
* Dim `console` calls on additional Effect invocations due to
`StrictMode` ([eps1lon](https://github.com/eps1lon) in
[#29007](#29007))
* refactor[react-devtools]: rewrite context menus
([hoxyq](https://github.com/hoxyq) in
[#29049](#29049))
@hoxyq hoxyq mentioned this pull request Jun 20, 2024
fix[react-devtools/extensions]: propagate globals from env #29963
Merged
hoxyq added a commit that referenced this pull request Jun 20, 2024
@hoxyq
fix[react-devtools/extensions]: propagate globals from env (#29963)
b15c849
Somehow missed this while working on
#29869.

With these changes, manual inspection of the
`react_devtools_backend_compact.js` doesn't have any occurences of
`__IS_FIREFOX__` flag.
@sofiia31 sofiia31 mentioned this pull request Jun 20, 2024
fix[react-devtools/extensions]: propagate globals from env (#29963) sofiia31/reactFork#1
Merged
@eps1lon eps1lon mentioned this pull request Jul 16, 2024
Update React from dfd30974ab-20240613 to 01172397-20240716 vercel/next.js#67810
Closed
This was referenced Jul 25, 2024
Update React from 6230622a1a-20240610 to 76002254-20240724 vercel/next.js#68149
Merged
Update React from 6230622a1a-20240610 to 3208e73e-20240730 vercel/next.js#68330
Merged
@hoxyq hoxyq mentioned this pull request Aug 1, 2024
refactor[react-devtools]: remove browserTheme from ConsolePatchSettings #30566
Merged
hoxyq added a commit that referenced this pull request Sep 18, 2024
@hoxyq
refactor[react-devtools]: remove browserTheme from ConsolePatchSettin…
b521ef8
…gs (#30566)

Stacked on #30564.

We are no longer using browser theme in our console patching, this was
removed in unification of console patching for strict mode, we started
using ansi escape symbols and forking based on browser theme is no
longer required - #29869

The real browser theme initialization for frontend is happening at the
other place and is not affected:

https://github.com/facebook/react/blob/40be968257a7a10a267210670103f20dd0429ef3/packages/react-devtools-shared/src/devtools/views/Settings/SettingsContext.js#L117-L120
github-actions Bot pushed a commit that referenced this pull request Sep 18, 2024
@hoxyq
refactor[react-devtools]: remove browserTheme from ConsolePatchSettin…
8bc2b9c
…gs (#30566)

Stacked on #30564.

We are no longer using browser theme in our console patching, this was
removed in unification of console patching for strict mode, we started
using ansi escape symbols and forking based on browser theme is no
longer required - #29869

The real browser theme initialization for frontend is happening at the
other place and is not affected:

https://github.com/facebook/react/blob/40be968257a7a10a267210670103f20dd0429ef3/packages/react-devtools-shared/src/devtools/views/Settings/SettingsContext.js#L117-L120

DiffTrain build for [b521ef8](b521ef8)
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@hoxyq
chore[react-devtools]: unify console patching and default to ansi esc…
a7b3372
…ape symbols (react#29869)

Stacked on react#29856.

## Summary

By default, React DevTools will apply dimming with ANSI escape symbols,
so it works for both terminals and browser consoles.

For Firefox, which doesn't support ANSI escape symbols console stylings,
we fallback to css properties, like we used to do before.

## How did you test this change?

| Environment | Dark mode | Light mode |
|--------|--------|--------|
| Terminal | ![Screenshot 2024-06-12 at 19 39
46](https://github.com/facebook/react/assets/28902667/2d470eee-ec5f-4362-be7d-8d80c6c72d09)
| ![Screenshot 2024-06-12 at 19 39
09](https://github.com/facebook/react/assets/28902667/616f2c58-a251-406b-aee6-841e07d652ba)
|
| Fusebox&nbsp;console | ![Screenshot 2024-06-12 at 21 03
14](https://github.com/facebook/react/assets/28902667/6050f730-8e82-4aa1-acbc-7179aac3a8aa)
| ![Screenshot 2024-06-12 at 21 02
48](https://github.com/facebook/react/assets/28902667/6708b938-8a90-476f-a057-427963d58caa)
|
| Firefox&nbsp;console | ![Screenshot 2024-06-12 at 21 40
29](https://github.com/facebook/react/assets/28902667/4721084f-bbfa-438c-b61b-395da8ded590)
| ![Screenshot 2024-06-12 at 21 40
42](https://github.com/facebook/react/assets/28902667/72bbf001-2d3d-49e7-91c9-20a4f0914d4d)
|
| Chrome&nbsp;console | ![Screenshot 2024-06-12 at 21 43
09](https://github.com/facebook/react/assets/28902667/93c47881-a0dd-44f8-8dc2-8710149774e5)
| ![Screenshot 2024-06-12 at 21 43
00](https://github.com/facebook/react/assets/28902667/07ea4ff5-4322-4db9-9c12-4321d9577c9d)
|
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@hoxyq
chore[react-devtools]: improve console arguments formatting before pa…
28a4b6e
…ssing it to original console (react#29873)

Stacked on react#29869.

## Summary

When using ANSI escape sequences, we construct a message in the
following way: `console.<method>('\x1b...%s\x1b[0m',
userspaceArgument1?, userspaceArgument2?, userspaceArgument3?, ...)`.

This won't dim all arguments, if user had something like `console.log(1,
2, 3)`, we would only apply it to `1`, since this is the first
arguments, so we need to:
- inline everything whats possible into a single string, while
preserving console substitutions defined by the user
- omit css and object substitutions, since we can't really inline them
and will delegate in to the environment

## How did you test this change?

Added some tests, manually inspected that it works well for web and
native cases.
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@hoxyq
React DevTools 5.2.0 -> 5.3.0 (react#29918)
83b41f2
Full list of changes:

* chore[react-devtools]: improve console arguments formatting before
passing it to original console ([hoxyq](https://github.com/hoxyq) in
[react#29873](react#29873))
* chore[react-devtools]: unify console patching and default to ansi
escape symbols ([hoxyq](https://github.com/hoxyq) in
[react#29869](react#29869))
* chore[react-devtools/backend]: remove
consoleManagedByDevToolsDuringStrictMode
([hoxyq](https://github.com/hoxyq) in
[react#29856](react#29856))
* chore[react-devtools/extensions]: make source maps url relative
([hoxyq](https://github.com/hoxyq) in
[react#29886](react#29886))
* fix[react-devtools] divided inspecting elements between inspecting do…
([vzaidman](https://github.com/vzaidman) in
[react#29885](react#29885))
* [Fiber] Create virtual Fiber when an error occurs during reconcilation
([sebmarkbage](https://github.com/sebmarkbage) in
[react#29804](react#29804))
* fix[react-devtools] component badge in light mode is now not invisible
([vzaidman](https://github.com/vzaidman) in
[react#29852](react#29852))
* Remove Warning: prefix and toString on console Arguments
([sebmarkbage](https://github.com/sebmarkbage) in
[react#29839](react#29839))
* Add jest lint rules ([rickhanlonii](https://github.com/rickhanlonii)
in [react#29760](react#29760))
* [Fiber] Track the Real Fiber for Key Warnings
([sebmarkbage](https://github.com/sebmarkbage) in
[react#29791](react#29791))
* fix[react-devtools/store-test]: fork the test to represent current be…
([hoxyq](https://github.com/hoxyq) in
[react#29777](react#29777))
* Default native inspections config false
([vzaidman](https://github.com/vzaidman) in
[react#29784](react#29784))
* fix[react-devtools] remove native inspection button when it can't be
used ([vzaidman](https://github.com/vzaidman) in
[react#29779](react#29779))
* chore[react-devtools]: ip => internal-ip
([hoxyq](https://github.com/hoxyq) in
[react#29772](react#29772))
* Fix react#29724: `ip` dependency update for CVE-2024-29415
([Rekl0w](https://github.com/Rekl0w) in
[react#29725](react#29725))
* cleanup[react-devtools]: remove unused supportsProfiling flag from
store config ([hoxyq](https://github.com/hoxyq) in
[react#29193](react#29193))
* [Fiber] Enable Native console.createTask Stacks When Available
([sebmarkbage](https://github.com/sebmarkbage) in
[react#29223](react#29223))
* Move createElement/JSX Warnings into the Renderer
([sebmarkbage](https://github.com/sebmarkbage) in
[react#29088](react#29088))
* Set the current fiber to the source of the error during error
reporting ([sebmarkbage](https://github.com/sebmarkbage) in
[react#29044](react#29044))
* Unify ReactFiberCurrentOwner and ReactCurrentFiber
([sebmarkbage](https://github.com/sebmarkbage) in
[react#29038](react#29038))
* Dim `console` calls on additional Effect invocations due to
`StrictMode` ([eps1lon](https://github.com/eps1lon) in
[react#29007](react#29007))
* refactor[react-devtools]: rewrite context menus
([hoxyq](https://github.com/hoxyq) in
[react#29049](react#29049))
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@hoxyq
fix[react-devtools/extensions]: propagate globals from env (react#29963)
632b423
Somehow missed this while working on
react#29869.

With these changes, manual inspection of the
`react_devtools_backend_compact.js` doesn't have any occurences of
`__IS_FIREFOX__` flag.
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@hoxyq
refactor[react-devtools]: remove browserTheme from ConsolePatchSettin…
de61dbe
…gs (react#30566)

Stacked on react#30564.

We are no longer using browser theme in our console patching, this was
removed in unification of console patching for strict mode, we started
using ansi escape symbols and forking based on browser theme is no
longer required - react#29869

The real browser theme initialization for frontend is happening at the
other place and is not affected:

https://github.com/facebook/react/blob/40be968257a7a10a267210670103f20dd0429ef3/packages/react-devtools-shared/src/devtools/views/Settings/SettingsContext.js#L117-L120

This branch was successfully deployed

1 active deployment
Preview — 9e0d9285 Deployed Jun 17, 2024 by vercel[bot]
View deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@yungsters yungsters Awaiting requested review from yungsters
@rickhanlonii rickhanlonii Awaiting requested review from rickhanlonii
1 more reviewer
@vzaidman vzaidman vzaidman approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@hoxyq @react-sizebot @vzaidman @facebook-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.