v3.23.7: the proactive log survives a TERMINAL PROFILE re-send

Pressing the Phone tab's Send (or Rescue) re-sends the profile and starts a
new CAT session.  The log was cleared with the rest of the session state,
losing the only record of the card's proactive commands - a common
tweak-the-profile-and-resend loop wiped the history every time.

_resend_terminal_profile now calls _mark_proactive_session(
'terminal-profile') instead: the entries stay, _PROACTIVE_SESSION_START
restarts (so the new session's elapsed values begin at 0) and a boundary
marker entry is appended.  The PWA renders the marker as a
'- TERMINAL PROFILE re-sent - new CAT session -' divider (EN/RU).

Equip / disconnect keep the full clear (a card change); the pending-command
cancel, menu timeout and event list reset are unchanged.

Tests: the marker keeps the entries and restarts the timer, the reset still
clears, the re-send path pinned by source (Python) and the renderer's marker
branch (Node).  857 frontend + 842 Python; sw cache simple-v420.
This commit is contained in:
2026-10-08 00:20:06 +03:00
parent 9fb46b786f
commit c9ab15c392
8 changed files with 85 additions and 8 deletions
+40
View File
@@ -1066,6 +1066,46 @@ class TestProactiveDecode(unittest.TestCase):
_record_tr(entry, bytes.fromhex('810303260082028181'))
self.assertNotIn('tr_result', entry)
def test_the_session_marker_keeps_the_proactive_history(self):
# v3.23.7: a TERMINAL PROFILE re-send keeps the log and appends a
# boundary marker; only the elapsed timer restarts
import time as _time
import pysim_simple_server.server as srv
srv._PROACTIVE_LOG.clear()
srv._init_proactive_session()
srv._log_proactive(0x21, b'\x00')
before = len(srv._PROACTIVE_LOG)
t0 = srv._PROACTIVE_SESSION_START
_time.sleep(0.01)
srv._mark_proactive_session('terminal-profile')
self.assertEqual(len(srv._PROACTIVE_LOG), before + 1)
marker = srv._PROACTIVE_LOG[-1]
self.assertEqual(marker['marker'], 'terminal-profile')
self.assertEqual(marker['elapsed'], 0.0)
self.assertGreater(srv._PROACTIVE_SESSION_START, t0)
# the new session's entries restart their elapsed values
srv._log_proactive(0x21, b'\x00')
self.assertLess(srv._PROACTIVE_LOG[-1]['elapsed'], 1.0)
srv._reset_proactive_log()
def test_the_log_reset_still_clears(self):
# equip / disconnect keep the full reset (a card change)
import pysim_simple_server.server as srv
srv._PROACTIVE_LOG.clear()
srv._init_proactive_session()
srv._log_proactive(0x21, b'\x00')
srv._reset_proactive_log()
self.assertEqual(srv._PROACTIVE_LOG, [])
def test_the_terminal_profile_resend_marks_the_session(self):
# the Send button / Rescue share _resend_terminal_profile: it must
# mark (not clear) - a source pin, since calling it needs a card
import inspect
import pysim_simple_server.server as srv
src = inspect.getsource(srv._resend_terminal_profile)
self.assertIn("_mark_proactive_session('terminal-profile')", src)
self.assertNotIn('_reset_proactive_log()', src)
class TestEventDownload(unittest.TestCase):
"""ENVELOPE (EVENT DOWNLOAD) assembly, TS 102 223 7.5.11."""