Skip to content

[P1][arch] editorStore.ts is a god object: 7 tab kinds share one store with growing add* methods and per-feature lifecycle #286

Closed

Description

@EVWorth

Context

src/stores/editorStore.ts (366 LOC) owns query|structure|admin|routine|compare|designer tab kinds, with one add*Tab method per kind that each dedup their own open-tab check. New tab kinds keep adding methods.

Problem

Any new feature adding a tab kind results in: a new union member, a new add* method with the same dedup shape, and a new lifecycle block. The store crosses feature boundaries (editor + structure + admin + routine + compare + designer). God object. Also drags the cross-cutting concern out: see batch 6 cross-cutting pass.

Files

  • src/stores/editorStore.ts:1-366
  • src/components/editor/EditorTabs.tsx (consumer of the god store)

Repro

Adding an "ERD" tab kind would require a union member + addErdTab method + dedup logic, in a 400-LOC store that already mixes 6 features.

Expected

A generic useTabRegistry<Kind, State> (or per-feature slices under a root store) where each feature registers its tab kind and dedup rule without bloating editorStore.

Proposed fix

Scope L. Split editorStore by tab kind: queryTabs, structureTabs, etc., each owning its dedup. Or: introduce a tabs slice with a TabKind registry where features register kinds. Cross-cutting pass (batch 6) handles the structural redesign.

Acceptance

editorStore.ts LOC drops to <200; adding a new tab kind requires editing at most the corresponding feature slice + the type union.

Needs human verify

No.

Activity

  1. added
    audit
    severity/p1
    kind/arch
    kind/doc-drift
    area/editor
    on Jul 24, 2026
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

    area/editorauditkind/archkind/doc-driftseverity/p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions