Summary
A code audit of HostManager.swift revealed that the App Extensions (FinderSync, Share) are still relying on legacy, single-host keys in UserDefaults (serverHost, serverToken, etc.).
The HostManager.saveProfiles() function explicitly keeps these legacy keys in sync for the active host, which is a brittle and error-prone workaround.
Technical Debt
This creates a risk of state inconsistency. If the sync fails or is not called, the extensions will operate with stale data, potentially causing connection failures or data being sent to the wrong host.
Task
The App Extensions should be refactored to be multi-host aware.
- Both
ClawsyFinderSync and ClawsyMacShare targets need to read the full hostProfiles array from the shared UserDefaults.
- They need to read the
activeHostId to identify which profile to use.
- All logic currently reading from legacy keys (
SharedConfig.serverHost, etc.) within the extensions must be updated to read from the appropriate HostProfile instance.
- Once the extensions are fully migrated, the legacy key synchronization code in
HostManager.saveProfiles() can be removed.
Summary
A code audit of
HostManager.swiftrevealed that the App Extensions (FinderSync, Share) are still relying on legacy, single-host keys inUserDefaults(serverHost,serverToken, etc.).The
HostManager.saveProfiles()function explicitly keeps these legacy keys in sync for the active host, which is a brittle and error-prone workaround.Technical Debt
This creates a risk of state inconsistency. If the sync fails or is not called, the extensions will operate with stale data, potentially causing connection failures or data being sent to the wrong host.
Task
The App Extensions should be refactored to be multi-host aware.
ClawsyFinderSyncandClawsyMacSharetargets need to read the fullhostProfilesarray from the sharedUserDefaults.activeHostIdto identify which profile to use.SharedConfig.serverHost, etc.) within the extensions must be updated to read from the appropriateHostProfileinstance.HostManager.saveProfiles()can be removed.