Skip to content

Butlerv4: per-account options and a Leader option - #41

Merged
noelrohi merged 3 commits into
Skuafrom
feat/butlerv4-per-leader
Nov 7, 2026
Merged

noelrohi merged 3 commits into
Skuafrom
feat/butlerv4-per-leader

Conversation

@noelrohi

Copy link
Copy Markdown
Owner

What was wrong

Butlerv4 (OptionsStorage = "Butler1") kept Leader1Name..Leader4Name and Leader1Butlers..Leader4Butlers in one file, <SkuaDIR>/options/Butler1.cfg, read by every account on the machine. Moving one account to another leader with skua script start --option Leader1Name=... --option Leader1Butlers=... rewrote that file for all accounts, so every switch meant backing it up and restoring it. A Butler that was already running kept its old leader until it was restarted.

What changed

before                                   after
options/Butler1.cfg  ← every account     options/Butler1-alt2.cfg  ← alt2 only
                                         options/Butler1-alt3.cfg  ← alt3 only
                                         options/Butler1.cfg       ← seed, and when nobody is logged in
  • Options per account. OptionsStorage is now Butler1-<account> (lower case) for the logged-in account. The first time an account uses it, it is copied from the shared Butler1.cfg, so existing lists, drops and quests carry over. With nobody logged in (or a name that can't be a file name) it stays Butler1.
  • New Leader option. When set, it wins over the lists: skua script start Tools/Butlerv4/Butlerv4.cs --option Leader=alt1. Since it lives in the account's own file, it never touches another account.
  • The Leader1..4 lists work as before. When Leader is empty, the first list that names the account picks its leader.
  • Runtime leader changes. Every 2 s the Butler checks the modified time of its options file. When the file changes, it calls Bot.Config.Load() and resolves the leader again. If the leader is different, it drops the TCP link and connects to the new one. If the file no longer names any leader, it logs that and keeps following the current one.

Why this design

These are the options I checked in Skua's source:

  • A transient Leader option: ruled out. Option<T> has a transient flag, but the Engine's script start --option rejects transient options ("it resets on every start, so it can't be set", Skua.Engine/Scripts/ScriptOperations.cs Store). Transient values also reset on every restart, auto re-logins included, so a Butler would lose its leader after a relogin.
  • A Leader option in the shared file: ruled out. script start --option loads the Script's one storage, sets the values and saves the whole file (config.Save()). OptionContainer.Save writes only the options the Script declares. So any option in Butler1.cfg is one value for every account, and per-account keys inside it would be dropped by the next save from another account.
  • Keying the storage by account: chosen. Skua reads OptionsStorage by reflection after it creates the Script (ScriptManager.LoadScriptConfig), so a field initializer can compute it. Both the options window and the Engine's --option then read and write Butler1-<account>.cfg. Scripts already keep per-account files this way: CBO_Storage(<user>).txt and UltraLoadoutRestore(<user>).txt.

Trade-off: after the first run, a setting changed in one client's options window (lists included) applies to that account only. It no longer reaches every account through the shared file. Seeding from Butler1.cfg happens only once.

Not tested live

  • I did not run this against logged-in accounts. Not tested: the per-account file being created and written by --option, the Leader override, and the runtime switch when the file is edited while a Butler runs.
  • Verified: skua scripts check Tools/Butlerv4/Butlerv4.cs compiles it with its 3 includes, and the scripts-compile-check workflow on noelrohi/Skua passes for this file.

🤖 Generated with Claude Code

noelrohi and others added 3 commits October 27, 2026 23:10
Butlerv4 kept every account's leader in one shared Butler1.cfg, so
'skua script start --option Leader1Name=...' for one account rewrote the
assignment of every account, and a running Butler kept its old leader.

- Options are stored per account (Butler1-<account>), seeded from the
  shared Butler1 on first use so existing setups carry over. With nobody
  logged in the shared Butler1 is used as before.
- New Leader option: when set it wins over the Leader 1-4 lists, which
  keep working as before.
- A running Butler re-reads its options when their file changes and
  switches to the new leader.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@noelrohi
noelrohi merged commit 66eca0d into Skua Nov 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant