Skip to content

Split oversized AppStore.swift and DeviceDocNormalizer.swift #34

@tashda

Description

@tashda

Summary

Follow-up to #33. The mechanical parts of the code-structure cleanup landed in v1.3.1, but two files remain over the 600-line hard cap because they need design thought rather than a rote extraction:

File Lines Why deferred
Shellbee/Core/Store/AppStore.swift 691 Single @Observable class. Splitting needs a domain partition (Devices / Groups / OTA / Notifications / Logs) realized as extension AppStore files. Stored properties have to stay in the main file (@Observable constraint), so the partition is methods-only.
Shellbee/Core/Parsing/DeviceDocNormalizer.swift 646 7 parsing helper types in one file. Some may be small enough to genuinely belong together; needs a read-through to confirm what's worth extracting and what reads better adjacent.

Plan for AppStore

  1. Read apply(_ event:) end to end (currently ~227 lines of switch). Identify per-domain handler clusters.
  2. Split methods into:
    • AppStore+Events.swift — the per-event handlers extracted from the giant apply switch.
    • AppStore+Notifications.swiftpopNotification, popFastTrackNotification, enqueueNotification, notification(...), stripped(...).
    • AppStore+OTA.swiftotaStatus(for:), startOTAUpdate, startOTACheck, startOTASchedule, cancelOTASchedule.
    • AppStore+Logs.swiftclearLogs, insertLogEntry, insertRawLogEntry.
    • AppStore+Devices.swiftdevice(named:), state(for:), isAvailable, optimisticRename, revertOptimisticRename, recordFirstSeen, removeFirstSeen.
  3. Keep stored properties + init + reset + apply dispatcher in the main file.
  4. Verify with the seeder mock + UI tests; the surface area is wide enough that visual review isn't enough.

Plan for DeviceDocNormalizer

  1. Read end to end. List the 7 types and their dependencies on each other.
  2. If any 3+ are tightly coupled (one calls into another and they're never used independently), keep them together in a sub-file.
  3. Otherwise split into one type per file under Core/Parsing/Normalizer/.
  4. Verify with the doc-parsing tests.

Acceptance criteria

  • Both files at or under 600 lines.
  • No regression in seeder-driven flows (notifications, OTA, logs, device events).
  • No regression in doc parsing — ShellbeeTests/Unit/DeviceDocNormalizer* (if present) still passes.

Notes

Lower priority than #33 because nothing in the codebase is blocked by these files being big — the rule violation is the only forcing function. Pick this up alongside other v2.0 / late-v1.x cleanup work, not before.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions