Files
datacat/frontend/README.md
CatoandClaude Fable 5.1 634ea86168 refactor: quality sweep — lint at zero warnings, one logger, shared ingestion kit, no generated client in git (#271)
* chore(repo): drop ralph.sh residue, ignore the generated Prisma client at the root

ralph.sh was byte-identical to reparaturbonus-zh/ralph.sh ("Ralph Loop for
Revamp-Hirn") and PROMPT.md was its blank task template; nothing in CI, docs
or scripts referenced either.

backend/generated/ is produced by `prisma generate` (typecheck, build and
Dockerfile.backend all run it) and was already ignored by backend/.gitignore,
so it was never committed — but tools that only read the root ignore file
(the fleet jscpd sweep) counted its ~1,300 generated lines as duplicated
source and reported the repo at 4.4%. Listing it at the root too makes those
sweeps see what git sees.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8

* refactor(backend): log through one pino instance, lint console.log out

The backend had pino-http for requests and bare console.log everywhere else
(index.js, jobs/, services/websocket.js — 26 lines). lib/logger.js now owns
the pino-http middleware and exposes its logger, so application logs and
request logs share level, destination and redaction. pino stays an indirect
dependency: pnpm does not hoist pino-http's copy, and a second pino would be
a second place to configure.

The backend had no linter at all. eslint.config.mjs enables exactly one rule,
no-console (warn/error allowed), so this cannot drift back; the root `lint`
now runs both halves, which is what `verify` and CI call.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8

* refactor(ingest): one shared kit for the image/video/audio/database ingestion components and the /ingest pages

The four data-ingestion components each carried their own copy of the
upload state machine (idle → uploading → processing → complete/error), the
file picker + drag-drop + object-URL preview, the auth header, the response
reader, the drop zone, progress bar, error banner, result card and submit
button. The five /ingest/<kind> pages likewise repeated the page frame, the
"Recent …" panel with its loading/error/empty states, the status badge and
the detail panel, plus a private copy of formatFileSize/formatDate.

Now there is one of each:
- components/data-ingestion/shared.tsx — useIngestionUpload, useFilePreview,
  authHeaders, readIngestionResponse and the shared markup pieces
- components/data-ingestion/icons.tsx — the inline SVG paths as data, one
  OutlineIcon/SpinnerIcon component
- ingest/shared.tsx — IngestPage, RecentPanel, StatusBadge, DetailPanel and
  the useRecentSources fetch
- lib/format.ts — formatFileSize/formatDuration/formatDate, with a test

Markup and copy are unchanged; the components render exactly what they did.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8

* refactor(forms): type the stored form structure once, drop the dead quick-field builder

`/api/v1/forms` returned `schema as any` and every consumer re-derived its
shape. `StoredFormStructure` / `FormListRow` in types/saved-form.ts are now
the one description of what the builder writes into the Json column, used by
the route, SavedFormsLibrary, ModernFormBuilderLayout and the builder page.

DynamicForm loses its unused `addQuickField` duplicate of FormFieldBuilder's
own field factory and an unused `handleCreateGroup` argument; the autosave
draft effect reads the current form through a ref instead of listing the
form as a dependency (which is what the exhaustive-deps warning was pointing
at — re-running it per keystroke would clobber the user's input).
SavedFormsLibrary wraps fetchForms in useCallback so the token effect is
honest about what it depends on; its `handleLoginSuccess` was never wired to
anything. Rendered output is unchanged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8

* refactor(frontend): fix every ESLint warning, gate lint at --max-warnings 0, ban console.log

The frontend lint config had downgraded no-unused-vars, no-explicit-any,
ban-ts-comment, exhaustive-deps, no-unescaped-entities and no-img-element to
"warn" ("temporarily, for build success") and `eslint .` ran with no
warning cap, so 152 warnings sat there unread. Every one is fixed at the
source rather than silenced:

- no-explicit-any: real types — jose's private `email` claim, the next-auth
  Session/User augmentation (`session.user.id` is set by the session
  callback), OpenAI.APIError for the vision route's status checks, typed
  event/data shapes elsewhere. The ambient `declare module '@dnd-kit/*'`
  stub is gone: `@dnd-kit/utilities` is now a declared dependency so its own
  types load.
- no-unused-vars: unused imports/params/state dropped. Seven components and
  one hook turned out to be rendered nowhere (BuilderToolbar,
  FormBuilderQuickStart, FormCreationHub, ModernSidebarStore, MultiStepForm,
  MultiStepFormBuilderStore, QuickActions, useApiRequest) — deleted, and the
  README paragraph that described the *Store wrappers updated.
- exhaustive-deps: callbacks memoised so the dependency arrays are truthful.
- ban-ts-comment / no-unescaped-entities: the comments were covering typed
  code; the entities are escaped.
- The 5 console.log calls in frontend/src (debug leftovers in components
  and services) are removed; console.warn/error stay. `no-console` (allow
  warn/error) is now an error so they cannot come back, with scripts/**
  exempt because printing is their job. (Of the 82 console.log in the repo,
  26 were the backend — routed through pino in the previous commit — and
  the rest are operator scripts, which print by design.)

The downgrade block is gone, so upstream next/core-web-vitals defaults
apply, and `lint` runs with `--max-warnings 0`: a warning fails the gate.
152 → 0.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012KAn51JHFcTrPeCjZDGXM8

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-14 22:22:22 -07:00

4.9 KiB
Raw Permalink Blame History

DataCat Frontend

The Next.js 16 frontend for DataCat, a universal AI-powered data capture platform (forms → AI analysis → action delivery).

Getting Started

From the repository root, pnpm run dev starts both the frontend (port 3000) and the Express/tRPC backend (port 5001). To run the frontend alone:

cd frontend
pnpm install
pnpm run dev

Open http://localhost:3000 in your browser. Edit pages under src/app/ — the page auto-updates as you save.

Fonts are loaded via next/font (Geist). The frontend talks to the backend through /api/* rewrites; see the root README.md and docs/deployment/docker-setup.md for the full architecture and the self-hosted (Docker on the Hetzner box, behind Caddy) deployment.


created_date: 2024-07-08 last_modified_date: 2026-09-04 last_modified_summary: "Commands updated to pnpm; Next.js version corrected to 16."


Neuerungen ab 2024-07-08

Drag-and-Drop Sortierung

Das zentrale Formular-Canvas und die Sidebar unterstützen jetzt modernes Drag-and-Drop über @dnd-kit. Sie können Felder nicht nur innerhalb eines Schritts, sondern auch zwischen Schritten verschieben. So funktioniert's:

  1. Bewegen Sie den Mauszeiger über ein Feld, bis der Cursor zur "Hand" wird.
  2. Klicken, halten und ziehen Sie das Feld an die gewünschte Stelle.
  3. Die benachbarten Felder gleiten nach oben / unten, sodass klar ersichtlich ist, wo das Element landet – selbst wenn Sie von Schritt 2 zu Schritt 1 ziehen.

Technische Details

  • Bibliotheken: @dnd-kit/core, @dnd-kit/sortable, @dnd-kit/modifiers
  • Implementation: ModernFormBuilderLayout verwendet DndContext + SortableContext.
  • Jedes Feld wird durch die neue SortableField-Komponente umhüllt, welche useSortable nutzt.

Schritt-Titel bearbeiten

Im Steps-Tab der Sidebar kann der Titel eines Schrittes jetzt inline editiert werden:

  1. Titel anklicken
  2. Neuen Namen eintippen
  3. Mit Enter bestätigen oder Fokus verlieren.
  4. Esc bricht den Vorgang ab.

Die Änderung wird via onUpdateStep sofort ins Formularmodell übernommen.

Duplizieren-Bug behoben

Ein einzelner Klick auf das Kopier-Icon erstellt nur noch eine Kopie.
Grund war ein doppeltes Event-Feuern; durch e.stopPropagation() im Button behoben.

Installation

Falls Sie das Projekt zum ersten Mal auschecken oder neue Abhängigkeiten installieren möchten:

cd frontend
pnpm install

Die neuen DnD-Bibliotheken werden automatisch mitinstalliert.

Neuerungen ab 2025-07-08

Global State with Zustand

The form builder (builder canvas, sidebar, and multi-step editor) now shares a single source of truth provided by Zustand (src/app/hooks/useFormBuilderStore.ts).

Benefits

  1. No more prop-drilling of fields, steps, or currentStep.
  2. Future features (undo/redo, collaboration, analytics) can plug into the store.
  3. Cleaner component APIs.

Key Store API

addField(field, stepId?)
updateField(fieldId, updates)
duplicateField(fieldId)
removeField(fieldId)
reorderField(from, to)

addStep(step) / updateStep(stepId, updates) / removeStep(stepId)
reorderStep(from, to)

toggleMultiStep()
setCurrentStep(index)
setFields(array)  // bulk replace
setSteps(array)   // bulk replace

Component Changes

ModernSidebar and MultiStepFormBuilder read the store directly via useFormBuilderStore(). (The *Store wrapper components that once injected store values as props were never rendered anywhere and have been removed.)

Migration Guide for Your Own Components

  1. Import the hook: const { fields } = useFormBuilderStore();
  2. Derive local UI state from the store rather than props.
  3. Dispatch actions instead of lifting state up.
import { useFormBuilderStore } from '../hooks/useFormBuilderStore';

function RequiredFieldBadge({ fieldId }: { fieldId: string }) {
  const required = useFormBuilderStore((s) => s.fields.find(f => f.id === fieldId)?.required);
  return required ? <span>*</span> : null;
}

Neuerungen ab 2025-07-09

Inline-Add-Buttons im Single-Step Modus

Der Ein-Seiten-Builder zeigt jetzt nach jeder Feldliste dieselben 「+ Feld」 und 「+ Sektion」-Schaltflächen wie der Multi-Step-Builder. Dadurch können Sie ohne Umwege neue Elemente einfügen, ganz egal ob Ihr Formular in Schritten aufgebaut ist oder nicht.

Formular-Titel nun oben

Der Titel des Formulars befindet sich jetzt als grosses, direkt editierbares Eingabefeld ganz oben in der Builder-Ansicht. Dadurch wirkt er wie eine eigentliche Überschrift und ist sofort sichtbar.

Einheitliche Button-Farben

Alle Call-to-Action-Buttons in der Fussleiste (Speichern, Vorschau, + Neu) verwenden jetzt Indigo-Töne und folgen damit einem klaren Farbkonzept.

Gleiche Feldbreite im Single-Step

Felder im Ein-Seiten-Modus sind nun ebenfalls auf max-w-4xl begrenzt, identisch zum Multi-Step-Modus. Dadurch wirken die Layouts konsistent.