Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add recommendation to enable 'preserve log' #125

Merged

Conversation

EdmondChuiHW
Copy link

@EdmondChuiHW EdmondChuiHW commented Oct 14, 2024

Summary

When the web socket between CDT and dev-middleware is closed, CDT consults the "Preserve log" setting and clears log upon disconnection accordingly.

This can be unexpected for React Native targets, as users may expect to continue inspecting the console messages even if the native app has crashed.

In this PR, we print a recommendation for Fusebox targets with a button to direct the user to the specific setting.

Related: UI improvement for users viewing console messages under the disconnection state: #116

Test plan

Conenct to a Fusebox target. The recommendation should show up if the "Preserve log" setting is off:
screenshot of the new console message
Notice the yellow highlight, but it's not a warning (does not increase the warning counter in the top-right).

Clicking on the "show settings" link opens the Settings panel and highlights the checkbox with an animation
freeze frame of the animation highlighting the settings entry

Video:

Screen.Recording.2024-10-14.at.22.07.35.mov

Upstreaming plan

  • This commit should be sent as a patch to the upstream devtools-frontend repo. I've reviewed the contribution guide.
  • This commit is React Native-specific and cannot be upstreamed.

?.addMessage(new SDK.ConsoleModel.ConsoleMessage(
target.model(SDK.RuntimeModel.RuntimeModel), Protocol.Log.LogEntrySource.Recommendation,
Protocol.Log.LogEntryLevel.Info,
'[React Native] Console messages are currently cleared upon DevTools disconnection. You can preserve logs in settings: ',
Copy link
Author

Choose a reason for hiding this comment

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

Text suggestions welcome!

Choose a reason for hiding this comment

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

Do we support other languages besides English?

Copy link
Author

@EdmondChuiHW EdmondChuiHW Oct 15, 2024

Choose a reason for hiding this comment

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

Sorry missed this. Yes I should use an i18n string. Don't think we're currently doing any translation at the moment but good practice regardless. Will follow up (@huntie has some ideas on improving the text so I'll likely do it together)

@@ -5,6 +5,7 @@
*/

:host {
display: block;
Copy link
Author

Choose a reason for hiding this comment

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

Needed for the existing animation util to work.

The util attempts to animation the background on a Shadow DOM element <setting-checkbox>:

But since the host element is not a block by default, the background wouldn't be applied:
https://stackoverflow.com/a/60702911

@vzaidman
Copy link

Could we also add that same message after the devices disconnects and logs are cleared?

@huntie
Copy link

huntie commented Oct 15, 2024

@vzaidman Ditto. Can we exclusively log this after the device disconnects?

@EdmondChuiHW
Copy link
Author

@vzaidman @huntie this has been explored. It's possible to impl, but not ergonomic to do it in a Fusebox-only/merge-conflict-minimal way, i.e. via the regular event listeners.

TLDR: will be ugly; can do if there's a strong preference

@vzaidman
Copy link

Displaying it after the disconnect is the important one despite the ugliness.

I do think there's value in displaying it before, but we might as well skip it to not introduce extra deviations from the main branch.

@EdmondChuiHW
Copy link
Author

Let's do it. Besides the code, a heads up on the UI: the message will be covered up by the "disconnected" dialog. That's what made me add it to the dialog initially, but I agree adding more to the dialog could get bloated.

@EdmondChuiHW
Copy link
Author

EdmondChuiHW commented Oct 15, 2024

New UI:

screenshot of the prompt in a console message behind the 'disconnected' dialog

Now exclusively prints after console is cleared.

PS: there's no Fusebox-target check. It's not upstream-able as-is.

@vzaidman
Copy link

Nice! Can you actually click on "Show Settings"?

@EdmondChuiHW
Copy link
Author

Nice! Can you actually click on "Show Settings"?

@vzaidman Yup! With an animation to highlight the checkbox. Check out the video in the original description

@vzaidman
Copy link

I'm asking because the popup seems to be hiding the logs at the moment. Can you close it?

@EdmondChuiHW
Copy link
Author

Yup. The "Dismiss" button in the dialog works the same way (doesn't clear this new message)

@EdmondChuiHW EdmondChuiHW merged commit 6f29504 into facebookexperimental:main Oct 15, 2024
1 of 2 checks passed
@EdmondChuiHW EdmondChuiHW deleted the preserve-log-prompt branch October 15, 2024 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants