Skip to content

Commit 8511f85

Browse files
committed
feat: replay duration selector, live counter refresh scoped to active replay
- Duration dropdown: 30s / 1min / 2min / 5min / 10min / Continuous - Replay stops automatically when duration elapses - Live counter refresh (2s rerun) only fires inside running state block - UI no longer sluggish when replay is not active
1 parent 9f2c3fa commit 8511f85

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

src/ui/app.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2781,6 +2781,12 @@ def _write_hash_to_env(hash_value: str) -> None:
27812781
if st.button("⏹ Stop Replay", key="stop_replay"):
27822782
stop_replay()
27832783
st.rerun()
2784+
2785+
# Live counter refresh — only fires while replay is running,
2786+
# stops automatically when replay ends (duration elapsed or stopped)
2787+
import time as _rep_time
2788+
_rep_time.sleep(2)
2789+
st.rerun()
27842790
else:
27852791
_rp_c1, _rp_c2 = st.columns(2)
27862792
with _rp_c1:
@@ -2809,6 +2815,19 @@ def _write_hash_to_env(hash_value: str) -> None:
28092815
help="Anomaly ratio shifts sinusoidally over time — simulates an attack campaign developing",
28102816
)
28112817

2818+
_rep_duration_opts = {
2819+
"30 seconds": 30, "1 minute": 60, "2 minutes": 120,
2820+
"5 minutes": 300, "10 minutes": 600, "Continuous": None,
2821+
}
2822+
_rep_duration_label = st.selectbox(
2823+
"Duration",
2824+
list(_rep_duration_opts.keys()),
2825+
index=1,
2826+
key="rep_duration",
2827+
help="Replay stops automatically after this time. Counters refresh live while running.",
2828+
)
2829+
_rep_duration_secs = _rep_duration_opts[_rep_duration_label]
2830+
28122831
if st.button("▶ Start Replay", type="primary", key="start_replay"):
28132832
try:
28142833
platforms = (["linux","windows","network"]
@@ -2820,6 +2839,7 @@ def _write_hash_to_env(hash_value: str) -> None:
28202839
rate = _rep_rate,
28212840
anomaly_ratio = _rep_ratio,
28222841
campaign_mode = _rep_campaign,
2842+
duration = _rep_duration_secs,
28232843
)
28242844
st.success("🎭 Replay generator started.")
28252845
st.rerun()
@@ -2852,3 +2872,5 @@ def _write_hash_to_env(hash_value: str) -> None:
28522872
""")
28532873
st.caption(f"CUDA-Q: {'available' if CUDAQ_AVAILABLE else 'not available (CPU mode)'} · "
28542874
f"LLM: {OLLAMA_MODEL} · DB: {DB_PATH}")
2875+
2876+

0 commit comments

Comments
 (0)