Feat/Fix: Static Work Windows and Enhanced Task Reliability#162
Feat/Fix: Static Work Windows and Enhanced Task Reliability#162rochasjk wants to merge 3 commits intovinaghost:mainfrom
Conversation
|
can you send me a few screenshot what did you change ? |
| // before trying to locate a building link, make sure the page is stable | ||
| // (logo rendered). using an empty fragment avoids hanging if we're already | ||
| // on a non-dorf page such as a build screen. | ||
| var waitResult = await browser.WaitPageChanged("", cancellationToken); |
There was a problem hiding this comment.
i saw the comment but what does it do? Comment is for explaining why the code is there, not how the code run
also wait page changed not work like this, you only need waitpageload
| // `WaitPageChanged` takes a URL fragment but we only care about the logo being | ||
| // visible; passing an empty string makes the URL check no‑op and still waits | ||
| // for the logo, avoiding deadlocks when we're on a non-dorf page. | ||
| var waitResult = await browser.WaitPageChanged("", cancellationToken); |
There was a problem hiding this comment.
same with tobuildingbylocationcommand.cs, wait page changed not work like this, you only need waitpageload
| if (workEndMinute < 0 || workEndMinute > 59) workEndMinute = 0; | ||
|
|
||
| // randomness range from 0 (no offset) up to configured max | ||
| var random = new Random(); |
| .Where(x => x.AccountId == accountId.Value) | ||
| .Where(x => x.Setting == setting.Key) | ||
| .ExecuteUpdate(x => x.SetProperty(x => x.Value, setting.Value)); | ||
| var entity = context.AccountsSetting |
There was a problem hiding this comment.
this is done when account creating,, don't do this
There was a problem hiding this comment.
not sure this is a good idea, but we can keep it
| { | ||
| Hour = Hour >= 23 ? 0 : Hour + 1; | ||
| } | ||
|
|
There was a problem hiding this comment.
we has installed ReactiveUI.SourceGenerator, please use "[ReactiveCommand]" and "[Reactive]"
There was a problem hiding this comment.
we has installed ReactiveUI.SourceGenerator, please use "[ReactiveCommand]" and "[Reactive]"
| <SelfContained>true</SelfContained> | ||
|
|
||
| <AssemblyVersion>1975.4.30</AssemblyVersion> | ||
| <AssemblyVersion>2603.01.4.0</AssemblyVersion> |
|
|
||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <EmbeddedResource Remove="Infrasturecture\ExtensionFiles\tampermonkey_stable.crx" /> |
There was a problem hiding this comment.
if you want an additional extension, please make another PR,
There was a problem hiding this comment.
if you want an additional extension, please make another PR,
🚀 Overview
This PR transitions the bot's scheduling logic from a duration-based model to a static daily work window and introduces several robustness improvements to the core execution engine and browser interactions.
🔩 Core Logic: Static Work Windows
New Scheduling Model: Replaced WorkTimeMin/Max (random intervals) with fixed WorkStart and WorkEnd daily windows.
Precision Control: Added minute-level granularity (WorkStartMinute, WorkEndMinute) and a user-configurable SleepRandomMinute offset to maintain human-like behavior.
Compatibility: Updated SleepTask and RxQueue to handle these new windows while maintaining default values that ensure backward compatibility.
🛠 Reliability & Stability
Auto-Recovery: Implemented an auto-restart mechanism in TimerManager. Fatal errors now trigger a screenshot, log the failure, and force an AccountInit cycle to recover the session without manual intervention.
Browser Resilience: Added StaleElementReferenceException handling in WaitForLogo and improved navigation commands (ToDorf, ToBuildingByLocation) with explicit page-render waits.
Thread Safety: Fixed CollectionWasModified exceptions in DebugViewModel by using snapshots during log reloads.
🧱 Architectural Housekeeping
Refactored AccountSettingInput and its validator to support the new time properties.
Updated XAML views and ViewModels to expose the new UI controls (MinuteInputUc).
Note on Project Files: Adjusted OutputType to Library and cleaned up unused Tampermonkey resources.
🧩 Testing
Extended AccountSettingInputTest to verify that the new minute and randomness settings persist correctly through the settings cycle.