fix(expert mode): do not apply auto start cooldown after a reboot#2196
Open
evil-raider wants to merge 1 commit into
Open
fix(expert mode): do not apply auto start cooldown after a reboot#2196evil-raider wants to merge 1 commit into
evil-raider wants to merge 1 commit into
Conversation
The system bridge auto start has a 5 minute cooldown that prevents it from being auto started again if it was last auto started less than 5 minutes ago. This exists to avoid an infinite restart loop when the system bridge keeps being killed shortly after starting. The cooldown was based solely on the wall clock time of the last auto start (systemBridgeLastAutoStartTime), which persists across reboots. So if the user rebooted, used the device for 1-2 minutes and rebooted again, the system bridge was stopped by the reboot (a correct termination, not a crash) but the cooldown still fired. The user got the "expert mode stopped unexpectedly / not auto restarting because last auto started less than 5 minutes ago" notification and the service did not start. Store the device boot time (unix time - elapsed realtime) alongside the last auto start time, and skip the cooldown when the current boot time differs from the stored one, i.e. the device has rebooted since the last auto start. A crash loop within a single boot session still triggers the cooldown because the boot time does not change between kills. Fixes keymapperorg#2195
evil-raider
force-pushed
the
fix/reboot-cooldown
branch
from
July 22, 2026 18:02
c4916c0 to
881ae88
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #2195
created by opus 4.8
The system bridge (Expert mode) has a 5-minute auto-start cooldown that
prevents it from restarting if it was last auto-started less than 5 minutes
ago. This exists to avoid an infinite restart loop when the bridge keeps
being killed shortly after starting.
The cooldown is based solely on the wall-clock time of the last auto start
(
systemBridgeLastAutoStartTime), which persists across reboots. So thishappens:
termination, not a crash), but the cooldown still fires.
because last auto started less than 5 minutes ago" notification and the
service does not start.
Fix
Store the device boot time (
unixTimestamp() - elapsedRealtime()/1000)alongside the last auto-start time, and skip the cooldown when the current
boot time differs from the stored one (i.e. the device has rebooted since the
last auto start).
A crash loop within a single boot session still triggers the cooldown,
because the boot time does not change between kills — so the original
protection is preserved. A 60-second tolerance absorbs clock jitter/NTP
adjustments so they aren't mistaken for a reboot.
Testing
Added a unit test in
SystemBridgeAutoStarterTestcovering the case: lastauto start was <5 minutes ago but during a previous boot → the bridge should
still auto start.