From be11cb5c4b36b42dcc4c8bdcbc67d9a9b4ac2e14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Markb=C3=A5ge?= Date: Mon, 4 Aug 2025 09:42:48 -0400 Subject: [PATCH] [DevTools] Tweak the presentation of the Promise value (#34097) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Show the value as "fulfilled: Type" or "rejected: Type" immediately instead of having to expand it twice. We could show all the properties of the object immediately like we do in the Performance Track but it's not always particularly interesting data in the value that isn't already in the header. I also moved it to the end after the stack traces since I think the stack is more interesting but I'm also visually trying to connect the stack trace with the "name" since typically the "name" will come from part of the stack trace. Before: Screenshot 2025-08-03 at 11 39 49 PM After: Screenshot 2025-08-03 at 11 58 35 PM --- .../src/ReactFlightPerformanceTrack.js | 4 +- .../InspectedElementSharedStyles.css | 4 +- .../Components/InspectedElementSuspendedBy.js | 61 +++++++++++-------- .../react-devtools-shared/src/hydration.js | 11 ++++ 4 files changed, 52 insertions(+), 28 deletions(-) diff --git a/packages/react-client/src/ReactFlightPerformanceTrack.js b/packages/react-client/src/ReactFlightPerformanceTrack.js index 2b35e82363..717d536dc9 100644 --- a/packages/react-client/src/ReactFlightPerformanceTrack.js +++ b/packages/react-client/src/ReactFlightPerformanceTrack.js @@ -490,7 +490,7 @@ export function logComponentAwait( if (typeof value === 'object' && value !== null) { addObjectToProperties(value, properties, 0, ''); } else if (value !== undefined) { - addValueToProperties('Resolved', value, properties, 0, ''); + addValueToProperties('awaited value', value, properties, 0, ''); } const tooltipText = getIOLongName( asyncInfo.awaited, @@ -547,7 +547,7 @@ export function logIOInfoErrored( String(error.message) : // eslint-disable-next-line react-internal/safe-string-coercion String(error); - const properties = [['Rejected', message]]; + const properties = [['rejected with', message]]; const tooltipText = getIOLongName(ioInfo, description, ioInfo.env, rootEnv) + ' Rejected'; debugTask.run( diff --git a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementSharedStyles.css b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementSharedStyles.css index 41e510b7c1..ded305bbc6 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementSharedStyles.css +++ b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementSharedStyles.css @@ -97,11 +97,11 @@ } .CollapsableContent { - padding: 0.25rem 0; + margin-top: -0.25rem; } .PreviewContainer { - padding: 0 0.25rem 0.25rem 0.25rem; + padding: 0.25rem; } .TimeBarContainer { diff --git a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementSuspendedBy.js b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementSuspendedBy.js index 9deddef14b..c7d0b39df3 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementSuspendedBy.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElementSuspendedBy.js @@ -107,11 +107,10 @@ function SuspendedByRow({ } const value: any = asyncInfo.awaited.value; - const isErrored = - value !== null && - typeof value === 'object' && - value[meta.name] === 'rejected Thenable'; - + const metaName = + value !== null && typeof value === 'object' ? value[meta.name] : null; + const isFulfilled = metaName === 'fulfilled Thenable'; + const isRejected = metaName === 'rejected Thenable'; return (