Skip to content

[Audit] Refactor App Extensions to use HostManager #110

Description

@iret77

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.

  1. Both ClawsyFinderSync and ClawsyMacShare targets need to read the full hostProfiles array from the shared UserDefaults.
  2. They need to read the activeHostId to identify which profile to use.
  3. All logic currently reading from legacy keys (SharedConfig.serverHost, etc.) within the extensions must be updated to read from the appropriate HostProfile instance.
  4. Once the extensions are fully migrated, the legacy key synchronization code in HostManager.saveProfiles() can be removed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpriority:lowLow prioritytech-debtTechnical debt and code hygienetriagedIssue has been triaged

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions