Skip to content

Consolidate duplicated utilities and remove dead components #149

Description

@cursor

Spec: Fowler-style refactoring review (cloud agent, 2026-08-05). Refactor only — no behavior change beyond deleting unreachable code.

What to change

Small mechanical consolidations, one PR:

  1. sha256Hex ×3lib/export/checksum.ts, lib/offline-region/checksum.ts, and a private copy in lib/offline-region/store.ts (~38–43). One shared implementation (keep export's fail-closed policy via an option).
  2. IDB promise helpers ×3requestToPromise/transactionDone in lib/local-capture/store.ts, lib/local-capture/media-store.ts (~49–65), lib/offline-region/pack-store.ts (~128–144). Extract lib/idb/promises.ts.
  3. Byte formatters ×3, mutually incompatiblecomponents/region-tracer.tsx formatBytes (decimal MB), components/offline-region-panel.tsx formatBytes (binary KB/MB), lib/offline-region/download-copy.ts formatRegionMegabytes. One policy in download-copy.ts; delete the locals.
  4. Close-X SVG ×4+ — the m6 6 12 12M18 6 6 18 path in map-journal.tsx, daily-digest-panel.tsx, artifact-lightbox.tsx, media-lightbox.tsx, thread-chat.tsx. Extract a CloseIcon.
  5. Lightbox chrome ×2ArtifactLightbox and MediaLightbox duplicate the Escape handling, scroll lock, and dialog frame. Extract LightboxShell (and/or a useModalLayer(onClose) hook).
  6. Slugify ×2readTopics in lib/enrichment/system-instruction.ts (~188–200) inlines the algorithm mentionSlug (~205–212) already provides; call it. Likewise lib/artifacts/document.ts escape duplicates escapeText from lib/artifacts/sanitize.ts — export and reuse.
  7. Dead codecomponents/offline-region-panel.tsx (OfflineRegionPanel), SheetMasthead and InstrumentStrip in components/sheet.tsx have zero product imports. Delete them (which also removes one of the byte formatters).

Out of scope: anything under app/prototype/ (throwaway by design).

Acceptance criteria

  • Each listed duplicate has exactly one implementation; dead exports are removed
  • mise run lint and mise run test pass

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions