3535from IPython .utils .process import arg_split , system # type:ignore[attr-defined]
3636from jupyter_client .session import Session , extract_header
3737from jupyter_core .paths import jupyter_runtime_dir
38- from traitlets import Any , CBool , CBytes , Instance , Type , default , observe
38+ from traitlets import Any , Bool , CBool , CBytes , Instance , Type , default , observe
3939
4040from ipykernel import connect_qtconsole , get_connection_file , get_connection_info
4141from ipykernel .displayhook import ZMQShellDisplayHook
@@ -59,6 +59,11 @@ class ZMQDisplayPublisher(DisplayPublisher):
5959 _parent_header : contextvars .ContextVar [dict [str , Any ]]
6060 topic = CBytes (b"display_data" )
6161
62+ store_display_history = Bool (
63+ False ,
64+ help = "If set to True, store display outputs in the history manager. Default is False." ,
65+ ).tag (config = True )
66+
6267 # thread_local:
6368 # An attribute used to ensure the correct output message
6469 # is processed. See ipykernel Issue 113 for a discussion.
@@ -121,7 +126,8 @@ def publish( # type:ignore[override]
121126 If True, send an update_display_data message instead of display_data.
122127 """
123128 if (
124- self .shell is not None
129+ self .store_display_history
130+ and self .shell is not None
125131 and hasattr (self .shell , "history_manager" )
126132 and HistoryOutput is not None
127133 ):
0 commit comments