Problem
The Import Category Set dialog was built (file upload, Valibot validation, duplicate detection, IndexedDB persistence) and the UI was wired into CategoriesEditorScreen in PR #147. However, the import flow is a dead end:
importCategorySet() writes to a local IndexedDB (comapeo-categories Dexie DB)
CategoriesEditorScreen reads categories from the server API via useApiPresets() (TanStack Query → GET /projects/:id/presets)
- These two data sources are not connected — nothing reads from IndexedDB
- After import shows "success", the category list doesn't change
- No
queryClient.invalidateQueries() is called
The Import button and dialog have been commented out in CategoriesEditorScreen and its tests until the full flow is implemented.
What exists (keep + build on)
src/screens/CategoriesEditor/ImportSetDialog.tsx — full dialog UI (317 lines)
src/lib/categories-db.ts — IndexedDB layer (78 lines): importCategorySet(), getCategorySets(), getCategorySet()
src/lib/schemas/preset.ts — comapeoCatSchema Valibot schema
- i18n keys in all 3 locales (en/pt/es):
categories.importSet.*, categories.importButton
What needs to happen
Decide on architecture before implementing:
Option A: Client-side bridge (offline-capable)
- Create a
useCategorySets() hook that reads from IndexedDB
- Merge IndexedDB sets with server presets in
CategoriesEditorScreen
- Invalidate/refetch the hook after import
- More complex, handles offline scenarios
Option B: Server-side import (single source of truth)
- Upload
.comapeocat file to the comapeo-cloud API
- Server imports + stores the category set
queryClient.invalidateQueries(['presets']) after successful upload
- Simpler architecture, but depends on server API support
Acceptance Criteria
Context
Problem
The Import Category Set dialog was built (file upload, Valibot validation, duplicate detection, IndexedDB persistence) and the UI was wired into
CategoriesEditorScreenin PR #147. However, the import flow is a dead end:importCategorySet()writes to a local IndexedDB (comapeo-categoriesDexie DB)CategoriesEditorScreenreads categories from the server API viauseApiPresets()(TanStack Query →GET /projects/:id/presets)queryClient.invalidateQueries()is calledThe Import button and dialog have been commented out in
CategoriesEditorScreenand its tests until the full flow is implemented.What exists (keep + build on)
src/screens/CategoriesEditor/ImportSetDialog.tsx— full dialog UI (317 lines)src/lib/categories-db.ts— IndexedDB layer (78 lines):importCategorySet(),getCategorySets(),getCategorySet()src/lib/schemas/preset.ts—comapeoCatSchemaValibot schemacategories.importSet.*,categories.importButtonWhat needs to happen
Decide on architecture before implementing:
Option A: Client-side bridge (offline-capable)
useCategorySets()hook that reads from IndexedDBCategoriesEditorScreenOption B: Server-side import (single source of truth)
.comapeocatfile to the comapeo-cloud APIqueryClient.invalidateQueries(['presets'])after successful uploadAcceptance Criteria
.comapeocatfile via the Import Category Set dialogCategoriesEditorScreen+ testsContext
agent/comapeo-cloud-app/issue-143src/screens/CategoriesEditor/index.tsx(Import button + dialog render),tests/unit/screens/CategoriesEditor/index.test.tsx(2 import dialog tests)