99from __future__ import annotations
1010
1111import os
12+ import time
1213from types import SimpleNamespace
1314from typing import cast
1415
@@ -86,25 +87,25 @@ def test_windows_source_checkout_keeps_python_upgrade_command(monkeypatch):
8687 ]
8788
8889
89- async def test_shell_auto_update_toast_shows_new_version_immediately (monkeypatch ):
90+ async def test_shell_auto_update_refreshes_persistent_notice (monkeypatch ):
9091 import pythinker_code .ui .shell as shell_mod
9192
9293 async def fake_refresh ():
9394 return update .UpdateResult .UPDATE_AVAILABLE
9495
95- toast_calls : list [tuple [str , dict [str , object ]]] = []
9696 invalidated : list [bool ] = []
9797
98- def fake_toast (message : str , ** kwargs ):
99- toast_calls .append ((message , kwargs ))
100-
10198 shell = shell_mod .Shell .__new__ (shell_mod .Shell )
102- # SimpleNamespace stand-in for the CustomPromptSession; only invalidate()
103- # is exercised by _auto_update().
99+ shell ._update_notice_cache = (time .monotonic (), "stale" ) # type: ignore[attr-defined]
104100 shell ._prompt_session = SimpleNamespace ( # type: ignore[assignment]
105101 invalidate = lambda : invalidated .append (True )
106102 )
107103
104+ toast_calls : list [tuple [str , dict [str , object ]]] = []
105+
106+ def fake_toast (message : str , ** kwargs ):
107+ toast_calls .append ((message , kwargs ))
108+
108109 monkeypatch .setattr (shell_mod , "refresh_update_cache_if_due" , fake_refresh )
109110 monkeypatch .setattr (
110111 shell_mod ,
@@ -115,18 +116,9 @@ def fake_toast(message: str, **kwargs):
115116
116117 await shell_mod .Shell ._auto_update (shell )
117118
118- assert toast_calls == [
119- (
120- "Update available: 0.19.0 → 0.21.0. Run /update to install." ,
121- {
122- "topic" : "update" ,
123- "duration" : 30.0 ,
124- "immediate" : True ,
125- "style" : "fg:ansibrightyellow bold" ,
126- },
127- )
128- ]
119+ assert toast_calls == []
129120 assert invalidated == [True ]
121+ assert shell ._update_notice_cache == (0.0 , None ) # type: ignore[attr-defined]
130122
131123
132124def test_windows_installer_launches_signed_inno_directly (monkeypatch , tmp_path ):
0 commit comments