Skip to content

The agent that grows with you

test(bot-mode): deterministic watermark timestamps + reset rerun flag on relay stop

kshitij1aadf863f9d6
diff --git a/apps/desktop/src/plugins/hermes-bots/plugin.js b/apps/desktop/src/plugins/hermes-bots/plugin.js
index e02beec4131..8a7009093e6 100644
--- a/apps/desktop/src/plugins/hermes-bots/plugin.js
+++ b/apps/desktop/src/plugins/hermes-bots/plugin.js
@@ -1651,6 +1651,9 @@ function startBotRelay() {
function stopBotRelay() {
relayDisposed = true
+ // A rerun remembered mid-drain must not leak into the next start —
+ // it would fire one stale drain after restart.
+ relayDrainRerun = false
if (relayRosterTimer !== null) {
clearInterval(relayRosterTimer)
diff --git a/tests/tui_gateway/test_change_watcher.py b/tests/tui_gateway/test_change_watcher.py
index 5ec73da7b35..9c612c555f0 100644
--- a/tests/tui_gateway/test_change_watcher.py
+++ b/tests/tui_gateway/test_change_watcher.py
@@ -221,6 +221,8 @@ def test_new_envelope_after_drain_fires_pending_again(watcher_home):
first.write_text("{}")
server._broadcast_watched_changes(now=0.0)
first.write_text("{}") # make the first sighting a change, not a seed
+ bump_ns = first.stat().st_mtime_ns + 1_000_000
+ os.utime(first, ns=(bump_ns, bump_ns)) # strictly newer, FS-independent
server._broadcast_watched_changes(now=10.0)
first.unlink() # the Desktop drained it
@@ -228,8 +230,8 @@ def test_new_envelope_after_drain_fires_pending_again(watcher_home):
second = outbox / ("d" * 32 + ".json")
second.write_text("{}")
- now_ns = time.time_ns()
- os.utime(second, ns=(now_ns, now_ns)) # strictly newer than the watermark
+ newer_ns = bump_ns + 1_000_000 # strictly beyond the watermark
+ os.utime(second, ns=(newer_ns, newer_ns))
server._broadcast_watched_changes(now=30.0)
assert [e for e in events if e[0] == "bot_relay.outbox.pending"] == [