Skip to content

12 components call api.* directly, bypassing the stores #862

Closed

Description

@EVWorth

Severity: P3 (architecture).

CLAUDE.md sets the IPC chain as Component → store action → api.* → invoke(), and says components never call api.* themselves. It also says store actions own the loading and error state. These components break that rule:

$ grep -rln "api\.\w\+(" src/components --include=*.tsx | grep -v __tests__
src/components/schema/TableStructure.tsx        (5 calls)
src/components/admin/ProcessListTab.tsx         (4)
src/components/history/HistoryQuickOpen.tsx     (1)
src/components/history/QueryHistory.tsx         (2)
src/components/routine/RoutineViewer.tsx        (1)
src/components/common/ShortcutsDialog.tsx       (1)
src/components/layout/StatusBar.tsx             (3)
src/components/import/ImportDialog.tsx          (6)
src/components/backup/RestoreDialog.tsx         (4)
src/components/backup/BackupDialog.tsx          (3)
src/components/favorites/QueryFavorites.tsx     (4)
src/components/designer/TableDesigner.tsx       (6)

This has practical costs, not only a style one:

Fix

Move the calls behind store actions, one area at a time (designer, backup/restore/import, history, admin), with the loading and error state in the store. An ESLint no-restricted-imports rule that forbids importing lib/tauri-api under src/components/ would stop new ones from appearing. It can be turned on once the existing calls are gone.

Found while fixing #810.

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