Skip to content

Multi-bridge Phase 1.1: Promote ConnectionHistory into SavedBridges model #62

@tashda

Description

@tashda

Why

ConnectionHistory (Shellbee/Core/Models/ConnectionHistory.swift) already stores up to 10 prior ConnectionConfig entries with Keychain-backed tokens. It's the right substrate for the "saved bridges" list, but it's currently presented as recents rather than a managed set. Multi-bridge support (Phase 1) needs each saved bridge to carry a stable identifier, a friendly name, and an optional "default" flag so the switcher (#1.3) and saved-bridges screen (#1.2) have something durable to bind to.

What

  • Add a stable id: UUID to ConnectionConfig. Persist it inside PersistedSnapshot (currently lines 154–211 of ConnectionConfig.swift). On legacy load (snapshot without id), mint a fresh UUID and re-save in place so the ID is stable across launches.
  • ConnectionConfig already has an optional name: String. Surface it everywhere it's currently silently dropped (display URL builders, history rows, log lines).
  • Add displayName: String computed property: name ?? host.
  • Promote ConnectionHistory semantics:
    • Keep the 10-entry cap.
    • Add pin(_:) / unpin(_:), rename(_:to:), setDefault(_:) APIs.
    • Persist defaultBridgeID: UUID? under the new UserDefaults key "savedBridges.defaultID".
  • Drop the host+port deduplication in ConnectionHistory.add(_:) — allow two saved entries pointing at the same host with different names (e.g. "Main" and "Lab" both on localhost:8080). Dedup instead by id only.
  • Optionally rename AppEnvironment.history (line 7 of AppEnvironment.swift) to savedBridges — or add an alias.

Files

  • Shellbee/Core/Networking/ConnectionConfig.swift — add id, migrate PersistedSnapshot.
  • Shellbee/Core/Models/ConnectionHistory.swift — pin/setDefault/rename APIs, dedup by id.
  • Shellbee/App/AppEnvironment.swift — alias/rename history.

Verification

  • Add a unit test that loads a legacy PersistedSnapshot blob (no id key), confirms a UUID is minted, that the snapshot is re-persisted with that UUID, and that the UUID is stable across a second load.
  • Manual: delete app, install, connect to bridge A, then change connection to bridge B — both should appear in the saved-bridges list with stable IDs across relaunch.
  • Manual: save two entries pointing at the same host with different names — both must persist.

Phase

Phase 1 of multi-bridge support. Tracking epic: see master tracking issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions