@@ -22,10 +22,10 @@ import * as Root from '../../core/root/root.js';
2222import * as SDK from '../../core/sdk/sdk.js' ;
2323import * as UI from '../../ui/legacy/legacy.js' ;
2424import * as Main from '../main/main.js' ;
25+ import * as Common from '../../core/common/common.js' ;
26+ import * as Protocol from '../../generated/protocol.js' ;
2527
26- import type * as Common from '../../core/common/common.js' ;
2728import type * as Platform from '../../core/platform/platform.js' ;
28- import type * as Protocol from '../../generated/protocol.js' ;
2929import type * as Sources from '../../panels/sources/sources.js' ;
3030import * as RNExperiments from '../../core/rn_experiments/rn_experiments.js' ;
3131
@@ -195,18 +195,39 @@ class ConnectionStatusToolbarItemProvider extends SDK.TargetManager.Observer imp
195195 SDK . TargetManager . TargetManager . instance ( ) . observeTargets ( this , { scoped : true } ) ;
196196 }
197197
198- override targetAdded ( _target : SDK . Target . Target ) : void {
199- this . #updateRootTarget ( ) ;
198+ override targetAdded ( target : SDK . Target . Target ) : void {
199+ this . #onTargetChanged ( target ) ;
200200 }
201- override targetRemoved ( _target : SDK . Target . Target ) : void {
202- this . #updateRootTarget( ) ;
201+
202+ override targetRemoved ( target : SDK . Target . Target ) : void {
203+ this . #onTargetChanged( target ) ;
203204 }
204205
205- #updateRootTarget ( ) : void {
206+ #onTargetChanged ( target : SDK . Target . Target ) : void {
206207 const rootTarget = SDK . TargetManager . TargetManager . instance ( ) . rootTarget ( ) ;
207208 this . #button. setTitle ( i18nLazyString ( UIStrings . connectionStatusDisconnectedTooltip ) ( ) ) ;
208209 this . #button. setText ( i18nLazyString ( UIStrings . connectionStatusDisconnectedLabel ) ( ) ) ;
209210 this . #button. setVisible ( ! rootTarget ) ;
211+
212+ if ( ! rootTarget ) {
213+ this . #printPreserveLogPrompt( target ) ;
214+ }
215+ }
216+
217+ #printPreserveLogPrompt( target : SDK . Target . Target ) : void {
218+ if ( Common . Settings . Settings . instance ( ) . moduleSetting ( 'preserve-console-log' ) . get ( ) ) {
219+ return ;
220+ }
221+
222+ target . model ( SDK . ConsoleModel . ConsoleModel )
223+ ?. addMessage ( new SDK . ConsoleModel . ConsoleMessage (
224+ target . model ( SDK . RuntimeModel . RuntimeModel ) , Protocol . Log . LogEntrySource . Recommendation ,
225+ Protocol . Log . LogEntryLevel . Info ,
226+ '[React Native] Console messages are currently cleared upon DevTools disconnection. You can preserve logs in settings: ' ,
227+ {
228+ type : SDK . ConsoleModel . FrontendMessageType . System ,
229+ context : 'fusebox_preserve_log_rec' ,
230+ } ) ) ;
210231 }
211232
212233 onClick ( ) : void {
0 commit comments